Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JEventProcessor_TOF_Eff.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: JEventProcessor_TOF_Eff.cc
4 //
5 
7 
8 // Routine used to create our JEventProcessor
9 extern "C"
10 {
11  void InitPlugin(JApplication *locApplication)
12  {
13  InitJANAPlugin(locApplication);
14  locApplication->AddProcessor(new JEventProcessor_TOF_Eff()); //register this plugin
15  }
16 } // "C"
17 
18 //define static local variable //declared in header file
20 
21 //------------------
22 // init
23 //------------------
25 {
26  //TRACK REQUIREMENTS
27  dMaxFCALDeltaT = 2.0;
28  dMinTrackingFOM = 5.73303E-7; // +/- 5 sigma
29  dMinNumTrackHits = 16; //e.g. 4 in each FDC plane
32  dMaxVertexR = 1.0;
33  dMaxTOFThetaCut = 15.0; //it could be projected to miss, but still hit it
35  //action initialize not necessary: is empty
36 
37  TDirectory* locOriginalDir = gDirectory;
38  gDirectory->mkdir("TOF_Eff")->cd();
39 
40  //Histograms
41  string locHistName, locHistTitle;
42  dMinTOFPaddleMatchDistance = 9.0; //1.5*BARWIDTH //What DTOFPoint factory uses as of this writing
43 
44  //TOFPaddle
45  gDirectory->mkdir("TOFPaddle")->cd();
46  locHistName = "TrackYVsVerticalPaddle_HasHit_Top";
47  locHistTitle = "TOF Paddle Has Top Hit;Projected Vertical Paddle;Projected TOF Hit Y (cm)";
48  dHist_TOFPaddleTrackYVsVerticalPaddle_HasHit_Top = new TH2I(locHistName.c_str(), locHistTitle.c_str(), 44, 0.5, 44.5, 130, -130.0, 130.0);
49 
50  locHistName = "TrackYVsVerticalPaddle_TotalHit_Top";
51  locHistTitle = "TOF Paddle Total Top Hit;Projected Vertical Paddle;Projected TOF Hit Y (cm)";
52  dHist_TOFPaddleTrackYVsVerticalPaddle_TotalHit_Top = new TH2I(locHistName.c_str(), locHistTitle.c_str(), 44, 0.5, 44.5, 130, -130.0, 130.0);
53 
54  locHistName = "HorizontalPaddleVsTrackX_HasHit_North";
55  locHistTitle = "TOF Paddle Has North Hit;Projected TOF Hit X (cm);Projected Horizontal Paddle";
56  dHist_TOFPaddleHorizontalPaddleVsTrackX_HasHit_North = new TH2I(locHistName.c_str(), locHistTitle.c_str(), 130, -130.0, 130.0, 44, 0.5, 44.5);
57 
58  locHistName = "HorizontalPaddleVsTrackX_TotalHit_North";
59  locHistTitle = "TOF Paddle Total North Hit;Projected TOF Hit X (cm);Projected Horizontal Paddle";
60  dHist_TOFPaddleHorizontalPaddleVsTrackX_TotalHit_North = new TH2I(locHistName.c_str(), locHistTitle.c_str(), 130, -130.0, 130.0, 44, 0.5, 44.5);
61 
62  locHistName = "TrackYVsVerticalPaddle_HasHit_Bottom";
63  locHistTitle = "TOF Paddle Has Bottom Hit;Projected Vertical Paddle;Projected TOF Hit Y (cm)";
64  dHist_TOFPaddleTrackYVsVerticalPaddle_HasHit_Bottom = new TH2I(locHistName.c_str(), locHistTitle.c_str(), 44, 0.5, 44.5, 130, -130.0, 130.0);
65 
66  locHistName = "TrackYVsVerticalPaddle_TotalHit_Bottom";
67  locHistTitle = "TOF Paddle Total Bottom Hit;Projected Vertical Paddle;Projected TOF Hit Y (cm)";
68  dHist_TOFPaddleTrackYVsVerticalPaddle_TotalHit_Bottom = new TH2I(locHistName.c_str(), locHistTitle.c_str(), 44, 0.5, 44.5, 130, -130.0, 130.0);
69 
70  locHistName = "HorizontalPaddleVsTrackX_HasHit_South";
71  locHistTitle = "TOF Paddle Has South Hit;Projected TOF Hit X (cm);Projected Horizontal Paddle";
72  dHist_TOFPaddleHorizontalPaddleVsTrackX_HasHit_South = new TH2I(locHistName.c_str(), locHistTitle.c_str(), 130, -130.0, 130.0, 44, 0.5, 44.5);
73 
74  locHistName = "HorizontalPaddleVsTrackX_TotalHit_South";
75  locHistTitle = "TOF Paddle Total South Hit;Projected TOF Hit X (cm);Projected Horizontal Paddle";
76  dHist_TOFPaddleHorizontalPaddleVsTrackX_TotalHit_South = new TH2I(locHistName.c_str(), locHistTitle.c_str(), 130, -130.0, 130.0, 44, 0.5, 44.5);
77  gDirectory->cd("..");
78 
79  //TOFPoint
80  gDirectory->mkdir("TOFPoint")->cd();
81  locHistName = "TrackTOFYVsX_HasHit";
82  locHistTitle = "TOF Has Hit;Projected TOF Hit X (cm);Projected TOF Hit Y (cm)";
83  dHist_TrackTOFYVsX_HasHit = new TH2I(locHistName.c_str(), locHistTitle.c_str(), 130, -130.0, 130.0, 130, -130.0, 130.0);
84 
85  locHistName = "TrackTOFYVsX_TotalHit";
86  locHistTitle = "TOF Total Hit;Projected TOF Hit X (cm);Projected TOF Hit Y (cm)";
87  dHist_TrackTOFYVsX_TotalHit = new TH2I(locHistName.c_str(), locHistTitle.c_str(), 130, -130.0, 130.0, 130, -130.0, 130.0);
88 
89  locHistName = "TrackTOF2DPaddles_HasHit";
90  locHistTitle = "TOF Has Hit;Projected Vertical TOF Paddle;Projected Horizontal TOF Paddle";
91  dHist_TrackTOF2DPaddles_HasHit = new TH2I(locHistName.c_str(), locHistTitle.c_str(), 44, 0.5, 44.5, 44, 0.5, 44.5);
92 
93  locHistName = "TrackTOF2DPaddles_TotalHit";
94  locHistTitle = "TOF Total Hit;Projected Vertical TOF Paddle;Projected Horizontal TOF Paddle";
95  dHist_TrackTOF2DPaddles_TotalHit = new TH2I(locHistName.c_str(), locHistTitle.c_str(), 44, 0.5, 44.5, 44, 0.5, 44.5);
96  gDirectory->cd("..");
97 
98  // back to original dir
99  locOriginalDir->cd();
100 
101  //TTREE INTERFACE
102  //MUST DELETE WHEN FINISHED: OR ELSE DATA WON'T BE SAVED!!!
103  dTreeInterface = DTreeInterface::Create_DTreeInterface("tof_eff", "tree_tof_eff.root");
104 
105  //TTREE BRANCHES
106  DTreeBranchRegister locTreeBranchRegister;
107 
108  //TRACK
109  locTreeBranchRegister.Register_Single<Int_t>("PID_PDG"); //gives charge, mass, beta //is unknown if no FCAL hit
110  locTreeBranchRegister.Register_Single<Float_t>("TrackVertexZ");
111  locTreeBranchRegister.Register_Single<TVector3>("TrackP3");
112  locTreeBranchRegister.Register_Single<UInt_t>("TrackCDCRings"); //rings correspond to bits (1 -> 28)
113  locTreeBranchRegister.Register_Single<UInt_t>("TrackFDCPlanes"); //planes correspond to bits (1 -> 24)
114 
115  //TOF
116  locTreeBranchRegister.Register_Single<UChar_t>("NumTOFPoints");
117  locTreeBranchRegister.Register_Single<Float_t>("ProjectedTOFX");
118  locTreeBranchRegister.Register_Single<Float_t>("ProjectedTOFY");
119  locTreeBranchRegister.Register_Single<UChar_t>("ProjectedTOFBar_Horizontal");
120  locTreeBranchRegister.Register_Single<UChar_t>("ProjectedTOFBar_Vertical");
121 
122  //SEARCH TOF PADDLE
123  //Nearest hit: //0 for none, 1 - 44 for both ends //101 - 144 for North/Top only, 201 - 244 for South/Bottom only (only = above threshold)
124  //Nearest: No time cut (yet?)
125  locTreeBranchRegister.Register_Single<UChar_t>("NearestTOFHit_Horizontal");
126  locTreeBranchRegister.Register_Single<Float_t>("HorizontalTOFHitDistance");
127  locTreeBranchRegister.Register_Single<UChar_t>("NearestTOFHit_Vertical");
128  locTreeBranchRegister.Register_Single<Float_t>("VerticalTOFHitDistance");
129 
130  //SEARCH TOF POINT //nearest: must be in time: PID:OUT_OF_TIME_CUT
131  locTreeBranchRegister.Register_Single<Float_t>("NearestTOFPointDeltaX");
132  locTreeBranchRegister.Register_Single<Float_t>("NearestTOFPointDeltaY");
133  locTreeBranchRegister.Register_Single<UShort_t>("NearestTOFPointStatus");
134  /*
135  NearestTOFPointStatus: horizontal_bar + 45*vertical_bar + 45*45*horizontal_status + 45*45*4*vertical_status
136  *_bar = 0 -> 44 (0 for none (not matched to this plane))
137  *_Status: 0 if no hit (not matched to this plane), 1 if only North/Top hit above threshold, 2 if only South/Bottom hit above threshold, 3 if both hits above threshold
138  Note that if it's a single-ended bar, the status cannot be 3.
139  */
140  locTreeBranchRegister.Register_Single<Bool_t>("IsMatchedToTrack"); //false if not registered in DDetectorMatches
141 
142  //FOUND TOF POINT //only if matched: for evaluating PID quality
143  locTreeBranchRegister.Register_Single<Float_t>("TOFPointDeltaT"); //TOF - RF
144  locTreeBranchRegister.Register_Single<Float_t>("TOFPointTimeFOM");
145  locTreeBranchRegister.Register_Single<Float_t>("TOFPointdEdX");
146 
147  //REGISTER BRANCHES
148  dTreeInterface->Create_Branches(locTreeBranchRegister);
149 
150  return NOERROR;
151 }
152 
153 
154 //------------------
155 // brun
156 //------------------
157 jerror_t JEventProcessor_TOF_Eff::brun(jana::JEventLoop* locEventLoop, int locRunNumber)
158 {
159  // This is called whenever the run number changes
160 
161  return NOERROR;
162 }
163 
164 //------------------
165 // evnt
166 //------------------
167 
168 jerror_t JEventProcessor_TOF_Eff::evnt(jana::JEventLoop* locEventLoop, uint64_t locEventNumber)
169 {
170  // This is called for every event. Use of common resources like writing
171  // to a file or filling a histogram should be mutex protected. Using
172  // locEventLoop->Get(...) to get reconstructed objects (and thereby activating the
173  // reconstruction algorithm) should be done outside of any mutex lock
174  // since multiple threads may call this method at the same time.
175 
176  // This plugin is used to determine the reconstruction efficiency of hits in the BCAL
177  // Note, this is hit-level, not shower-level. Hits: By sector/layer/module/end
178 
179  //CUT ON TRIGGER TYPE
180  const DTrigger* locTrigger = NULL;
181  locEventLoop->GetSingle(locTrigger);
182  if(locTrigger->Get_L1FrontPanelTriggerBits() != 0)
183  return NOERROR;
184 
185  const DEventRFBunch* locEventRFBunch = NULL;
186  locEventLoop->GetSingle(locEventRFBunch);
187  if(locEventRFBunch->dNumParticleVotes <= 1)
188  return NOERROR; //don't trust PID: beta-dependence
189 
190  vector<const DChargedTrack*> locChargedTracks;
191  locEventLoop->Get(locChargedTracks);
192 
193  const DParticleID* locParticleID = NULL;
194  locEventLoop->GetSingle(locParticleID);
195 
196  vector<const DTOFPoint*> locTOFPoints;
197  locEventLoop->Get(locTOFPoints);
198 
199  vector<const DTOFPaddleHit*> locTOFPaddleHits;
200  locEventLoop->Get(locTOFPaddleHits);
201 
202  const DDetectorMatches* locDetectorMatches = NULL;
203  locEventLoop->GetSingle(locDetectorMatches);
204 
205  //Try to select the most-pure sample of tracks possible
206  set<const DChargedTrackHypothesis*> locBestTracks;
207  for(auto& locChargedTrack : locChargedTracks)
208  {
209  //loop over PID hypotheses and find the best (if any good enough)
210  const DChargedTrackHypothesis* locBestChargedTrackHypothesis = nullptr;
211  double locBestTrackingFOM = -1.0;
212  for(auto& locChargedTrackHypothesis : locChargedTrack->dChargedTrackHypotheses)
213  {
214  if((locChargedTrackHypothesis->PID() == Electron) || (locChargedTrackHypothesis->PID() == Positron))
215  continue; //don't evaluate for these
216 
217  if(locChargedTrackHypothesis->position().Perp() > dMaxVertexR)
218  continue; //don't trust reconstruction if not close to target
219 
220  //Need PID for beta-dependence, but cannot use TOF info: would bias
221  if(!Cut_FCALTiming(locChargedTrackHypothesis, locParticleID, locEventRFBunch))
222  continue;
223 
224  auto locTrackTimeBased = locChargedTrackHypothesis->Get_TrackTimeBased();
225  if(locTrackTimeBased->FOM < dMinTrackingFOM)
226  continue; //don't trust tracking results: bad tracking FOM
227 
228  if(!dCutAction_TrackHitPattern->Cut_TrackHitPattern(locParticleID, locTrackTimeBased))
229  continue; //don't trust tracking results: not many grouped hits
230 
231  unsigned int locNumTrackHits = locTrackTimeBased->Ndof + 5;
232  if(locNumTrackHits < dMinNumTrackHits)
233  continue; //don't trust tracking results: not many hits
234 
235  if(locTrackTimeBased->FOM < locBestTrackingFOM)
236  continue; //not the best mass hypothesis
237 
238  locBestTrackingFOM = locTrackTimeBased->FOM;
239  locBestChargedTrackHypothesis = locChargedTrackHypothesis;
240  }
241 
242  //if passed all cuts, save the best
243  if(locBestChargedTrackHypothesis != nullptr)
244  locBestTracks.insert(locBestChargedTrackHypothesis);
245  }
246 
247  // Loop over the good tracks, using the best DTrackTimeBased object for each
248  for(auto& locChargedTrackHypothesis : locBestTracks)
249  {
250  auto locTrackTimeBased = locChargedTrackHypothesis->Get_TrackTimeBased();
251 
252  //Predict TOF Surface Hit Location
253  DVector3 locProjectedTOFIntersection;
254  unsigned int locProjectedHorizontalBar = 0, locProjectedVerticalBar = 0;
255  vector<DTrackFitter::Extrapolation_t>extrapolations=locTrackTimeBased->extrapolations.at(SYS_TOF);
256  if(!locParticleID->PredictTOFPaddles(extrapolations, locProjectedHorizontalBar, locProjectedVerticalBar, &locProjectedTOFIntersection))
257  {
258  if(locTrackTimeBased->momentum().Theta()*180.0/TMath::Pi() > dMaxTOFThetaCut)
259  continue; //not predicted to hit TOF
260  }
261 
262  //Find closest TOF point
263  double locStartTime = locTrackTimeBased->t0();
264  shared_ptr<const DTOFHitMatchParams> locClosestMatchParams;
265  double locBestPointDeltaX = 999.9, locBestPointDeltaY = 999.9;
266  const DTOFPoint* locClosestTOFPoint = nullptr;
267  if(locParticleID->Get_ClosestToTrack(extrapolations, locTOFPoints, false, locStartTime, locClosestMatchParams))
268  {
269  locClosestTOFPoint = locClosestMatchParams->dTOFPoint;
270  locBestPointDeltaX = locClosestMatchParams->dDeltaXToHit;
271  locBestPointDeltaY = locClosestMatchParams->dDeltaYToHit;
272  }
273 
274  //Find closest TOF paddles
275  double locBestPaddleDeltaX = 999.9, locBestPaddleDeltaY = 999.9, locBestPaddleDistance_Vertical = 999.9, locBestPaddleDistance_Horizontal = 999.9;
276  //first in pair is vertical, second is horizontal // NULL If none / doesn't hit TOF
277  locStartTime = locParticleID->Calc_PropagatedRFTime(locChargedTrackHypothesis, locEventRFBunch);
278  const DTOFPaddleHit* locClosestTOFPaddleHit_Vertical = locParticleID->Get_ClosestTOFPaddleHit_Vertical(extrapolations, locTOFPaddleHits, locStartTime, locBestPaddleDeltaX, locBestPaddleDistance_Vertical);
279  const DTOFPaddleHit* locClosestTOFPaddleHit_Horizontal = locParticleID->Get_ClosestTOFPaddleHit_Horizontal(extrapolations, locTOFPaddleHits, locStartTime, locBestPaddleDeltaY, locBestPaddleDistance_Horizontal);
280 
281  //Is match to TOF point?
282  auto locTOFHitMatchParams = locChargedTrackHypothesis->Get_TOFHitMatchParams();
283  bool locIsMatchedToTrack = (locTOFHitMatchParams != nullptr);
284 
285  //If so, calc PID info: timing, dE/dx
286  double locTOFPointDeltaT = 0.0;
287  double locTOFTimeFOM = Calc_TOFTiming(locChargedTrackHypothesis, locParticleID, locEventRFBunch, locTOFPointDeltaT);
288  double locTOFPointdEdX = locIsMatchedToTrack ? locTOFHitMatchParams->dEdx : 0.0;
289 
290  //calc nearest tof hit/point status, bars
291  int locNearestTOFPointStatus = 0;
292  if(locClosestTOFPoint != NULL)
293  {
294  locNearestTOFPointStatus = locClosestTOFPoint->dHorizontalBar + 45*locClosestTOFPoint->dVerticalBar;
295  locNearestTOFPointStatus += 45*45*locClosestTOFPoint->dHorizontalBarStatus + 45*45*4*locClosestTOFPoint->dVerticalBarStatus;
296  }
297 
298  int locNearestTOFHitHorizontal = Calc_NearestHit(locClosestTOFPaddleHit_Horizontal);
299  int locNearestTOFHitVertical = Calc_NearestHit(locClosestTOFPaddleHit_Vertical);
300 
301 
302  // FILL HISTOGRAMS
303  // Since we are filling histograms local to this plugin, it will not interfere with other ROOT operations: can use plugin-wide ROOT fill lock
304  japp->RootFillLock(this); //ACQUIRE ROOT FILL LOCK
305  {
306  //TOFPaddle
307  dHist_TOFPaddleTrackYVsVerticalPaddle_TotalHit_Top->Fill(locProjectedVerticalBar, locProjectedTOFIntersection.Y());
308  dHist_TOFPaddleHorizontalPaddleVsTrackX_TotalHit_North->Fill(locProjectedTOFIntersection.X(), locProjectedHorizontalBar);
309  dHist_TOFPaddleTrackYVsVerticalPaddle_TotalHit_Bottom->Fill(locProjectedVerticalBar, locProjectedTOFIntersection.Y());
310  dHist_TOFPaddleHorizontalPaddleVsTrackX_TotalHit_South->Fill(locProjectedTOFIntersection.X(), locProjectedHorizontalBar);
311 
312  //TOFPoint
313  dHist_TrackTOFYVsX_TotalHit->Fill(locProjectedTOFIntersection.X(), locProjectedTOFIntersection.Y());
314  dHist_TrackTOF2DPaddles_TotalHit->Fill(locProjectedVerticalBar, locProjectedHorizontalBar);
315 
316  //TOFPaddle: Horizontal
317  if(locBestPaddleDeltaY <= dMinTOFPaddleMatchDistance) //horizontal match
318  {
319  dHist_TOFPaddleHorizontalPaddleVsTrackX_HasHit_North->Fill(locProjectedTOFIntersection.X(), locProjectedHorizontalBar);
320  dHist_TOFPaddleHorizontalPaddleVsTrackX_HasHit_South->Fill(locProjectedTOFIntersection.X(), locProjectedHorizontalBar);
321  }
322 
323  //TOFPaddle: Vertical
324  if(locBestPaddleDeltaX <= dMinTOFPaddleMatchDistance) //vertical match
325  {
326  dHist_TOFPaddleTrackYVsVerticalPaddle_HasHit_Top->Fill(locProjectedVerticalBar, locProjectedTOFIntersection.Y());
327  dHist_TOFPaddleTrackYVsVerticalPaddle_HasHit_Bottom->Fill(locProjectedVerticalBar, locProjectedTOFIntersection.Y());
328  }
329 
330  //TOFPoint
331  if(locIsMatchedToTrack)
332  {
333  dHist_TrackTOFYVsX_HasHit->Fill(locProjectedTOFIntersection.X(), locProjectedTOFIntersection.Y());
334  dHist_TrackTOF2DPaddles_HasHit->Fill(locProjectedVerticalBar, locProjectedHorizontalBar);
335  }
336  }
337  japp->RootFillUnLock(this); //RELEASE ROOT FILL LOCK
338 
339  //TRACK
340  Particle_t locPID = (locChargedTrackHypothesis->Get_FCALShowerMatchParams() != NULL) ? locChargedTrackHypothesis->PID() : Unknown;
341  dTreeFillData.Fill_Single<Int_t>("PID_PDG", PDGtype(locPID));
342  dTreeFillData.Fill_Single<Float_t>("TrackVertexZ", locChargedTrackHypothesis->position().Z());
343  dTreeFillData.Fill_Single<UInt_t>("TrackCDCRings", locTrackTimeBased->dCDCRings);
344  dTreeFillData.Fill_Single<UInt_t>("TrackFDCPlanes", locTrackTimeBased->dFDCPlanes);
345  DVector3 locDP3 = locChargedTrackHypothesis->momentum();
346  TVector3 locP3(locDP3.X(), locDP3.Y(), locDP3.Z());
347  dTreeFillData.Fill_Single<TVector3>("TrackP3", locP3);
348 
349  //TOF
350  dTreeFillData.Fill_Single<UChar_t>("NumTOFPoints", locTOFPoints.size());
351  dTreeFillData.Fill_Single<Float_t>("ProjectedTOFX", locProjectedTOFIntersection.X());
352  dTreeFillData.Fill_Single<Float_t>("ProjectedTOFY", locProjectedTOFIntersection.Y());
353  dTreeFillData.Fill_Single<UChar_t>("ProjectedTOFBar_Horizontal", locProjectedHorizontalBar);
354  dTreeFillData.Fill_Single<UChar_t>("ProjectedTOFBar_Vertical", locProjectedVerticalBar);
355 
356  //SEARCH TOF PADDLE
357  dTreeFillData.Fill_Single<UChar_t>("NearestTOFHit_Horizontal", locNearestTOFHitHorizontal);
358  dTreeFillData.Fill_Single<Float_t>("HorizontalTOFHitDistance", locBestPaddleDistance_Horizontal);
359  dTreeFillData.Fill_Single<UChar_t>("NearestTOFHit_Vertical", locNearestTOFHitVertical);
360  dTreeFillData.Fill_Single<Float_t>("VerticalTOFHitDistance", locBestPaddleDistance_Vertical);
361 
362  //SEARCH TOF POINT
363  dTreeFillData.Fill_Single<Float_t>("NearestTOFPointDeltaX", locBestPointDeltaX);
364  dTreeFillData.Fill_Single<Float_t>("NearestTOFPointDeltaY", locBestPointDeltaY);
365  dTreeFillData.Fill_Single<UShort_t>("NearestTOFPointStatus", locNearestTOFPointStatus);
366  dTreeFillData.Fill_Single<Bool_t>("IsMatchedToTrack", locIsMatchedToTrack);
367 
368  //FOUND TOF POINT
369  dTreeFillData.Fill_Single<Float_t>("TOFPointDeltaT", locTOFPointDeltaT);
370  dTreeFillData.Fill_Single<Float_t>("TOFPointTimeFOM", locTOFTimeFOM);
371  dTreeFillData.Fill_Single<Float_t>("TOFPointdEdX", locTOFPointdEdX);
372 
373  //FILL TTREE
375  }
376 
377  return NOERROR;
378 }
379 
381 {
382  //Nearest hit: //0 for none, 1 - 44 for both ends //101 - 144 for North/Top only, 201 - 244 for South/Bottom only (only = above threshold)
383  if(locPaddleHit == nullptr)
384  return 0;
385 
386  int locNearestHit = locPaddleHit->bar;
387  if((locPaddleHit->E_north > 0.00001) && !(locPaddleHit->E_south > 0.00001)) //0.00001: tolerance
388  locNearestHit += 100.0;
389  else if(!(locPaddleHit->E_north > 0.00001) && (locPaddleHit->E_south > 0.00001))
390  locNearestHit += 200.0;
391 
392  return locNearestHit;
393 }
394 
395 bool JEventProcessor_TOF_Eff::Cut_FCALTiming(const DChargedTrackHypothesis* locChargedTrackHypothesis, const DParticleID* locParticleID, const DEventRFBunch* locEventRFBunch)
396 {
397  auto locFCALShowerMatchParams = locChargedTrackHypothesis->Get_FCALShowerMatchParams();
398  if(locFCALShowerMatchParams == NULL)
399  return true; //don't require FCAL hit: limits reach of study
400 
401  double locStartTime = locParticleID->Calc_PropagatedRFTime(locChargedTrackHypothesis, locEventRFBunch);
402  const DFCALShower* locFCALShower = locFCALShowerMatchParams->dFCALShower;
403 
404  double locDeltaT = locFCALShower->getTime() - locFCALShowerMatchParams->dFlightTime - locStartTime;
405  return (fabs(locDeltaT) <= dMaxFCALDeltaT);
406 }
407 
408 double JEventProcessor_TOF_Eff::Calc_TOFTiming(const DChargedTrackHypothesis* locChargedTrackHypothesis, const DParticleID* locParticleID, const DEventRFBunch* locEventRFBunch, double& locDeltaT)
409 {
410  auto locTOFHitMatchParams = locChargedTrackHypothesis->Get_TOFHitMatchParams();
411  if(locTOFHitMatchParams == nullptr)
412  return -1.0;
413 
414  double locStartTime = locParticleID->Calc_PropagatedRFTime(locChargedTrackHypothesis, locEventRFBunch);
415  locDeltaT = locTOFHitMatchParams->dHitTime - locTOFHitMatchParams->dFlightTime - locStartTime;
416 
417  double locPIDFOM = -1.0; //not able to calc this correctly yet
418  return locPIDFOM;
419 }
420 
421 //------------------
422 // erun
423 //------------------
425 {
426  // This is called whenever the run number changes, before it is
427  // changed to give you a chance to clean up before processing
428  // events from the next run number.
429 
430  return NOERROR;
431 }
432 
433 //------------------
434 // fini
435 //------------------
437 {
438  // Called before program exit after event processing is finished.
439 
441  delete dTreeInterface; //saves trees to file, closes file
442 
443  return NOERROR;
444 }
445 
jerror_t fini(void)
Called after last event of last event source has been processed.
TH2I * dHist_TOFPaddleHorizontalPaddleVsTrackX_HasHit_North
jerror_t init(void)
Called once at program start.
int dHorizontalBar
Definition: DTOFPoint.h:38
TH2I * dHist_TOFPaddleHorizontalPaddleVsTrackX_HasHit_South
const DTOFPaddleHit * Get_ClosestTOFPaddleHit_Horizontal(const DReferenceTrajectory *locReferenceTrajectory, const vector< const DTOFPaddleHit * > &locTOFPaddleHits, double locInputStartTime, double &locBestDeltaY, double &locBestDistance) const
TVector3 DVector3
Definition: DVector3.h:14
TH2I * dHist_TOFPaddleHorizontalPaddleVsTrackX_TotalHit_North
int dHorizontalBarStatus
Definition: DTOFPoint.h:43
double getTime() const
Definition: DFCALShower.h:161
void Register_Single(string locBranchName)
const DTrackTimeBased * Get_TrackTimeBased(void) const
bool Create_Branches(const DTreeBranchRegister &locTreeBranchRegister)
uint32_t Get_L1FrontPanelTriggerBits(void) const
jerror_t erun(void)
Called every time run number changes, provided brun has been called.
double Calc_PropagatedRFTime(const DKinematicData *locKinematicData, const DEventRFBunch *locEventRFBunch) const
static int PDGtype(Particle_t p)
shared_ptr< const DTOFHitMatchParams > Get_TOFHitMatchParams(void) const
JApplication * japp
jerror_t brun(jana::JEventLoop *locEventLoop, int locRunNumber)
Called every time a new run number is detected.
TH2I * dHist_TOFPaddleTrackYVsVerticalPaddle_HasHit_Bottom
bool PredictTOFPaddles(const DReferenceTrajectory *rt, unsigned int &hbar, unsigned int &vbar, DVector3 *intersection=nullptr) const
void Fill(DTreeFillData &locTreeFillData)
static DTreeInterface * Create_DTreeInterface(string locTreeName, string locFileName)
InitPlugin_t InitPlugin
Definition: GlueX.h:20
jerror_t evnt(jana::JEventLoop *locEventLoop, uint64_t locEventNumber)
Called every event.
const DTOFPaddleHit * Get_ClosestTOFPaddleHit_Vertical(const DReferenceTrajectory *locReferenceTrajectory, const vector< const DTOFPaddleHit * > &locTOFPaddleHits, double locInputStartTime, double &locBestDeltaX, double &locBestDistance) const
static thread_local DTreeFillData dTreeFillData
int Calc_NearestHit(const DTOFPaddleHit *locPaddleHit) const
bool Get_ClosestToTrack(const DReferenceTrajectory *rt, const vector< const DBCALShower * > &locBCALShowers, bool locCutFlag, double &locStartTime, shared_ptr< const DBCALShowerMatchParams > &locBestMatchParams, double *locStartTimeVariance=nullptr, DVector3 *locBestProjPos=nullptr, DVector3 *locBestProjMom=nullptr) const
int Ndof
Number of degrees of freedom in the fit.
shared_ptr< const DFCALShowerMatchParams > Get_FCALShowerMatchParams(void) const
int dVerticalBar
Definition: DTOFPoint.h:39
bool Cut_TrackHitPattern(const DParticleID *locParticleID, const DKinematicData *locTrack) const
Definition: DCutActions.cc:809
double Calc_TOFTiming(const DChargedTrackHypothesis *locChargedTrackHypothesis, const DParticleID *locParticleID, const DEventRFBunch *locEventRFBunch, double &locDeltaT)
TH2I * dHist_TOFPaddleTrackYVsVerticalPaddle_TotalHit_Bottom
unsigned int dNumParticleVotes
Definition: DEventRFBunch.h:32
TH2I * dHist_TOFPaddleTrackYVsVerticalPaddle_TotalHit_Top
bool Cut_FCALTiming(const DChargedTrackHypothesis *locChargedTrackHypothesis, const DParticleID *locParticleID, const DEventRFBunch *locEventRFBunch)
DCutAction_TrackHitPattern * dCutAction_TrackHitPattern
Particle_t
Definition: particleType.h:12
void Fill_Single(string locBranchName, const DType &locData)
int dVerticalBarStatus
Definition: DTOFPoint.h:44
TH2I * dHist_TOFPaddleHorizontalPaddleVsTrackX_TotalHit_South