All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
hit::HitAnaModule Class Reference
Inheritance diagram for hit::HitAnaModule:

Public Member Functions

 HitAnaModule (fhicl::ParameterSet const &p)
 

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::string > fHitModuleLabels
 
std::string fMCHitModuleLabel
 
std::string fWireModuleLabel
 
TTree * wireDataTree
 
std::vector< TTree * > hitDataTree
 
HitAnaAlg analysisAlg
 

Detailed Description

Definition at line 46 of file HitAnaModule_module.cc.

Member Typedef Documentation

Definition at line 55 of file HitAnaModule_module.cc.

Constructor & Destructor Documentation

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

Definition at line 78 of file HitAnaModule_module.cc.

78  : EDAnalyzer(p) // ,
79 // More initializers here.
80 {
81  fHitModuleLabels = p.get<std::vector<std::string>>("HitModuleLabels");
82  fWireModuleLabel = p.get<std::string>("WireModuleLabel");
83  fMCHitModuleLabel = p.get<std::string>("MCHitModuleLabel");
84 }
std::vector< std::string > fHitModuleLabels
std::string fWireModuleLabel
pdgs p
Definition: selectors.fcl:22
std::string fMCHitModuleLabel

Member Function Documentation

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

Definition at line 135 of file HitAnaModule_module.cc.

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

Definition at line 189 of file HitAnaModule_module.cc.

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

Definition at line 87 of file HitAnaModule_module.cc.

89 {
90  // WireHitAssocVector: for each wire, indices of all the hits associated to it
91 
92  // the iteration to art::Assns<Hit, Wire> points to a art::Ptr pair (assn_t)
93  // with a hit as first element ("left") and a wire as the second one ("right")
94  for (HitWireAssns_t::assn_t const& assn : HitToWire)
95  WireHitAssocVector.at(assn.second.key()).push_back(assn.first.key());
96 }
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 99 of file HitAnaModule_module.cc.

102 {
103  WireHitAssocVector.resize(wireVector.size());
104  for (size_t iwire = 0; iwire < wireVector.size(); iwire++) {
105  for (size_t ihit = 0; ihit < hitVector.size(); ihit++) {
106  if (hitVector[ihit].Channel() == wireVector[iwire].Channel())
107  WireHitAssocVector[iwire].push_back(ihit);
108  }
109  }
110 }
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 113 of file HitAnaModule_module.cc.

116 {
117 
118  WireMCHitAssocVector.clear();
119  WireMCHitAssocVector.resize(wireVector.size());
120 
121  //first, store all the MCHitCollection indices in a map keyed on channel
122  //then, loop through wires, and lookup mchitcollections based on the wire's channel
123 
124  std::map<unsigned int, std::vector<int>> mcHitIndicesByChannel;
125  for (unsigned int icol = 0; icol < mcHitVector.size(); icol++)
126  mcHitIndicesByChannel[mcHitVector[icol].Channel()].push_back(icol);
127 
128  for (unsigned int iwire = 0; iwire < wireVector.size(); iwire++)
129  WireMCHitAssocVector[iwire].insert(WireMCHitAssocVector[iwire].end(),
130  mcHitIndicesByChannel[wireVector[iwire].Channel()].begin(),
131  mcHitIndicesByChannel[wireVector[iwire].Channel()].end());
132 }
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585

Member Data Documentation

HitAnaAlg hit::HitAnaModule::analysisAlg
private

Definition at line 75 of file HitAnaModule_module.cc.

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

Definition at line 68 of file HitAnaModule_module.cc.

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

Definition at line 69 of file HitAnaModule_module.cc.

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

Definition at line 70 of file HitAnaModule_module.cc.

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

Definition at line 73 of file HitAnaModule_module.cc.

TTree* hit::HitAnaModule::wireDataTree
private

Definition at line 72 of file HitAnaModule_module.cc.


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