LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
trkf::SeedAna Class Reference
Inheritance diagram for trkf::SeedAna:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Classes

struct  MCHists
 
struct  RecoHists
 

Public Types

using ModuleType = EDAnalyzer
 

Public Member Functions

 SeedAna (fhicl::ParameterSet const &pset)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
std::unique_ptr< Worker > makeWorker (WorkerParams const &wp)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Protected Member Functions

std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResults > getTriggerResults (Event const &e) const
 
ConsumesCollector & consumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Private Member Functions

void analyze (const art::Event &evt) override
 
void endJob () override
 

Private Attributes

std::string fSeedModuleLabel
 
std::string fMCTrackModuleLabel
 
int fDump
 
double fMinMCKE
 
double fMinMCLen
 
double fMatchColinearity
 
double fMatchDisp
 
bool fIgnoreSign
 
std::map< int, MCHistsfMCHistMap
 
std::map< int, RecoHistsfRecoHistMap
 
int fNumEvent
 

Detailed Description

Definition at line 224 of file SeedAna_module.cc.

Member Typedef Documentation

Definition at line 22 of file EDAnalyzer.h.

Constructor & Destructor Documentation

trkf::SeedAna::SeedAna ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 513 of file SeedAna_module.cc.

References fDump, fMCTrackModuleLabel, fMinMCKE, fMinMCLen, and fSeedModuleLabel.

514  : EDAnalyzer(pset)
515  , fSeedModuleLabel(pset.get<std::string>("SeedModuleLabel"))
516  , fMCTrackModuleLabel(pset.get<std::string>("MCTrackModuleLabel"))
517  , fDump(pset.get<int>("Dump"))
518  , fMinMCKE(pset.get<double>("MinMCKE"))
519  , fMinMCLen(pset.get<double>("MinMCLen"))
520  , fMatchColinearity(pset.get<double>("MatchColinearity"))
521  , fMatchDisp(pset.get<double>("MatchDisp"))
522  , fIgnoreSign(pset.get<bool>("IgnoreSign"))
523  , fNumEvent(0)
524  {
525  mf::LogInfo("SeedAna") << "SeedAna configured with the following parameters:\n"
526  << " SeedModuleLabel = " << fSeedModuleLabel << "\n"
527  << " MCTrackModuleLabel = " << fMCTrackModuleLabel << "\n"
528  << " Dump = " << fDump << "\n"
529  << " MinMCKE = " << fMinMCKE << "\n"
530  << " MinMCLen = " << fMinMCLen;
531  }
std::string fMCTrackModuleLabel
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::string fSeedModuleLabel
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.cc:6
double fMatchColinearity

Member Function Documentation

void trkf::SeedAna::analyze ( const art::Event evt)
overrideprivate

Definition at line 533 of file SeedAna_module.cc.

References util::abs(), dir, detinfo::DetectorPropertiesData::DriftVelocity(), sim::MCStep::E(), fDump, trkf::SeedAna::MCHists::fHcosth, trkf::SeedAna::RecoHists::fHdist, trkf::SeedAna::MCHists::fHduvcosth, trkf::SeedAna::MCHists::fHgendx, trkf::SeedAna::MCHists::fHgendy, trkf::SeedAna::MCHists::fHgendz, trkf::SeedAna::MCHists::fHglen, trkf::SeedAna::MCHists::fHgmom, trkf::SeedAna::MCHists::fHgphi, trkf::SeedAna::MCHists::fHgstartx, trkf::SeedAna::MCHists::fHgstarty, trkf::SeedAna::MCHists::fHgstartz, trkf::SeedAna::MCHists::fHgtheta, trkf::SeedAna::MCHists::fHgtheta_xz, trkf::SeedAna::MCHists::fHgtheta_yz, trkf::SeedAna::MCHists::fHmcdudw, trkf::SeedAna::MCHists::fHmcdvdw, trkf::SeedAna::MCHists::fHmcendx, trkf::SeedAna::MCHists::fHmcendy, trkf::SeedAna::MCHists::fHmcendz, trkf::SeedAna::MCHists::fHmclen, trkf::SeedAna::MCHists::fHmcmom, trkf::SeedAna::MCHists::fHmcphi, trkf::SeedAna::MCHists::fHmcstartx, trkf::SeedAna::MCHists::fHmcstarty, trkf::SeedAna::MCHists::fHmcstartz, trkf::SeedAna::MCHists::fHmctheta, trkf::SeedAna::MCHists::fHmctheta_xz, trkf::SeedAna::MCHists::fHmctheta_yz, trkf::SeedAna::MCHists::fHmcu, trkf::SeedAna::MCHists::fHmcv, trkf::SeedAna::MCHists::fHmcw, trkf::SeedAna::MCHists::fHmendx, trkf::SeedAna::MCHists::fHmendy, trkf::SeedAna::MCHists::fHmendz, trkf::SeedAna::MCHists::fHmlen, trkf::SeedAna::MCHists::fHmmom, trkf::SeedAna::MCHists::fHmphi, trkf::SeedAna::MCHists::fHmstartx, trkf::SeedAna::MCHists::fHmstarty, trkf::SeedAna::MCHists::fHmstartz, trkf::SeedAna::MCHists::fHmtheta, trkf::SeedAna::MCHists::fHmtheta_xz, trkf::SeedAna::MCHists::fHmtheta_yz, trkf::SeedAna::RecoHists::fHphi, trkf::SeedAna::RecoHists::fHtheta, trkf::SeedAna::RecoHists::fHtheta_xz, trkf::SeedAna::RecoHists::fHtheta_yz, trkf::SeedAna::RecoHists::fHx, trkf::SeedAna::RecoHists::fHy, trkf::SeedAna::RecoHists::fHz, fIgnoreSign, fMatchColinearity, fMatchDisp, fMCHistMap, fMCTrackModuleLabel, fMinMCKE, fMinMCLen, fNumEvent, fRecoHistMap, fSeedModuleLabel, art::ProductRetriever::getByLabel(), recob::Seed::GetDirection(), recob::Seed::GetPoint(), art::Event::isRealData(), art::Handle< T >::isValid(), sim::MCStep::Momentum(), sim::MCTrack::PdgCode(), seed, sim::MCTrack::Start(), sim::MCStep::T(), sim::MCTrack::TrackID(), and w.

