LArSoft  v09_90_00
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 226 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 544 of file SeedAna_module.cc.

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

550  : EDAnalyzer(pset)
551  , fSeedModuleLabel(pset.get<std::string>("SeedModuleLabel"))
552  , fMCTrackModuleLabel(pset.get<std::string>("MCTrackModuleLabel"))
553  , fDump(pset.get<int>("Dump"))
554  , fMinMCKE(pset.get<double>("MinMCKE"))
555  , fMinMCLen(pset.get<double>("MinMCLen"))
556  , fMatchColinearity(pset.get<double>("MatchColinearity"))
557  , fMatchDisp(pset.get<double>("MatchDisp"))
558  , fIgnoreSign(pset.get<bool>("IgnoreSign"))
559  , fNumEvent(0)
560  {
561  mf::LogInfo("SeedAna") << "SeedAna configured with the following parameters:\n"
562  << " SeedModuleLabel = " << fSeedModuleLabel << "\n"
563  << " MCTrackModuleLabel = " << fMCTrackModuleLabel << "\n"
564  << " Dump = " << fDump << "\n"
565  << " MinMCKE = " << fMinMCKE << "\n"
566  << " MinMCLen = " << fMinMCLen;
567  }
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 569 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.

575  {
576  ++fNumEvent;
577 
578  // Optional dump stream.
579 
580  std::unique_ptr<mf::LogInfo> pdump;
581  if (fDump > 0) {
582  --fDump;
583  pdump = std::unique_ptr<mf::LogInfo>(new mf::LogInfo("TrackAna"));
584  }
585 
586  // Make sure histograms are booked.
587 
588  bool mc = !evt.isRealData();
589 
590  // Get seed handle.
591 
593  evt.getByLabel(fSeedModuleLabel, seedh);
594 
595  // Seed->mc track matching map.
596 
597  std::map<const recob::Seed*, int> seedmap;
598 
599  if (mc) {
600 
601  // Get MCTracks.
602 
604  evt.getByLabel(fMCTrackModuleLabel, mctrackh);
605 
606  // Dump MCTracks.
607 
608  if (pdump) {
609  *pdump << "MC Tracks\n"
610  << " Id pdg x y z dx dy dz "
611  " p\n"
612  << "--------------------------------------------------------------------------------"
613  "-----------\n";
614  }
615 
616  // Loop over mc tracks, and fill histograms that depend only
617  // on mc particles.
618  auto const detProp =
620 
621  for (std::vector<sim::MCTrack>::const_iterator imctrk = mctrackh->begin();
622  imctrk != mctrackh->end();
623  ++imctrk) {
624  const sim::MCTrack& mctrk = *imctrk;
625  int pdg = mctrk.PdgCode();
626  if (fIgnoreSign) pdg = std::abs(pdg);
627 
628  // Ignore everything except stable charged nonshowering particles.
629 
630  int apdg = std::abs(pdg);
631  if (apdg == 13 || // Muon
632  apdg == 211 || // Charged pion
633  apdg == 321 || // Charged kaon
634  apdg == 2212) { // (Anti)proton
635 
636  // Apply minimum energy cut.
637 
638  if (mctrk.Start().E() >= mctrk.Start().Momentum().Mag() + 1000. * fMinMCKE) {
639 
640  // Calculate the x offset due to nonzero mc particle time.
641 
642  double mctime = mctrk.Start().T(); // nsec
643  double mcdx = mctime * 1.e-3 * detProp.DriftVelocity(); // cm
644 
645  // Calculate the length of this mc particle inside the fiducial volume.
646 
647  TVector3 mcstart;
648  TVector3 mcend;
649  TVector3 mcstartmom;
650  TVector3 mcendmom;
651  double plen = length(detProp, mctrk, mcdx, mcstart, mcend, mcstartmom, mcendmom);
652 
653  // Apply minimum fiducial length cut. Always reject particles that have
654  // zero length in the tpc regardless of the configured cut.
655 
656  if (plen > 0. && plen > fMinMCLen) {
657 
658  // Dump MC particle information here.
659 
660  if (pdump) {
661  double pstart = mcstartmom.Mag();
662  double pend = mcendmom.Mag();
663  *pdump << "\nOffset" << std::setw(3) << mctrk.TrackID() << std::setw(6)
664  << mctrk.PdgCode() << " " << std::fixed << std::setprecision(2)
665  << std::setw(10) << mcdx << "\nStart " << std::setw(3) << mctrk.TrackID()
666  << std::setw(6) << mctrk.PdgCode() << " " << std::fixed
667  << std::setprecision(2) << std::setw(10) << mcstart[0] << std::setw(10)
668  << mcstart[1] << std::setw(10) << mcstart[2];
669  if (pstart > 0.) {
670  *pdump << " " << std::fixed << std::setprecision(3) << std::setw(10)
671  << mcstartmom[0] / pstart << std::setw(10) << mcstartmom[1] / pstart
672  << std::setw(10) << mcstartmom[2] / pstart;
673  }
674  else
675  *pdump << std::setw(32) << " ";
676  *pdump << std::setw(12) << std::fixed << std::setprecision(3) << pstart;
677  *pdump << "\nEnd " << std::setw(3) << mctrk.TrackID() << std::setw(6)
678  << mctrk.PdgCode() << " " << std::fixed << std::setprecision(2)
679  << std::setw(10) << mcend[0] << std::setw(10) << mcend[1] << std::setw(10)
680  << mcend[2];
681  if (pend > 0.01) {
682  *pdump << " " << std::fixed << std::setprecision(3) << std::setw(10)
683  << mcendmom[0] / pend << std::setw(10) << mcendmom[1] / pend
684  << std::setw(10) << mcendmom[2] / pend;
685  }
686  else
687  *pdump << std::setw(32) << " ";
688  *pdump << std::setw(12) << std::fixed << std::setprecision(3) << pend << "\n";
689  }
690 
691  // Fill histograms.
692 
693  if (fMCHistMap.count(pdg) == 0) {
694  std::ostringstream ostr;
695  ostr << "MC" << (fIgnoreSign ? "All" : (pdg > 0 ? "Pos" : "Neg")) << std::abs(pdg);
696  fMCHistMap.emplace(pdg, MCHists{ostr.str()});
697  }
698  const MCHists& mchists = fMCHistMap.at(pdg);
699 
700  double mctheta_xz = std::atan2(mcstartmom.X(), mcstartmom.Z());
701  double mctheta_yz = std::atan2(mcstartmom.Y(), mcstartmom.Z());
702 
703  mchists.fHmcstartx->Fill(mcstart.X());
704  mchists.fHmcstarty->Fill(mcstart.Y());
705  mchists.fHmcstartz->Fill(mcstart.Z());
706  mchists.fHmcendx->Fill(mcend.X());
707  mchists.fHmcendy->Fill(mcend.Y());
708  mchists.fHmcendz->Fill(mcend.Z());
709  mchists.fHmctheta->Fill(mcstartmom.Theta());
710  mchists.fHmcphi->Fill(mcstartmom.Phi());
711  mchists.fHmctheta_xz->Fill(mctheta_xz);
712  mchists.fHmctheta_yz->Fill(mctheta_yz);
713  mchists.fHmcmom->Fill(mcstartmom.Mag());
714  mchists.fHmclen->Fill(plen);
715 
716  // Loop over seeds and do matching.
717 
718  int nmatch = 0;
719  if (seedh.isValid()) {
720 
721  // Loop over seeds.
722 
723  int nseed = seedh->size();
724  for (int i = 0; i < nseed; ++i) {
725  art::Ptr<recob::Seed> pseed(seedh, i);
726  const recob::Seed& seed = *pseed;
727  if (seedmap.count(&seed) == 0) seedmap[&seed] = -1;
728 
729  // Get parameters of this seed.
730 
731  TVector3 pos;
732  TVector3 dir;
733  double err[3];
734  seed.GetPoint(&pos[0], err);
735  seed.GetDirection(&dir[0], err);
736 
737  // Calculate the global-to-local rotation matrix.
738  // Copied from Track.cxx.
739 
740  TMatrixD rot(3, 3);
741  double dirmag = dir.Mag();
742  double diryz = std::sqrt(dir.Y() * dir.Y() + dir.Z() * dir.Z());
743 
744  double sinth = dir.X() / dirmag;
745  double costh = diryz / dirmag;
746  double sinphi = 0.;
747  double cosphi = 1.;
748  if (diryz != 0) {
749  sinphi = -dir.Y() / diryz;
750  cosphi = dir.Z() / diryz;
751  }
752  rot(0, 0) = costh;
753  rot(1, 0) = 0.;
754  rot(2, 0) = sinth;
755  rot(0, 1) = sinth * sinphi;
756  rot(1, 1) = cosphi;
757  rot(2, 1) = -costh * sinphi;
758  rot(0, 2) = -sinth * cosphi;
759  rot(1, 2) = sinphi;
760  rot(2, 2) = costh * cosphi;
761 
762  // Get best matching mc trajectory point.
763 
764  int itraj = mcmatch(detProp, mctrk, seed);
765  if (itraj >= 0) {
766 
767  // Get mc relative position and direction at matching trajectory point.
768 
769  TVector3 mcpos = mctrk[itraj].Position().Vect() - pos;
770  TVector3 mcmom = mctrk[itraj].Momentum().Vect();
771  mcpos[0] += mcdx;
772 
773  // Rotate the momentum and position to the
774  // seed-local coordinate system.
775 
776  TVector3 mcmoml = rot * mcmom;
777  TVector3 mcposl = rot * mcpos;
778 
779  if (mcmoml.Z() < 0.) mcmoml = -mcmoml;
780  double costh = mcmoml.Z() / mcmoml.Mag();
781 
782  double u = mcposl.X();
783  double v = mcposl.Y();
784  double w = mcposl.Z();
785 
786  double pu = mcmoml.X();
787  double pv = mcmoml.Y();
788  double pw = mcmoml.Z();
789 
790  double dudw = pu / pw;
791  double dvdw = pv / pw;
792 
793  double u0 = u - w * dudw;
794  double v0 = v - w * dvdw;
795  double uv0 = std::sqrt(u0 * u0 + v0 * v0);
796 
797  // Fill matching histograms.
798 
799  mchists.fHduvcosth->Fill(costh, uv0);
800  if (std::abs(uv0) < fMatchDisp) {
801 
802  // Fill slope matching histograms.
803 
804  mchists.fHmcdudw->Fill(dudw);
805  mchists.fHmcdvdw->Fill(dvdw);
806  }
807  mchists.fHcosth->Fill(costh);
808  if (costh > fMatchColinearity) {
809 
810  // Fill displacement matching histograms.
811 
812  mchists.fHmcu->Fill(u0);
813  mchists.fHmcv->Fill(v0);
814  mchists.fHmcw->Fill(w);
815 
816  if (std::abs(uv0) < fMatchDisp) {
817 
818  // Now we have passed all matching cuts and we have a matching
819  // mc particle + seed pair.
820 
821  ++nmatch;
822  seedmap[&seed] = mctrk.TrackID();
823 
824  // Fill matched seed histograms (seed multiplicity).
825 
826  mchists.fHmstartx->Fill(mcstart.X());
827  mchists.fHmstarty->Fill(mcstart.Y());
828  mchists.fHmstartz->Fill(mcstart.Z());
829  mchists.fHmendx->Fill(mcend.X());
830  mchists.fHmendy->Fill(mcend.Y());
831  mchists.fHmendz->Fill(mcend.Z());
832  mchists.fHmtheta->Fill(mcstartmom.Theta());
833  mchists.fHmphi->Fill(mcstartmom.Phi());
834  mchists.fHmtheta_xz->Fill(mctheta_xz);
835  mchists.fHmtheta_yz->Fill(mctheta_yz);
836  mchists.fHmmom->Fill(mcstartmom.Mag());
837  mchists.fHmlen->Fill(plen);
838  }
839  }
840  }
841  }
842 
843  // If we found at least one matched seed, fill good
844  // particle histograms.
845 
846  if (nmatch > 0) {
847  mchists.fHgstartx->Fill(mcstart.X());
848  mchists.fHgstarty->Fill(mcstart.Y());
849  mchists.fHgstartz->Fill(mcstart.Z());
850  mchists.fHgendx->Fill(mcend.X());
851  mchists.fHgendy->Fill(mcend.Y());
852  mchists.fHgendz->Fill(mcend.Z());
853  mchists.fHgtheta->Fill(mcstartmom.Theta());
854  mchists.fHgphi->Fill(mcstartmom.Phi());
855  mchists.fHgtheta_xz->Fill(mctheta_xz);
856  mchists.fHgtheta_yz->Fill(mctheta_yz);
857  mchists.fHgmom->Fill(mcstartmom.Mag());
858  mchists.fHglen->Fill(plen);
859  }
860  }
861  }
862  }
863  }
864  }
865  }
866 
867  // Loop over seeds and fill reco-only seed histograms.
868 
869  if (seedh.isValid()) {
870 
871  // Loop over seeds.
872 
873  int nseed = seedh->size();
874 
875  if (nseed > 0 && pdump != 0) {
876  *pdump << "\nReconstructed Seeds\n"
877  << " MCid x y z dx dy dz "
878  " p\n"
879  << "--------------------------------------------------------------------------------"
880  "-----------\n";
881  }
882 
883  for (int i = 0; i < nseed; ++i) {
884  art::Ptr<recob::Seed> pseed(seedh, i);
885  const recob::Seed& seed = *pseed;
886 
887  // Fill histograms involving reco seeds only.
888 
889  TVector3 pos;
890  TVector3 dir;
891  double err[3];
892  seed.GetPoint(&pos[0], err);
893  seed.GetDirection(&dir[0], err);
894  double mdir = dir.Mag();
895  if (mdir != 0.) { dir *= (1. / mdir); }
896 
897  double dpos = bdist(pos);
898  double theta_xz = std::atan2(dir.X(), dir.Z());
899  double theta_yz = std::atan2(dir.Y(), dir.Z());
900 
901  // Dump seed information here.
902 
903  if (pdump) {
904  int mcid = seedmap[&seed];
905  *pdump << std::setw(15) << mcid << " " << std::fixed << std::setprecision(2)
906  << std::setw(10) << pos[0] << std::setw(10) << pos[1] << std::setw(10) << pos[2]
907  << " " << std::fixed << std::setprecision(3) << std::setw(10) << dir[0]
908  << std::setw(10) << dir[1] << std::setw(10) << dir[2] << "\n";
909  }
910 
911  // Fill histograms.
912 
913  if (fRecoHistMap.count(0) == 0) fRecoHistMap.emplace(0, RecoHists{"Reco"});
914  const RecoHists& rhists = fRecoHistMap.at(0);
915 
916  rhists.fHx->Fill(pos.X());
917  rhists.fHy->Fill(pos.Y());
918  rhists.fHz->Fill(pos.Z());
919  rhists.fHdist->Fill(dpos);
920  rhists.fHtheta->Fill(dir.Theta());
921  rhists.fHphi->Fill(dir.Phi());
922  rhists.fHtheta_xz->Fill(theta_xz);
923  rhists.fHtheta_yz->Fill(theta_yz);
924  }
925  }
926  }
std::string fMCTrackModuleLabel
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
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
intermediate_table::const_iterator const_iterator
double T() const
Definition: MCStep.h:41
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
int PdgCode() const
Definition: MCTrack.h:39
const TLorentzVector & Momentum() const
Definition: MCStep.h:34
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
double E() const
Definition: MCStep.h:45
const MCStep & Start() const
Definition: MCTrack.h:42
unsigned int TrackID() const
Definition: MCTrack.h:40
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 928 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.

