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

Public Member Functions

 CRTEventProducer (fhicl::ParameterSet const &p)
 
 CRTEventProducer (CRTEventProducer const &)=delete
 
 CRTEventProducer (CRTEventProducer &&)=delete
 
CRTEventProduceroperator= (CRTEventProducer const &)=delete
 
CRTEventProduceroperator= (CRTEventProducer &&)=delete
 
void produce (art::Event &e) override
 
void beginJob () override
 
void endJob () override
 
void reconfigure (fhicl::ParameterSet const &p)
 

Private Attributes

std::string fInFile
 
float fTimeWindow
 
icarus::crt::CRTPreProcessTreefAnaTree
 
std::map< size_t, size_t > fEventEntryStart
 
std::map< size_t, size_t > fEventEntryEnd
 

Detailed Description

Definition at line 47 of file CRTEventProducer_module.cc.

Constructor & Destructor Documentation

icarus::crt::CRTEventProducer::CRTEventProducer ( fhicl::ParameterSet const &  p)
explicit

Definition at line 82 of file CRTEventProducer_module.cc.

83  : EDProducer{p}
84  // Initialize member data here, if know don't want to reconfigure on the fly
85  {
86 
87  // Call appropriate produces<>() functions here.
88  produces< std::vector<icarus::crt::CRTData> >();
89 
90  reconfigure(p);
91 
92  /*std::cout << "opening file " << fInFile << std::endl;
93  TFile fin(fInFile.c_str());
94  TTree* tree=(TTree*)fin.FindObjectAny("anaTree");
95  if(tree==nullptr) std::cout << "anaTree not found!" << std::endl;
96  fAnaTree = new icarus::crt::CRTPreProcessTree(tree);
97  std::cout << "constructed CRTPreProcessTree with " << fAnaTree->GetNEntries() << " entries" << std::endl;
98  std::cout << "earliest timestamp: " << fAnaTree->GetAbsTime(0) << std::endl;
99 */
100  } // CRTEventProducer()
pdgs p
Definition: selectors.fcl:22
void reconfigure(fhicl::ParameterSet const &p)
icarus::crt::CRTEventProducer::CRTEventProducer ( CRTEventProducer const &  )
delete
icarus::crt::CRTEventProducer::CRTEventProducer ( CRTEventProducer &&  )
delete

Member Function Documentation

void icarus::crt::CRTEventProducer::beginJob ( )
override

Definition at line 110 of file CRTEventProducer_module.cc.

111  {
112  std::cout << "opening file " << fInFile << std::endl;
113  TFile fin(fInFile.c_str());
114  TTree* tree=(TTree*)fin.FindObjectAny("anaTree");
115  if(tree==nullptr) std::cout << "anaTree not found!" << std::endl;
117 
118  std::cout << "running 'beginJob'" << std::endl;
119  size_t event=0;
120  uint64_t ti = fAnaTree->GetAbsTime(0);
121  fEventEntryStart[0] = 0;
122 
123  std::cout << "time slicing tree with " << fAnaTree->GetNEntries() << " entries" << std::endl;
124 
125  for(size_t ientry =0; ientry<fAnaTree->GetNEntries(); ientry++){
126  if(fAnaTree->GetAbsTime(ientry)>=ti &&
127  fAnaTree->GetAbsTime(ientry)<ti+fTimeWindow*1.0e9)
128  continue;
129 
130  else if(fAnaTree->GetAbsTime(ientry)>=ti+fTimeWindow*1.0e9 ||
131  ientry == fAnaTree->GetNEntries()-1){
132  ti += fTimeWindow*1.0e9;
133  fEventEntryEnd[event] = ientry-1;
134  event++;
135  if (ientry < fAnaTree->GetNEntries()-1)
136  fEventEntryStart[event] = ientry;
137 
138  }
139  }
140 
141  std::cout << "found " << event << " time slices" << std::endl;
142  if(fEventEntryEnd.size()!=fEventEntryStart.size())
143  std::cout << "event map start/end size mismatch!" << std::endl;
144 
145  fin.Close();
146  delete fAnaTree;
147 
148  } // CRTEventProducer::beginJob()
std::map< size_t, size_t > fEventEntryStart
std::map< size_t, size_t > fEventEntryEnd
icarus::crt::CRTPreProcessTree * fAnaTree
uint64_t GetAbsTime(size_t ientry) const
BEGIN_PROLOG could also be cout
void icarus::crt::CRTEventProducer::endJob ( )
override

