@@ -432,21 +432,22 @@ void TPCPMTBarycenterMatchProducer::produce(art::Event& e)
432432
433433 // Fetch slices, TPC hits, and PFPs; pointer vector needed for generating associations
434434 ::art::Handle<std::vector<recob::Slice>> sliceHandle;
435- e.getByLabel (fPandoraLabel , sliceHandle);
436- art::FindManyP<recob::Hit> fmTPCHits (sliceHandle, e, fPandoraLabel );
437- art::FindManyP<recob::PFParticle> fmPFPs (sliceHandle, e, fPandoraLabel );
435+ e.getByLabel (fPandoraLabel , sliceHandle);
436+
437+ // Slice to PFP assns
438438 unsigned nSlices = (*sliceHandle).size ();
439439 ::art::Handle<std::vector<recob::PFParticle>> pfpHandle;
440440 e.getByLabel (fPandoraLabel , pfpHandle);
441- art::FindManyP<larpandoraobj::PFParticleMetadata> pfp_to_metadata (pfpHandle, e, fPandoraLabel );
442- art::FindManyP<recob::PFParticle> slice_pfp_assns (sliceHandle, e, fPandoraLabel );
443441
442+ // PFP to metadata assns
443+ art::FindManyP<recob::PFParticle> slice_pfp_assns (sliceHandle, e, fPandoraLabel );
444444
445445 // Hit to PFP assns
446- art::FindManyP<recob::Hit> fmHitsPFPs (pfpHandle, e, fPandoraLabel );
447- art::FindManyP<recob::Cluster> fmClusterPfp (pfpHandle, e, fPandoraLabel );
446+ art::FindManyP<recob::Cluster> pfp_cluster_assns (pfpHandle, e, fPandoraLabel );
448447 ::art::Handle<std::vector<recob::Cluster>> clusterHandle;
449448 e.getByLabel (fPandoraLabel , clusterHandle);
449+
450+ // Cluster to Hit assns
450451 art::FindManyP<recob::Hit> cluster_hit_assns (clusterHandle, e, fPandoraLabel );
451452
452453
@@ -458,53 +459,50 @@ void TPCPMTBarycenterMatchProducer::produce(art::Event& e)
458459 std::vector<art::Ptr<recob::OpFlash>> flashPtrVector;
459460 fSliceNum = j;
460461 const art::Ptr<recob::Slice> slicePtr { sliceHandle, j };
461- // -----------------> This is to get the nuscore of the slice, only for debugging purposes <--------------------- //
462- // Slice to PFParticles association
463462 // Vector for recob PFParticles
464463 std::vector<art::Ptr<recob::Hit>> tpcHitsVec;
465464 std::vector<art::Ptr<recob::PFParticle>> pfpVect = slice_pfp_assns.at (j);
466465
467466 // Get the hits associated to the PFParticles in this slice
468467 for (const art::Ptr<recob::PFParticle> &pfp : pfpVect){
469- std::vector<art::Ptr<recob::Cluster>> cluster_v = fmClusterPfp .at (pfp.key ());
468+ std::vector<art::Ptr<recob::Cluster>> cluster_v = pfp_cluster_assns .at (pfp.key ());
470469 for (size_t i=0 ; i<cluster_v.size (); i++){
471470 std::vector<art::Ptr<recob::Hit>> hitVect = cluster_hit_assns.at (cluster_v[i].key ());
472471 tpcHitsVec.insert (tpcHitsVec.end (), hitVect.begin (), hitVect.end ());
473472 }
474473 }
475474
475+ int nPFPs = pfpVect.size ();
476+ // Retrieve Pandora's T0 for this slice if available, same for every PFP in slice so we only need one
477+ if ( nPFPs != 0 ) {
478+ art::FindOne<anab::T0 > f1T0 ( {pfpVect.at (0 )}, e, fPandoraLabel );
479+ if ( f1T0.at (0 ).isValid () ) {
480+ fChargeT0 = f1T0.at (0 ).ref ().Time () / 1e3 ;
481+ }
482+ }
483+
476484 for ( size_t tpc=0 ; tpc<2 ; tpc ++) {
477485 fTPC = tpc;
478486 InitializeSlice ();
479487 sbn::TPCPMTBarycenterMatch sliceMatchInfo;
480488 updateMatchInfo (sliceMatchInfo);
481-
482- const std::vector<art::Ptr<recob::PFParticle>> &pfpsVec = fmPFPs.at (j);
483489 art::FindOne<recob::SpacePoint> f1SpacePoint (tpcHitsVec, e, fPandoraLabel );
484490
485491 std::vector<double > hit_z;
486492 std::vector<double > hit_y;
487493 std::vector<double > hit_weight;
488-
489- int nHits = tpcHitsVec.size ();
490- int nPFPs = pfpsVec.size ();
491494
492- // Retrieve Pandora's T0 for this slice if available, same for every PFP in slice so we only need one
493- if ( nPFPs != 0 ) {
494- art::FindOne<anab::T0 > f1T0 ( {pfpsVec.at (0 )}, e, fPandoraLabel );
495- if ( f1T0.at (0 ).isValid () ) {
496- fChargeT0 = f1T0.at (0 ).ref ().Time () / 1e3 ;
497- }
498- }
495+ int nHits = tpcHitsVec.size ();
499496
500497 double thisCharge;
501498 double sumCharge = 0 .;
502499 TVector3 sumPos {0 .,0 .,0 .};
503500 TVector3 sumPosSqr {0 .,0 .,0 .};
504501
505502 size_t maxChargePlaneIdx=99999 ;
506- if (!fCollectionOnly )
507- {
503+
504+ // If we are not using collection plane only, we need to find the plane with the most charge
505+ if (!fCollectionOnly ){
508506 std::vector<double > PlaneCharge (3 , 0 .); // Vector to store the charge for each plane
509507 // Loop to get the charge of each plane
510508 for ( int k = 0 ; k < nHits; k++ ) {
@@ -832,13 +830,8 @@ double TPCPMTBarycenterMatchProducer::GetSliceCharge(const std::vector<art::Ptr<
832830 plane_hits.at (hit_plane)++;
833831 }
834832
835- // uint bestPlane = std::max_element(plane_charge.begin(), plane_charge.end()) - plane_charge.begin();
836833 uint bestHits = std::max_element (plane_hits.begin (), plane_hits.end ()) - plane_hits.begin ();
837-
838- // double _mean_charge = (plane_charge[0] + plane_charge[1] + plane_charge[2])/3;
839- // double _max_charge = plane_charge.at(bestPlane);
840834 double _comp_charge = plane_charge.at (bestHits);
841- // double _coll_charge = plane_charge[2];
842835
843836 return _comp_charge;
844837}
@@ -871,8 +864,7 @@ double TPCPMTBarycenterMatchProducer::GetFlashLight(double flash_pe, std::vector
871864
872865 double tot_visibility=0 ;
873866
874- for (size_t ch=0 ; ch<dir_visibility.size (); ch++)
875- {
867+ for (size_t ch=0 ; ch<dir_visibility.size (); ch++){
876868 if (std::find (fSkipChannelList .begin (), fSkipChannelList .end (), ch) != fSkipChannelList .end ()) continue ;
877869 if (fOpDetType [ch]==0 ) tot_visibility += fOpDetVUVEff *dir_visibility[ch] + fOpDetVISEff *ref_visibility[ch];
878870 else if (fOpDetType [ch]==1 ) tot_visibility += fOpDetVISEff *ref_visibility[ch];
0 commit comments