Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ParticleFilterModule.cxx

Go to the documentation of this file.
00001 
00002 // $Id: ParticleFilterModule.cxx,v 1.3 2003/12/16 03:23:46 vahle Exp $
00003 //
00004 // Filters data using information from CandCalDetPIDHandle objects
00005 //
00006 // kordosky@hep.utexas.edu
00008 #include "CalDetDST/ParticleFilterModule.h"
00009 #include "CalDetPID/CalDetParticleType.h"
00010 #include "CalDetPID/CandCalDetPIDHandle.h"
00011 #include "CalDetPID/NtpCalDetPID.h"
00012 #include "CalDetDST/UberRecord.h"
00013 #include "CalDetDST/UberRecordLite.h"
00014 #include "MessageService/MsgService.h"
00015 #include "MinosObjectMap/MomNavigator.h"
00016 #include "JobControl/JobCModuleRegistry.h" // For JOBMODULE macro
00017 #include "DataUtil/GetCandidate.h"
00018 
00019 JOBMODULE(ParticleFilterModule, "ParticleFilterModule",
00020           "Filters events based on CandCalDetPID objects");
00021 CVSID("$Id: ParticleFilterModule.cxx,v 1.3 2003/12/16 03:23:46 vahle Exp $");
00022 //......................................................................
00023 
00024 ParticleFilterModule::ParticleFilterModule()
00025 {
00026 //======================================================================
00027 // Default constructor
00028 //======================================================================
00029 }
00030 
00031 //......................................................................
00032 
00033 ParticleFilterModule::~ParticleFilterModule()
00034 {
00035 //======================================================================
00036 // Destructor
00037 //======================================================================
00038 }
00039 
00040 //......................................................................
00041 
00042 void ParticleFilterModule::BeginJob()
00043 {
00044 //======================================================================
00045 // blah
00046 //======================================================================
00047 }
00048 
00049 //......................................................................
00050 
00051 JobCResult ParticleFilterModule::Ana(const MomNavigator* mom)
00052 {
00053 //======================================================================
00054 // 
00055 //======================================================================
00056    MSG("CalDetDST",Msg::kDebug)<<"In Particle filter mod, ana"<<endl;
00057      JobCResult result=JobCResult::kPassed;
00058      bool got_nada=true;
00059      Int_t ptype = CalDetParticleType::kUnknown;
00060      Bool_t nov = kFALSE;
00061      Bool_t inct = kFALSE;
00062      Float_t olchi2 = 0.;
00063      
00064      if(fUseDST==0){
00065           const CandCalDetPIDHandle* cpidh_ptr= 
00066                DataUtil::GetCandidate<CandCalDetPIDHandle>(mom,
00067                                "CandCalDetPIDHandle");
00068 
00069           ptype=cpidh_ptr->GetPIDType();
00070           nov=cpidh_ptr->NoOverlap();
00071           inct=cpidh_ptr->InCERTime();
00072           olchi2=cpidh_ptr->GetOLChi2();
00073           got_nada=false;
00074      }
00075      else{
00076           const UberRecord* ur=
00077                dynamic_cast<const UberRecord*>(mom->GetFragment("UberRecord"));
00078           if(ur!=0){
00079                ptype=ur->cpid.pid;
00080                nov=ur->cpid.nov;
00081                inct=ur->cpid.inct;
00082                olchi2=ur->cpid.olchi2;
00083                got_nada=false;
00084           }
00085           else{
00086                const UberRecordLite* url=
00087                     dynamic_cast<const UberRecordLite*>
00088                     (mom->GetFragment("UberRecordLite"));
00089                if(url!=0){
00090                     ptype=url->cpid.pid;
00091                     nov=url->cpid.nov;
00092                     inct=url->cpid.inct;
00093                     got_nada=false;
00094                }
00095           }
00096      }
00097 
00098      // fail an event for which I can't find pid information
00099      if(got_nada){
00100           if(fUseDST==0){
00101                MSG("CalDetDST", Msg::kWarning)<<"Could not find a CandCalDetPIDHandle to use in the PID selection.\nI'll fail this event!"<<endl;
00102           }
00103           else{
00104                MSG("CalDetDST", Msg::kWarning)<<"Could not find an UberRecord or UberRecordLite to use in the PID selection.\nI'll fail this event!"<<endl;
00105           }
00106           return JobCResult::kFailed;
00107      }
00108 
00109      // filter based on particle type
00110      if(ptype&fParticleType){
00111           // pass this event
00112           MSG("CalDetDST", Msg::kDebug)
00113                <<"Configured to pass: "
00114                <<CalDetParticleType::AsString(fParticleType)<<"\n"
00115                <<"Passing a: "<<CalDetParticleType::AsString(ptype)<<endl;
00116      }
00117      else{
00118           // fail it
00119           result=JobCResult::kFailed;
00120           MSG("CalDetDST", Msg::kDebug)
00121                <<"Configured to pass: "
00122                <<CalDetParticleType::AsString(fParticleType)<<"\n"
00123                <<"Failing a: "<<CalDetParticleType::AsString(ptype)<<endl;
00124      }
00125 
00126      // filter based on overlap criterion
00127      if(fCutOverlaps){
00128           if(nov){
00129                MSG("CalDetDST", Msg::kDebug)<<"Not an overlap."<<endl;
00130           }
00131           else{
00132                MSG("CalDetDST", Msg::kDebug)<<"An overlap."<<endl;
00133                result=JobCResult::kFailed;
00134           }
00135      }
00136 
00137      if(fCutCerTime){
00138         if(inct){
00139            MSG("CalDetDST", Msg::kDebug)<<"Cerenkov in time."<<endl;
00140         }
00141         else{
00142            MSG("CalDetDST", Msg::kDebug)<<"Cerenkov not in time."<<endl;
00143            result=JobCResult::kFailed;
00144         }
00145      }
00146      
00147      if(fCutChi2){
00148         if(olchi2<fChi2Limit){
00149            MSG("CalDetDST", Msg::kDebug)<<"olchi2 below "<<fChi2Limit<<endl;
00150         }
00151         else{
00152            MSG("CalDetDST", Msg::kDebug)<<"olchi2 above "<<fChi2Limit<<endl;
00153            result=JobCResult::kFailed;
00154         }
00155      } 
00156      
00157      return result;
00158 }
00159 
00160 //......................................................................
00161 
00162 const Registry& ParticleFilterModule::DefaultConfig() const
00163 {
00164 //======================================================================
00165 // Supply the default configuration for the module
00166 //======================================================================
00167   static Registry r; // Default configuration for module
00168 
00169   // Set name of config
00170   std::string name = this->GetName();
00171   name += ".config.default";
00172   r.SetName(name.c_str());
00173 
00174   // Set values in configuration
00175   r.UnLockValues();
00176   // by default look for electrons
00177   r.Set("ParticleType", CalDetParticleType::kElectron);
00178 
00179   r.Set("CutOverlaps", 0); // do not cut out overlaps by default
00180   r.Set("CutCerTime", 0); // do not cut out overlaps by default
00181   r.Set("CutChi2",0); //do not cut out chi2 by default
00182   r.Set("Chi2Limit",1.1); //set default limit of chi2 cut at <1.1
00183   r.Set("UseDST", 0); // do not try to use the uberdst by default
00184 
00185   r.LockValues();
00186 
00187   return r;
00188 }
00189 
00190 //......................................................................
00191 
00192 void ParticleFilterModule::Config(const Registry& r)
00193 {
00194 //======================================================================
00195 // Configure the module given the Registry r
00196 //======================================================================
00197   int    tmpi;
00198 
00199   if (r.Get("ParticleType",tmpi)) { fParticleType = tmpi; }
00200   if (r.Get("CutOverlaps", tmpi)) { fCutOverlaps = tmpi; }
00201   if (r.Get("CutCerTime", tmpi)) { fCutCerTime = tmpi; }
00202   if (r.Get("CutChi2", tmpi)) {fCutChi2=tmpi;}
00203   if (r.Get("UseDST", tmpi)) { fUseDST = tmpi; }
00204   
00205   double tmpf;
00206   if (r.Get("Chi2Limit",tmpf)) {fChi2Limit = (Float_t)tmpf; }
00207 
00208 }
00209 
00210 //......................................................................
00211 
00212 void ParticleFilterModule::Help()
00213 {
00214 //======================================================================
00215 // Prints a helpful message.
00216 //======================================================================
00217 
00218      MSG("CalDetDST", Msg::kInfo)
00219           <<"\n************** Help with ParticleFilterModule *****************\n"
00220           <<"ParticleFilterModule::Ana():\n"
00221           <<"===============================================================\n"
00222           <<"Filters events based on the contents of a\n"
00223           <<"CandCalDetPID object.\n"
00224           <<"Example: To select pions and muons do:\n\n"
00225           <<"Registry& r = \n"
00226           <<"jc.Path(\"X\").Mod(\"ParticleFilterModule\").GetConfig();\n"
00227           <<"r.UnlockValues();\n"
00228           <<"r.Set(\"ParticleType\","
00229           <<"CalDetParticleType::kPion|CalDetParticleType::kMuon);\n"
00230           <<"r.LockValues();\n"
00231           <<"jc.Path(\"X\").Mod(\"ParticleFilterModule\").Config(r);\n"
00232           <<"\nThis method will return kFailed if the particle type does\n"
00233           <<"not match the requested type, or in case no CandCalDetPID\n"
00234           <<"object can be found.\n"
00235           <<"===============================================================\n"
00236           <<"\nTakes config parameters:\n"
00237           <<" Int_t \"ParticleType\".\n"
00238           <<" Int_t \"CutOverlaps\". (!=0 to remove overlappers)\n"
00239           <<" Int_t \"CutCerTime\". (!=0 to cut on cer timing)\n"
00240           <<" Int_t \"CutChi2\". (!=0 to cut on chi2)\n"
00241           <<" Float_t \"Chi2Limit\". (Set upper limit on acceptable chi2)\n"
00242           <<" Int_t \"UseDST\". (!=0 to try and use the dst)\n"
00243           <<endl;
00244 
00245 }
00246 
00248 
00249 
00250 
00251 

Generated on Mon Feb 15 11:07:18 2010 for loon by  doxygen 1.3.9.1