Classes | Public Types | Public Member Functions | Private Attributes | List of all members
beam::ReadBeamInfo Class Reference
Inheritance diagram for beam::ReadBeamInfo:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Classes

struct  Config
 

Public Types

using Parameters = art::EDAnalyzer::Table< Config >
 
- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 ReadBeamInfo (Parameters const &pset)
 
virtual ~ReadBeamInfo ()
 
void analyze (const art::Event &event) override
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
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)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
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)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Attributes

art::InputTag fBeamLabel
 The name of the beam event producer. More...
 

Additional Inherited Members

- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
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 ()
 

Detailed Description

Definition at line 34 of file ReadBeamInfo_module.cc.

Member Typedef Documentation

Definition at line 48 of file ReadBeamInfo_module.cc.

Constructor & Destructor Documentation

beam::ReadBeamInfo::ReadBeamInfo ( ReadBeamInfo::Parameters const &  pset)
explicit

Definition at line 66 of file ReadBeamInfo_module.cc.

66  : art::EDAnalyzer(pset){
67 
68 // fBeamLabel = pset.get<art::InputTag>("BeamLabel");
69  fBeamLabel = pset().BeamLabel();
70 
71 }
art::InputTag fBeamLabel
The name of the beam event producer.
beam::ReadBeamInfo::~ReadBeamInfo ( )
virtual

Definition at line 73 of file ReadBeamInfo_module.cc.

73  {
74 
75 }

Member Function Documentation

void beam::ReadBeamInfo::analyze ( const art::Event event)
override

Definition at line 77 of file ReadBeamInfo_module.cc.

77  {
78 
79  // Just for MC!
80  if(evt.isRealData()) return;
81 
82  // ProtoDUNE beam generator information
83 
84  std::vector<art::Ptr<simb::MCTruth> > beamTruth;
85  auto beamTruthListHandle = evt.getHandle< std::vector<simb::MCTruth> >(fBeamLabel);
86  if (beamTruthListHandle){
87  art::fill_ptr_vector(beamTruth,beamTruthListHandle);
88  }
89  else{
90  // If we requested this info but it doesn't exist, don't use it.
91  mf::LogError("ReadBeamInfo") << "Requested protoDUNE beam generator information with name " << fBeamLabel << " but none exists";
92  return;
93  }
94 
95  // There is only one MC truth, so use it to get the number of primaries
96  Int_t nPrimaries = beamTruth[0]->NParticles();
97 
98  for(Int_t iPartp = 0; iPartp < nPrimaries; ++iPartp){
99  const simb::MCParticle& partp(beamTruth[0]->GetParticle(iPartp));
100 
101  // Access the beam particle variables
102  TVector3 beamVtx(partp.Vx(), partp.Vy(), partp.Vz());
103  TVector3 beamMom(partp.Px(), partp.Py(), partp.Pz());
104  TVector3 beamDir = beamMom.Unit();
105  double beamTime = partp.T();
106  double beamMomentum = partp.P();
107  double beamEnergy = partp.E();
108  int beamPDG = partp.PdgCode();
109 
110  // There are two types of beam particles...
111  // The ones we trigger on, "GoodParticles" have Process() == "primary"
112  // The background ones have Process() == "primaryBackground"
113  // This is how we identify which ones are the good particle.
114  bool beamIsGood = partp.Process()=="primary";
115 
116  std::string type = "good";
117  if(!beamIsGood){
118  type = "background";
119  }
120 
121  std::cout << " -- Read " << type << " beam particle with pdg code " << beamPDG << " from event " << evt.event() << std::endl;
122 
123  if(beamIsGood){
124  std::cout << " - Vtx = (" << beamVtx.X() << ", " << beamVtx.Y() << ", " << beamVtx.Z() << ")" << std::endl;
125  std::cout << " - Time = " << beamTime << std::endl;
126  std::cout << " - Dir = (" << beamDir.X() << ", " << beamDir.Y() << ", " << beamDir.Z() << ")" << std::endl;
127  std::cout << " - Mom = (" << beamMom.X() << ", " << beamMom.Y() << ", " << beamMom.Z() << ")" << std::endl;
128  std::cout << " - |Mom| = " << beamMomentum << std::endl;
129  std::cout << " - Energy = " << beamEnergy << std::endl;
130  std::cout << " - PDG = " << beamPDG << std::endl;
131  }
132 
133  } // End loop over the beam particles
134 
135 }
unsigned int event
Definition: DataStructs.h:636
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
TCEvent evt
Definition: DataStructs.cxx:7
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
QTextStream & endl(QTextStream &s)
art::InputTag fBeamLabel
The name of the beam event producer.

Member Data Documentation

art::InputTag beam::ReadBeamInfo::fBeamLabel
private

The name of the beam event producer.

Definition at line 59 of file ReadBeamInfo_module.cc.


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