00001 /**************************************************************************/ 00002 /* A CLASS TO MAKE CUTS ON EVENTS */ 00003 /* PATRICIA VAHLE */ 00004 /* DECEMBER 14, 2001 */ 00005 /**************************************************************************/ 00006 00007 #ifndef CUTTER_H 00008 #define CUTTER_H 00009 00010 #include <string> 00011 #include <map> 00012 #include <set> 00013 #include "JobControl/JobCModule.h" 00014 #include "TH1.h" 00015 #include "TCanvas.h" 00016 00017 class JobCResult; 00018 class MomNavigator; 00019 class RawRecord; 00020 00021 #include "CalDetSI/CandCalDetSIHandle.h" 00022 #include "CalDetSI/Helpers.h" 00023 const int fNCuts = 19; //evil and vile, quick fix. Must be incremented when new cuts are added 00024 00025 class Cutter : public JobCModule 00026 { 00027 00028 public: 00029 00030 typedef bool (Cutter::* CP)() const; 00031 00032 Cutter(); //constructor 00033 ~Cutter(); //destructor 00034 00035 //JobCResults methods 00036 virtual JobCResult Get(MomNavigator* mom); //gets the data from mom 00037 virtual JobCResult Ana(const MomNavigator* mom); //runs the cutters 00038 virtual void HandleCommand(JobCommand *cmd); 00039 00040 const Registry& DefaultConfig() const; 00041 void Config(const Registry& r); 00042 00043 00044 void SetCuts(); 00045 00046 //Cutters should return true if the event passes the cut, false otherwise 00047 //ie. true if we want to analyze the event 00048 00049 //A method that cuts out sparsification errors 00050 bool SparseErrorCutter() const; 00051 00052 //A method that cuts out faf errors 00053 bool FafErrorCutter() const; 00054 00055 //A method that cuts on the trigger (ie plane trigger) 00056 bool TriggerCutter() const; 00057 00058 //A method that cuts out events with trigger PMT signal 00059 bool TrigPMTCutter() const; 00060 00061 //A method that cuts out events with cosmic counter signal 00062 bool CosmicCounterCutter() const; 00063 00064 //A method that cuts out dead chips 00065 bool DeadChipCutter() const; 00066 00067 //A method that cuts out over shoot chips 00068 bool OverShootCutter() const; 00069 00070 //A method that cuts on events that have a Cerenkov hit 00071 bool KovCutter() const; 00072 00073 //A method that cuts on events that have a non-zero TDC reading 00074 bool TOFCutter() const; 00075 00076 //A method that cuts on events that have a TOF trigger 00077 bool TOFTrigCutter() const; 00078 00079 //A method that cuts on events that have a Cer1 trigger 00080 bool Kov1TrigCutter() const; 00081 00082 //A method that cuts on events that have a Cer2 trigger 00083 bool Kov2TrigCutter() const; 00084 00085 //A method that cuts on events that have a Cer3 trigger 00086 bool Kov3TrigCutter() const; 00087 00088 //A method that cuts on events that have a Cer trigger 00089 bool KovORTrigCutter() const; 00090 00091 //A method that cuts on events that have both a CER1 and CER2 trigger 00092 bool AllKovTrigCutter() const; 00093 00094 //A method to veto LI events 00095 bool LITrigCutter() const; 00096 00097 //A method to accept TOF or any kov trigger 00098 bool PIDOrTrigCutter() const; 00099 00100 //A method to cut events with dead cerenkov chips 00101 bool DeadKovCutter() const; 00102 00103 // A method to cut events with ND errors 00104 bool NDErrorCutter() const; 00105 00106 //a dummy cut so that others can be skipped 00107 bool DummyCutter() const {return true;} 00108 00109 //Other Cutters go here 00110 00111 //The Getters 00112 int GetDCPlaneCut() const {return fDCPlaneCut;} //get the plane cut on dead chips 00113 int GetMinOST() const {return fMinOST;} //get the minimum overshoot time 00114 const TH1F *GetCutHistogram() const {return &fCutHistogram;} //get the cut Histogram 00115 00116 //Methods to draw and write the cut histogram 00117 void DrawCutHistogram(); 00118 void WriteCutHistogram(); 00119 00120 private: 00121 bool fSparseErrCut; //execute sparsification error cut? 00122 bool fFafErrCut; //execute Faf error cut? 00123 bool fTrigCut; //execute trigger cut? 00124 bool fTPMTCut; //execute trigger pmt cut? 00125 bool fCCCut; //execute cosmic counter cut? 00126 bool fDCCut; //execute dead chip cut? 00127 bool fOSCut; //execute overshoot time cut? 00128 bool fKovCut; //execute kov cut? 00129 bool fTOFCut; //execute TOF cut? 00130 bool fTOFTrigCut; //execute TOF trigger cut? 00131 bool fKov1TrigCut; //execute Kov1 trigger cut? 00132 bool fKov2TrigCut; //execute kov2 trigger cut? 00133 bool fKov3TrigCut; 00134 bool fKovORTrigCut; 00135 bool fAllKovTrigCut; //execute both kov trigger cut? 00136 bool fLITrigCut; // execute LI trig cut? 00137 bool fPIDOrTrigCut; 00138 bool fDeadKovCut; 00139 bool fNDErrorCut; // execute NDErrorCutter 00140 00141 bool fDrawHist; //draw the histogram? 00142 bool fWriteHist; //write the histogram to a file? 00143 bool fWait; //wait for display after an event that passes all cuts? 00144 00145 bool fCutsSet; //are the cuts set? 00146 // static const int fNCuts; //number of cuts to perform 00147 int fKovADCCutLow1; //lower limit on passisng Kov adc 00148 int fKovADCCutHigh1; //upper limit on passing Kov adc 00149 int fKovADCCutLow2; //lower limit on passisng Kov adc 00150 int fKovADCCutHigh2; //upper limit on passing Kov adc 00151 int fKovADCCutLow3; //lower limit on passisng Kov adc 00152 int fKovADCCutHigh3; //upper limit on passing Kov adc 00153 00154 int fDCPlaneCut; //a plane less than which there should be no dead chips 00155 int fMinOST; //a minumum allowable overshoot time 00156 00157 int fFrequency; //freqency of histogram update 00158 int fCounter; //to keep track of how many events have been processed 00159 std::string fFileName; //filename in which to save cut histogram 00160 int fRunNumber; 00161 std::string fBinLabel[fNCuts+1]; //list of bin labels 00162 RawRecord* fRR; //pointer to the current raw record 00163 CandCalDetSIHandle *fCCDH; //pointer to candidate caldetSI handle 00164 TH1F fCutHistogram; //a histogram to store cut statistics 00165 TCanvas fCanvas; //a canvas to draw the histogram on 00166 CP fCutList[fNCuts]; //list of cuts to perform 00167 std::set<RawChannelId> fChipsToCut; // a set of deadchips with plane<fDCPlaneCut 00168 bool fFilledChipsToCut; // true if fFilledChipsToCut has been filled 00169 void FillChipsToCut(); 00170 }; 00171 00172 //A method that cuts out errors 00173 inline bool Cutter::SparseErrorCutter() const 00174 { 00175 if(fCCDH->GetSparseErr()){ //true if there are sparse errs 00176 return false; 00177 } 00178 00179 return true; //if we get here, no errors, passes cut 00180 }//end SparseErrorCutter() 00181 00182 //-------------------------------------------------------------------------------------- 00183 00184 //A method that cuts out faf errors 00185 inline bool Cutter::FafErrorCutter() const 00186 { 00187 00188 if(fCCDH->GetFafErr()){ //true if there is a faf error 00189 return false; 00190 } 00191 00192 return true; //if we get here, no errors, passes cut 00193 }//end FafErrorCutter() 00194 00195 //------------------------------------------------------------------------------------ 00196 00197 //A method that cuts on the trigger (ie plane trigger) 00198 inline bool Cutter::TriggerCutter() const 00199 { 00200 00201 // cout<<hex<<fCCDH->GetTrigSource()<<dec<<endl; 00202 if(fCCDH->GetTrigSource()&0x04){ //plane trigger 00203 if((fCCDH->GetTrigSource()>>8)>1){ 00204 //cout<<"PASSED TRIGGER CUT"<<endl; 00205 return true; //2/3 plane trigger 00206 } 00207 else{ 00208 return false; 00209 } 00210 } 00211 else{ //otherwise it fails 00212 return false; 00213 } 00214 00215 }//End TriggerCutter() 00216 00217 //------------------------------------------------------------------------------------- 00218 00219 //A method that cuts out events with trigger PMT signal 00220 inline bool Cutter::TrigPMTCutter() const 00221 { 00222 00223 if(fCCDH->GetTriggerPMT()){ //true if there is a trigger pmt signal 00224 return false; 00225 } 00226 00227 return true; 00228 00229 } //end TrigPMTCutter 00230 00231 //------------------------------------------------------------------------------------- 00232 00233 //A method that cuts out events with cosmic counter signal 00234 inline bool Cutter::CosmicCounterCutter() const 00235 { 00236 00237 if(fCCDH->GetCosmicCnt()){//true if there is a cosmic cnt signal 00238 return false; 00239 } 00240 return true; 00241 00242 }//end CosmicCntCutter 00243 00244 //------------------------------------------------------------------------------------ 00245 00246 inline bool Cutter::KovCutter() const 00247 { 00248 00249 if((fCCDH->GetKovADC1()>fKovADCCutLow1&&fCCDH->GetKovADC1()<fKovADCCutHigh1) 00250 ||(fCCDH->GetKovADC2()>fKovADCCutLow2&&fCCDH->GetKovADC2()<fKovADCCutHigh2)||(fCCDH->GetKovADC3()>fKovADCCutLow3&&fCCDH->GetKovADC3()<fKovADCCutHigh3)){//if there is non-zero adc on cernekov, there was a hit in kov 00251 return true; 00252 } 00253 return false; 00254 00255 } //end KovCutter 00256 00257 //______________________________________________________________________ 00258 00259 inline bool Cutter::TOFCutter() const 00260 { 00261 00262 if(fCCDH->GetTofTDC0()>0||fCCDH->GetTofTDC1()>0||fCCDH->GetTofTDC2()>0){ 00263 return true; 00264 } 00265 00266 return false; 00267 00268 }//end TOFCut 00269 00270 //_____________________________________________________________________ 00271 00272 inline bool Cutter::TOFTrigCutter() const 00273 { 00274 00275 if(fCCDH->GetTrigSource()&0x08){ 00276 return true; 00277 } 00278 00279 return false; 00280 }//end TOFTrigCutter() 00281 00282 //_____________________________________________________________________ 00283 00284 inline bool Cutter::Kov1TrigCutter() const 00285 { 00286 00287 if(fCCDH->GetTrigSource()&0x10){ 00288 return true; 00289 } 00290 00291 return false; 00292 }//end Kov1TrigCutter() 00293 00294 //_____________________________________________________________________ 00295 00296 inline bool Cutter::Kov2TrigCutter() const 00297 { 00298 00299 if(fCCDH->GetTrigSource()&0x20){ 00300 return true; 00301 } 00302 00303 return false; 00304 }//end Kov2TrigCutter() 00305 00306 //_____________________________________________________________________ 00307 inline bool Cutter::Kov3TrigCutter() const 00308 { 00309 00310 if(fCCDH->GetTrigSource()&0x40){ 00311 return true; 00312 } 00313 00314 return false; 00315 }//end Kov3TrigCutter() 00316 00317 //_____________________________________________________________________ 00318 00319 inline bool Cutter::KovORTrigCutter() const 00320 { 00321 00322 if(fCCDH->GetTrigSource()&0x10||fCCDH->GetTrigSource()&0x20 00323 ||fCCDH->GetTrigSource()&0x40){ 00324 return true; 00325 } 00326 00327 return false; 00328 }//end KovORTrigCutter() 00329 00330 //_____________________________________________________________________ 00331 00332 00333 inline bool Cutter::AllKovTrigCutter() const 00334 { 00335 00336 if((fCCDH->GetTrigSource()&0x10)&&(fCCDH->GetTrigSource()&0x20) 00337 &&fCCDH->GetTrigSource()&0x40){ 00338 return true; 00339 } 00340 00341 return false; 00342 }//end AllKovTrigCutter() 00343 00344 //_____________________________________________________________________ 00345 inline bool Cutter::LITrigCutter() const 00346 { 00347 00348 if(fCCDH->GetTrigSource()&0x02){ 00349 return false; 00350 } 00351 00352 return true; 00353 }//end LITrigCutter() 00354 00355 //_____________________________________________________________________ 00356 00357 inline bool Cutter::PIDOrTrigCutter() const 00358 { 00359 00360 if(fCCDH->GetTrigSource()&0x08 00361 ||fCCDH->GetTrigSource()&0x10 00362 ||fCCDH->GetTrigSource()&0x20 00363 ||fCCDH->GetTrigSource()&0x40){ 00364 return true; 00365 } 00366 00367 return false; 00368 }//end PIDOrTrigCutter 00369 //__________________________________________________________________________ 00370 00371 00372 00373 #endif //CUTTER_H 00374 00375 00376 00377 00378 00379 00380 00381 00382 00383 00384 00385 00386 00387
1.3.9.1