21 #include "art_root_io/TFileService.h" 38 template <
typename Hist>
39 void writeAndDelete(Hist*&
hist) {
59 Comment(
"Text files with all needed data dumped.")};
63 Comment(
"Dump to ROOT histogram file (replaces the text files)")};
67 Comment(
"use selected views only, or all views if empty list")};
71 Comment(
"use selected tpc's only, or all tpc's if empty list")};
74 Comment(
"Crop the projection to the event region plus margin")};
115 for (
size_t tpc = 0; tpc < TPC_CNT; ++tpc)
129 fEvent =
event.id().event();
135 std::ostringstream os;
138 std::cout <<
"analyze " << os.str() <<
std::endl;
140 auto const clockData =
150 unsigned int w0, w1, d0, d1;
151 if (
fCrop && saveSim) {
153 std::cout <<
" crop: " << w0 <<
" " << w1 <<
" " << d0 <<
" " << d1 <<
std::endl;
169 std::ostringstream ss1;
170 ss1 <<
"raw_" << os.str() <<
"_tpc_" <<
fSelectedTPC[i] <<
"_view_" 175 tfs->make<TH2F>((ss1.str() +
"_raw").c_str(),
"ADC", w1 - w0, w0, w1, d1 - d0, d0, d1);
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);
185 for (
size_t w = w0;
w < w1; ++
w) {
187 for (
size_t d = d0;
d < d1; ++
d) {
188 rawHist->Fill(
w,
d,
raw[
d]);
193 for (
size_t d = d0;
d < d1; ++
d) {
194 depHist->Fill(
w,
d, edep[
d]);
198 for (
size_t d = d0;
d < d1; ++
d) {
199 pdgHist->Fill(
w,
d,
pdg[
d]);
204 writeAndDelete(rawHist);
205 writeAndDelete(depHist);
206 writeAndDelete(pdgHist);
210 std::ostringstream ss1;
214 std::ofstream fout_raw, fout_deposit, fout_pdg;
216 fout_raw.open(ss1.str() +
".raw");
218 fout_deposit.open(ss1.str() +
".deposit");
219 fout_pdg.open(ss1.str() +
".pdg");
222 for (
size_t w = w0;
w < w1; ++
w) {
224 for (
size_t d = d0;
d < d1; ++
d) {
225 fout_raw <<
raw[
d] <<
" ";
231 for (
size_t d = d0;
d < d1; ++
d) {
232 fout_deposit << edep[
d] <<
" ";
237 for (
size_t d = d0;
d < d1; ++
d) {
238 fout_pdg <<
pdg[
d] <<
" ";
246 fout_deposit.close();
std::vector< float > const & wireEdep(size_t widx) const
bool setEventData(const art::Event &event, detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, unsigned int plane, unsigned int tpc, unsigned int cryo)
fhicl::Sequence< int > SelectedTPC
ChannelGroupService::Name Name
EDAnalyzer(fhicl::ParameterSet const &pset)
art framework interface to geometry description
int fRun
number of the event being processed
unsigned int NWires() const
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.
#define DEFINE_ART_MODULE(klass)
fhicl::Atom< bool > DumpToRoot
std::vector< int > fSelectedTPC
nnet::TrainingDataAlg fTrainingDataAlg
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.
fhicl::Atom< std::string > OutTextFilePath
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.
fhicl::Sequence< int > SelectedView
int fSubRun
number of the run being processed
void analyze(const art::Event &event) override
std::vector< int > fSelectedPlane
PointIdTrainingData(Parameters const &config)
unsigned int NScaledDrifts() const
Access the description of detector geometry.
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