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

Classes

struct  Config
 

Public Types

using Parameters = art::EDAnalyzer::Table< Config >
 
- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 PointIdTrainingData (Parameters const &config)
 
- 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 analyze (const art::Event &event) override
 

Private Attributes

nnet::TrainingDataAlg fTrainingDataAlg
 
std::string fOutTextFilePath
 
bool fDumpToRoot
 
std::vector< int > fSelectedTPC
 
std::vector< int > fSelectedPlane
 
int fEvent
 
int fRun
 number of the event being processed More...
 
int fSubRun
 number of the run being processed More...
 
bool fCrop
 number of the sub-run being processed More...
 
geo::GeometryCore const * fGeometry
 crop data to event (set to false when dumping noise!) More...
 

Additional Inherited Members

- 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 50 of file PointIdTrainingData_module.cc.

Member Typedef Documentation

Definition at line 76 of file PointIdTrainingData_module.cc.

Constructor & Destructor Documentation

nnet::PointIdTrainingData::PointIdTrainingData ( PointIdTrainingData::Parameters const &  config)
explicit

Definition at line 102 of file PointIdTrainingData_module.cc.

104  , fTrainingDataAlg(config().TrainingDataAlg())
105  , fOutTextFilePath(config().OutTextFilePath())
106  , fDumpToRoot(config().DumpToRoot())
107  , fSelectedTPC(config().SelectedTPC())
108  , fSelectedPlane(config().SelectedView())
109  , fCrop(config().Crop())
110  {
112 
113  const size_t TPC_CNT = (size_t)fGeometry->NTPC(0);
114  if (fSelectedTPC.empty()) {
115  for (size_t tpc = 0; tpc < TPC_CNT; ++tpc)
116  fSelectedTPC.push_back(tpc);
117  }
118 
119  if (fSelectedPlane.empty()) {
120  for (size_t p = 0; p < fGeometry->MaxPlanes(); ++p)
121  fSelectedPlane.push_back(p);
122  }
123  }
geo::GeometryCore const * fGeometry
crop data to event (set to false when dumping noise!)
unsigned int MaxPlanes() const
Returns the largest number of planes among all TPCs in this detector.
static Config * config
Definition: config.cpp:1054
p
Definition: test.py:223
nnet::TrainingDataAlg fTrainingDataAlg
bool fCrop
number of the sub-run being processed
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.

Member Function Documentation

void nnet::PointIdTrainingData::analyze ( const art::Event event)
overrideprivate

Definition at line 127 of file PointIdTrainingData_module.cc.

