67int main(
const int argc,
const char *
const argv[])
87 JParser<> zap(
"Auxiliary program to compute the PMT thresholds according to the small time-over-threshold fraction.");
93 zap[
'f'] =
make_field(inputFile,
"list of file names (output of JCalibrateToT)");
96 zap[
't'] =
make_field(fraction,
"maximal fraction of signal allowed for noise.") = 0.5;
97 zap[
'T'] =
make_field(testType,
"test type") =
"TH-TUNING-SEA-v1";
102 catch(
const exception& error) {
103 FATAL(error.what() << endl);
107 if (inputFile.empty()) {
108 FATAL(
"No input files.");
116 JDB::reset(usr, pwd, cookie);
124 catch(
const exception& error) {
125 FATAL(error.what() << endl);
129 const JDAQHeader header = getDAQHeader(inputFile[0].c_str());
142 detector[parameters.DOMID][parameters.CABLEPOS] = parameters;
147 catch(
const exception& error) {
148 FATAL(error.what() << endl);
152 struct parameters_type {
164 for (vector<string>::const_iterator i = inputFile.begin(); i != inputFile.end(); ++i) {
166 const JDAQHeader header = getDAQHeader(i->c_str());
174 TFile* in = TFile::Open(i->c_str(),
"exist");
176 if (in == NULL || !in->IsOpen()) {
177 FATAL(
"File: " << *i <<
" not opened." << endl);
180 for (detector_type::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
182 if (!module->second.empty()) {
188 for (
int ix = 1; ix <= h2s->GetXaxis()->GetNbins(); ++ix) {
193 for (
int iy = 1; iy <= h2s->GetYaxis()->GetNbins(); ++iy) {
195 const double x = h2s->GetYaxis()->GetBinCenter(iy);
196 const double y = h2s->GetBinContent(ix, iy);
205 const JUPI_t upi =
module->second.at(ix-1).PMTUPI;
207 data[upi].push_back({ getPMTThreshold(upi).value, signal, noise});
212 WARNING(
"No histogram for module " << module->first <<
"; skip." << endl);
223 for (map_type::iterator i = data.begin(); i != data.end(); ++i) {
225 sort(i->second.begin(), i->second.end(),
make_comparator(¶meters_type::threshold));
227 int threshold = i->second.begin()->threshold;
229 for (data_type::const_iterator p = i->second.begin(); p != i->second.end(); ++p) {
231 if (p->noise <= fraction * p->signal) {
233 threshold = p->threshold;
239 if (
debug >=
debug_t || threshold > i->second.begin()->threshold) {
241 cout <<
"PMT " << left << setw(32) << i->first <<
" -> " << right << setw(3) << threshold <<
" (" << i->second.begin()->threshold <<
")" << endl;
243 for (data_type::const_iterator p = i->second.begin(); p != i->second.end(); ++p) {
244 DEBUG(setw(3) << p->threshold <<
' ' <<
FIXED(7,0) << p->noise <<
"/" <<
FIXED(7,0) << p->signal <<
' ' << (p->noise <= fraction * p->signal) << endl);
265 out << setw(2) << setprecision(8);