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

Public Member Functions

 anatest (fhicl::ParameterSet const &p)
 
 anatest (anatest const &)=delete
 
 anatest (anatest &&)=delete
 
anatestoperator= (anatest const &)=delete
 
anatestoperator= (anatest &&)=delete
 
virtual void beginJob () 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 Member Functions

void ClearVectors ()
 
void FillVectors (art::Event const &e)
 

Private Attributes

double ItsInTulsa [3]
 
std::vector< std::stringfGeneratorLabels
 
std::string fGeantLabel
 
std::string fHitLabel
 
std::string fTPCClusterLabel
 
std::string fTrackLabel
 
std::string fVertexLabel
 
std::string fRawCaloHitLabel
 
std::string fCaloHitLabel
 
std::string fClusterLabel
 
std::string fECALAssnLabel
 
TTree * fTree
 
Int_t fEvent
 number of the event being processed More...
 
Int_t fRun
 number of the run being processed More...
 
Int_t fSubRun
 number of the sub-run being processed More...
 
std::vector< Int_t > fNeutrinoType
 
std::vector< Int_t > fInteractionType
 
std::vector< Float_t > fQ2
 

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 59 of file anatest_module.cc.

Constructor & Destructor Documentation

gar::anatest::anatest ( fhicl::ParameterSet const &  p)
explicit

Definition at line 119 of file anatest_module.cc.

119  : EDAnalyzer(p) {
120 
121  bool usegenlabels =
122  p.get_if_present<std::vector<std::string> >("GeneratorLabels",fGeneratorLabels);
123  if (!usegenlabels) fGeneratorLabels.clear();
124 
125  fGeantLabel = p.get<std::string>("GEANTLabel","geant");
126  fHitLabel = p.get<std::string>("HitLabel","hit");
127  fTPCClusterLabel = p.get<std::string>("TPCClusterLabel","tpccluster");
128  fTrackLabel = p.get<std::string>("TrackLabel","track");
129  fVertexLabel = p.get<std::string>("VertexLabel","vertex");
130  fRawCaloHitLabel = p.get<std::string>("RawCaloHitLabel","daqecal");
131  fCaloHitLabel = p.get<std::string>("CaloHitLabel","calohit");
132  fClusterLabel = p.get<std::string>("ClusterLabel","calocluster");
133  fECALAssnLabel = p.get<std::string>("ECALAssnLabel","trkecalassn");
134 
135  fTree = nullptr;
136 
137  if (usegenlabels) {
138  for (size_t i=0; i<fGeneratorLabels.size(); ++i) {
139  consumes<std::vector<simb::MCTruth> >(fGeneratorLabels.at(i));
140  }
141  } else {
142  consumesMany<std::vector<simb::MCTruth> >();
143  }
144 
145 
146 
147  consumes<art::Assns<simb::MCTruth, simb::MCParticle> >(fGeantLabel);
148 
149  consumes<std::vector<rec::Hit> >(fHitLabel);
150  consumes<std::vector<rec::TPCCluster> >(fTPCClusterLabel);
151  consumes<std::vector<rec::Track> >(fTrackLabel);
152  consumes<art::Assns<rec::Track, rec::TPCCluster> >(fTPCClusterLabel);
153  consumes<std::vector<rec::Vertex> >(fVertexLabel);
154  consumes<art::Assns<rec::Track, rec::Vertex> >(fVertexLabel);
155 
156  consumes<std::vector<gar::sdp::CaloDeposit> >(fGeantLabel);
157  consumes<std::vector<raw::CaloRawDigit> >(fRawCaloHitLabel);
158  consumes<std::vector<rec::CaloHit> >(fCaloHitLabel);
159  consumes<std::vector<rec::Cluster> >(fClusterLabel);
160  consumes<art::Assns<rec::Cluster, rec::Track>>(fECALAssnLabel);
161 
162  return;
163 } // end constructor
std::string fRawCaloHitLabel
std::string string
Definition: nybbler.cc:12
std::string fClusterLabel
std::string fTrackLabel
std::string fVertexLabel
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
std::string fECALAssnLabel
std::string fHitLabel
std::string fTPCClusterLabel
std::string fCaloHitLabel
p
Definition: test.py:223
std::vector< std::string > fGeneratorLabels
std::string fGeantLabel
gar::anatest::anatest ( anatest const &  )
delete
gar::anatest::anatest ( anatest &&  )
delete

Member Function Documentation

void gar::anatest::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 200 of file anatest_module.cc.

200  {
201 
202  ClearVectors();
203  FillVectors(e);
204  fTree->Fill();
205  return;
206 }
const double e
void FillVectors(art::Event const &e)
void gar::anatest::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 170 of file anatest_module.cc.

