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

Public Member Functions

 HitAnaModule (fhicl::ParameterSet const &p)
 
- 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 Types

using HitWireAssns_t = art::Assns< recob::Hit, recob::Wire >
 

Private Member Functions

void analyze (art::Event const &e) override
 
void beginJob () override
 
void createAssocVector (HitWireAssns_t const &, std::vector< std::vector< int >> &)
 
void createAssocVector (std::vector< recob::Wire > const &, std::vector< recob::Hit > const &, std::vector< std::vector< int >> &)
 
void createMCAssocVector (std::vector< recob::Wire > const &, std::vector< sim::MCHitCollection > const &, std::vector< std::vector< int >> &)
 

Private Attributes

std::vector< std::stringfHitModuleLabels
 
std::string fMCHitModuleLabel
 
std::string fWireModuleLabel
 
TTree * wireDataTree
 
std::vector< TTree * > hitDataTree
 
HitAnaAlg analysisAlg
 

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 45 of file HitAnaModule_module.cc.

Member Typedef Documentation

Definition at line 54 of file HitAnaModule_module.cc.

Constructor & Destructor Documentation

hit::HitAnaModule::HitAnaModule ( fhicl::ParameterSet const &  p)
explicit

Definition at line 77 of file HitAnaModule_module.cc.

77  : EDAnalyzer(p) // ,
78 // More initializers here.
79 {
80  fHitModuleLabels = p.get<std::vector<std::string>>("HitModuleLabels");
81  fWireModuleLabel = p.get<std::string>("WireModuleLabel");
82  fMCHitModuleLabel = p.get<std::string>("MCHitModuleLabel");
83 }
std::vector< std::string > fHitModuleLabels
std::string fWireModuleLabel
std::string string
Definition: nybbler.cc:12
std::string fMCHitModuleLabel
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
p
Definition: test.py:223

Member Function Documentation

void hit::HitAnaModule::analyze ( art::Event const &  e)
overrideprivatevirtual

Implements art::EDAnalyzer.

Definition at line 134 of file HitAnaModule_module.cc.

135 {
136  //get event and run numbers
137  unsigned int eventNumber = e.id().event();
138  unsigned int runNumber = e.run();
139 
141 
142  // get the data
143  auto const& wireVector = *e.getValidHandle<std::vector<recob::Wire>>(fWireModuleLabel);
144  auto const& mcHitVector = *e.getValidHandle<std::vector<sim::MCHitCollection>>(fMCHitModuleLabel);
145 
146  // make the association vector. First index is wire index, second is
147  // mcHitCollection index
148  std::vector<std::vector<int>> WireMCHitAssocVector;
149  createMCAssocVector(wireVector, mcHitVector, WireMCHitAssocVector);
150 
151  //get the hit data
152  size_t nHitModules = fHitModuleLabels.size();
153  std::vector<art::Handle<std::vector<recob::Hit>>> hitHandles(nHitModules);
154  // for each hit module output (first index), for each wire (second index)
155  // the list of hits associated with that wire is stored
156  std::vector<std::vector<std::vector<int>>> WireHitAssocVectors(nHitModules);
157  for (size_t iter = 0; iter < nHitModules; iter++) {
158 
159  e.getByLabel(fHitModuleLabels[iter], hitHandles[iter]);
160 
161  //create association vectors by hand for now
162  //art::ValidHandle<HitWireAssns_t> HitToWireAssns
163  //= e.getValidHandle<HitWireAssns_t>(fHitModuleLabels[iter]);
164  //WireHitAssocVectors[iter].resize(wireVector.size());
165  //createAssocVector(*HitToWireAssns,WireHitAssocVectors[iter]);
166 
167  WireHitAssocVectors[iter].resize(wireVector.size());
168  art::Handle<HitWireAssns_t> HitToWireAssns;
169  if (e.getByLabel(fHitModuleLabels[iter], HitToWireAssns))
170  createAssocVector(*HitToWireAssns, WireHitAssocVectors[iter]);
171  else
172  createAssocVector(wireVector, *(hitHandles[iter]), WireHitAssocVectors[iter]);
173 
174  //load in this hit/assoc pair
176  *(hitHandles[iter]), WireHitAssocVectors[iter], fHitModuleLabels[iter]);
177  }
178 
179  // get time service
180  auto const clock_data = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(e);
181 
182  // run the analzyer alg
184  wireVector, mcHitVector, WireMCHitAssocVector, clock_data, eventNumber, runNumber);
185 }
void LoadHitAssocPair(std::vector< recob::Hit > const &, std::vector< std::vector< int >> const &, std::string const &)
Definition: HitAnaAlg.cxx:97
void createMCAssocVector(std::vector< recob::Wire > const &, std::vector< sim::MCHitCollection > const &, std::vector< std::vector< int >> &)
std::vector< std::string > fHitModuleLabels
std::string fWireModuleLabel
std::string fMCHitModuleLabel
const double e
void AnalyzeWires(std::vector< recob::Wire > const &, std::vector< sim::MCHitCollection > const &, std::vector< std::vector< int >> const &, detinfo::DetectorClocksData const &, unsigned int, unsigned int)
Definition: HitAnaAlg.cxx:109
void createAssocVector(HitWireAssns_t const &, std::vector< std::vector< int >> &)
void ClearHitModules()
Definition: HitAnaAlg.cxx:89
void hit::HitAnaModule::beginJob ( )
overrideprivatevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 188 of file HitAnaModule_module.cc.