534  {
535  ++fNumEvent;
536 
537  // Optional dump stream.
538 
539  std::unique_ptr<mf::LogInfo> pdump;
540  if (fDump > 0) {
541  --fDump;
542  pdump = std::make_unique<mf::LogInfo>("TrackAna");
543  }
544 
545  // Make sure histograms are booked.
546 
547  bool mc = !evt.isRealData();
548 
549  // Get seed handle.
550 
552  evt.getByLabel(fSeedModuleLabel, seedh);
553 
554  // Seed->mc track matching map.
555 
556  std::map<const recob::Seed*, int> seedmap;
557 
558  if (mc) {
559 
560  // Get MCTracks.
561 
563  evt.getByLabel(fMCTrackModuleLabel, mctrackh);
564 
565  // Dump MCTracks.
566 
567  if (pdump) {
568  *pdump << "MC Tracks\n"
569  << " Id pdg x y z dx dy dz "
570  " p\n"
571  << "--------------------------------------------------------------------------------"
572  "-----------\n";
573  }
574 
575  // Loop over mc tracks, and fill histograms that depend only
576  // on mc particles.
577  auto const detProp =
579 
580  for (auto const& mctrk : *mctrackh) {
581  int pdg = mctrk.PdgCode();
582  if (fIgnoreSign) pdg = std::abs(pdg);
583 
584  // Ignore everything except stable charged nonshowering particles.
585  int apdg = std::abs(pdg);
586  if (apdg != 13 && // Muon
587  apdg != 211 && // Charged pion
588  apdg != 321 && // Charged kaon
589  apdg != 2212) { // (Anti)proton
590  continue;
591  }
592 
593  // Apply minimum energy cut.
594 
595  if (mctrk.Start().E() < mctrk.Start().Momentum().Mag() + 1000. * fMinMCKE) { continue; }
596 
597  // Calculate the x offset due to nonzero mc particle time.
598 
599  double mctime = mctrk.Start().T(); // nsec
600  double mcdx = mctime * 1.e-3 * detProp.DriftVelocity(); // cm
601 
602  // Calculate the length of this mc particle inside the fiducial volume.
603 
604  TVector3 mcstart;
605  TVector3 mcend;
606  TVector3 mcstartmom;
607  TVector3 mcendmom;
608  double plen = length(detProp, mctrk, mcdx, mcstart, mcend, mcstartmom, mcendmom);
609 
610  // Apply minimum fiducial length cut. Always reject particles that have
611  // zero length in the tpc regardless of the configured cut.
612 
613  if (plen <= std::max(fMinMCLen, 0.)) { continue; }
614 
615  // Dump MC particle information here.
616 
617  if (pdump) {
618  double pstart = mcstartmom.Mag();
619  double pend = mcendmom.Mag();
620  *pdump << "\nOffset" << std::setw(3) << mctrk.TrackID() << std::setw(6) << mctrk.PdgCode()
621  << " " << std::fixed << std::setprecision(2) << std::setw(10) << mcdx
622  << "\nStart " << std::setw(3) << mctrk.TrackID() << std::setw(6) << mctrk.PdgCode()
623  << " " << std::fixed << std::setprecision(2) << std::setw(10) << mcstart[0]
624  << std::setw(10) << mcstart[1] << std::setw(10) << mcstart[2];
625  if (pstart > 0.) {
626  *pdump << " " << std::fixed << std::setprecision(3) << std::setw(10)
627  << mcstartmom[0] / pstart << std::setw(10) << mcstartmom[1] / pstart
628  << std::setw(10) << mcstartmom[2] / pstart;
629  }
630  else
631  *pdump << std::setw(32) << " ";
632  *pdump << std::setw(12) << std::fixed << std::setprecision(3) << pstart;
633  *pdump << "\nEnd " << std::setw(3) << mctrk.TrackID() << std::setw(6) << mctrk.PdgCode()
634  << " " << std::fixed << std::setprecision(2) << std::setw(10) << mcend[0]
635  << std::setw(10) << mcend[1] << std::setw(10) << mcend[2];
636  if (pend > 0.01) {
637  *pdump << " " << std::fixed << std::setprecision(3) << std::setw(10)
638  << mcendmom[0] / pend << std::setw(10) << mcendmom[1] / pend << std::setw(10)
639  << mcendmom[2] / pend;
640  }
641  else
642  *pdump << std::setw(32) << " ";
643  *pdump << std::setw(12) << std::fixed << std::setprecision(3) << pend << "\n";
644  }
645 
646  // Fill histograms.
647 
648  if (fMCHistMap.count(pdg) == 0) {
649  std::ostringstream ostr;
650  ostr << "MC" << (fIgnoreSign ? "All" : (pdg > 0 ? "Pos" : "Neg")) << std::abs(pdg);
651  fMCHistMap.emplace(pdg, MCHists{ostr.str()});
652  }
653  const MCHists& mchists = fMCHistMap.at(pdg);
654 
655  double mctheta_xz = std::atan2(mcstartmom.X(), mcstartmom.Z());
656  double mctheta_yz = std::atan2(mcstartmom.Y(), mcstartmom.Z());
657 
658  mchists.fHmcstartx->Fill(mcstart.X());
659  mchists.fHmcstarty->Fill(mcstart.Y());
660  mchists.fHmcstartz->Fill(mcstart.Z());
661  mchists.fHmcendx->Fill(mcend.X());
662  mchists.fHmcendy->Fill(mcend.Y());
663  mchists.fHmcendz->Fill(mcend.Z());
664  mchists.fHmctheta->Fill(mcstartmom.Theta());
665  mchists.fHmcphi->Fill(mcstartmom.Phi());
666  mchists.fHmctheta_xz->Fill(mctheta_xz);
667  mchists.fHmctheta_yz->Fill(mctheta_yz);
668  mchists.fHmcmom->Fill(mcstartmom.Mag());
669  mchists.fHmclen->Fill(plen);
670 
671  // Loop over seeds and do matching.
672 
673  int nmatch = 0;
674  if (!seedh.isValid()) { continue; }
675 
676  // Loop over seeds.
677 
678  int nseed = seedh->size();
679  for (int i = 0; i < nseed; ++i) {
680  art::Ptr<recob::Seed> pseed(seedh, i);
681  const recob::Seed& seed = *pseed;
682  if (seedmap.count(&seed) == 0) seedmap[&seed] = -1;
683 
684  // Get parameters of this seed.
685 
686  TVector3 pos;
687  TVector3 dir;
688  double err[3];
689  seed.GetPoint(&pos[0], err);
690  seed.GetDirection(&dir[0], err);
691 
692  // Calculate the global-to-local rotation matrix.
693  // Copied from Track.cxx.
694 
695  TMatrixD rot(3, 3);
696  double dirmag = dir.Mag();
697  double diryz = std::sqrt(dir.Y() * dir.Y() + dir.Z() * dir.Z());
698 
699  double sinth = dir.X() / dirmag;
700  double costh = diryz / dirmag;
701  double sinphi = 0.;
702  double cosphi = 1.;
703  if (diryz != 0) {
704  sinphi = -dir.Y() / diryz;
705  cosphi = dir.Z() / diryz;
706  }
707  rot(0, 0) = costh;
708  rot(1, 0) = 0.;
709  rot(2, 0) = sinth;
710  rot(0, 1) = sinth * sinphi;
711  rot(1, 1) = cosphi;
712  rot(2, 1) = -costh * sinphi;
713  rot(0, 2) = -sinth * cosphi;
714  rot(1, 2) = sinphi;
715  rot(2, 2) = costh * cosphi;
716 
717  // Get best matching mc trajectory point.
718 
719  int itraj = mcmatch(detProp, mctrk, seed);
720  if (itraj < 0) { continue; }
721 
722  // Get mc relative position and direction at matching trajectory point.
723 
724  TVector3 mcpos = mctrk[itraj].Position().Vect() - pos;
725  TVector3 mcmom = mctrk[itraj].Momentum().Vect();
726  mcpos[0] += mcdx;
727 
728  // Rotate the momentum and position to the
729  // seed-local coordinate system.
730 
731  TVector3 mcmoml = rot * mcmom;
732  TVector3 mcposl = rot * mcpos;
733 
734  if (mcmoml.Z() < 0.) mcmoml = -mcmoml;
735  costh = mcmoml.Z() / mcmoml.Mag();
736 
737  double u = mcposl.X();
738  double v = mcposl.Y();
739  double w = mcposl.Z();
740 
741  double pu = mcmoml.X();
742  double pv = mcmoml.Y();
743  double pw = mcmoml.Z();
744 
745  double dudw = pu / pw;
746  double dvdw = pv / pw;
747 
748  double u0 = u - w * dudw;
749  double v0 = v - w * dvdw;
750  double uv0 = std::sqrt(u0 * u0 + v0 * v0);
751 
752  // Fill matching histograms.
753 
754  mchists.fHduvcosth->Fill(costh, uv0);
755  if (std::abs(uv0) < fMatchDisp) {
756 
757  // Fill slope matching histograms.
758 
759  mchists.fHmcdudw->Fill(dudw);
760  mchists.fHmcdvdw->Fill(dvdw);
761  }
762  mchists.fHcosth->Fill(costh);
763  if (costh <= fMatchColinearity) { continue; }
764 
765  // Fill displacement matching histograms.
766 
767  mchists.fHmcu->Fill(u0);
768  mchists.fHmcv->Fill(v0);
769  mchists.fHmcw->Fill(w);
770 
771  if (std::abs(uv0) >= fMatchDisp) { continue; }
772 
773  // Now we have passed all matching cuts and we have a matching
774  // mc particle + seed pair.
775 
776  ++nmatch;
777  seedmap[&seed] = mctrk.TrackID();
778 
779  // Fill matched seed histograms (seed multiplicity).
780 
781  mchists.fHmstartx->Fill(mcstart.X());
782  mchists.fHmstarty->Fill(mcstart.Y());
783  mchists.fHmstartz->Fill(mcstart.Z());
784  mchists.fHmendx->Fill(mcend.X());
785  mchists.fHmendy->Fill(mcend.Y());
786  mchists.fHmendz->Fill(mcend.Z());
787  mchists.fHmtheta->Fill(mcstartmom.Theta());
788  mchists.fHmphi->Fill(mcstartmom.Phi());
789  mchists.fHmtheta_xz->Fill(mctheta_xz);
790  mchists.fHmtheta_yz->Fill(mctheta_yz);
791  mchists.fHmmom->Fill(mcstartmom.Mag());
792  mchists.fHmlen->Fill(plen);
793  }
794 
795  // If we found at least one matched seed, fill good
796  // particle histograms.
797 
798  if (nmatch == 0) { continue; }
799 
800  mchists.fHgstartx->Fill(mcstart.X());
801  mchists.fHgstarty->Fill(mcstart.Y());
802  mchists.fHgstartz->Fill(mcstart.Z());
803  mchists.fHgendx->Fill(mcend.X());
804  mchists.fHgendy->Fill(mcend.Y());
805  mchists.fHgendz->Fill(mcend.Z());
806  mchists.fHgtheta->Fill(mcstartmom.Theta());
807  mchists.fHgphi->Fill(mcstartmom.Phi());
808  mchists.fHgtheta_xz->Fill(mctheta_xz);
809  mchists.fHgtheta_yz->Fill(mctheta_yz);
810  mchists.fHgmom->Fill(mcstartmom.Mag());
811  mchists.fHglen->Fill(plen);
812  }
813  }
814 
815  // Loop over seeds and fill reco-only seed histograms.
816 
817  if (seedh.isValid()) {
818 
819  // Loop over seeds.
820 
821  int nseed = seedh->size();
822 
823  if (nseed > 0 && pdump != 0) {
824  *pdump << "\nReconstructed Seeds\n"
825  << " MCid x y z dx dy dz "
826  " p\n"
827  << "--------------------------------------------------------------------------------"
828  "-----------\n";
829  }
830 
831  for (int i = 0; i < nseed; ++i) {
832  art::Ptr<recob::Seed> pseed(seedh, i);
833  const recob::Seed& seed = *pseed;
834 
835  // Fill histograms involving reco seeds only.
836 
837  TVector3 pos;
838  TVector3 dir;
839  double err[3];
840  seed.GetPoint(&pos[0], err);
841  seed.GetDirection(&dir[0], err);
842  double mdir = dir.Mag();
843  if (mdir != 0.) { dir *= (1. / mdir); }
844 
845  double dpos = bdist(pos);
846  double theta_xz = std::atan2(dir.X(), dir.Z());
847  double theta_yz = std::atan2(dir.Y(), dir.Z());
848 
849  // Dump seed information here.
850 
851  if (pdump) {
852  int mcid = seedmap[&seed];
853  *pdump << std::setw(15) << mcid << " " << std::fixed << std::setprecision(2)
854  << std::setw(10) << pos[0] << std::setw(10) << pos[1] << std::setw(10) << pos[2]
855  << " " << std::fixed << std::setprecision(3) << std::setw(10) << dir[0]
856  << std::setw(10) << dir[1] << std::setw(10) << dir[2] << "\n";
857  }
858 
859  // Fill histograms.
860 
861  if (fRecoHistMap.count(0) == 0) fRecoHistMap.emplace(0, RecoHists{"Reco"});
862  const RecoHists& rhists = fRecoHistMap.at(0);
863 
864  rhists.fHx->Fill(pos.X());
865  rhists.fHy->Fill(pos.Y());
866  rhists.fHz->Fill(pos.Z());
867  rhists.fHdist->Fill(dpos);
868  rhists.fHtheta->Fill(dir.Theta());
869  rhists.fHphi->Fill(dir.Phi());
870  rhists.fHtheta_xz->Fill(theta_xz);
871  rhists.fHtheta_yz->Fill(theta_yz);
872  }
873  }
874  }
std::string fMCTrackModuleLabel
void GetPoint(double *Pt, double *Err) const
Definition: Seed.cxx:89
constexpr auto abs(T v)
Returns the absolute value of the argument.
std::string fSeedModuleLabel
bool isRealData() const
Definition: Event.cc:53
bool isValid() const noexcept
Definition: Handle.h:203
double fMatchColinearity
long seed
Definition: chem4.cc:67
std::map< int, RecoHists > fRecoHistMap
std::map< int, MCHists > fMCHistMap
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
TDirectory * dir
Definition: macro.C:5
Float_t w
Definition: plot.C:20
void GetDirection(double *Dir, double *Err) const
Definition: Seed.cxx:80
Definition: fwd.h:26
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::consumes ( InputTag const &  tag)
protectedinherited