170  {
171 
173  ItsInTulsa[0] = euclid->TPCXCent();
174  ItsInTulsa[1] = euclid->TPCYCent();
175  ItsInTulsa[2] = euclid->TPCZCent();
176 
177 
178 
180  fTree = tfs->make<TTree>("MPDtestTree","MPDtestTree");
181 
182 
183 
184  fTree->Branch("Run", &fRun, "Run/I");
185  fTree->Branch("SubRun", &fSubRun, "SubRun/I");
186  fTree->Branch("Event", &fEvent, "Event/I");
187 
188  fTree->Branch("NType", &fNeutrinoType);
189  fTree->Branch("InterT", &fInteractionType);
190  fTree->Branch("MC_Q2", &fQ2);
191 
192  return;
193 } // End of :anatest::beginJob
Int_t fSubRun
number of the sub-run being processed
Int_t fEvent
number of the event being processed
std::vector< Float_t > fQ2
std::vector< Int_t > fInteractionType
Int_t fRun
number of the run being processed
double ItsInTulsa[3]
std::vector< Int_t > fNeutrinoType
void gar::anatest::ClearVectors ( )
private

Definition at line 213 of file anatest_module.cc.

213  {
214 
215  // clear out all our vectors
216  fNeutrinoType.clear();
217  fInteractionType.clear();
218  fQ2.clear();
219 
220  return;
221 } // end :anatest::ClearVectors
std::vector< Float_t > fQ2
std::vector< Int_t > fInteractionType
std::vector< Int_t > fNeutrinoType
void gar::anatest::FillVectors ( art::Event const &  e)
private

Definition at line 228 of file anatest_module.cc.

