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

Public Member Functions

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

TTree * mdmtree
 
int run
 
int subrun
 
int event
 
std::vector< int > trackid
 
std::vector< double > tracklen
 
std::vector< int > trackorg
 
std::vector< int > trackpdg
 

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 35 of file MDMAna_module.cc.

Constructor & Destructor Documentation

pdsp::MDMAna::MDMAna ( fhicl::ParameterSet const &  p)
explicit

Definition at line 68 of file MDMAna_module.cc.

69  : EDAnalyzer{p} // ,
70  // More initializers here.
71 {
72  // Call appropriate consumes<>() for any products to be retrieved by this module.
73 }
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
p
Definition: test.py:223
pdsp::MDMAna::MDMAna ( MDMAna const &  )
delete
pdsp::MDMAna::MDMAna ( MDMAna &&  )
delete

Member Function Documentation

void pdsp::MDMAna::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 75 of file MDMAna_module.cc.

76 {
77  run = e.run();
78  subrun = e.subRun();
79  event = e.id().event();
80  trackid.clear();
81  tracklen.clear();
82  trackorg.clear();
83  trackpdg.clear();
84 
85  //Services
88 
89  // Reconstruciton information
90  std::vector < art::Ptr < recob::Track > > trackList;
91  auto trackListHandle = e.getHandle < std::vector < recob::Track > >("pandoraTrack");
92  if (trackListHandle) {
93  art::fill_ptr_vector(trackList, trackListHandle);
94  }
95  else return;
96 
97  //Get hits associated with track
98  art::FindManyP < recob::Hit > hitsFromTrack(trackListHandle, e, "pandoraTrack");
99 
100  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService>()->DataFor(e);
101  for (auto const& track : trackList){
102  int this_trackid = track.key();
103  double this_tracklen = track->Length();
104  int this_trackorg = -1;
105  int this_trackpdg = 0;
106 
107  auto const & allHits = hitsFromTrack.at(track.key());
108 
109  if (!e.isRealData()){
110  // Find true particle for reconstructed track
111  int TrackID = 0;
112  std::map<int,double> trkide;
113  for(size_t h = 0; h < allHits.size(); ++h){
114  art::Ptr<recob::Hit> hit = allHits[h];
115  std::vector<sim::TrackIDE> TrackIDs = bt_serv->HitToTrackIDEs(clockData, hit);
116  for(size_t e = 0; e < TrackIDs.size(); ++e){
117  trkide[TrackIDs[e].trackID] += TrackIDs[e].energy;
118  }
119  }
120  // Work out which IDE despoited the most charge in the hit if there was more than one.
121  double maxe = -1;
122  double tote = 0;
123  for (std::map<int,double>::iterator ii = trkide.begin(); ii!=trkide.end(); ++ii){
124  tote += ii->second;
125  if ((ii->second)>maxe){
126  maxe = ii->second;
127  TrackID = ii->first;
128  }
129  }
130  // Now have trackID, so get PdG code and T0 etc.
131  if (TrackID){
132  const simb::MCParticle *particle = pi_serv->TrackIdToParticle_P(TrackID);
133  if (particle){
134  this_trackpdg = particle->PdgCode();
135  auto & truth = pi_serv->ParticleToMCTruth_P(particle);
136  this_trackorg = truth->Origin();
137  }
138  }
139  }
140  trackid.push_back(this_trackid);
141  tracklen.push_back(this_tracklen);
142  trackorg.push_back(this_trackorg);
143  trackpdg.push_back(this_trackpdg);
144  }
145  if (!trackid.empty()) mdmtree->Fill();
146 }
intermediate_table::iterator iterator
int PdgCode() const
Definition: MCParticle.h:212
TTree * mdmtree
std::vector< sim::TrackIDE > HitToTrackIDEs(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
std::vector< int > trackpdg
std::vector< TrackID > TrackIDs
const simb::MCParticle * TrackIdToParticle_P(int id) const
simb::Origin_t Origin() const
Definition: MCTruth.h:74
const art::Ptr< simb::MCTruth > & ParticleToMCTruth_P(const simb::MCParticle *p) const
std::vector< double > tracklen
const double e
std::vector< int > trackorg
Detector simulation of raw signals on wires.
std::vector< int > trackid
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
void pdsp::MDMAna::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 148 of file MDMAna_module.cc.

149 {
150  art::ServiceHandle<art::TFileService> fileServiceHandle;
151  mdmtree = fileServiceHandle->make<TTree>("mdmtree", "MDM info");
152  mdmtree->Branch("run", &run, "run/I");
153  mdmtree->Branch("subrun", &subrun, "subrun/I");
154  mdmtree->Branch("event", &event, "event/I");
155  mdmtree->Branch("trackid", &trackid);
156  mdmtree->Branch("tracklen", &tracklen);
157  mdmtree->Branch("trackorg", &trackorg);
158  mdmtree->Branch("trackpdg", &trackpdg);
159 
160 }
TTree * mdmtree
std::vector< int > trackpdg
std::vector< double > tracklen
std::vector< int > trackorg
std::vector< int > trackid
Event finding and building.
MDMAna& pdsp::MDMAna::operator= ( MDMAna const &  )
delete
MDMAna& pdsp::MDMAna::operator= ( MDMAna &&  )
delete

Member Data Documentation

int pdsp::MDMAna::event
private

Definition at line 59 of file MDMAna_module.cc.

TTree* pdsp::MDMAna::mdmtree
private

Definition at line 56 of file MDMAna_module.cc.

int pdsp::MDMAna::run
private

Definition at line 57 of file MDMAna_module.cc.

int pdsp::MDMAna::subrun
private

Definition at line 58 of file MDMAna_module.cc.

std::vector<int> pdsp::MDMAna::trackid
private

Definition at line 60 of file MDMAna_module.cc.

std::vector<double> pdsp::MDMAna::tracklen
private

Definition at line 61 of file MDMAna_module.cc.

std::vector<int> pdsp::MDMAna::trackorg
private

Definition at line 62 of file MDMAna_module.cc.

std::vector<int> pdsp::MDMAna::trackpdg
private

Definition at line 63 of file MDMAna_module.cc.


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