14 #include <JANA/JApplication.h>
15 #include <JANA/JFactory.h>
56 gPARMS->SetDefaultParameter(
"TRKFIT:USE_SC_TIME", USE_SC_TIME,
"Do not reconstruct tracks with start counter time if set to 0!");
62 cout <<
"=========================================================================="<< endl;
63 cout <<
"TRKFIT: USE_SC_TIME = 0; WARNING SC TIME WILL NOT BE USED IN TRACK FITTING"<< endl;
64 cout <<
"Which is required in this ST_online_efficiency plugin "<< endl;
65 cout <<
"=========================================================================="<< endl;
69 cout <<
"=========================================================================="<< endl;
70 cout <<
"TRKFIT: USE_SC_TIME = 1; "<< endl;
71 cout <<
"Which will render this publing ST_online_efficiency useless! "<< endl;
72 cout <<
"=========================================================================="<< endl;
75 TDirectory *
main = gDirectory;
76 gDirectory->mkdir(
"st_efficiency")->cd();
78 h_N_trck_prd_All =
new TH1D(
"h_N_trck_prd_All",
"h_N_trck_prd_All; Sector; Predicted Hit Counts", 31, -0.5, 30.5);
79 h_N_recd_hit_All =
new TH1D(
"h_N_recd_hit_All",
"h_N_recd_hit_All; Sector; Recorded Hit Counts", 31, -0.5, 30.5);
81 h_N_trck_prd_ss =
new TH1D(
"h_N_trck_prd_ss",
"h_N_trck_prd_ss; Sector; Predicted Hit Counts", 31, -0.5, 30.5);
82 h_N_recd_hit_ss =
new TH1D(
"h_N_recd_hit_ss",
"h_N_recd_hit_ss; Sector; Recorded Hit Counts", 31, -0.5, 30.5);
84 h_N_trck_prd_bs =
new TH1D(
"h_N_trck_prd_bs",
"h_N_trck_prd_bs; Sector; Predicted Hit Counts", 31, -0.5, 30.5);
85 h_N_recd_hit_bs =
new TH1D(
"h_N_recd_hit_bs",
"h_N_recd_hit_bs; Sector; Recorded Hit Counts", 31, -0.5, 30.5);
87 h_N_trck_prd_ns =
new TH1D(
"h_N_trck_prd_ns",
"h_N_trck_prd_ns; Sector; Predicted Hit Counts", 31, -0.5, 30.5);
88 h_N_recd_hit_ns =
new TH1D(
"h_N_recd_hit_ns",
"h_N_recd_hit_ns; Sector; Recorded Hit Counts", 31, -0.5, 30.5);
90 h_ST_Eff_All=
new TH1D(
"h_ST_Eff_All",
" Efficiency; Sector; N_{RECD}/N_{TRCK}", 31, -0.5, 30.5);
91 h_ST_Eff_ss =
new TH1D(
"h_ST_Eff_ss",
" SS Efficiency; Sector; N_{RECD}/N_{TRCK}", 31, -0.5, 30.5);
92 h_ST_Eff_bs =
new TH1D(
"h_ST_Eff_bs",
" BS Efficiency; Sector; N_{RECD}/N_{TRCK}", 31, -0.5, 30.5);
93 h_ST_Eff_ns =
new TH1D(
"h_ST_Eff_ns",
" NS Efficiency; Sector; N_{RECD}/N_{TRCK}", 31, -0.5, 30.5);
95 gDirectory->cd(
"../");
118 map<string,double> target_params;
119 if (eventLoop->GetCalib(
"/TARGET/target_parms", target_params))
120 jout <<
"Error loading /TARGET/target_parms/ !" << endl;
121 if (target_params.find(
"TARGET_Z_POSITION") != target_params.end())
122 z_target_center = target_params[
"TARGET_Z_POSITION"];
124 jerr <<
"Unable to get TARGET_Z_POSITION from /TARGET/target_parms !" << endl;
128 _DBG_<<
"Cannot get DApplication from JEventLoop! (are you using a JApplication based program?)"<<endl;
154 eventLoop->GetSingle(locTrigger);
158 vector<const DSCDigiHit*> st_adc_digi_hits;
159 vector<const DParticleID*> pid_algorithm;
160 vector<const DSCHit*> st_hits;
161 vector<const DChargedTrack*> chargedTrackVector;
162 eventLoop->Get(st_adc_digi_hits);
163 eventLoop->Get(pid_algorithm);
164 eventLoop->Get(st_hits);
165 eventLoop->Get(chargedTrackVector);
168 eventLoop->GetSingle(locDetectorMatches);
172 japp->RootFillLock(
this);
175 for (uint32_t i = 0; i < chargedTrackVector.size(); i++)
178 const DChargedTrack *thisChargedTrack = chargedTrackVector[i];
183 float trackingFOMCut = 0.0027;
184 if(timeBasedTrack->
FOM < trackingFOMCut)
continue;
188 vertex = timeBasedTrack->
position();
190 double z_v = vertex.z();
191 double r_v = vertex.Perp();
192 bool z_vertex_cut = fabs(z_target_center - z_v) <= 15.0;
193 bool r_vertex_cut = r_v < 1.0;
195 if (!z_vertex_cut)
continue;
196 if (!r_vertex_cut)
continue;
198 int st_pred_id = pid_algorithm[0]->PredictSCSector(extrapolations,&locProjPos,&Barrel);
199 int st_pred_id_index = st_pred_id - 1;
201 locSCzIntersection = locProjPos.z();
202 locSCrIntersection = locProjPos.Perp();
206 Momentum = timeBasedTrack->
momentum();
210 sc_index = st_pred_id_index;
212 sc_pos_soss = sc_pos[sc_index][0].z();
213 sc_pos_eoss = sc_pos[sc_index][1].z();
214 sc_pos_eobs = sc_pos[sc_index][11].z();
215 sc_pos_eons = sc_pos[sc_index][12].z();
225 for (uint32_t j = 0; j < st_hits.size(); j++)
227 int phi_sec_hit_sector = st_hits[j]->sector;
231 if (st_pred_id == phi_sec_hit_sector){
239 if ( sc_pos_soss <= locSCzIntersection && locSCzIntersection <= sc_pos_eoss)
243 for (uint32_t j = 0; j < st_hits.size(); j++)
245 int phi_sec_hit_sector = st_hits[j]->sector;
246 if (st_pred_id == phi_sec_hit_sector)
256 if ( sc_pos_eoss < locSCzIntersection && locSCzIntersection <= sc_pos_eobs)
260 for (uint32_t j = 0; j < st_hits.size(); j++)
262 int phi_sec_hit_sector = st_hits[j]->sector;
263 if (st_pred_id == phi_sec_hit_sector)
273 if ( sc_pos_eobs < locSCzIntersection && locSCzIntersection <= sc_pos_eons)
278 for (uint32_t j = 0; j < st_hits.size(); j++)
280 int phi_sec_hit_sector = st_hits[j]->sector;
281 if (st_pred_id == phi_sec_hit_sector)
291 japp->RootFillUnLock(
this);
jerror_t fini(void)
Called after last event of last event source has been processed.
static TH1D * h_ST_Eff_ss
static TH1D * h_ST_Eff_All
static TH1D * h_N_trck_prd_ss
uint32_t N_trck_prd_bs[NCHANNELS]
static TH1D * h_N_recd_hit_ns
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
const uint32_t Nof_ss_intervals
const DChargedTrackHypothesis * Get_BestTrackingFOM(void) const
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
const DVector3 & position(void) const
const DTrackTimeBased * Get_TrackTimeBased(void) const
uint32_t N_recd_hit_bs[NCHANNELS]
JEventProcessor_ST_online_efficiency()
uint32_t Get_L1FrontPanelTriggerBits(void) const
static TH1D * h_ST_Eff_bs
static TH1D * h_N_recd_hit_ss
uint32_t N_recd_hit_ns[NCHANNELS]
static TH1D * h_N_trck_prd_All
uint32_t N_recd_hit_ss[NCHANNELS]
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
DGeometry * GetDGeometry(unsigned int run_number)
uint32_t N_trck_prd_ns[NCHANNELS]
~JEventProcessor_ST_online_efficiency()
const uint32_t Nof_ns_intervals
uint32_t N_recd_hit_All[NCHANNELS]
jerror_t init(void)
Called once at program start.
const DVector3 & momentum(void) const
uint32_t N_trck_prd_All[NCHANNELS]
map< DetectorSystem_t, vector< DTrackFitter::Extrapolation_t > > extrapolations
static TH1D * h_N_recd_hit_bs
static TH1D * h_N_trck_prd_ns
static TH1D * h_ST_Eff_ns
uint32_t N_trck_prd_ss[NCHANNELS]
static TH1D * h_N_recd_hit_All
static TH1D * h_N_trck_prd_bs
int main(int argc, char *argv[])
const uint32_t Nof_bs_intervals
bool GetStartCounterGeom(vector< vector< DVector3 > > &pos, vector< vector< DVector3 > > &norm) const