228  {
229 
230 
231 
232  // ============= Get art handles ==========================================
233  // Get handles for MCinfo, also good for MCPTrajectory
234  std::vector< art::Handle<std::vector<simb::MCTruth>> > mcthandlelist;
235  if (fGeneratorLabels.size()<1) {
236  mcthandlelist = e.getMany<std::vector<simb::MCTruth> >(); // get them all (even if there are none)
237  } else {
238  mcthandlelist.resize(fGeneratorLabels.size());
239  for (size_t i=0; i< fGeneratorLabels.size(); ++i) {
240  mcthandlelist.at(i) = e.getHandle<std::vector<simb::MCTruth> >(fGeneratorLabels.at(i));
241  if (!mcthandlelist.at(i))
242  throw cet::exception("anatest") << " No simb::MCTruth branch."
243  << " Line " << __LINE__ << " in file " << __FILE__ << std::endl;
244  }
245  }
246 
247 
248 
249  auto MCPHandle = e.getHandle<std::vector<simb::MCParticle> >(fGeantLabel);
250  if (!MCPHandle) {
251  throw cet::exception("anatest") << " No simb::MCParticle branch."
252  << " Line " << __LINE__ << " in file " << __FILE__ << std::endl;
253  }
254 
255 
256 
257  // Get handles for MCCaloInfo
258  auto SimHitHandle = e.getHandle< std::vector<gar::sdp::CaloDeposit> >(fGeantLabel);
259  if (!SimHitHandle) {
260  throw cet::exception("anatest") << " No gar::sdp::CaloDeposit branch."
261  << " Line " << __LINE__ << " in file " << __FILE__ << std::endl;
262  }
263 
264 
265 
266  // Get handle for TPC hit data
267  auto HitHandle = e.getHandle< std::vector<rec::Hit> >(fHitLabel);
268  if (!HitHandle) {
269  throw cet::exception("anatest") << " No rec::Hit branch."
270  << " Line " << __LINE__ << " in file " << __FILE__ << std::endl;
271  }
272 
273 
274 
275  // Get handle for TPCClusters
276  auto TPCClusterHandle = e.getHandle< std::vector<rec::TPCCluster> >(fTPCClusterLabel);
277  if (!TPCClusterHandle) {
278  throw cet::exception("anatest") << " No rec::TPCCluster branch."
279  << " Line " << __LINE__ << " in file " << __FILE__ << std::endl;
280  }
281 
282 
283 
284  // Get handles for Tracks and also Assn's to TPCClusters, TrackIoniz
285  auto TrackHandle = e.getHandle< std::vector<rec::Track> >(fTrackLabel);
286  if (!TrackHandle) {
287  throw cet::exception("anatest") << " No rec::Track branch."
288  << " Line " << __LINE__ << " in file " << __FILE__ << std::endl;
289  }
290  //art::FindManyP<rec::TPCCluster>* findManyTPCClusters = NULL;
291  //findManyTPCClusters = new art::FindManyP<rec::TPCCluster>(TrackHandle,e,fTrackLabel);
292 
293 
294 
295  // Get handle for Vertices; also Assn's to Tracks
296  auto VertexHandle = e.getHandle< std::vector<rec::Vertex> >(fVertexLabel);
297  if (!VertexHandle) {
298  throw cet::exception("anatest") << " No rec::Vertex branch."
299  << " Line " << __LINE__ << " in file " << __FILE__ << std::endl;
300  }
301  //art::FindManyP<rec::Track, rec::TrackEnd>* findManyTrackEnd = NULL;
302  //findManyTrackEnd = new art::FindManyP<rec::Track, rec::TrackEnd>(VertexHandle,e,fVertexLabel);
303 
304 
305  // Get handle for CaloDigits
306  auto RawHitHandle = e.getHandle< std::vector<gar::raw::CaloRawDigit> >(fRawCaloHitLabel);
307  if (!RawHitHandle) {
308  throw cet::exception("anatest") << " No :raw::CaloRawDigit branch."
309  << " Line " << __LINE__ << " in file " << __FILE__ << std::endl;
310  }
311 
312 
313  // Get handle for CaloHits
314  auto RecoHitHandle = e.getHandle< std::vector<rec::CaloHit> >(fCaloHitLabel);
315  if (!RecoHitHandle) {
316  throw cet::exception("anatest") << " No rec::CaloHit branch."
317  << " Line " << __LINE__ << " in file " << __FILE__ << std::endl;
318  }
319 
320 
321  // Get handle for CaloClusters; also Assn for matching tracks
322  auto RecoClusterHandle = e.getHandle< std::vector<rec::Cluster> >(fClusterLabel);
323  if (!RecoClusterHandle) {
324  throw cet::exception("anatest") << " No rec::Cluster branch."
325  << " Line " << __LINE__ << " in file " << __FILE__ << std::endl;
326  }
327  //art::FindManyP<rec::Track, rec::TrackEnd>* findManyCALTrackEnd = NULL;
328  //findManyCALTrackEnd = new art::FindManyP<rec::Track, rec::TrackEnd>
329  // (RecoClusterHandle,e,fECALAssnLabel);
330 
331 
332 
333  // ============= Pull art handles =========================================
334  fRun = e.run();
335  fSubRun = e.subRun();
336  fEvent = e.id().event();
337 
338  for (size_t imchl = 0; imchl < mcthandlelist.size(); ++imchl) {
339  for ( auto const& mct : (*mcthandlelist.at(imchl)) ) {
340  if (mct.NeutrinoSet()) {
341  simb::MCNeutrino nuw = mct.GetNeutrino();
342  fNeutrinoType.push_back(nuw.Nu().PdgCode());
343  fInteractionType.push_back(nuw.InteractionType());
344  }
345  }
346  }
347 
348  // Need a non-constant backtracker instance, for now.
349  cheat::BackTrackerCore const* const_bt = gar::providerFrom<cheat::BackTracker>();
350  cheat::BackTrackerCore* bt = const_cast<cheat::BackTrackerCore*>(const_bt);
351 
352  bool const dumpMCP = false;
353  sim::ParticleList* partList = bt->GetParticleList();
354  int nMotherless = 0;
355  for ( auto const& mcp : *MCPHandle ) {
356  if (mcp.Mother() > 0) {
357  simb::MCParticle* TPCeve = bt->FindTPCEve(mcp.TrackId());
358  if ( TPCeve->TrackId() == mcp.TrackId() ) ++nMotherless;
359  }
360  if (dumpMCP) {
361  std::cout << "TrackID: " << mcp.TrackId() << " is PDG: " << mcp.PdgCode() <<
362  " with mother " << mcp.Mother() << " produced by process " << mcp.Process()
363  << std::endl;
364  }
365  }
366  if (dumpMCP) {
367  std::cout << "Number of children: " << partList->size() << std::endl;
368  std::cout << "Number of motherless children: " << nMotherless << std::endl;
369  }
370 
371 
372 
373 
374  std::vector<art::Ptr<rec::Hit>> allhits;
375  art::PtrMaker<rec::Hit> makeHitPtr(e,HitHandle.id());
376  for (size_t iHit=0; iHit<HitHandle->size(); ++iHit) {
377  art::Ptr<rec::Hit> aPtr = makeHitPtr(iHit);
378  allhits.push_back(aPtr);
379  }
380  for (simb::MCParticle mcp : *MCPHandle) {
381  if ( mcp.Mother() > 0 ) continue;
382  if ( abs(mcp.PdgCode()) == 13 ) bt->ParticleToHits(&mcp,allhits);
383  }
384 
385 
386 
387 
388 
389 /* for ( rec::Cluster cluster : *RecoClusterHandle ) {
390  std::vector<std::pair<simb::MCParticle*,float>> whatMatches;
391  whatMatches = bt->ClusterToMCParticles(&cluster);
392  std::cout << "\nCluster No. " << cluster.getIDNumber() << " is made of MCParticles: " << std::endl;
393  for (auto itr = whatMatches.begin(); itr!=whatMatches.end(); ++itr) {
394  std::cout << "G4 track number " << itr->first->TrackId() << "\thas PDG code " <<
395  itr->first->PdgCode() << "\tand its mother is G4 track " << itr->first->Mother()
396  << "\tand energy fraction " << 100*(itr->second) << "%\n";
397  }
398  }
399 
400  std::vector<art::Ptr<rec::Cluster>> clusterCol;
401  art::PtrMaker<rec::Cluster> makeClusterPtr(e,RecoClusterHandle.id());
402  for (size_t iCluster=0; iCluster<RecoClusterHandle->size(); ++iCluster ) {
403  art::Ptr<rec::Cluster> aPtr = makeClusterPtr(iCluster);
404  clusterCol.push_back(aPtr);
405  }
406  for ( simb::MCParticle mcp : *MCPHandle ) {
407  if (mcp.Mother() == 0) {
408  std::cout << "Particle PDG: " << mcp.PdgCode() << " matches to\n";
409  std::vector<art::Ptr<rec::Cluster>> clusterList =
410  bt->MCParticleToClusters(&mcp, clusterCol);
411  for (art::Ptr<rec::Cluster> iCluster : clusterList)
412  std::cout << iCluster->getIDNumber() << std::endl;
413  }
414  } */
415 
416 
417 
418 
419 
420  return;
421 }
int PdgCode() const
Definition: MCParticle.h:212
std::string fRawCaloHitLabel
Int_t fSubRun
number of the sub-run being processed
Int_t fEvent
number of the event being processed
std::string fClusterLabel
std::string fTrackLabel
const simb::MCParticle & Nu() const
Definition: MCNeutrino.h:146
std::string fVertexLabel
int TrackId() const
Definition: MCParticle.h:210
int InteractionType() const
Definition: MCNeutrino.h:150
T abs(T value)
const double e
bt
Definition: tracks.py:83
std::string fHitLabel
std::string fTPCClusterLabel
std::string fCaloHitLabel
std::vector< Int_t > fInteractionType
std::vector< std::string > fGeneratorLabels
Int_t fRun
number of the run being processed
std::string fGeantLabel
Event generator information.
Definition: MCNeutrino.h:18
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
std::vector< Int_t > fNeutrinoType
anatest& gar::anatest::operator= ( anatest const &  )
delete
anatest& gar::anatest::operator= ( anatest &&  )
delete

