23 #include "art_root_io/TFileService.h" 48 Name(
"TrainingDataAlg")
52 Name(
"OutTextFilePath"),
53 Comment(
"Text files with all needed data dumped.")
58 Comment(
"Dump to ROOT histogram file (replaces the text files)")
63 Comment(
"use selected views only, or all views if empty list")
68 Comment(
"use selected tpc's only, or all tpc's if empty list")
73 Comment(
"Crop the projection to the event region plus margin")
114 for (
size_t tpc = 0; tpc < TPC_CNT; ++tpc)
128 fEvent =
event.id().event();
134 std::ostringstream os;
137 std::cout <<
"analyze " << os.str() <<
std::endl;
144 unsigned int w0, w1, d0, d1;
145 if (
fCrop && saveSim)
149 std::cout <<
" crop: " << w0 <<
" " << w1 <<
" " << d0 <<
" " << d1 <<
std::endl;
165 std::ostringstream ss1;
169 TH2F* rawHist = tfs->make<TH2F>((ss1.str() +
"_raw").c_str(),
"ADC", w1 - w0, w0, w1, d1 - d0, d0, d1);
174 depHist = tfs->make<TH2F>((ss1.str() +
"_deposit").c_str(),
"Deposit", w1 - w0, w0, w1, d1 - d0, d0, d1);
175 pdgHist = tfs->make<TH2I>((ss1.str() +
"_pdg").c_str(),
"PDG", w1 - w0, w0, w1, d1 - d0, d0, d1);
178 for (
size_t w = w0;
w < w1; ++
w)
181 for (
size_t d = d0;
d < d1; ++
d) { rawHist->Fill(
w,
d,
raw[
d]); }
186 for (
size_t d = d0;
d < d1; ++
d) { depHist->Fill(
w,
d, edep[
d]); }
189 for (
size_t d = d0;
d < d1; ++
d) { pdgHist->Fill(
w,
d,
pdg[
d]); }
195 std::ostringstream ss1;
199 std::ofstream fout_raw, fout_deposit, fout_pdg;
201 fout_raw.open(ss1.str() +
".raw");
204 fout_deposit.open(ss1.str() +
".deposit");
205 fout_pdg.open(ss1.str() +
".pdg");
208 for (
size_t w = w0;
w < w1; ++
w)
211 for (
size_t d = d0;
d < d1; ++
d) { fout_raw <<
raw[
d] <<
" "; }
217 for (
size_t d = d0;
d < d1; ++
d) { fout_deposit << edep[
d] <<
" "; }
221 for (
size_t d = d0;
d < d1; ++
d) { fout_pdg <<
pdg[
d] <<
" "; }
229 fout_deposit.close();
std::vector< int > fSelectedPlane
std::vector< float > const & wireEdep(size_t widx) const
unsigned int NScaledDrifts(void) const
bool setEventData(const art::Event &event, unsigned int plane, unsigned int tpc, unsigned int cryo)
EDAnalyzer(fhicl::ParameterSet const &pset)
unsigned int NWires(void) const
int fRun
number of the event being processed
Access the description of detector geometry.
unsigned int MaxPlanes() const
Returns the largest number of planes among all TPCs in this detector.
fhicl::Sequence< int > SelectedView
#define DEFINE_ART_MODULE(klass)
fhicl::Atom< bool > DumpToRoot
nnet::TrainingDataAlg fTrainingDataAlg
geo::GeometryCore const * fGeometry
crop data to event (set to false when dumping noise!)
std::string fOutTextFilePath
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
Description of geometry of one entire detector.
Definition of data types for geometry description.
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
int fSubRun
number of the run being processed
void analyze(const art::Event &event) override
fhicl::Sequence< int > SelectedTPC
PointIdTrainingData(Parameters const &config)
fhicl::Atom< std::string > OutTextFilePath
std::vector< int > const & wirePdg(size_t widx) const
QTextStream & endl(QTextStream &s)
Event finding and building.
std::vector< float > const & wireData(size_t widx) const
std::vector< int > fSelectedTPC