ProtoDUNEbeamsim.cxx
Go to the documentation of this file.
1 /////////////////////////////////////////////////////////
2 ///////// ProtoDUNEbeamsim.cxx///////////////////////////
3 ///////// Caroline Zhang carolineligezhang@gmail.com/////
4 ///////// August 2017 ///////////////////////////////////
5 /////////////////////////////////////////////////////////
6 // Modified by Pablo and Leigh H. Howard,
7 // pablo.fer@cern.ch
8 // July 2018
9 /////////////////////////////////////////////////////////
10 
11 #include <iostream>
12 #include <fstream>
14 #include <string.h>
15 #include <time.h>
16 #include <cmath>
17 #include <iomanip>
18 
20 
21 namespace sim{
22 
23  //--------------------------constructors-----------------------------------------------
25 
26  //-------------------------------default destructor------------------------------------------
28 
29  // Leigh - I have encapsulated each beam instrument into a ProtoDUNEBeamInstrument object.
30  // The below provides the interface for these.
32 
33  bool alreadyExists = false;
34  for(auto const &inst : fAllInstruments){
35  if(newInst.GetInstrumentName() == inst.GetInstrumentName()){
36  alreadyExists = true;
37  break;
38  }
39  }
40 
41  if(!alreadyExists){
42  fAllInstruments.push_back(newInst);
43  }
44  else{
45  mf::LogError("ProtoDUNEbeamsim") << "Beam Instrument " << newInst.GetInstrumentName() << " already exists." << std::endl;
46  }
47 
48  }
49 
52  bool found = false;
53  for(auto const inst : fAllInstruments){
54  if(name == inst.GetInstrumentName()){
55  temp = inst;
56  found = true;
57  break;
58  }
59  }
60 
61  if(!found){
62  mf::LogWarning("ProtoDUNEbeamsim") << "Beam Instrument " << name << " not found, returning empty object." << std::endl;
63  }
64 
65  return temp;
66  }
67 }// namespace
68 
69 
70 
71 
72 
73 
static QCString name
Definition: declinfo.cpp:673
std::string string
Definition: nybbler.cc:12
std::string GetInstrumentName() const
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
ProtoDUNEBeamInstrument GetInstrument(std::string name) const
Code to link reconstructed objects back to the MC truth information.
std::vector< ProtoDUNEBeamInstrument > fAllInstruments
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
void AddInstrument(ProtoDUNEBeamInstrument newInst)
QTextStream & endl(QTextStream &s)