Definition at line 61 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumes().

62  {
63  return collector_.consumes<T, BT>(tag);
64  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ProductToken< T > consumes(InputTag const &)
ConsumesCollector & art::ModuleBase::consumesCollector ( )
protectedinherited

Definition at line 57 of file ModuleBase.cc.

References art::ModuleBase::collector_.

58  {
59  return collector_;
60  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 75 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesMany().

76  {
77  collector_.consumesMany<T, BT>();
78  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 68 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesView().

69  {
70  return collector_.consumesView<T, BT>(tag);
71  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > consumesView(InputTag const &)
void art::detail::Analyzer::doBeginJob ( SharedResources const &  resources)
inherited

Definition at line 25 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

26  {
27  setupQueues(resources);
28  ProcessingFrame const frame{ScheduleID{}};
29  beginJobWithFrame(frame);
30  }
virtual void beginJobWithFrame(ProcessingFrame const &)=0
virtual void setupQueues(SharedResources const &)=0
bool art::detail::Analyzer::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 68 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

69  {
70  ProcessingFrame const frame{mc.scheduleID()};
71  beginRunWithFrame(std::as_const(rp).makeRun(mc), frame);
72  return true;
73  }
virtual void beginRunWithFrame(Run const &, ProcessingFrame const &)=0
bool art::detail::Analyzer::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 84 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

85  {
86  ProcessingFrame const frame{mc.scheduleID()};
87  beginSubRunWithFrame(std::as_const(srp).makeSubRun(mc), frame);
88  return true;
89  }
virtual void beginSubRunWithFrame(SubRun const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doEndJob ( )
inherited

Definition at line 33 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

34  {
35  ProcessingFrame const frame{ScheduleID{}};
36  endJobWithFrame(frame);
37  }
virtual void endJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Analyzer::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 76 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

77  {
78  ProcessingFrame const frame{mc.scheduleID()};
79  endRunWithFrame(std::as_const(rp).makeRun(mc), frame);
80  return true;
81  }
virtual void endRunWithFrame(Run const &, ProcessingFrame const &)=0
bool art::detail::Analyzer::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 92 of file Analyzer.cc.

References art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

93  {
94  ProcessingFrame const frame{mc.scheduleID()};
95  endSubRunWithFrame(std::as_const(srp).makeSubRun(mc), frame);
96  return true;
97  }
virtual void endSubRunWithFrame(SubRun const &, ProcessingFrame const &)=0
bool art::detail::Analyzer::doEvent ( EventPrincipal ep,
ModuleContext const &  mc,
std::atomic< std::size_t > &  counts_run,
std::atomic< std::size_t > &  counts_passed,
std::atomic< std::size_t > &  counts_failed 
)
inherited

Definition at line 100 of file Analyzer.cc.

References e, and art::ModuleContext::scheduleID().

Referenced by art::detail::Analyzer::Analyzer().

105  {
106  auto const e = std::as_const(ep).makeEvent(mc);
107  if (wantEvent(mc.scheduleID(), e)) {
108  ++counts_run;
109  ProcessingFrame const frame{mc.scheduleID()};
110  analyzeWithFrame(e, frame);
111  ++counts_passed;
112  }
113  return true;
114  }
bool wantEvent(ScheduleID id, Event const &e) const
Definition: Observer.cc:63
Float_t e
Definition: plot.C:35
virtual void analyzeWithFrame(Event const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited

Definition at line 47 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

48  {
49  ProcessingFrame const frame{ScheduleID{}};
51  }
TFile fb("Li6.root")
virtual void respondToCloseInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 61 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

62  {
63  ProcessingFrame const frame{ScheduleID{}};
65  }
virtual void respondToCloseOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Analyzer::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited

Definition at line 40 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

41  {
42  ProcessingFrame const frame{ScheduleID{}};
44  }
TFile fb("Li6.root")
virtual void respondToOpenInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
void art::detail::Analyzer::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 54 of file Analyzer.cc.

Referenced by art::detail::Analyzer::Analyzer().

55  {
56  ProcessingFrame const frame{ScheduleID{}};
58  }
virtual void respondToOpenOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void trkf::SeedAna::endJob ( )
overrideprivatevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 876 of file SeedAna_module.cc.

References trkf::SeedAna::MCHists::fHeendx, trkf::SeedAna::MCHists::fHeendy, trkf::SeedAna::MCHists::fHeendz, trkf::SeedAna::MCHists::fHelen, trkf::SeedAna::MCHists::fHemom, trkf::SeedAna::MCHists::fHephi, trkf::SeedAna::MCHists::fHestartx, trkf::SeedAna::MCHists::fHestarty, trkf::SeedAna::MCHists::fHestartz, trkf::SeedAna::MCHists::fHetheta, trkf::SeedAna::MCHists::fHetheta_xz, trkf::SeedAna::MCHists::fHetheta_yz, trkf::SeedAna::MCHists::fHgendx, trkf::SeedAna::MCHists::fHgendy, trkf::SeedAna::MCHists::fHgendz, trkf::SeedAna::MCHists::fHglen, trkf::SeedAna::MCHists::fHgmom, trkf::SeedAna::MCHists::fHgphi, trkf::SeedAna::MCHists::fHgstartx, trkf::SeedAna::MCHists::fHgstarty, trkf::SeedAna::MCHists::fHgstartz, trkf::SeedAna::MCHists::fHgtheta, trkf::SeedAna::MCHists::fHgtheta_xz, trkf::SeedAna::MCHists::fHgtheta_yz, trkf::SeedAna::MCHists::fHmcendx, trkf::SeedAna::MCHists::fHmcendy, trkf::SeedAna::MCHists::fHmcendz, trkf::SeedAna::MCHists::fHmclen, trkf::SeedAna::MCHists::fHmcmom, trkf::SeedAna::MCHists::fHmcphi, trkf::SeedAna::MCHists::fHmcstartx, trkf::SeedAna::MCHists::fHmcstarty, trkf::SeedAna::MCHists::fHmcstartz, trkf::SeedAna::MCHists::fHmctheta, trkf::SeedAna::MCHists::fHmctheta_xz, trkf::SeedAna::MCHists::fHmctheta_yz, trkf::SeedAna::MCHists::fHmendx, trkf::SeedAna::MCHists::fHmendy, trkf::SeedAna::MCHists::fHmendz, trkf::SeedAna::MCHists::fHmlen, trkf::SeedAna::MCHists::fHmmom, trkf::SeedAna::MCHists::fHmphi, trkf::SeedAna::MCHists::fHmstartx, trkf::SeedAna::MCHists::fHmstarty, trkf::SeedAna::MCHists::fHmstartz, trkf::SeedAna::MCHists::fHmtheta, trkf::SeedAna::MCHists::fHmtheta_xz, trkf::SeedAna::MCHists::fHmtheta_yz, trkf::SeedAna::MCHists::fHmulendx, trkf::SeedAna::MCHists::fHmulendy, trkf::SeedAna::MCHists::fHmulendz, trkf::SeedAna::MCHists::fHmullen, trkf::SeedAna::MCHists::fHmulmom, trkf::SeedAna::MCHists::fHmulphi, trkf::SeedAna::MCHists::fHmulstartx, trkf::SeedAna::MCHists::fHmulstarty, trkf::SeedAna::MCHists::fHmulstartz, trkf::SeedAna::MCHists::fHmultheta, trkf::SeedAna::MCHists::fHmultheta_xz, trkf::SeedAna::MCHists::fHmultheta_yz, fMCHistMap, and fNumEvent.

877  {
878  // Print summary.
879 
880  mf::LogInfo("SeedAna") << "SeedAna statistics:\n"
881  << " Number of events = " << fNumEvent;
882 
883  // Fill multiplicity histograms.
884 
885  for (std::map<int, MCHists>::const_iterator i = fMCHistMap.begin(); i != fMCHistMap.end();
886  ++i) {
887  const MCHists& mchists = i->second;
888  mulcalc(mchists.fHmstartx, mchists.fHmcstartx, mchists.fHmulstartx);
889  mulcalc(mchists.fHmstarty, mchists.fHmcstarty, mchists.fHmulstarty);
890  mulcalc(mchists.fHmstartz, mchists.fHmcstartz, mchists.fHmulstartz);
891  mulcalc(mchists.fHmendx, mchists.fHmcendx, mchists.fHmulendx);
892  mulcalc(mchists.fHmendy, mchists.fHmcendy, mchists.fHmulendy);
893  mulcalc(mchists.fHmendz, mchists.fHmcendz, mchists.fHmulendz);
894  mulcalc(mchists.fHmtheta, mchists.fHmctheta, mchists.fHmultheta);
895  mulcalc(mchists.fHmphi, mchists.fHmcphi, mchists.fHmulphi);
896  mulcalc(mchists.fHmtheta_xz, mchists.fHmctheta_xz, mchists.fHmultheta_xz);
897  mulcalc(mchists.fHmtheta_yz, mchists.fHmctheta_yz, mchists.fHmultheta_yz);
898  mulcalc(mchists.fHmmom, mchists.fHmcmom, mchists.fHmulmom);
899  mulcalc(mchists.fHmlen, mchists.fHmclen, mchists.fHmullen);
900  }
901  // Fill efficiency histograms.
902 
903  for (std::map<int, MCHists>::const_iterator i = fMCHistMap.begin(); i != fMCHistMap.end();
904  ++i) {
905  const MCHists& mchists = i->second;
906  effcalc(mchists.fHgstartx, mchists.fHmcstartx, mchists.fHestartx);
907  effcalc(mchists.fHgstarty, mchists.fHmcstarty, mchists.fHestarty);
908  effcalc(mchists.fHgstartz, mchists.fHmcstartz, mchists.fHestartz);
909  effcalc(mchists.fHgendx, mchists.fHmcendx, mchists.fHeendx);
910  effcalc(mchists.fHgendy, mchists.fHmcendy, mchists.fHeendy);
911  effcalc(mchists.fHgendz, mchists.fHmcendz, mchists.fHeendz);
912  effcalc(mchists.fHgtheta, mchists.fHmctheta, mchists.fHetheta);
913  effcalc(mchists.fHgphi, mchists.fHmcphi, mchists.fHephi);
914  effcalc(mchists.fHgtheta_xz, mchists.fHmctheta_xz, mchists.fHetheta_xz);
915  effcalc(mchists.fHgtheta_yz, mchists.fHmctheta_yz, mchists.fHetheta_yz);
916  effcalc(mchists.fHgmom, mchists.fHmcmom, mchists.fHemom);
917  effcalc(mchists.fHglen, mchists.fHmclen, mchists.fHelen);
918  }
919  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
intermediate_table::const_iterator const_iterator
std::map< int, MCHists > fMCHistMap
std::array< std::vector< ProductInfo >, NumBranchTypes > const & art::ModuleBase::getConsumables ( ) const
inherited

Definition at line 43 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::getConsumables().

44  {
45  return collector_.getConsumables();
46  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables() const
Handle< TriggerResults > art::Observer::getTriggerResults ( Event const &  e) const
protectedinherited

Definition at line 75 of file Observer.cc.

References art::ProductRetriever::get(), and art::Observer::selectors_.

Referenced by art::OutputModule::doWriteEvent(), and art::Observer::wantAllEvents().

76  {
77  if (selectors_) {
78  return selectors_->getOneTriggerResults(e);
79  }
80 
81  // The following applies for cases where no SelectEvents entries
82  // exist.
83  Handle<TriggerResults> h;
84  if (e.get(empty_process_name, h)) {
85  return h;
86  }
87  return Handle<TriggerResults>{};
88  }
Float_t e
Definition: plot.C:35
std::optional< detail::ProcessAndEventSelectors > selectors_
Definition: Observer.h:79
std::unique_ptr< Worker > art::ModuleBase::makeWorker ( WorkerParams const &  wp)
inherited

Definition at line 37 of file ModuleBase.cc.

References art::ModuleBase::doMakeWorker(), and art::NumBranchTypes.

38  {
39  return doMakeWorker(wp);
40  }
virtual std::unique_ptr< Worker > doMakeWorker(WorkerParams const &wp)=0
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 82 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsume().

83  {
84  return collector_.mayConsume<T, BT>(tag);
85  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 96 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeMany().

97  {
98  collector_.mayConsumeMany<T, BT>();
99  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 89 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeView().

90  {
91  return collector_.mayConsumeView<T, BT>(tag);
92  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > mayConsumeView(InputTag const &)
ModuleDescription const & art::ModuleBase::moduleDescription ( ) const
inherited

Definition at line 13 of file ModuleBase.cc.

References art::errors::LogicError.

Referenced by art::OutputModule::doRespondToOpenInputFile(), art::OutputModule::doWriteEvent(), art::Modifier::fillProductDescriptions(), art::OutputModule::makePlugins_(), art::OutputWorker::OutputWorker(), reco::shower::LArPandoraModularShowerCreation::produce(), art::Modifier::registerProducts(), and art::OutputModule::registerProducts().

14  {
15  if (md_.has_value()) {
16  return *md_;
17  }
18 
20  "There was an error while calling moduleDescription().\n"}
21  << "The moduleDescription() base-class member function cannot be called\n"
22  "during module construction. To determine which module is "
23  "responsible\n"
24  "for calling it, find the '<module type>:<module "
25  "label>@Construction'\n"
26  "tag in the message prefix above. Please contact artists@fnal.gov\n"
27  "for guidance.\n";
28  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
string const & art::Observer::processName ( ) const
protectedinherited

Definition at line 57 of file Observer.cc.

References art::Observer::process_name_.

Referenced by art::FileDumperOutput::printPrincipal().

58  {
59  return process_name_;
60  }
std::string process_name_
Definition: Observer.h:76
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  md)
inherited

Definition at line 31 of file ModuleBase.cc.

References art::ModuleBase::md_.

32  {
33  md_ = md;
34  }
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited

Definition at line 49 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::sortConsumables().

50  {
51  // Now that we know we have seen all the consumes declarations,
52  // sort the results for fast lookup later.
53  collector_.sortConsumables(current_process_name);
54  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
void sortConsumables(std::string const &current_process_name)
bool art::Observer::wantAllEvents ( ) const
inlineprotectednoexceptinherited

Definition at line 31 of file Observer.h.

References e, art::Observer::getTriggerResults(), art::Observer::wantAllEvents_, and art::Observer::wantEvent().

32  {
33  return wantAllEvents_;
34  }
bool wantAllEvents_
Definition: Observer.h:75
bool art::Observer::wantEvent ( ScheduleID  id,
Event const &  e 
) const
protectedinherited

Definition at line 63 of file Observer.cc.

References art::Observer::rejectors_, art::Observer::selectors_, and art::Observer::wantAllEvents_.

Referenced by art::OutputModule::doEvent(), art::OutputModule::doWriteEvent(), and art::Observer::wantAllEvents().

64  {
65  if (wantAllEvents_) {
66  return true;
67  }
68  bool const select_event = selectors_ ? selectors_->matchEvent(id, e) : true;
69  bool const reject_event =
70  rejectors_ ? rejectors_->matchEvent(id, e) : false;
71  return select_event and not reject_event;
72  }
bool wantAllEvents_
Definition: Observer.h:75
std::optional< detail::ProcessAndEventSelectors > rejectors_
Definition: Observer.h:80
Float_t e
Definition: plot.C:35
std::optional< detail::ProcessAndEventSelectors > selectors_
Definition: Observer.h:79

Member Data Documentation

int trkf::SeedAna::fDump
private

Definition at line 346 of file SeedAna_module.cc.

Referenced by analyze(), and SeedAna().

bool trkf::SeedAna::fIgnoreSign
private

Definition at line 351 of file SeedAna_module.cc.

Referenced by analyze().

double trkf::SeedAna::fMatchColinearity
private

Definition at line 349 of file SeedAna_module.cc.

Referenced by analyze().

double trkf::SeedAna::fMatchDisp
private

Definition at line 350 of file SeedAna_module.cc.

Referenced by analyze().

std::map<int, MCHists> trkf::SeedAna::fMCHistMap
private

Definition at line 355 of file SeedAna_module.cc.

Referenced by analyze(), and endJob().

std::string trkf::SeedAna::fMCTrackModuleLabel
private

Definition at line 345 of file SeedAna_module.cc.

Referenced by analyze(), and SeedAna().

double trkf::SeedAna::fMinMCKE
private

Definition at line 347 of file SeedAna_module.cc.

Referenced by analyze(), and SeedAna().

double trkf::SeedAna::fMinMCLen
private

Definition at line 348 of file SeedAna_module.cc.

Referenced by analyze(), and SeedAna().

int trkf::SeedAna::fNumEvent
private

Definition at line 360 of file SeedAna_module.cc.

Referenced by analyze(), and endJob().

std::map<int, RecoHists> trkf::SeedAna::fRecoHistMap
private

Definition at line 356 of file SeedAna_module.cc.

Referenced by analyze().

std::string trkf::SeedAna::fSeedModuleLabel
private

Definition at line 344 of file SeedAna_module.cc.

Referenced by analyze(), and SeedAna().


The documentation for this class was generated from the following file: