27int main(
const int argc,
const char *
const argv[])
38 bool overwriteDetector;
43 JParser<> zap(
"Auxiliary program to update the PMT status in the detector file based on the fraction of short time-over-threshold values.");
45 zap[
'f'] =
make_field(inputFile,
"input file (output from JCalibrateToT).");
46 zap[
'a'] =
make_field(detectorFile,
"detector file.");
47 zap[
'x'] =
make_field(range,
"integration range for noise.") = JRange_t(0.0, 8.0);
48 zap[
't'] =
make_field(fraction,
"maximal fraction of signal allowed for noise.") = 0.5;
49 zap[
'A'] =
make_field(overwriteDetector,
"overwrite detector file.");
54 catch(
const exception& error) {
55 FATAL(error.what() << endl);
71 NOTICE(
"Set detector version to " <<
detector.getVersion() << endl);
75 gErrorIgnoreLevel = kError;
77 TFile* in = TFile::Open(inputFile.c_str(),
"exist");
79 if (in == NULL || !in->IsOpen()) {
80 FATAL(
"File: " << inputFile <<
" not opened." << endl);
84 for (JDetector::iterator module =
detector.begin(); module !=
detector.end(); ++module) {
86 if (!module->empty()) {
88 TH2D* h2s = (TH2D*) in->Get(
MAKE_CSTRING(module->getID() << _2SToT));
92 for (
int ix = 1; ix <= h2s->GetXaxis()->GetNbins(); ++ix) {
97 for (
int iy = 1; iy <= h2s->GetYaxis()->GetNbins(); ++iy) {
99 const double x = h2s->GetYaxis()->GetBinCenter(iy);
100 const double y = h2s->GetBinContent(ix, iy);
109 const bool disable = noise > fraction * signal;
111 if (
debug >= debug_t || disable) {
112 cout <<
"PMT " <<
FILL(10,
'0') << module->getID() <<
"." <<
FILL(2,
'0') << (ix - 1) <<
FILL()
113 <<
" noise/signal " <<
FIXED(7,0) << noise <<
"/" <<
FIXED(7,0) << signal << (disable ?
" *" :
"") << endl;
116 if (overwriteDetector) {
118 module->getPMT(ix - 1).getStatus().set(PMT_DISABLE);
125 WARNING(
"No histogram for module " << module->getID() <<
"; skip." << endl);
132 if (overwriteDetector) {
134 NOTICE(
"Store PMT status on file " << detectorFile << endl);