189 {
191  wireDataTree = tfs->make<TTree>("wireDataTree", "WireDataTree");
193 
194  // The below creates a Tree with one branch - a recob::Hit branch - for each
195  // Hit module specified in the fcl file. So, don't run this module once per Hit
196  // Finder as one normally would. Just run it once and specify all HitFinders.
197  // This was the design for the WireDataTree; we follow it here for the
198  // Hit trees.
199  for (auto const& label : fHitModuleLabels) {
200  std::string firstArg("hitData_");
201  firstArg += label;
202  std::string secArg("HitDataTree_");
203  secArg += label;
204  TTree* intermediateTree = tfs->make<TTree>(firstArg.c_str(), secArg.c_str());
205  hitDataTree.push_back(intermediateTree);
206  }
208 }
void SetHitDataTree(std::vector< TTree * > &trees)
Definition: HitAnaAlg.cxx:34
std::vector< std::string > fHitModuleLabels
std::string string
Definition: nybbler.cc:12
std::vector< TTree * > hitDataTree
void SetWireDataTree(TTree *)
Definition: HitAnaAlg.cxx:27
void hit::HitAnaModule::createAssocVector ( HitWireAssns_t const &  HitToWire,
std::vector< std::vector< int >> &  WireHitAssocVector 
)
private

Definition at line 86 of file HitAnaModule_module.cc.

88 {
89  // WireHitAssocVector: for each wire, indices of all the hits associated to it
90 
91  // the iteration to art::Assns<Hit, Wire> points to a art::Ptr pair (assn_t)
92  // with a hit as first element ("left") and a wire as the second one ("right")
93  for (HitWireAssns_t::assn_t const& assn : HitToWire)
94  WireHitAssocVector.at(assn.second.key()).push_back(assn.first.key());
95 }
fInnerVessel push_back(Point(-578.400000, 0.000000, 0.000000))
details::FindAllP< recob::Hit, recob::Wire > HitToWire
Query object connecting a hit to a wire.
Definition: HitUtils.h:56
void hit::HitAnaModule::createAssocVector ( std::vector< recob::Wire > const &  wireVector,
std::vector< recob::Hit > const &  hitVector,
std::vector< std::vector< int >> &  WireHitAssocVector 
)
private

Definition at line 98 of file HitAnaModule_module.cc.

101 {
102  WireHitAssocVector.resize(wireVector.size());
103  for (size_t iwire = 0; iwire < wireVector.size(); iwire++) {
104  for (size_t ihit = 0; ihit < hitVector.size(); ihit++) {
105  if (hitVector[ihit].Channel() == wireVector[iwire].Channel())
106  WireHitAssocVector[iwire].push_back(ihit);
107  }
108  }
109 }
fInnerVessel push_back(Point(-578.400000, 0.000000, 0.000000))
void hit::HitAnaModule::createMCAssocVector ( std::vector< recob::Wire > const &  wireVector,
std::vector< sim::MCHitCollection > const &  mcHitVector,
std::vector< std::vector< int >> &  WireMCHitAssocVector 
)
private

Definition at line 112 of file HitAnaModule_module.cc.

115 {
116 
117  WireMCHitAssocVector.clear();
118  WireMCHitAssocVector.resize(wireVector.size());
119 
120  //first, store all the MCHitCollection indices in a map keyed on channel
121  //then, loop through wires, and lookup mchitcollections based on the wire's channel
122 
123  std::map<unsigned int, std::vector<int>> mcHitIndicesByChannel;
124  for (unsigned int icol = 0; icol < mcHitVector.size(); icol++)
125  mcHitIndicesByChannel[mcHitVector[icol].Channel()].push_back(icol);
126 
127  for (unsigned int iwire = 0; iwire < wireVector.size(); iwire++)
128  WireMCHitAssocVector[iwire].insert(WireMCHitAssocVector[iwire].end(),
129  mcHitIndicesByChannel[wireVector[iwire].Channel()].begin(),
130  mcHitIndicesByChannel[wireVector[iwire].Channel()].end());
131 }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...

Member Data Documentation

HitAnaAlg hit::HitAnaModule::analysisAlg
private

Definition at line 74 of file HitAnaModule_module.cc.

std::vector<std::string> hit::HitAnaModule::fHitModuleLabels
private

Definition at line 67 of file HitAnaModule_module.cc.

std::string hit::HitAnaModule::fMCHitModuleLabel
private

Definition at line 68 of file HitAnaModule_module.cc.

std::string hit::HitAnaModule::fWireModuleLabel
private

Definition at line 69 of file HitAnaModule_module.cc.

std::vector<TTree*> hit::HitAnaModule::hitDataTree
private

Definition at line 72 of file HitAnaModule_module.cc.

TTree* hit::HitAnaModule::wireDataTree
private

Definition at line 71 of file HitAnaModule_module.cc.


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