932  {
933  // Print summary.
934 
935  mf::LogInfo("SeedAna") << "SeedAna statistics:\n"
936  << " Number of events = " << fNumEvent;
937 
938  // Fill multiplicity histograms.
939 
940  for (std::map<int, MCHists>::const_iterator i = fMCHistMap.begin(); i != fMCHistMap.end();
941  ++i) {
942  const MCHists& mchists = i->second;
943  mulcalc(mchists.fHmstartx, mchists.fHmcstartx, mchists.fHmulstartx);
944  mulcalc(mchists.fHmstarty, mchists.fHmcstarty, mchists.fHmulstarty);
945  mulcalc(mchists.fHmstartz, mchists.fHmcstartz, mchists.fHmulstartz);
946  mulcalc(mchists.fHmendx, mchists.fHmcendx, mchists.fHmulendx);
947  mulcalc(mchists.fHmendy, mchists.fHmcendy, mchists.fHmulendy);
948  mulcalc(mchists.fHmendz, mchists.fHmcendz, mchists.fHmulendz);
949  mulcalc(mchists.fHmtheta, mchists.fHmctheta, mchists.fHmultheta);
950  mulcalc(mchists.fHmphi, mchists.fHmcphi, mchists.fHmulphi);
951  mulcalc(mchists.fHmtheta_xz, mchists.fHmctheta_xz, mchists.fHmultheta_xz);
952  mulcalc(mchists.fHmtheta_yz, mchists.fHmctheta_yz, mchists.fHmultheta_yz);
953  mulcalc(mchists.fHmmom, mchists.fHmcmom, mchists.fHmulmom);
954  mulcalc(mchists.fHmlen, mchists.fHmclen, mchists.fHmullen);
955  }
956  // Fill efficiency histograms.
957 
958  for (std::map<int, MCHists>::const_iterator i = fMCHistMap.begin(); i != fMCHistMap.end();
959  ++i) {
960  const MCHists& mchists = i->second;
961  effcalc(mchists.fHgstartx, mchists.fHmcstartx, mchists.fHestartx);
962  effcalc(mchists.fHgstarty, mchists.fHmcstarty, mchists.fHestarty);
963  effcalc(mchists.fHgstartz, mchists.fHmcstartz, mchists.fHestartz);
964  effcalc(mchists.fHgendx, mchists.fHmcendx, mchists.fHeendx);
965  effcalc(mchists.fHgendy, mchists.fHmcendy, mchists.fHeendy);
966  effcalc(mchists.fHgendz, mchists.fHmcendz, mchists.fHeendz);
967  effcalc(mchists.fHgtheta, mchists.fHmctheta, mchists.fHetheta);
968  effcalc(mchists.fHgphi, mchists.fHmcphi, mchists.fHephi);
969  effcalc(mchists.fHgtheta_xz, mchists.fHmctheta_xz, mchists.fHetheta_xz);
970  effcalc(mchists.fHgtheta_yz, mchists.fHmctheta_yz, mchists.fHetheta_yz);
971  effcalc(mchists.fHgmom, mchists.fHmcmom, mchists.fHemom);
972  effcalc(mchists.fHglen, mchists.fHmclen, mchists.fHelen);
973  }
974  }
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 348 of file SeedAna_module.cc.

