13 InitJANAPlugin(locApplication);
37 TDirectory* locOriginalDir = gDirectory;
38 gDirectory->mkdir(
"TOF_Eff")->cd();
41 string locHistName, locHistTitle;
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)";
50 locHistName =
"TrackYVsVerticalPaddle_TotalHit_Top";
51 locHistTitle =
"TOF Paddle Total Top Hit;Projected Vertical Paddle;Projected TOF Hit Y (cm)";
54 locHistName =
"HorizontalPaddleVsTrackX_HasHit_North";
55 locHistTitle =
"TOF Paddle Has North Hit;Projected TOF Hit X (cm);Projected Horizontal Paddle";
58 locHistName =
"HorizontalPaddleVsTrackX_TotalHit_North";
59 locHistTitle =
"TOF Paddle Total North Hit;Projected TOF Hit X (cm);Projected Horizontal Paddle";
62 locHistName =
"TrackYVsVerticalPaddle_HasHit_Bottom";
63 locHistTitle =
"TOF Paddle Has Bottom Hit;Projected Vertical Paddle;Projected TOF Hit Y (cm)";
66 locHistName =
"TrackYVsVerticalPaddle_TotalHit_Bottom";
67 locHistTitle =
"TOF Paddle Total Bottom Hit;Projected Vertical Paddle;Projected TOF Hit Y (cm)";
70 locHistName =
"HorizontalPaddleVsTrackX_HasHit_South";
71 locHistTitle =
"TOF Paddle Has South Hit;Projected TOF Hit X (cm);Projected Horizontal Paddle";
74 locHistName =
"HorizontalPaddleVsTrackX_TotalHit_South";
75 locHistTitle =
"TOF Paddle Total South Hit;Projected TOF Hit X (cm);Projected Horizontal Paddle";
80 gDirectory->mkdir(
"TOFPoint")->cd();
81 locHistName =
"TrackTOFYVsX_HasHit";
82 locHistTitle =
"TOF Has Hit;Projected TOF Hit X (cm);Projected TOF Hit Y (cm)";
85 locHistName =
"TrackTOFYVsX_TotalHit";
86 locHistTitle =
"TOF Total Hit;Projected TOF Hit X (cm);Projected TOF Hit Y (cm)";
89 locHistName =
"TrackTOF2DPaddles_HasHit";
90 locHistTitle =
"TOF Has Hit;Projected Vertical TOF Paddle;Projected Horizontal TOF Paddle";
93 locHistName =
"TrackTOF2DPaddles_TotalHit";
94 locHistTitle =
"TOF Total Hit;Projected Vertical TOF Paddle;Projected Horizontal TOF Paddle";
119 locTreeBranchRegister.
Register_Single<UChar_t>(
"ProjectedTOFBar_Horizontal");
120 locTreeBranchRegister.
Register_Single<UChar_t>(
"ProjectedTOFBar_Vertical");
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");
131 locTreeBranchRegister.
Register_Single<Float_t>(
"NearestTOFPointDeltaX");
132 locTreeBranchRegister.
Register_Single<Float_t>(
"NearestTOFPointDeltaY");
133 locTreeBranchRegister.
Register_Single<UShort_t>(
"NearestTOFPointStatus");
181 locEventLoop->GetSingle(locTrigger);
186 locEventLoop->GetSingle(locEventRFBunch);
190 vector<const DChargedTrack*> locChargedTracks;
191 locEventLoop->Get(locChargedTracks);
194 locEventLoop->GetSingle(locParticleID);
196 vector<const DTOFPoint*> locTOFPoints;
197 locEventLoop->Get(locTOFPoints);
199 vector<const DTOFPaddleHit*> locTOFPaddleHits;
200 locEventLoop->Get(locTOFPaddleHits);
203 locEventLoop->GetSingle(locDetectorMatches);
206 set<const DChargedTrackHypothesis*> locBestTracks;
207 for(
auto& locChargedTrack : locChargedTracks)
211 double locBestTrackingFOM = -1.0;
212 for(
auto& locChargedTrackHypothesis : locChargedTrack->dChargedTrackHypotheses)
214 if((locChargedTrackHypothesis->PID() ==
Electron) || (locChargedTrackHypothesis->PID() ==
Positron))
217 if(locChargedTrackHypothesis->position().Perp() >
dMaxVertexR)
221 if(!
Cut_FCALTiming(locChargedTrackHypothesis, locParticleID, locEventRFBunch))
231 unsigned int locNumTrackHits = locTrackTimeBased->
Ndof + 5;
235 if(locTrackTimeBased->FOM < locBestTrackingFOM)
238 locBestTrackingFOM = locTrackTimeBased->FOM;
239 locBestChargedTrackHypothesis = locChargedTrackHypothesis;
243 if(locBestChargedTrackHypothesis !=
nullptr)
244 locBestTracks.insert(locBestChargedTrackHypothesis);
248 for(
auto& locChargedTrackHypothesis : locBestTracks)
250 auto locTrackTimeBased = locChargedTrackHypothesis->Get_TrackTimeBased();
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))
258 if(locTrackTimeBased->momentum().Theta()*180.0/TMath::Pi() >
dMaxTOFThetaCut)
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))
269 locClosestTOFPoint = locClosestMatchParams->dTOFPoint;
270 locBestPointDeltaX = locClosestMatchParams->dDeltaXToHit;
271 locBestPointDeltaY = locClosestMatchParams->dDeltaYToHit;
275 double locBestPaddleDeltaX = 999.9, locBestPaddleDeltaY = 999.9, locBestPaddleDistance_Vertical = 999.9, locBestPaddleDistance_Horizontal = 999.9;
282 auto locTOFHitMatchParams = locChargedTrackHypothesis->Get_TOFHitMatchParams();
283 bool locIsMatchedToTrack = (locTOFHitMatchParams !=
nullptr);
286 double locTOFPointDeltaT = 0.0;
287 double locTOFTimeFOM =
Calc_TOFTiming(locChargedTrackHypothesis, locParticleID, locEventRFBunch, locTOFPointDeltaT);
288 double locTOFPointdEdX = locIsMatchedToTrack ? locTOFHitMatchParams->dEdx : 0.0;
291 int locNearestTOFPointStatus = 0;
292 if(locClosestTOFPoint != NULL)
298 int locNearestTOFHitHorizontal =
Calc_NearestHit(locClosestTOFPaddleHit_Horizontal);
299 int locNearestTOFHitVertical =
Calc_NearestHit(locClosestTOFPaddleHit_Vertical);
304 japp->RootFillLock(
this);
331 if(locIsMatchedToTrack)
337 japp->RootFillUnLock(
this);
340 Particle_t locPID = (locChargedTrackHypothesis->Get_FCALShowerMatchParams() != NULL) ? locChargedTrackHypothesis->PID() :
Unknown;
345 DVector3 locDP3 = locChargedTrackHypothesis->momentum();
346 TVector3 locP3(locDP3.X(), locDP3.Y(), locDP3.Z());
383 if(locPaddleHit ==
nullptr)
386 int locNearestHit = locPaddleHit->
bar;
387 if((locPaddleHit->
E_north > 0.00001) && !(locPaddleHit->
E_south > 0.00001))
388 locNearestHit += 100.0;
389 else if(!(locPaddleHit->
E_north > 0.00001) && (locPaddleHit->
E_south > 0.00001))
390 locNearestHit += 200.0;
392 return locNearestHit;
398 if(locFCALShowerMatchParams == NULL)
401 double locStartTime = locParticleID->
Calc_PropagatedRFTime(locChargedTrackHypothesis, locEventRFBunch);
402 const DFCALShower* locFCALShower = locFCALShowerMatchParams->dFCALShower;
404 double locDeltaT = locFCALShower->
getTime() - locFCALShowerMatchParams->dFlightTime - locStartTime;
411 if(locTOFHitMatchParams ==
nullptr)
414 double locStartTime = locParticleID->
Calc_PropagatedRFTime(locChargedTrackHypothesis, locEventRFBunch);
415 locDeltaT = locTOFHitMatchParams->dHitTime - locTOFHitMatchParams->dFlightTime - locStartTime;
417 double locPIDFOM = -1.0;
DTreeInterface * dTreeInterface
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.
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
TH2I * dHist_TOFPaddleHorizontalPaddleVsTrackX_TotalHit_North
void Register_Single(string locBranchName)
unsigned int dMinNumTrackHits
TH2I * dHist_TrackTOFYVsX_TotalHit
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
jerror_t brun(jana::JEventLoop *locEventLoop, int locRunNumber)
Called every time a new run number is detected.
TH2I * dHist_TOFPaddleTrackYVsVerticalPaddle_HasHit_Bottom
TH2I * dHist_TrackTOF2DPaddles_TotalHit
bool PredictTOFPaddles(const DReferenceTrajectory *rt, unsigned int &hbar, unsigned int &vbar, DVector3 *intersection=nullptr) const
void Fill(DTreeFillData &locTreeFillData)
double dMinTOFPaddleMatchDistance
static DTreeInterface * Create_DTreeInterface(string locTreeName, string locFileName)
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
TH2I * dHist_TrackTOF2DPaddles_HasHit
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
TH2I * dHist_TrackTOFYVsX_HasHit
bool Cut_TrackHitPattern(const DParticleID *locParticleID, const DKinematicData *locTrack) const
double Calc_TOFTiming(const DChargedTrackHypothesis *locChargedTrackHypothesis, const DParticleID *locParticleID, const DEventRFBunch *locEventRFBunch, double &locDeltaT)
TH2I * dHist_TOFPaddleTrackYVsVerticalPaddle_TotalHit_Bottom
int dMinHitPlanesPerFDCPackage
unsigned int dNumParticleVotes
TH2I * dHist_TOFPaddleTrackYVsVerticalPaddle_TotalHit_Top
bool Cut_FCALTiming(const DChargedTrackHypothesis *locChargedTrackHypothesis, const DParticleID *locParticleID, const DEventRFBunch *locEventRFBunch)
TH2I * dHist_TOFPaddleTrackYVsVerticalPaddle_HasHit_Top
int dMinHitRingsPerCDCSuperlayer
DCutAction_TrackHitPattern * dCutAction_TrackHitPattern
void Fill_Single(string locBranchName, const DType &locData)
TH2I * dHist_TOFPaddleHorizontalPaddleVsTrackX_TotalHit_South