Member Data Documentation

std::string gar::anatest::fCaloHitLabel
private

Definition at line 94 of file anatest_module.cc.

std::string gar::anatest::fClusterLabel
private

Definition at line 95 of file anatest_module.cc.

std::string gar::anatest::fECALAssnLabel
private

Definition at line 96 of file anatest_module.cc.

Int_t gar::anatest::fEvent
private

number of the event being processed

Definition at line 102 of file anatest_module.cc.

std::string gar::anatest::fGeantLabel
private

Definition at line 88 of file anatest_module.cc.

std::vector<std::string> gar::anatest::fGeneratorLabels
private

Definition at line 87 of file anatest_module.cc.

std::string gar::anatest::fHitLabel
private

Definition at line 89 of file anatest_module.cc.

std::vector<Int_t> gar::anatest::fInteractionType
private

Definition at line 108 of file anatest_module.cc.

std::vector<Int_t> gar::anatest::fNeutrinoType
private

Definition at line 107 of file anatest_module.cc.

std::vector<Float_t> gar::anatest::fQ2
private

Definition at line 109 of file anatest_module.cc.

std::string gar::anatest::fRawCaloHitLabel
private

Definition at line 93 of file anatest_module.cc.

Int_t gar::anatest::fRun
private

number of the run being processed

Definition at line 103 of file anatest_module.cc.

Int_t gar::anatest::fSubRun
private

number of the sub-run being processed

Definition at line 104 of file anatest_module.cc.

std::string gar::anatest::fTPCClusterLabel
private

Definition at line 90 of file anatest_module.cc.

std::string gar::anatest::fTrackLabel
private

Definition at line 91 of file anatest_module.cc.

TTree* gar::anatest::fTree
private

Definition at line 99 of file anatest_module.cc.

std::string gar::anatest::fVertexLabel
private

Definition at line 92 of file anatest_module.cc.

double gar::anatest::ItsInTulsa[3]
private

Definition at line 84 of file anatest_module.cc.


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