Referenced by analyze(), and SeedAna().

bool trkf::SeedAna::fIgnoreSign
private

Definition at line 353 of file SeedAna_module.cc.

Referenced by analyze().

double trkf::SeedAna::fMatchColinearity
private

Definition at line 351 of file SeedAna_module.cc.

Referenced by analyze().

double trkf::SeedAna::fMatchDisp
private

Definition at line 352 of file SeedAna_module.cc.

Referenced by analyze().

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

Definition at line 357 of file SeedAna_module.cc.

Referenced by analyze(), and endJob().

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

Definition at line 347 of file SeedAna_module.cc.

Referenced by analyze(), and SeedAna().

double trkf::SeedAna::fMinMCKE
private

Definition at line 349 of file SeedAna_module.cc.

Referenced by analyze(), and SeedAna().

double trkf::SeedAna::fMinMCLen
private

Definition at line 350 of file SeedAna_module.cc.

Referenced by analyze(), and SeedAna().

int trkf::SeedAna::fNumEvent
private

Definition at line 362 of file SeedAna_module.cc.

Referenced by analyze(), and endJob().

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

Definition at line 358 of file SeedAna_module.cc.

Referenced by analyze().

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

Definition at line 346 of file SeedAna_module.cc.

Referenced by analyze(), and SeedAna().


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