// $Id$ // // File: DL3Trigger_factory.cc // Created: Tue Jan 8 14:46:49 EST 2013 // Creator: davidl (on Linux ifarm12s01 2.6.32-220.7.1.el6.x86_64 x86_64) // #include #include using namespace std; #include "DL3Trigger_factory.h" #include "JFactoryGenerator_DL3Trigger.h" using namespace jana; #include #include #include #include #include #include #include #include #include #include #include #include #include // Routine used to create our JEventProcessor #include extern "C"{ void InitPlugin(JApplication *app){ InitJANAPlugin(app); app->AddFactoryGenerator(new JFactoryGenerator_DL3Trigger()); } } // "C" //------------------ // init //------------------ jerror_t DL3Trigger_factory::init(void) { // Total guesses for now THRESH_FCAL = 0.200; THRESH_BCAL = 0.200; THRESH_FCAL_AND_BCAL = 0.200; MIN_TRACK_CANDIDATES = 0; gPARMS->SetDefaultParameter("L3:THRESH_FCAL", THRESH_FCAL, "Threshold for FCAL energy suffcient to fire L3 trigger"); gPARMS->SetDefaultParameter("L3:THRESH_BCAL", THRESH_BCAL, "Threshold for BCAL energy suffcient to fire L3 trigger"); gPARMS->SetDefaultParameter("L3:THRESH_FCAL_AND_BCAL", THRESH_FCAL_AND_BCAL, "Threshold for FCAL + BCAL energy suffcient to fire L3 trigger"); gPARMS->SetDefaultParameter("L3:MIN_TRACK_CANDIDATES", MIN_TRACK_CANDIDATES, "Number of track candidates sufficient to fire L3 trigger"); return NOERROR; } //------------------ // brun //------------------ jerror_t DL3Trigger_factory::brun(jana::JEventLoop *eventLoop, int runnumber) { return NOERROR; } //------------------ // evnt //------------------ jerror_t DL3Trigger_factory::evnt(JEventLoop *loop, int eventnumber) { vector beamphotons; vector taggers; vector schits; vector tofhits; vector fdchits; vector fdcpseudos; vector cdchits; vector candidates; vector tracks_wb; vector bcalhits; vector fcalhits; vector bcalclusters; vector fcalclusters; DL3Trigger *l3 = new DL3Trigger(); // Use execption throwing for flow control here. It lets // us jump quickly to the end of the routine at any point // specifying the state that L3good should be set to try{ loop->Get(beamphotons); l3->Ephoton_truth = beamphotons.size()>0 ? beamphotons[0]->energy():0.0; loop->Get(taggers); l3->Ntagger = (int)taggers.size(); loop->Get(schits); l3->Nstart_counter = (int)schits.size(); loop->Get(tofhits); l3->Ntof = (int)tofhits.size(); loop->Get(fdchits); l3->Nfdc = (int)fdchits.size(); loop->Get(fdcpseudos); l3->Nfdc_pseudo = (int)fdcpseudos.size(); loop->Get(cdchits); l3->Ncdc = (int)cdchits.size(); loop->Get(candidates); l3->Ntrack_candidates = (int)candidates.size(); loop->Get(tracks_wb); l3->Ntrack_wb = (int)tracks_wb.size(); loop->Get(bcalclusters); l3->Nbcal_clusters = (int)bcalclusters.size(); loop->Get(fcalclusters); l3->Nfcal_clusters = (int)fcalclusters.size(); loop->Get(bcalhits); l3->Ebcal = 0.0; for(unsigned int i=0; iEbcal += bcalhits[i]->E; loop->Get(fcalhits); l3->Efcal = 0.0; for(unsigned int i=0; iEfcal += fcalhits[i]->E; l3->Ptot_tracks_wb = 0.0; for(unsigned int i=0; iPtot_tracks_wb += tracks_wb[i]->pmag(); l3->Ncdc_layers = 0; int cdc_layers = 0; // bits to hold CDC layers hit for(unsigned int i=0; iring); for(unsigned int i=0; i<30; i++){ if( cdc_layers&0x1 )l3->Ncdc_layers++; cdc_layers = (cdc_layers>>1); } l3->Nfdc_planes = 0; int fdc_layers = 0; // bits to hold CDC layers hit for(unsigned int i=0; itype) fdc_layers |= (1 << fdchits[i]->gLayer); for(unsigned int i=0; i<30; i++){ if( fdc_layers&0x1 )l3->Nfdc_planes++; fdc_layers = (fdc_layers>>1); } }catch(bool L3good){ // only get her if a "definitely keep" or "definitely reject" // criteria was met l3->L3good = L3good; } _data.push_back(l3); return NOERROR; } //------------------ // erun //------------------ jerror_t DL3Trigger_factory::erun(void) { return NOERROR; } //------------------ // fini //------------------ jerror_t DL3Trigger_factory::fini(void) { return NOERROR; }