128  {
129  fEvent = event.id().event();
130  fRun = event.run();
131  fSubRun = event.subRun();
132 
133  bool saveSim = fTrainingDataAlg.saveSimInfo() && !event.isRealData();
134 
135  std::ostringstream os;
136  os << "event_" << fEvent << "_run_" << fRun << "_subrun_" << fSubRun;
137 
138  std::cout << "analyze " << os.str() << std::endl;
139 
140  auto const clockData =
142  auto const detProp =
144 
145  for (size_t i = 0; i < fSelectedTPC.size(); ++i)
146  for (size_t v = 0; v < fSelectedPlane.size(); ++v) {
148  event, clockData, detProp, fSelectedPlane[v], fSelectedTPC[i], 0);
149 
150  unsigned int w0, w1, d0, d1;
151  if (fCrop && saveSim) {
152  if (fTrainingDataAlg.findCrop(0.004F, w0, w1, d0, d1)) {
153  std::cout << " crop: " << w0 << " " << w1 << " " << d0 << " " << d1 << std::endl;
154  }
155  else {
156  std::cout << " skip empty tpc:" << fSelectedTPC[i] << " / view:" << fSelectedPlane[v]
157  << std::endl;
158  continue;
159  }
160  }
161  else {
162  w0 = 0;
163  w1 = fTrainingDataAlg.NWires();
164  d0 = 0;
166  }
167 
168  if (fDumpToRoot) {
169  std::ostringstream ss1;
170  ss1 << "raw_" << os.str() << "_tpc_" << fSelectedTPC[i] << "_view_"
171  << fSelectedPlane[v]; // TH2's name
172 
174  TH2F* rawHist =
175  tfs->make<TH2F>((ss1.str() + "_raw").c_str(), "ADC", w1 - w0, w0, w1, d1 - d0, d0, d1);
176  TH2F* depHist = 0;
177  TH2I* pdgHist = 0;
178  if (saveSim) {
179  depHist = tfs->make<TH2F>(
180  (ss1.str() + "_deposit").c_str(), "Deposit", w1 - w0, w0, w1, d1 - d0, d0, d1);
181  pdgHist = tfs->make<TH2I>(
182  (ss1.str() + "_pdg").c_str(), "PDG", w1 - w0, w0, w1, d1 - d0, d0, d1);
183  }
184 
185  for (size_t w = w0; w < w1; ++w) {
186  auto const& raw = fTrainingDataAlg.wireData(w);
187  for (size_t d = d0; d < d1; ++d) {
188  rawHist->Fill(w, d, raw[d]);
189  }
190 
191  if (saveSim) {
192  auto const& edep = fTrainingDataAlg.wireEdep(w);
193  for (size_t d = d0; d < d1; ++d) {
194  depHist->Fill(w, d, edep[d]);
195  }
196 
197  auto const& pdg = fTrainingDataAlg.wirePdg(w);
198  for (size_t d = d0; d < d1; ++d) {
199  pdgHist->Fill(w, d, pdg[d]);
200  }
201  }
202  }
203 
204  writeAndDelete(rawHist);
205  writeAndDelete(depHist);
206  writeAndDelete(pdgHist);
207 
208  }
209  else {
210  std::ostringstream ss1;
211  ss1 << fOutTextFilePath << "/raw_" << os.str() << "_tpc_" << fSelectedTPC[i] << "_view_"
212  << fSelectedPlane[v];
213 
214  std::ofstream fout_raw, fout_deposit, fout_pdg;
215 
216  fout_raw.open(ss1.str() + ".raw");
217  if (saveSim) {
218  fout_deposit.open(ss1.str() + ".deposit");
219  fout_pdg.open(ss1.str() + ".pdg");
220  }
221 
222  for (size_t w = w0; w < w1; ++w) {
223  auto const& raw = fTrainingDataAlg.wireData(w);
224  for (size_t d = d0; d < d1; ++d) {
225  fout_raw << raw[d] << " ";
226  }
227  fout_raw << std::endl;
228 
229  if (saveSim) {
230  auto const& edep = fTrainingDataAlg.wireEdep(w);
231  for (size_t d = d0; d < d1; ++d) {
232  fout_deposit << edep[d] << " ";
233  }
234  fout_deposit << std::endl;
235 
236  auto const& pdg = fTrainingDataAlg.wirePdg(w);
237  for (size_t d = d0; d < d1; ++d) {
238  fout_pdg << pdg[d] << " ";
239  }
240  fout_pdg << std::endl;
241  }
242  }
243 
244  fout_raw.close();
245  if (saveSim) {
246  fout_deposit.close();
247  fout_pdg.close();
248  }
249  }
250  }
251 
252  } // PointIdTrainingData::analyze()
std::vector< float > const & wireEdep(size_t widx) const
Definition: PointIdAlg.h:298
bool saveSimInfo() const
Definition: PointIdAlg.h:265
bool setEventData(const art::Event &event, detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, unsigned int plane, unsigned int tpc, unsigned int cryo)
Definition: PointIdAlg.cxx:859
Raw data description.
int fRun
number of the event being processed
unsigned int NWires() const
nnet::TrainingDataAlg fTrainingDataAlg
bool fCrop
number of the sub-run being processed
bool findCrop(float max_e_cut, unsigned int &w0, unsigned int &w1, unsigned int &d0, unsigned int &d1) const
int fSubRun
number of the run being processed
unsigned int NScaledDrifts() const
std::vector< int > const & wirePdg(size_t widx) const
Definition: PointIdAlg.h:303
QTextStream & endl(QTextStream &s)
std::vector< float > const & wireData(size_t widx) const

Member Data Documentation

bool nnet::PointIdTrainingData::fCrop
private

number of the sub-run being processed

Definition at line 95 of file PointIdTrainingData_module.cc.

bool nnet::PointIdTrainingData::fDumpToRoot
private

Definition at line 86 of file PointIdTrainingData_module.cc.

int nnet::PointIdTrainingData::fEvent
private

Definition at line 91 of file PointIdTrainingData_module.cc.

geo::GeometryCore const* nnet::PointIdTrainingData::fGeometry
private

crop data to event (set to false when dumping noise!)

Definition at line 97 of file PointIdTrainingData_module.cc.

std::string nnet::PointIdTrainingData::fOutTextFilePath
private

Definition at line 85 of file PointIdTrainingData_module.cc.

int nnet::PointIdTrainingData::fRun
private

number of the event being processed

Definition at line 92 of file PointIdTrainingData_module.cc.

std::vector<int> nnet::PointIdTrainingData::fSelectedPlane
private

Definition at line 89 of file PointIdTrainingData_module.cc.

std::vector<int> nnet::PointIdTrainingData::fSelectedTPC
private

Definition at line 88 of file PointIdTrainingData_module.cc.

int nnet::PointIdTrainingData::fSubRun
private

number of the run being processed

Definition at line 93 of file PointIdTrainingData_module.cc.

nnet::TrainingDataAlg nnet::PointIdTrainingData::fTrainingDataAlg
private

Definition at line 83 of file PointIdTrainingData_module.cc.


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