Definition at line 189 of file CRTEventProducer_module.cc.

190  {
191 
192  } // CRTEventProducer::endJob()
CRTEventProducer& icarus::crt::CRTEventProducer::operator= ( CRTEventProducer const &  )
delete
CRTEventProducer& icarus::crt::CRTEventProducer::operator= ( CRTEventProducer &&  )
delete
void icarus::crt::CRTEventProducer::produce ( art::Event &  e)
override

Definition at line 150 of file CRTEventProducer_module.cc.

151  {
152  TFile fin(fInFile.c_str());
153  TTree* tree=(TTree*)fin.FindObjectAny("anaTree");
154  if(tree==nullptr) std::cout << "anaTree not found!" << std::endl;
156 
157  std::unique_ptr< std::vector<icarus::crt::CRTData> > crtdata( new std::vector<icarus::crt::CRTData>);
158 
159  size_t eveId = (size_t) event.event();
160  std::cout << "processing event " << eveId << " with " << fEventEntryEnd[eveId]+1-fEventEntryStart[eveId] << " triggers" << std::endl;
161 
162  int entry=0;
163  for(size_t ientry=fEventEntryStart[eveId]; ientry<=fEventEntryEnd[eveId]; ientry++){
164  fAnaTree->Load(ientry);
165  CRTData data;
166  data.fMac5 = fAnaTree->Mac5();
167  data.fTs0 = fAnaTree->GetAbsTime();
168  data.fTs1 = data.fTs0;
169  for(size_t ichan=0; ichan<32; ichan++){
170  if(fAnaTree->Above(ichan)&&fAnaTree->Active(ichan)) {
171  data.fAdc[ichan] = fAnaTree->PE(ichan);
172  }//if channel active and above threshold
173  else
174  data.fAdc[ichan] = 0;
175  }//for channels
176 
177  crtdata->push_back(data);
178  entry++;
179 
180  }//for entries in time slice
181 
182  delete fAnaTree;
183  fin.Close();
184 
185  event.put(std::move(crtdata));
186 
187  } // CRTEventProducer::produce()
std::map< size_t, size_t > fEventEntryStart
std::map< size_t, size_t > fEventEntryEnd
icarus::crt::CRTPreProcessTree * fAnaTree
void Load(size_t ientry) const
uint64_t GetAbsTime(size_t ientry) const
bool Above(uint8_t chan) const
CRT Hit Info.
bool Active(uint8_t chan) const
float PE(uint8_t chan) const
BEGIN_PROLOG could also be cout
void icarus::crt::CRTEventProducer::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 102 of file CRTEventProducer_module.cc.

103  {
104  //fCrtModuleLabel = (p.get<art::InputTag> ("CrtModuleLabel"));
105  fInFile = p.get<string>("infile");
106  fTimeWindow = p.get<float>("time_window");
107 
108  } // CRTEventProducer::reconfigure()
pdgs p
Definition: selectors.fcl:22

Member Data Documentation

icarus::crt::CRTPreProcessTree* icarus::crt::CRTEventProducer::fAnaTree
private

Definition at line 75 of file CRTEventProducer_module.cc.

std::map<size_t,size_t> icarus::crt::CRTEventProducer::fEventEntryEnd
private

Definition at line 78 of file CRTEventProducer_module.cc.

std::map<size_t,size_t> icarus::crt::CRTEventProducer::fEventEntryStart
private

Definition at line 77 of file CRTEventProducer_module.cc.

std::string icarus::crt::CRTEventProducer::fInFile
private

Definition at line 73 of file CRTEventProducer_module.cc.

float icarus::crt::CRTEventProducer::fTimeWindow
private

Definition at line 74 of file CRTEventProducer_module.cc.


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