Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JEventProcessor_ST_ZEff.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: JEventProcessor_ST_ZEff.cc
4 // Created: Wed Aug 26 17:18:47 EDT 2015
5 // Creator: mkamel (on Linux ifarm1102 2.6.32-431.el6.x86_64 x86_64)
6 //
8 #include "TRIGGER/DTrigger.h"
9 using namespace jana;
10 using namespace std;
11 // Routine used to create our JEventProcessor
12 #include <JANA/JApplication.h>
13 #include <JANA/JFactory.h>
14 extern "C"{
15 void InitPlugin(JApplication *app){
16  InitJANAPlugin(app);
17  app->AddProcessor(new JEventProcessor_ST_ZEff());
18 }
19 } // "C"
20 //------------------
21 // JEventProcessor_ST_ZEff (Constructor)
22 //------------------
24 {
25 
26 }
27 //------------------
28 // ~JEventProcessor_ST_ZEff (Destructor)
29 //------------------
31 {
32 
33 }
34 //------------------
35 // init
36 //------------------
38 {
39  // ROOT mutex like this:
40  //
41  // japp->RootWriteLock();
42  // ... fill historgrams or trees ...
43  // japp->RootUnLock();
44  //****** Define Some Constants*********************************
45  int NoBins_z = 240;
46  double z_lower_limit = 38.5;
47  double z_upper_limit = 98.5;
48  // Do not reconstruct tracks with start counter time
49  gPARMS->SetParameter("TRKFIT:USE_SC_TIME",false);
50  int USE_SC_TIME = 0;
51  if(gPARMS->Exists("TRKFIT:USE_SC_TIME"))
52  gPARMS->GetParameter("TRKFIT:USE_SC_TIME", USE_SC_TIME);
53 
54  //cout << "USE_SC_TIME = " << USE_SC_TIME << endl;
55  // Warning message if sc time is used in track reconstruction
56  if (USE_SC_TIME == 0)
57  {
58  cout << "=========================================================================="<< endl;
59  cout << "TRKFIT: USE_SC_TIME = 0; WARNING SC TIME WILL NOT BE USED IN TRACK FITTING"<< endl;
60  cout << "This is required in ST_ZEff plugin which calculate SC efficiency "<< endl;
61  cout << "=========================================================================="<< endl;
62  }
63  // Create root folder for ST and cd to it, store main dir
64  TDirectory *main = gDirectory;
65  gDirectory->mkdir("st_efficiency")->cd();
66  //eff histos
67  h_fom =new TH1D("h_fom", " FOM ; FOM ; Counts", 1000,0.0, 1.0);
68  h_N_Hit_in_track = new TH1D("h_N_Hit_in_track", " Ndof + 5; Number of Hits per track ; Counts", 70,0.0, 70.0);
69  h1_qVectorSize=new TH1D(" h1_qVectorSize", " number of q tracks; number of q tracks; Counts", 50,0.0, 50.0);
70  h1_qVectorSize_ACuts=new TH1D(" h1_qVectorSize_ACuts", " number of q tracks; number of q tracks; Counts", 50,0.0, 50.0);
71  h1_tDiff= new TH1D("h1_tDiff", " SC_time - RF; t(ns) ; Counts", 600,-30.0, 30.0);
72  h1_RFtime= new TH1D("h1_RFtime", " t0; t0(ns) ; Counts", 600,-30.0, 30.0);
73  h1_Centered_RFtime= new TH1D("h1_Centered_RFtime", " RF_C; RF_C(ns) ; Counts", 600,-30.0, 30.0);
74  h1_SC_ShiftedTime= new TH1D("h1_SC_ShiftedTime", " SC_shifted Time; Time(ns) ; Counts", 600,-30.0, 30.0);
75 
76  h_z_v = new TH1D("h_z_v", " z_v; Z (cm); Counts", 1000,0.0, 100.0);
77  h1_st_pred_id = new TH1D("h1_st_prd_id", "h1_st_prd_id; Sector; Predicted Hit Counts", 31, -0.5, 30.5);
78 
79  h2_z_vs_r = new TH2I("h2_z_vs_r", "Z vs R; Z (cm); R (cm)", NoBins_z, z_lower_limit, z_upper_limit, 100, 0.0, 10.0);
80  h2_x_vs_y = new TH2I ("h2_x_vs_y", "X vs Y; X (cm); Y (cm)", 1000, -20., 20., 500, -10., 10.);
81 
82 
83  for (unsigned int i = 0; i < Nof_ss_intervals; i++)
84  {
85  h_N_trck_prd_z_ss[i] = new TH1D(Form("h_N_trck_prd_z_ss_%i",i+1), Form("z #in interval %i; Sector; Predicted Hit Counts", i+1), 31, -0.5, 30.5);
86  h_N_recd_hit_z_ss[i] = new TH1D(Form("h_N_recd_hit_z_ss_%i",i+1), Form("z #in interval %i; Sector; Recorded Hit Counts", i+1), 31, -0.5, 30.5);
87  h_N_recd_hit_z_ss_ACC[i] = new TH1D(Form("h_N_recd_hit_z_ss_ACC_%i",i+1), Form("z #in interval %i; Sector; ACC Hit Counts", i+1), 31, -0.5, 30.5);
88  h_N_trck_prd_z_ss_eff[i] = new TH1D(Form("h_N_trck_prd_z_ss_eff_%i",i+1), Form("z #in interval %i; Sector; SS Effeiciency ", i+1), 31, -0.5, 30.5);
89  }
90  for (unsigned int i = 0; i < Nof_bs_intervals; i++)
91  {
92  h_N_trck_prd_z_bs[i] = new TH1D(Form("h_N_trck_prd_z_bs_%i",i+1), Form("z #in interval %i; Sector; Predicted Hit Counts", i+1), 31, -0.5, 30.5);
93  h_N_recd_hit_z_bs[i] = new TH1D(Form("h_N_recd_hit_z_bs_%i",i+1), Form("z #in interval %i; Sector; Recorded Hit Counts", i+1), 31, -0.5, 30.5);
94  h_N_recd_hit_z_bs_ACC[i] = new TH1D(Form("h_N_recd_hit_z_bs_ACC_%i",i+1), Form("z #in interval %i; Sector; ACC Hit Counts", i+1), 31, -0.5, 30.5);
95  h_N_trck_prd_z_bs_eff[i] = new TH1D(Form("h_N_trck_prd_z_bs_eff_%i",i+1), Form("z #in interval %i; Sector; BS Effeiciency ", i+1), 31, -0.5, 30.5);
96  }
97  for (unsigned int i = 0; i < Nof_ns_intervals; i++)
98  {
99  h_N_trck_prd_z_ns[i] = new TH1D(Form("h_N_trck_prd_z_ns_%i",i+1), Form("z #in interval %i; Sector; Predicted Hit Counts", i+1), 31, -0.5, 30.5);
100  h_N_recd_hit_z_ns[i] = new TH1D(Form("h_N_recd_hit_z_ns_%i",i+1), Form("z #in interval %i; Sector; Recorded Hit Counts", i+1), 31, -0.5, 30.5);
101  h_N_recd_hit_z_ns_ACC[i] = new TH1D(Form("h_N_recd_hit_z_ns_ACC_%i",i+1), Form("z #in interval %i; Sector; ACC Hit Counts", i+1), 31, -0.5, 30.5);
102  h_N_trck_prd_z_ns_eff[i] = new TH1D(Form("h_N_trck_prd_z_ns_eff_%i",i+1), Form("z #in interval %i; Sector; NS Effeiciency ", i+1), 31, -0.5, 30.5);
103  }
104 
105  // cd back to main directory
106  gDirectory->cd("../");
107  main->cd();
108  return NOERROR;
109 }
110 //------------------
111 // brun
112 //------------------
113 jerror_t JEventProcessor_ST_ZEff::brun(JEventLoop *eventLoop, int32_t runnumber)
114 {
115  // This is called whenever the run number changes
116 
117  // Obtain the target center along z;
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"];
123  else
124  jerr << "Unable to get TARGET_Z_POSITION from /TARGET/target_parms !" << endl;
125  // Obtain the Start Counter geometry
126  DApplication* dapp = dynamic_cast<DApplication*>(eventLoop->GetJApplication());
127  if(!dapp)
128  _DBG_<<"Cannot get DApplication from JEventLoop! (are you using a JApplication based program?)"<<endl;
129  DGeometry* locGeometry = dapp->GetDGeometry(eventLoop->GetJEvent().GetRunNumber());
130  sc_angle_corr = 1.;
131  if (locGeometry->GetStartCounterGeom(sc_pos, sc_norm))
132  {
133  double theta = sc_norm[0][sc_norm[0].size()-2].Theta();
134  sc_angle_corr = 1./cos(M_PI_2 - theta);
135  }
136 
137  // Propagation Time constant
138  if(eventLoop->GetCalib("START_COUNTER/propagation_time_corr", propagation_time_corr))
139  jout << "Error loading /START_COUNTER/propagation_time_corr !" << endl;
140  // Propagation Time fit Boundaries
141  if(eventLoop->GetCalib("START_COUNTER/PTC_Boundary", PTC_Boundary))
142  jout << "Error loading /START_COUNTER/PTC_Boundary !" << endl;
143 
144  return NOERROR;
145 }
146 //------------------
147 // evnt
148 //------------------
149 jerror_t JEventProcessor_ST_ZEff::evnt(JEventLoop *eventLoop, uint64_t eventnumber)
150 {
151  //cout << USE_SC_TIME << endl;
152  //cout << " *********************** Event number" << eventnumber << "**************"<<endl;
153  // Here's an example:
154  //
155  // vector<const MyDataClass*> mydataclasses;
156  // loop->Get(mydataclasses);
157  //
158  // japp->RootWriteLock();
159  // ... fill historgrams or trees ...
160  // japp->RootUnLock();
161 
162  vector<const DSCHit*> st_hits;
163  vector<const DChargedTrack*> chargedTrackVector;
164 
165  eventLoop->Get(st_hits);
166  eventLoop->Get(chargedTrackVector);
167  vector<DVector3> sc_track_position;
168  // select events with physics events, i.e., not LED and other front panel triggers
169  const DTrigger* locTrigger = NULL;
170  eventLoop->GetSingle(locTrigger);
171  if(locTrigger->Get_L1FrontPanelTriggerBits() != 0)
172  return NOERROR;
173  double speed_light = 29.9792458;
174  const DEventRFBunch* locEventRFBunch = NULL;
175  eventLoop->GetSingle(locEventRFBunch);
176  if(locEventRFBunch->dNumParticleVotes <= 1)
177  return NOERROR; //don't trust PID: beta-dependence
178 
179  // Get the particleID object for each run
180  vector<const DParticleID* > locParticleID_algos;
181  eventLoop->Get(locParticleID_algos);
182  if(locParticleID_algos.size() < 1)
183  {
184  _DBG_<<"Unable to get a DParticleID object! NO PID will be done!"<<endl;
185  return RESOURCE_UNAVAILABLE;
186  }
187  auto locParticleID = locParticleID_algos[0];
188  // We want to be use some of the tools available in the RFTime factory
189  // Specifically steping the RF back to a chosen time
190  auto locRFTimeFactory = static_cast<DRFTime_factory*>(eventLoop->GetFactory("DRFTime"));
191 
192  // Grab the associated detector matches object
193  const DDetectorMatches* locDetectorMatches = NULL;
194  eventLoop->GetSingle(locDetectorMatches);
195 
196  japp->RootFillLock(this); //ACQUIRE ROOT FILL LOCK
197  sc_track_position.clear();
198  for (uint32_t i = 0; i < chargedTrackVector.size(); i++)
199  {
200  // Grab the charged track
201  const DChargedTrack *thisChargedTrack = chargedTrackVector[i];
202  // Grab associated time based track object by selecting charged track with best FOM
203  const DTrackTimeBased *tb_track = thisChargedTrack->Get_BestTrackingFOM()->Get_TrackTimeBased();
204 
205  //const DReferenceTrajectory* rt = tb_track->rt;
206  // Implement quality cuts for the time based tracks
207  float trackingFOMCut = 2.699796E-3; // +/- 3 sigma: CL
208  float NHitsTrack = 14.0; // Number of hits per track
209 
210  h_fom->Fill(tb_track->FOM);
211  h_N_Hit_in_track->Fill(tb_track->Ndof + 5); // at lest 10 hits per track
212  h1_qVectorSize->Fill(chargedTrackVector.size());
213 
214  if(tb_track->Ndof + 5 < NHitsTrack) continue;
215  if(tb_track->FOM < trackingFOMCut) continue;
216  // Grab the ST hit match params object and cut on only tracks matched to the ST
217  shared_ptr<const DSCHitMatchParams> locBestSCHitMatchParams;
218  bool foundSC = locParticleID->Get_BestSCMatchParams(tb_track, locDetectorMatches, locBestSCHitMatchParams);
219  if (!foundSC) continue;
220 
221  // Define vertex vector
222  DVector3 vertex,Momentum;
223  // Vertex info
224  vertex = tb_track->position();
225  Momentum = tb_track->momentum();
226  // Cartesian Coordinates
227  double z_v = vertex.z();
228  double r_v = vertex.Perp();
229  bool z_vertex_cut = fabs(z_target_center - z_v) <= 15.0;
230  bool r_vertex_cut = r_v < 1.0;
231 
232  // applied vertex cut
233  if (!z_vertex_cut) continue;
234  if (!r_vertex_cut) continue;
235 
236  // Grab the TOF hit match params object and cut on tracks matched to the TOF
237  // Want to use TOF/RF time for t0 for SC hit time
238  shared_ptr<const DTOFHitMatchParams> locTOFHitMatchParams;
239  bool foundTOF = locParticleID->Get_BestTOFMatchParams(tb_track, locDetectorMatches, locTOFHitMatchParams);
240 
241  //BCAL Match Param
242  shared_ptr<const DBCALShowerMatchParams> locBCALHitMatchParams;
243  bool foundBCAL = locParticleID->Get_BestBCALMatchParams(tb_track, locDetectorMatches, locBCALHitMatchParams);
244  //FCAL Match Param
245  shared_ptr<const DFCALShowerMatchParams> locFCALHitMatchParams;
246  bool foundFCAL = locParticleID->Get_BestFCALMatchParams(tb_track, locDetectorMatches, locFCALHitMatchParams);
247  // Hit must be matched to TOF, BCAL, or FCAL
248  if (!(foundBCAL || (foundFCAL && foundTOF))) continue;
249 
250 
251  // Grab the paramteres associated to a track matched to the ST
252  vector<shared_ptr<const DSCHitMatchParams>> st_params;
253  bool st_match = locDetectorMatches->Get_SCMatchParams(tb_track, st_params);
254  // If st_match = true, there is a match between this track and the ST
255  if (!st_match) continue;
256 
257  DVector3 IntersectionPoint, IntersectionMomentum,locProjMom, locPaddleNorm;
258  shared_ptr<DSCHitMatchParams> locSCHitMatchParams;
259  vector<DTrackFitter::Extrapolation_t>extrapolations=tb_track->extrapolations.at(SYS_START);
260  bool st_match_pid = locParticleID->Cut_MatchDistance(extrapolations, st_params[0]->dSCHit, st_params[0]->dSCHit->t, locSCHitMatchParams, true, &IntersectionPoint, &IntersectionMomentum);
261 
262  if(!st_match_pid) continue;
263 
264  int st_pred_id=locBestSCHitMatchParams->dSCHit->sector;
265  double t0 = locEventRFBunch->dTime;
266 
267  h1_qVectorSize_ACuts->Fill(chargedTrackVector.size());
268  h1_st_pred_id->Fill(st_pred_id);
269  int st_pred_id_index = st_pred_id - 1;
270  // Z intersection of charged track and SC
271  // Acquire the intersection point
272  sc_track_position.push_back(IntersectionPoint);
273 
274  h1_RFtime->Fill(t0);
275 
276  double locCenteredRFTime = t0;
277  h1_Centered_RFtime->Fill(locCenteredRFTime);
278  // RF time at center of target
279  double locCenterToVertexRFTime = (tb_track->z() - z_target_center)*(1.0/speed_light); // Time correction for photon from target center to vertex of track
280  double locVertexRFTime = locCenteredRFTime + locCenterToVertexRFTime;
281  // Define sector array index
282  int sc_index = st_pred_id_index;
283  // Start Counter geometry in hall coordinates
284  double sc_pos_soss, sc_pos_eoss, sc_pos_eobs, sc_pos_eons;
285 
286  sc_pos_soss = sc_pos[sc_index][0].z(); // Start of straight section
287  sc_pos_eoss = sc_pos[sc_index][1].z(); // End of straight section
288  sc_pos_eobs = sc_pos[sc_index][11].z(); // End of bend section
289  sc_pos_eons = sc_pos[sc_index][12].z(); // End of nose section
290 
291  // Read the constants from CCDB
292  incpt_ss = propagation_time_corr[sc_index][0];
293  slope_ss = propagation_time_corr[sc_index][1];
294  incpt_bs = propagation_time_corr[sc_index][2];
295  slope_bs = propagation_time_corr[sc_index][3];
296  incpt_ns = propagation_time_corr[sc_index][4];
297  slope_ns = propagation_time_corr[sc_index][5];
298  //Read fit boundary from CCDB
299  Bound1 = PTC_Boundary[0][0];
300  Bound2 = PTC_Boundary[1][0];
301  for (uint32_t i = 0; i < sc_track_position.size(); i++)
302  {
303  //double locSCzIntersection = IntersectionPoint.z();
304  h_z_v->Fill(sc_track_position[i].z());
305  h2_z_vs_r->Fill(sc_track_position[i].z(),sc_track_position[i].Perp());
306  h2_x_vs_y->Fill(sc_track_position[i].x(), sc_track_position[i].y());
307  double locSCzIntersection = sc_track_position[i].z();
308  // double locSCrIntersection =sc_track_position[i].Perp();
309 
310  double ss_interval = (sc_pos_eoss - sc_pos_soss)/Nof_ss_intervals;
311  double bs_interval = (sc_pos_eobs - sc_pos_eoss)/Nof_bs_intervals;
312  double ns_interval = (sc_pos_eons - sc_pos_eobs)/Nof_ns_intervals;
313  // SS intervals
314  for (uint32_t k = 0; k < Nof_ss_intervals; k++)
315  {
316  z_ss[k] = sc_pos_soss + ss_interval * k ;
317  //cout << z_ss[k]<<endl;
318  if ((z_ss[k] <= locSCzIntersection) && (locSCzIntersection < (z_ss[k]+ss_interval)))
319  {
320  //predicted tracks to hit SS interval
321  h_N_trck_prd_z_ss[k]->Fill(st_pred_id);
322 
323  for (uint32_t j = 0; j < st_hits.size(); j++)
324  {
325  int hit_sector = st_hits[j]->sector;
326  if ((st_pred_id == hit_sector)||(st_pred_id == hit_sector-1) || (st_pred_id == hit_sector+1) ||(st_pred_id == hit_sector+29)||(st_pred_id == hit_sector-29))
327  {
328  // Get the Flight time
329  double FlightTime = locBestSCHitMatchParams->dFlightTime;
330  //St time corrected for the flight time
331  double st_corr_FlightTime = st_hits[j]->t - FlightTime;
332 
333  double pathlength = locSCzIntersection - sc_pos_soss;
334  double corr_time = st_corr_FlightTime - (incpt_ss + (slope_ss * pathlength));
335  SC_RFShiftedTime = locRFTimeFactory->Step_TimeToNearInputTime(locVertexRFTime, corr_time);
336  // double t_diff =SC_RFShiftedTime - t0;
337  double t_diff =corr_time - t0;
338  h1_tDiff->Fill(t_diff);
339  h1_SC_ShiftedTime->Fill(SC_RFShiftedTime);
340  //SS accidentals
341  if (!((-10 < t_diff) && (t_diff <10)) && (-20 < t_diff) && (t_diff < 20))
342  {
343  h_N_recd_hit_z_ss_ACC[k]->Fill(st_pred_id);
344  }
345  //SS recorded hits
346  if ((-10 < t_diff) && (t_diff <10))
347  {
348  h_N_recd_hit_z_ss[k]->Fill(st_pred_id);
349  break;
350  }
351  }// sector cretria
352  }// recorded hits loop
353  }// z verification in an interval
354  }// loop over ss intervals
355  //BS intervals
356  for (uint32_t p = 0; p < Nof_bs_intervals; p++)
357  {
358  z_bs[p] = sc_pos_eoss + bs_interval * p ;
359  //cout << z_bs[p]<<endl;
360  if ((z_bs[p] <= locSCzIntersection) && (locSCzIntersection < (z_bs[p]+bs_interval)))
361  {
362  //predicted tracks to hit BS interval
363  h_N_trck_prd_z_bs[p]->Fill(st_pred_id);
364  for (uint32_t j = 0; j < st_hits.size(); j++)
365  {
366  int hit_sector = st_hits[j]->sector;
367  if ((st_pred_id == hit_sector)||(st_pred_id == hit_sector-1) || (st_pred_id == hit_sector+1) ||(st_pred_id == hit_sector+29)||(st_pred_id == hit_sector-29))
368  {
369  //BS efficiency
370  // Get the Flight time
371  double FlightTime = locBestSCHitMatchParams->dFlightTime;
372  //St time corrected for the flight time
373  double st_corr_FlightTime = st_hits[j]->t - FlightTime;
374  double SS_Length = sc_pos_eoss - sc_pos_soss;// same for along z or along the paddle
375 
376  double path_bs = SS_Length + (locSCzIntersection - sc_pos_eoss)*sc_angle_corr;
377  double corr_time_bs= st_corr_FlightTime - (incpt_bs + (slope_bs * path_bs));
378 
379  // double t_diff =SC_RFShiftedTime - t0;
380  double t_diff = corr_time_bs - t0;
381  h1_tDiff->Fill(t_diff);
382  h1_SC_ShiftedTime->Fill(SC_RFShiftedTime);
383 
384  SC_RFShiftedTime = locRFTimeFactory->Step_TimeToNearInputTime(locVertexRFTime, Corr_Time_bs);
385 
386  //BS accidentals
387  if (!((-10 < t_diff) && (t_diff <10)) && (-20 < t_diff) && (t_diff < 20))
388  {
389  h_N_recd_hit_z_bs_ACC[p]->Fill(st_pred_id);
390  }
391  //BS recorded hits
392  if ((-10 < t_diff) && (t_diff <10))
393  {
394  h_N_recd_hit_z_bs[p]->Fill(st_pred_id);
395  break;
396  }
397  } // sector cretria
398  } // recorded hits loop
399  } // z verification in an interval
400  }// loop over ss intervals
401  for (uint32_t k = 0; k < Nof_ns_intervals; k++)
402  {
403  z_ns[k] = sc_pos_eobs + ns_interval * k ;
404  //cout << z_ns[k]<<endl;
405  if ((z_ns[k] <= locSCzIntersection) && (locSCzIntersection <= (z_ns[k]+ns_interval)))
406  {
407  h_N_trck_prd_z_ns[k]->Fill(st_pred_id);
408  for (uint32_t j = 0; j < st_hits.size(); j++)
409  {
410  int hit_sector = st_hits[j]->sector;
411  if ((st_pred_id == hit_sector)||(st_pred_id == hit_sector-1) || (st_pred_id == hit_sector+1) ||(st_pred_id == hit_sector+29)||(st_pred_id == hit_sector-29))
412  {
413  // Get the Flight time
414  double FlightTime = locBestSCHitMatchParams->dFlightTime;
415  double SS_Length = sc_pos_eoss - sc_pos_soss;// same for along z or along the paddle
416  //St time corrected for the flight time
417  double st_corr_FlightTime = st_hits[j]->t - FlightTime;
418  //NS efficiency
419  double path_ns = SS_Length + (locSCzIntersection - sc_pos_eoss)*sc_angle_corr;
420  if (path_ns <= Bound1)
421  {
422  Corr_Time_ns= st_corr_FlightTime - (incpt_ss + (slope_ss * path_ns));
423  SC_RFShiftedTime = locRFTimeFactory->Step_TimeToNearInputTime(locVertexRFTime, Corr_Time_ns);
424  }
425  else if ((Bound1 < path_ns)&&(path_ns <= Bound2))
426  {
427  Corr_Time_ns = st_corr_FlightTime - (incpt_bs + (slope_bs * path_ns));
428  SC_RFShiftedTime = locRFTimeFactory->Step_TimeToNearInputTime(locVertexRFTime, Corr_Time_ns);
429  }
430  else
431  {
432  Corr_Time_ns = st_corr_FlightTime - (incpt_ns + (slope_ns * path_ns));
433  SC_RFShiftedTime = locRFTimeFactory->Step_TimeToNearInputTime(locVertexRFTime, Corr_Time_ns);
434  }
435  double t_diff =Corr_Time_ns - t0;
436  //NS Accidentals
437  if (!((-10 < t_diff) && (t_diff <10)) && (-20 < t_diff) && (t_diff < 20))
438  {
439  h_N_recd_hit_z_ns_ACC[k]->Fill(st_pred_id);
440  }
441  // NS recorded hits
442  if ((-10 < t_diff) && (t_diff <10))
443  {
444  h_N_recd_hit_z_ns[k]->Fill(st_pred_id);
445  break;
446  }
447  }// sector cretria
448  } // recorded hits loop
449  } // z verification in an interval
450  }// loop over ss intervals
451  }//end of trcak position loop
452 
453  }// end of charged track loop
454  japp->RootFillUnLock(this); //RELEASE ROOT FILL LOCK
455  return NOERROR;
456 }
457 
458 //------------------
459 // erun
460 //------------------
462 {
463  // This is called whenever the run number changes, before it is
464  // changed to give you a chance to clean up before processing
465  // events from the next run number.
466  return NOERROR;
467 }
468 
469 //------------------
470 // fini
471 //------------------
473 {
474 
475  // Called before program exit after event processing is finished.
476  japp->RootUnLock();
477  return NOERROR;
478 }
479 
static TH1D * h_N_trck_prd_z_ns_eff[Nof_ns_intervals]
static TH1D * h_N_recd_hit_z_bs[Nof_bs_intervals]
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
DApplication * dapp
DRFTime_factory * locRFTimeFactory
static TH2I * h2_x_vs_y
static TH1D * h_N_recd_hit_z_ss[Nof_ss_intervals]
static TH1D * h_N_trck_prd_z_bs_eff[Nof_bs_intervals]
double z(void) const
bool Get_SCMatchParams(const DTrackingData *locTrack, vector< shared_ptr< const DSCHitMatchParams > > &locMatchParams) const
TVector3 DVector3
Definition: DVector3.h:14
static TH1D * h_z_v
Double_t x[NCHANNELS]
Definition: st_tw_resols.C:39
const uint32_t Nof_ss_intervals
jerror_t fini(void)
Called after last event of last event source has been processed.
#define y
const DChargedTrackHypothesis * Get_BestTrackingFOM(void) const
Definition: DChargedTrack.h:86
static TH1D * h1_RFtime
static TH1D * h_N_Hit_in_track
const DVector3 & position(void) const
const DTrackTimeBased * Get_TrackTimeBased(void) const
static TH1D * h1_qVectorSize
uint32_t Get_L1FrontPanelTriggerBits(void) const
static TH1D * h_N_trck_prd_z_ss[Nof_ss_intervals]
static TH1D * h1_qVectorSize_ACuts
static TH2I * h2_z_vs_r
static TH1D * h_N_recd_hit_z_ss_ACC[Nof_ss_intervals]
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
JApplication * japp
static TH1D * h_N_trck_prd_z_ns[Nof_ns_intervals]
InitPlugin_t InitPlugin
static TH1D * h1_Centered_RFtime
DGeometry * GetDGeometry(unsigned int run_number)
#define _DBG_
Definition: HDEVIO.h:12
static TH1D * h_N_trck_prd_z_bs[Nof_bs_intervals]
int Ndof
Number of degrees of freedom in the fit.
static TH1D * h_N_recd_hit_z_ns[Nof_ns_intervals]
const uint32_t Nof_ns_intervals
static TH1D * h_fom
static TH1D * h_N_recd_hit_z_bs_ACC[Nof_bs_intervals]
const DVector3 & momentum(void) const
static TH1D * h1_tDiff
jerror_t init(void)
Called once at program start.
map< DetectorSystem_t, vector< DTrackFitter::Extrapolation_t > > extrapolations
unsigned int dNumParticleVotes
Definition: DEventRFBunch.h:32
double Step_TimeToNearInputTime(double locTimeToStep, double locTimeToStepTo) const
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
static TH1D * h_N_recd_hit_z_ns_ACC[Nof_ns_intervals]
static TH1D * h1_SC_ShiftedTime
static TH1D * h1_st_pred_id
int main(int argc, char *argv[])
Definition: gendoc.cc:6
const uint32_t Nof_bs_intervals
bool GetStartCounterGeom(vector< vector< DVector3 > > &pos, vector< vector< DVector3 > > &norm) const
Definition: DGeometry.cc:1983
static TH1D * h_N_trck_prd_z_ss_eff[Nof_ss_intervals]