Public Member Functions | Private Attributes | List of all members
protoana::BeamExample Class Reference
Inheritance diagram for protoana::BeamExample:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 BeamExample (fhicl::ParameterSet const &p)
 
 BeamExample (BeamExample const &)=delete
 
 BeamExample (BeamExample &&)=delete
 
BeamExampleoperator= (BeamExample const &)=delete
 
BeamExampleoperator= (BeamExample &&)=delete
 
virtual void beginJob () override
 
virtual void endJob () override
 
void analyze (art::Event const &e) 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

std::string fCalorimetryTag
 
std::string fTrackerTag
 
std::string fShowerTag
 
std::string fPFParticleTag
 
std::string fGeneratorTag
 
bool fVerbose
 
protoana::ProtoDUNEDataUtils dataUtil
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- 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 50 of file BeamExample_module.cc.

Constructor & Destructor Documentation

protoana::BeamExample::BeamExample ( fhicl::ParameterSet const &  p)
explicit

Definition at line 84 of file BeamExample_module.cc.

85  :
86  EDAnalyzer(p),
87  fCalorimetryTag(p.get<std::string>("CalorimetryTag")),
88  fTrackerTag(p.get<std::string>("TrackerTag")),
89  fShowerTag(p.get<std::string>("ShowerTag")),
90  fPFParticleTag(p.get<std::string>("PFParticleTag")),
91  fGeneratorTag(p.get<std::string>("GeneratorTag")),
92  fVerbose(p.get<bool>("Verbose")),
93  dataUtil(p.get<fhicl::ParameterSet>("DataUtils"))
94 {
95 
96 }
std::string string
Definition: nybbler.cc:12
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
p
Definition: test.py:223
protoana::ProtoDUNEDataUtils dataUtil
protoana::BeamExample::BeamExample ( BeamExample const &  )
delete
protoana::BeamExample::BeamExample ( BeamExample &&  )
delete

Member Function Documentation

void protoana::BeamExample::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 103 of file BeamExample_module.cc.

