// $Id: DEventProcessor_trackeff_hists.cc 2774 2007-07-19 15:59:02Z davidl $ // // File: DEventProcessor_trackeff_hists.cc // Created: Sun Apr 24 06:45:21 EDT 2005 // Creator: davidl (on Darwin Harriet.local 7.8.0 powerpc) // #include #include using namespace std; #include #include "DEventProcessor_trackeff_hists.h" #include "DTrackingResolutionGEANT.h" #include #include #include #include #include #include #include #include #include #include #include #include // Routine used to create our DEventProcessor extern "C"{ void InitPlugin(JApplication *app){ InitJANAPlugin(app); app->AddProcessor(new DEventProcessor_trackeff_hists()); } } // "C" //------------------ // DEventProcessor_trackeff_hists //------------------ DEventProcessor_trackeff_hists::DEventProcessor_trackeff_hists() { trk_ptr = &trk; trkres = new DTrackingResolutionGEANT(); pthread_mutex_init(&mutex, NULL); } //------------------ // ~DEventProcessor_trackeff_hists //------------------ DEventProcessor_trackeff_hists::~DEventProcessor_trackeff_hists() { } //------------------ // init //------------------ jerror_t DEventProcessor_trackeff_hists::init(void) { // Create TRACKING directory TDirectory *dir = new TDirectory("TRACKING","TRACKING"); dir->cd(); // Create Trees trkeff = new TTree("trkeff","Tracking Efficiency"); trkeff->Branch("E","track",&trk_ptr); dir->cd("../"); JParameterManager *parms = app->GetJParameterManager(); DEBUG = 1; parms->SetDefaultParameter("TRKEFF:DEBUG", DEBUG); return NOERROR; } //------------------ // brun //------------------ jerror_t DEventProcessor_trackeff_hists::brun(JEventLoop *loop, int runnumber) { DApplication *dapp = dynamic_cast(loop->GetJApplication()); const DGeometry *dgeom = dapp->GetDGeometry(runnumber); double dz, rmin, rmax; dgeom->GetCDCEndplate(CDCZmax, dz, rmin, rmax); double cdc_axial_length; dgeom->GetCDCAxialLength(cdc_axial_length); CDCZmin = CDCZmax-cdc_axial_length; _DBG_<<"CDCZmin="<Get(mcthrowns); loop->Get(mctrajpoints); // Lock mutex pthread_mutex_lock(&mutex); // Get hit list for all throwns for(unsigned int i=0; icharge())==0.0)continue; // Momentum of thrown particle DVector3 pthrown = mcthrown->momentum(); trk.pthrown = pthrown; // Get resolutions for this thrown track double pt_res, theta_res, phi_res; trkres->GetResolution(8 , pthrown, pt_res, theta_res, phi_res); // Initialize with the "no candidate" values trk.likelihood = 0.0; trk.chisq=1.0E20; trk.pt_pull=1.0E20; trk.theta_pull=1.0E20; trk.phi_pull=1.0E20; trk.isreconstructable = isReconstructable(mcthrown, mctrajpoints); // Loop over found/fit tracks and calculate chisq and likelihood // for each to be from this thrown track for(unsigned int j=0; j10)_DBG_<<"pt_res="<1)cerr<<" pt_pull="<track != mcthrown->myid)continue; if(mctraj->primary_track != mcthrown->myid)continue; // redundant? if(mctraj_first==NULL)mctraj_first = mctraj; mctraj_last = mctraj; } if(mctraj_last!=NULL){ double r = sqrt(pow((double)mctraj_last->x,2.0) + pow((double)mctraj_last->y,2.0)); if(r>45.0)return true; if(mctraj_last->z<17.0)return true; if(mctraj_last->z<17.0)return true; } return false; }