1111// //////////////////////////////////////////////////////////////////////
1212
1313#include " TrackCaloSkimmer.h"
14- #include " sbnobj/SBND/CRT/CRTTrack.hh"
1514
1615#include " art/Utilities/make_tool.h"
1716
@@ -70,6 +69,7 @@ sbn::TrackCaloSkimmer::TrackCaloSkimmer(fhicl::ParameterSet const& p)
7069 fPFPproducer = p.get < art::InputTag > (" PFPproducer" ," pandoraGausCryo0" );
7170 fPFPT0producer = p.get < art::InputTag > (" PFPT0producer" , " pandoraGausCryo0" );
7271 fCRTTrackT0producer = p.get < art::InputTag >(" CRTTrackT0producer" , " crttrackmatching" );
72+ fCRTSpacePointT0producer = p.get < art::InputTag >(" CRTSpacePointT0producer" , " crtspacepointmatching" );
7373 fCRTHitT0producer = p.get < art::InputTag >(" CRTHitT0producer" , " CRTT0Tagging" );
7474
7575 fCALOproducer = p.get < art::InputTag > (" CALOproducer" );
@@ -92,7 +92,8 @@ sbn::TrackCaloSkimmer::TrackCaloSkimmer(fhicl::ParameterSet const& p)
9292 fTopCRTDistanceCutPassing = p.get <double >(" TopCRTDistanceCut_throughgoing" , 100 .);
9393 fSideCRTDistanceCutStopping = p.get <double >(" SideCRTDistanceCut_stopping" , 100 .);
9494 fSideCRTDistanceCutPassing = p.get <double >(" SideCRTDistanceCut_throughgoing" , 100 .);
95-
95+ fAllowShowerLikePFPs = p.get <bool >(" AllowShowerLikePFPs" , false );
96+
9697 if (fTailFitResidualRange > 10 .) {
9798 std::cout << " sbn::TrackCaloSkimmer: Bad tail fit residual range config :(" << fTailFitResidualRange << " ). Fits will not be meaningful.\n " ;
9899 }
@@ -231,6 +232,8 @@ void sbn::TrackCaloSkimmer::analyze(art::Event const& e)
231232 //
232233 // Tracks (SBND style)
233234 art::FindManyP<sbnd::crt::CRTTrack, anab::T0> fmT0CRTTrack (tracks, e, fCRTTrackT0producer );
235+ // SpacePoints (SBND style)
236+ art::FindManyP<sbnd::crt::CRTSpacePoint, anab::T0> fmT0CRTSpacePoint (tracks, e, fCRTSpacePointT0producer );
234237
235238 // Hits (ICARUS style)
236239 art::FindManyP<anab::T0> fmT0CRTHit (tracks, e, fCRTHitT0producer );
@@ -313,6 +316,9 @@ void sbn::TrackCaloSkimmer::analyze(art::Event const& e)
313316 for (art::Ptr<recob::PFParticle> p_pfp: PFParticleList) {
314317 const recob::PFParticle &pfp = *p_pfp;
315318
319+ if (p_pfp->PdgCode () == 11 && !fAllowShowerLikePFPs )
320+ continue ;
321+
316322 const std::vector<art::Ptr<recob::Track>> thisTrack = fmTracks.at (p_pfp.key ());
317323 if (thisTrack.size () != 1 )
318324 continue ;
@@ -345,8 +351,9 @@ void sbn::TrackCaloSkimmer::analyze(art::Event const& e)
345351 }
346352
347353 // Collect T0s
348- bool hasT0 = false , hasPFPT0 = false , hasCRTTrackT0 = false , hasCRTHitT0 = false ;
354+ bool hasT0 = false , hasPFPT0 = false , hasCRTTrackT0 = false , hasCRTHitT0 = false , hasCRTSpacePointT0 = false ;
349355 int whicht0 = -1 ;
356+ float crtMatchingScore = std::numeric_limits<float >::signaling_NaN ();
350357
351358 double t0PFP = std::numeric_limits<float >::signaling_NaN ();
352359 if (fmT0PFP.isValid () && fmT0PFP.at (p_pfp.key ()).size ()) {
@@ -356,12 +363,23 @@ void sbn::TrackCaloSkimmer::analyze(art::Event const& e)
356363 }
357364
358365 double t0CRTTrack = std::numeric_limits<float >::signaling_NaN ();
366+ double t0CRTTrackScore = std::numeric_limits<float >::signaling_NaN ();
359367 if (fmT0CRTTrack.isValid () && fmT0CRTTrack.at (trkPtr.key ()).size ()) {
360368 t0CRTTrack = fmT0CRTTrack.data (trkPtr.key ()).at (0 )->Time ();
369+ t0CRTTrackScore = fmT0CRTTrack.data (trkPtr.key ()).at (0 )->TriggerConfidence ();
361370 hasCRTTrackT0 = true ;
362371 }
363372
373+ double t0CRTSpacePoint = std::numeric_limits<float >::signaling_NaN ();
374+ double t0CRTSpacePointScore = std::numeric_limits<float >::signaling_NaN ();
375+ if (fmT0CRTSpacePoint.isValid () && fmT0CRTSpacePoint.at (trkPtr.key ()).size ()) {
376+ t0CRTSpacePoint = fmT0CRTSpacePoint.data (trkPtr.key ()).at (0 )->Time ();
377+ t0CRTSpacePointScore = fmT0CRTSpacePoint.data (trkPtr.key ()).at (0 )->TriggerConfidence ();
378+ hasCRTSpacePointT0 = true ;
379+ }
380+
364381 double t0CRTHit = std::numeric_limits<float >::signaling_NaN ();
382+ double t0CRTHitScore = std::numeric_limits<float >::signaling_NaN ();
365383 if (fIncludeCRTHitTagging && fmT0CRTHit.isValid () && fmT0CRTHit.at (trkPtr.key ()).size ()) {
366384 const sbn::crt::CRTHitT0TaggingInfo &tag = *fmCRTHitT0TaggingInfo.at (trkPtr.key ()).at (0 );
367385 double time = fmT0CRTHit.at (trkPtr.key ()).at (0 )->Time ();
@@ -384,23 +402,42 @@ void sbn::TrackCaloSkimmer::analyze(art::Event const& e)
384402
385403 if (!crtHitSysRejected && !crtHitDistanceRejected) {
386404 t0CRTHit = time;
405+ t0CRTHitScore = tag.Distance ;
387406 hasCRTHitT0 = true ;
388407 }
389408 }
390409
391- T0TimingInfo thisTrackTimingInfo = {t0PFP, t0CRTTrack, t0CRTHit, hasPFPT0, hasCRTTrackT0, hasCRTHitT0};
392- hasT0 = hasPFPT0 || hasCRTTrackT0 || hasCRTHitT0;
410+ hasT0 = hasPFPT0 || hasCRTTrackT0 || hasCRTHitT0 || hasCRTSpacePointT0;
393411
394412 // "whicht0" should reflect the T0 used for the reconstruction of the drift coordinate.
395- if (!hasT0) whicht0 = -1 ;
413+ if (!hasT0) whicht0 = -1 ;
396414 // In this way, if a track is T0 tagged from PFP and CRT tagged, which T0 reflects the PFP Tag.
397- else if (hasPFPT0) whicht0 = 0 ;
398- else if (hasCRTTrackT0) whicht0 = 1 ;
399- else if (hasCRTHitT0) whicht0 = 2 ;
415+ else if (hasPFPT0) whicht0 = 0 ;
416+ else if (hasCRTTrackT0)
417+ {
418+ whicht0 = 1 ;
419+ crtMatchingScore = t0CRTTrackScore;
420+ }
421+ else if (hasCRTHitT0)
422+ {
423+ whicht0 = 2 ;
424+ crtMatchingScore = t0CRTHitScore;
425+ }
426+ else if (hasCRTSpacePointT0)
427+ {
428+ whicht0 = 3 ;
429+ crtMatchingScore = t0CRTSpacePointScore;
430+ }
431+
432+ T0TimingInfo thisTrackTimingInfo = {t0PFP, t0CRTTrack, t0CRTHit, t0CRTSpacePoint, hasPFPT0, hasCRTTrackT0, hasCRTHitT0, hasCRTSpacePointT0, crtMatchingScore};
400433
401434 if (fRequireT0 && !hasT0) continue ;
402435
403- if (fVerbose ) std::cout << " Processing new track! ID: " << trkPtr->ID () << " time: " << t0PFP << " timeCRTTrack: " << t0CRTTrack << " timeCRTHit " <<t0CRTHit<<std::endl;
436+ if (fVerbose ) std::cout << " Processing new track! ID: " << trkPtr->ID () << " \n "
437+ << " \t Pandora time: " << t0PFP << " \n "
438+ << " \t CRTTrack (SBND) time: " << t0CRTTrack << " \n "
439+ << " \t CRTHit (ICARUS) time: " << t0CRTHit << " \n "
440+ << " \t CRTSpacePoint (SBND) time: " << t0CRTSpacePoint << std::endl;
404441
405442 // Reset the track object
406443 *fTrack = sbn::TrackInfo ();
@@ -1124,6 +1161,8 @@ void sbn::TrackCaloSkimmer::FillTrack(const recob::Track &track,
11241161 fTrack ->t0PFP = t0Info.t0Pandora ;
11251162 fTrack ->t0CRTTrack = t0Info.t0CRTTrack ;
11261163 fTrack ->t0CRTHit = t0Info.t0CRTHit ;
1164+ fTrack ->t0CRTSpacePoint = t0Info.t0CRTSpacePoint ;
1165+ fTrack ->crtMatchingScore = t0Info.crtMatchingScore ;
11271166 fTrack ->id = track.ID ();
11281167 fTrack ->clear_cosmic_muon = pfp.Parent () == recob::PFParticle::kPFParticlePrimary ;
11291168
@@ -1135,30 +1174,48 @@ void sbn::TrackCaloSkimmer::FillTrack(const recob::Track &track,
11351174 fTrack ->dir .x = track.StartDirection ().X ();
11361175 fTrack ->dir .y = track.StartDirection ().Y ();
11371176 fTrack ->dir .z = track.StartDirection ().Z ();
1138- // If track is only CRTt0 tagged, undo the assumed trigger correction
1139- if (t0Info.hasT0Pandora ) {
1140- fTrack ->start .x = track.Start ().X ();
1141- fTrack ->end .x = track.End ().X ();
1142- } else if (t0Info.hasT0CRTTrack ) {
1143- int driftDir = geo->TPC (hits[0 ]->WireID ()).DriftDir ().X ();
1144- const double driftv (dprop.DriftVelocity (dprop.Efield (), dprop.Temperature ()));
1145- fTrack ->start .x = track.Start ().X () + driftDir*driftv*t0Info.t0CRTTrack *1e-3 ;
1146- fTrack ->end .x = track.End ().X () + driftDir*driftv*t0Info.t0CRTTrack *1e-3 ;
1147- } else if (t0Info.hasT0CRTHit ){
1148- // If the track does not have a a Pandora T0, the tracks will always be either on the left or (ex Or) right of the cathode.
1149- int driftDir = geo->TPC (hits[0 ]->WireID ()).DriftDir ().X ();
1150- const double driftv (dprop.DriftVelocity (dprop.Efield (), dprop.Temperature ()));
1151- fTrack ->start .x = track.Start ().X () + driftDir*driftv*t0Info.t0CRTHit *1e-3 ;
1152- fTrack ->end .x = track.End ().X () + driftDir*driftv*t0Info.t0CRTHit *1e-3 ;
1153- }
1177+
1178+ if (t0Info.hasT0Pandora )
1179+ {
1180+ fTrack ->start .x = track.Start ().X ();
1181+ fTrack ->end .x = track.End ().X ();
1182+ }
1183+ else
1184+ {
1185+ // If CRT T0 tagged we can shift the x positions appropriately
1186+ int driftDir = geo->TPC (hits[0 ]->WireID ()).DriftDir ().X ();
1187+ const double driftv (dprop.DriftVelocity (dprop.Efield (), dprop.Temperature ()));
1188+
1189+ if (t0Info.hasT0CRTTrack )
1190+ {
1191+ const double xshift = driftDir*driftv*t0Info.t0CRTTrack *1e-3 ;
1192+ fTrack ->start .x = track.Start ().X () + xshift;
1193+ fTrack ->end .x = track.End ().X () + xshift;
1194+ fTrack ->xShiftCRT = xshift;
1195+ }
1196+ else if (t0Info.hasT0CRTHit )
1197+ {
1198+ const double xshift = driftDir*driftv*t0Info.t0CRTHit *1e-3 ;
1199+ fTrack ->start .x = track.Start ().X () + xshift;
1200+ fTrack ->end .x = track.End ().X () + xshift;
1201+ fTrack ->xShiftCRT = xshift;
1202+ }
1203+ else if (t0Info.hasT0CRTSpacePoint )
1204+ {
1205+ const double xshift = driftDir*driftv*t0Info.t0CRTSpacePoint *1e-3 ;
1206+ fTrack ->start .x = track.Start ().X () + xshift;
1207+ fTrack ->end .x = track.End ().X () + xshift;
1208+ fTrack ->xShiftCRT = xshift;
1209+ }
1210+ }
11541211
11551212 if (hits.size () > 0 ) {
11561213 fTrack ->cryostat = hits[0 ]->WireID ().Cryostat ;
11571214 }
11581215
11591216 // Fill each hit
11601217 for (unsigned i_hit = 0 ; i_hit < hits.size (); i_hit++) {
1161- sbn::TrackHitInfo hinfo = MakeHit (*hits[i_hit], hits[i_hit].key (), *thms[i_hit], track, t0Info, sps[i_hit], calo, geo, wireReadout, clock_data, bt_serv, dprop);
1218+ sbn::TrackHitInfo hinfo = MakeHit (*hits[i_hit], hits[i_hit].key (), *thms[i_hit], track, t0Info, sps[i_hit], calo, geo, wireReadout, clock_data, bt_serv, dprop, fTrack -> xShiftCRT );
11621219 if (hinfo.h .plane == 0 ) {
11631220 fTrack ->hits0 .push_back (hinfo);
11641221 }
@@ -1325,7 +1382,8 @@ sbn::TrackHitInfo sbn::TrackCaloSkimmer::MakeHit(const recob::Hit &hit,
13251382 const geo::WireReadoutGeom *wireReadout,
13261383 const detinfo::DetectorClocksData &dclock,
13271384 const cheat::BackTrackerService *bt_serv,
1328- const detinfo::DetectorPropertiesData &dprop) {
1385+ const detinfo::DetectorPropertiesData &dprop,
1386+ const float &xshift) {
13291387
13301388 // TrackHitInfo to save
13311389 sbn::TrackHitInfo hinfo;
@@ -1400,13 +1458,6 @@ sbn::TrackHitInfo sbn::TrackCaloSkimmer::MakeHit(const recob::Hit &hit,
14001458 }
14011459 }
14021460
1403- // This is needed to reconstrut drift coordinate using a different Time
1404- int driftDir = geo->TPC (hit.WireID ()).DriftDir ().X ();
1405- const double driftv (dprop.DriftVelocity (dprop.Efield (), dprop.Temperature ()));
1406- double anodeDistance = std::numeric_limits<float >::signaling_NaN ();
1407- if (t0Info.hasT0CRTHit ) anodeDistance = (hit.PeakTime ()-dclock.Time2Tick (dclock.TriggerTime ())-t0Info.t0CRTHit *1e-3 /dclock.TPCClock ().TickPeriod ())*dclock.TPCClock ().TickPeriod ()*driftv;
1408- double wirePlaneX = wireReadout->Plane (geo::PlaneID (hit.WireID ().Cryostat , hit.WireID ().TPC , hit.WireID ().Plane )).GetCenter ().X ();
1409- double recoX = wirePlaneX - driftDir*anodeDistance;
14101461 // Information from the TrackHitMeta
14111462 bool badhit = (thm.Index () == std::numeric_limits<unsigned int >::max ()) ||
14121463 (!trk.HasValidPoint (thm.Index ()));
@@ -1419,7 +1470,7 @@ sbn::TrackHitInfo sbn::TrackCaloSkimmer::MakeHit(const recob::Hit &hit,
14191470
14201471 // The tp X coordinate is reconstructed only if it does not have a PandoraT0.
14211472 hinfo.tp .x = loc.X ();
1422- if (t0Info.hasT0CRTHit && !t0Info.hasT0Pandora && !isnan (hinfo.tp .x )) hinfo.tp .x = recoX ;
1473+ if (( t0Info.hasT0CRTTrack || t0Info. hasT0CRTHit || t0Info. hasT0CRTSpacePoint ) && !t0Info.hasT0Pandora && !isnan (hinfo.tp .x )) hinfo.tp .x = loc. X () + xshift ;
14231474 hinfo.tp .y = loc.Y ();
14241475 hinfo.tp .z = loc.Z ();
14251476
@@ -1451,7 +1502,7 @@ sbn::TrackHitInfo sbn::TrackCaloSkimmer::MakeHit(const recob::Hit &hit,
14511502 if (sp) {
14521503 hinfo.h .sp .x = sp->position ().x ();
14531504 // If the track has a Pandora T0, do not displace, track is already reconstructed at the correct position
1454- if (t0Info.hasT0CRTHit && !t0Info.hasT0Pandora ) hinfo.h .sp .x = sp->position ().x () + driftDir*driftv*t0Info. t0CRTHit * 1e-3 ;
1505+ if (( t0Info.hasT0CRTTrack || t0Info. hasT0CRTHit || t0Info. hasT0CRTSpacePoint ) && !t0Info.hasT0Pandora ) hinfo.h .sp .x = sp->position ().x () + xshift ;
14551506 hinfo.h .sp .y = sp->position ().y ();
14561507 hinfo.h .sp .z = sp->position ().z ();
14571508 hinfo.h .hasSP = true ;
0 commit comments