100 JParser<> zap(
"Auxiliary program to verify processing of Monte Carlo events.");
102 zap[
'f'] =
make_field(inputFile,
"input file (output of detector simulation)");
103 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
104 zap[
'a'] =
make_field(detectorFileA,
"detector used for converion from Monte Carlo truth to raw data.");
105 zap[
'b'] =
make_field(detectorFileB,
"detector used for conversion of raw data to calibrated data.") =
"";
113 catch(
const exception &error) {
114 FATAL(error.what() << endl);
118 if (detectorFileB ==
"") {
119 detectorFileB = detectorFileA;
127 load(detectorFileA, detectorA);
128 load(detectorFileB, detectorB);
134 NOTICE(
"Number of modules in detector A <" << detectorFileA <<
">: " << setw(4) << detectorA.size() << endl);
135 NOTICE(
"Number of modules in detector B <" << detectorFileB <<
">: " << setw(4) << detectorB.size() << endl);
137 JPMTParametersMap::Throw(
true);
139 if (!pmtParameters.is_valid()) {
140 FATAL(
"Invalid PMT parameters " << pmtParameters << endl);
143 if (pmtParameters.getQE() != 1.0) {
145 NOTICE(
"Correct background rates with global efficiency " << pmtParameters.getQE() << endl);
147 rates_Hz.correct(pmtParameters.getQE());
149 NOTICE(
"Back ground rates: " << rates_Hz << endl);
158 DEBUG(
"PMT parameters:" << endl << pmtParameters << endl);
169 const JPosition3D center = get<JPosition3D>(header);
171 NOTICE(
"Apply detector offset from Monte Carlo run header (" << center <<
")" << endl);
183 while (inputFile.hasNext()) {
185 STATUS(
"event: " << setw(10) << inputFile.getCounter() <<
'\r');
187 Evt*
event = inputFile.next();
189 if (!event->mc_hits.empty()) {
195 if (!pmtRouter.hasPMT(hit->pmt_id)) {
197 miss[hit->pmt_id].put(
getNPE(*hit));
204 if (!moduleRouter.hasModule(pmt.
getID())) {
206 lost[pmt].put(
getNPE(*hit));
211 const double t0 =
getTime(*hit);
212 const double t1 =
putTime(t0, pmtRouter .getPMT(hit->pmt_id));
213 const double t2 =
getTime(t1, moduleRouter.getPMT(pmt));
215 if (fabs(t2 - t0) >
parameters.TMaxLocal_ns) {
216 slip[pmt].put(
getNPE(*hit));
222 npe[pmt][0].put(
getNPE(*hit));
223 npe[pmt][1].put(
getNPE(*hit) * P);
224 npe[pmt][2].put(
getNPE(*hit) * P * data.
QE);
230 NOTICE(
"Number of PMTs absent in detector A: " << setw(6) << miss.size() << endl);
233 DEBUG(setw(5) << i->first <<
' ' <<
FIXED(8,0) << i->second.getTotal() << endl);
236 NOTICE(
"Number of PMTs absent in detector B: " << setw(6) << lost.size() << endl);
239 DEBUG(setw(8) << i->first.getModuleID() <<
"[" << setw(2) << i->first.getPMTAddress() <<
"] " <<
FIXED(8,0) << i->second.getTotal() << endl);
242 NOTICE(
"Number of PMTs with t0 detector A - B > " <<
FIXED(4,1) <<
parameters.TMaxLocal_ns <<
" [ns]: " << setw(6) << slip.size() << endl);
245 DEBUG(setw(8) << i->first.getModuleID() <<
"[" << setw(2) << i->first.getPMTAddress() <<
"] " <<
FIXED(8,0) << i->second.getTotal() << endl);
249 NOTICE(
"Number of true photo-electrons, passed threshold and survived QE." << endl);
255 DEBUG(setw(8) << p->first.getModuleID() <<
"[" << setw(2) << p->first.getPMTAddress() <<
"]");
257 for (
size_t i = 0; i != p->second.size(); ++i) {
258 DEBUG(
' ' <<
FIXED(8,0) << p->second[i].getTotal());
262 for (
size_t i = 0; i != p->second.size(); ++i) {
263 total[i].put(p->second[i].getTotal());
267 NOTICE(setw(12) <<
"total");
269 for (
size_t i = 0; i != total.size(); ++i) {
275 NOTICE(
"Time range of hits [ns]: " << QT.getXmin() <<
" - " << QT.getXmax() << endl);
Router for direct addressing of PMT data in detector data structure.
Utility class to parse command line options.
Router for direct addressing of module data in detector data structure.
const JPMTParameters & getPMTParameters() const
Get PMT parameters.
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary data structure for floating point format specification.
double getTime(const Hit &hit)
Get true time of hit.
JTimeRange getTimeRange(const Evt &event)
Get time range (i.e. time between earliest and latest hit) of Monte Carlo event.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
Auxiliary class for defining the range of iterations of objects.
double putTime(const T &t1, const JCalibration &cal)
Get de-calibrated time.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
int getID() const
Get identifier.
Auxiliary class for map of PMT parameters.
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
General purpose class for object reading from a list of file names.
double getSurvivalProbability(const JPMTParameters ¶meters)
Get model dependent probability that a one photo-electron hit survives the simulation of the PMT assu...
double getMaximalDistance(const JDetector &detector, const bool option=false)
Get maximal distance between modules in detector.
double getNPE(const Hit &hit)
Get true charge of hit.
Data structure for position in three dimensions.
const JLimit & getLimit() const
Get limit.
Data structure for PMT parameters.
double QE
relative quantum efficiency
Auxiliary class for K40 rates.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
#define DEBUG(A)
Message macros.