104 {
105 
106  bool beamTriggerEvent = false;
107  // If this event is MC then we can check what the true beam particle is
108  if(!evt.isRealData()){
109  // Get the truth utility to help us out
111  // Firstly we need to get the list of MCTruth objects from the generator. The standard protoDUNE
112  // simulation has fGeneratorTag = "generator"
113  auto mcTruths = evt.getValidHandle<std::vector<simb::MCTruth>>(fGeneratorTag);
114  // mcTruths is basically a pointer to an std::vector of simb::MCTruth objects. There should only be one
115  // of these, so we pass the first element into the function to get the good particle
116  const simb::MCParticle* geantGoodParticle = truthUtil.GetGeantGoodParticle((*mcTruths)[0],evt);
117  if(geantGoodParticle != 0x0){
118  std::cout << "Found GEANT particle corresponding to the good particle with pdg = " << geantGoodParticle->PdgCode() << std::endl;
119  }
120  }
121  else{
122  // For data we can see if this event comes from a beam trigger
123  beamTriggerEvent = dataUtil.IsBeamTrigger(evt);
124  if(beamTriggerEvent){
125  std::cout << "This data event has a beam trigger" << std::endl;
126  }
127  }
128 
129  /*
130  // Now we want to access the output from Pandora. This comes in the form of particle flow objects (recob::PFParticle).
131  // The primary PFParticles are those we want to consider and these PFParticles then have a hierarchy of daughters that
132  // describe the whole interaction of a given primary particle
133  //
134  // / daughter track
135  // /
136  // primary track /
137  // ---------------- ---- daughter track
138  // \
139  // /\-
140  // /\\-- daughter shower
141  //
142  // The above primary PFParticle will have links to three daughter particles, two track-like and one shower-like
143  */
144 
145  // Get the PFParticle utility
147 
148  // Get all of the PFParticles, by default from the "pandora" product
149  auto recoParticles = evt.getValidHandle<std::vector<recob::PFParticle>>(fPFParticleTag);
150 
151  // We'd like to find the beam particle. Pandora tries to do this for us, so let's use the PFParticle utility
152  // to look for it. Pandora reconstructs slices containing one (or sometimes more) primary PFParticles. These
153  // are tagged as either beam or cosmic for ProtoDUNE. This function automatically considers only those
154  // PFParticles considered as primary
155  std::vector<const recob::PFParticle*> beamParticles = pfpUtil.GetPFParticlesFromBeamSlice(evt,fPFParticleTag);
156 
157  if(beamParticles.size() == 0){
158  std::cerr << "We found no beam particles for this event... moving on" << std::endl;
159  return;
160  }
161 
162  // We can now look at these particles
163  for(const recob::PFParticle* particle : beamParticles){
164 
165  // "particle" is the pointer to our beam particle. The recob::Track or recob::Shower object
166  // of this particle might be more helpful. These return null pointers if not track-like / shower-like
167  const recob::Track* thisTrack = pfpUtil.GetPFParticleTrack(*particle,evt,fPFParticleTag,fTrackerTag);
168  const recob::Shower* thisShower = pfpUtil.GetPFParticleShower(*particle,evt,fPFParticleTag,fShowerTag);
169  if(thisTrack != 0x0) std::cout << "Beam particle is track-like" << std::endl;
170  if(thisShower != 0x0) std::cout << "Beam particle is shower-like" << std::endl;
171 
172  // Find the particle vertex. We need the tracker tag here because we need to do a bit of
173  // additional work if the PFParticle is track-like to find the vertex.
174  const TVector3 vtx = pfpUtil.GetPFParticleVertex(*particle,evt,fPFParticleTag,fTrackerTag);
175 
176  // Now we can look for the interaction point of the particle if one exists, i.e where the particle
177  // scatters off an argon nucleus. Shower-like objects won't have an interaction point, so we can
178  // check this by making sure we get a sensible position
179  const TVector3 interactionVtx = pfpUtil.GetPFParticleSecondaryVertex(*particle,evt,fPFParticleTag,fTrackerTag);
180 
181  // Let's get the daughter PFParticles... we can do this simply without the utility
182  for(const int daughterID : particle->Daughters()){
183  // Daughter ID is the element of the original recoParticle vector
184  const recob::PFParticle *daughterParticle = &(recoParticles->at(daughterID));
185  std::cout << "Daughter " << daughterID << " has " << daughterParticle->NumDaughters() << " daughters" << std::endl;
186  }
187 
188  // For actually studying the objects, it is easier to have the daughters in their track and shower forms.
189  // We can use the utility to get a vector of track-like and a vector of shower-like daughters
190  const std::vector<const recob::Track*> trackDaughters = pfpUtil.GetPFParticleDaughterTracks(*particle,evt,fPFParticleTag,fTrackerTag);
191  const std::vector<const recob::Shower*> showerDaughters = pfpUtil.GetPFParticleDaughterShowers(*particle,evt,fPFParticleTag,fShowerTag);
192  std::cout << "Beam particle has " << trackDaughters.size() << " track-like daughters and " << showerDaughters.size() << " shower-like daughters." << std::endl;
193 
194  // At this point we have access to the primary particle track or shower, plus the track and shower daughters of this event.
195  // For other information that can be extracted from the PFParticle objects please see the ProtoDUNEPFParticleUtils header file
196  // /dunetpc/dune/ProtoDUNE/Analysis/ProtoDUNEPFParticleUtils.h
197 
198  }
199 
200 }
int NumDaughters() const
Returns the number of daughter particles flowing from this one.
Definition: PFParticle.h:89
const simb::MCParticle * GetGeantGoodParticle(const simb::MCTruth &genTruth, const art::Event &evt) const
const recob::Shower * GetPFParticleShower(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string showerLabel) const
Get the shower associated to this particle. Returns a null pointer if not found.
const TVector3 GetPFParticleVertex(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string trackLabel) const
Function to find the interaction vertex of a primary PFParticle.
const recob::Track * GetPFParticleTrack(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string trackLabel) const
Get the track associated to this particle. Returns a null pointer if not found.
const std::vector< const recob::PFParticle * > GetPFParticlesFromBeamSlice(art::Event const &evt, const std::string particleLabel) const
Return the pointers for the PFParticles in the beam slice. Returns an empty vector is no beam slice w...
Hierarchical representation of particle flow.
Definition: PFParticle.h:44
const std::vector< const recob::Shower * > GetPFParticleDaughterShowers(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string showerLabel) const
Get the daughter showers from the PFParticle.
const TVector3 GetPFParticleSecondaryVertex(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string trackLabel) const
Function to find the secondary interaction vertex of a primary PFParticle.
TCEvent evt
Definition: DataStructs.cxx:7
const std::vector< const recob::Track * > GetPFParticleDaughterTracks(const recob::PFParticle &particle, art::Event const &evt, const std::string particleLabel, const std::string trackLabel) const
Get the daughter tracks from the PFParticle.
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:49
QTextStream & endl(QTextStream &s)
bool IsBeamTrigger(art::Event const &evt) const
protoana::ProtoDUNEDataUtils dataUtil
void protoana::BeamExample::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 98 of file BeamExample_module.cc.

99 {
100 
101 }
void protoana::BeamExample::endJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 202 of file BeamExample_module.cc.

203 {
204 
205 }
BeamExample& protoana::BeamExample::operator= ( BeamExample const &  )
delete
BeamExample& protoana::BeamExample::operator= ( BeamExample &&  )
delete

Member Data Documentation

protoana::ProtoDUNEDataUtils protoana::BeamExample::dataUtil
private

Definition at line 79 of file BeamExample_module.cc.

std::string protoana::BeamExample::fCalorimetryTag
private

Definition at line 72 of file BeamExample_module.cc.

std::string protoana::BeamExample::fGeneratorTag
private

Definition at line 76 of file BeamExample_module.cc.

std::string protoana::BeamExample::fPFParticleTag
private

Definition at line 75 of file BeamExample_module.cc.

std::string protoana::BeamExample::fShowerTag
private

Definition at line 74 of file BeamExample_module.cc.

std::string protoana::BeamExample::fTrackerTag
private

Definition at line 73 of file BeamExample_module.cc.

bool protoana::BeamExample::fVerbose
private

Definition at line 77 of file BeamExample_module.cc.


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