109 JParser<> zap(
"Auxiliary program to fit PMT parameters from JMergeCalibrateK40 output.");
112 zap[
'f'] =
make_field(inputFile,
"input file (output from JMergeCalibrateK40).");
115 zap[
'P'] =
make_field(
pmtFile,
"specify PMT file name that can be given to JTriggerEfficiency.") =
"";
117 "Fix time offset(s) of PMT(s) of certain module(s), e.g."
118 "\n-! \"808969848 0 808982077 23\" will fix time offsets of PMT 0 of module 808969848 and of PMT 23 of module 808982077."
119 "\nSame PMT offset can be fixed for all optical modules, e.g."
120 "\n-! \"-1 0 -1 23\" will fix time offsets of PMTs 0 and 23 of all optical modules.") =
JPARSER::initialised();
121 zap[
'r'] =
make_field(reverse,
"reverse TDC constraints due to option -! <TDC>.");
123 zap[
'w'] =
make_field(
writeFits,
"write fit results to ROOT file; -ww also write fitted TTS to PMT file.");
126 zap[
'M'] =
make_field(
fitModel,
"fit angular distribution as well as normalisation; fix PMT QEs = 1.0.");
134 catch(
const exception &error) {
142 (
fixQE ? 1 : 0) > 1) {
143 FATAL(
"Use either option -M, -D, -B or -Q" <<
endl);
156 for (JTDC_t::const_iterator i = TDC.begin(); i != TDC.end(); ++i) {
157 DEBUG(
"PMT " <<
setw(10) << i->first <<
' ' <<
setw(2) << i->second <<
" constrain t0." <<
endl);
163 catch(
const exception &error) {
183 catch(
const exception& error) {}
189 TFile* in = TFile::Open(inputFile.c_str(),
"exist");
191 if (in ==
NULL || !in->IsOpen()) {
192 FATAL(
"File: " << inputFile <<
" not opened." <<
endl);
198 TH1D h0(
"chi2",
NULL, 500, 0.0, 5.0);
201 TH1D h1(
"p1",
NULL, 500, -5.0, +5.0);
202 TH1D h2(
"p2",
NULL, 500, -5.0, +5.0);
212 string.size() + 0, -0.5,
string.size() - 0.5,
228 if (
module->getFloor() == 0) {
240 NOTICE(
"No data for module " <<
module->getID() <<
" -> set QEs to 0." <<
endl);
260 auto& buffer = data[
pair];
267 const double x =
h2d->GetXaxis()->GetBinCenter(
ix);
268 const double y =
h2d->GetYaxis()->GetBinCenter(
iy);
272 double value =
h2d->GetBinContent(
ix,
iy);
273 double error =
h2d->GetBinError (
ix,
iy);
275 buffer.push_back(
rate_type(y, value, error));
277 double width =
h2d->GetYaxis()->GetBinWidth(
iy);
289 if (V <= 0.0 -
STDEV*W) {
290 count[0][
pair.first] += 1;
291 count[0][
pair.second] += 1;
295 count[1][
pair.first] += 1;
296 count[1][
pair.second] += 1;
306 if (fit.value.parameters[pmt].status) {
307 model.parameters[pmt].bg.set();
311 if (count[1][pmt] == NUMBER_OF_PMTS) {
315 model.parameters[pmt].disable();
338 if (fit.value.parameters[pmt].status) {
340 if (fit.value.parameters[pmt].QE() <= QE_MIN ||
341 fit.value.parameters[pmt].QE() <= 0.0 +
STDEV * fit.error.parameters[pmt].QE()) {
345 <<
FIXED(5,3) << fit.value.parameters[pmt].QE() <<
" +/- "
346 <<
FIXED(5,3) << fit.error.parameters[pmt].QE() <<
" "
347 <<
" -> disable" << (!
refit ?
" and refit" :
"") <<
endl);
349 fit.value.parameters[pmt].disable();
354 if (fit.value.parameters[pmt].t0.atLimit(
T0_NS)) {
358 <<
FIXED(5,3) << fit.value.parameters[pmt].t0() <<
" +/- "
359 <<
FIXED(5,3) << fit.error.parameters[pmt].t0() <<
" "
360 <<
" -> disable" << (!
refit ?
" and refit" :
"") <<
endl);
362 fit.value.parameters[pmt].disable();
372 if (fit.value.parameters[pmt].status) {
392 hn.Fill(fit.numberOfIterations);
393 hr.Fill(fit.value.R );
394 h1.Fill(fit.value.p1);
395 h2.Fill(fit.value.p2);
396 h3.Fill(fit.value.p3);
397 h4.Fill(fit.value.p4);
398 hc.Fill(fit.value.cc);
399 hb.Fill(fit.value.bc);
406 h1t.SetBinContent(pmt + 1, fit.value.parameters[pmt].t0 ());
408 h1s.SetBinContent(pmt + 1, fit.value.parameters[pmt].TTS());
410 h1q.SetBinContent(pmt + 1, fit.value.parameters[pmt].QE ());
422 const double dt_ns =
h2d->GetYaxis()->GetBinCenter(
iy);
424 h2d->SetBinContent(
ix,
iy, fit.value.getValue(
pair, dt_ns));
425 h2d->SetBinError (
ix,
iy, 0.0);
432 const double x =
string.getIndex(
module->getString());
433 const double y =
module->getFloor();
436 HN->Fill(x, y, fit.numberOfIterations);
439 const double t0 = (fit.value.hasFixedTimeOffset() ? fit.value.getFixedTimeOffset() : 0.0);
448 data.QE = fit.value.parameters[pmt].QE / P;
453 data.TTS_ns = fit.value.parameters[pmt].TTS();
456 module->getPMT(pmt).addT0(fit.value.parameters[pmt].t0.get() - t0);
459 catch(
const exception& error) {
461 ERROR(
"Module " <<
setw(10) <<
module->getID() <<
' ' << error.what() <<
" -> set QEs to 0." <<
endl);
KM3NeT DAQ constants, bit handling, etc.
Data structure for detector geometry and calibration.
int main(int argc, char **argv)
General purpose messaging.
#define DEBUG(A)
Message macros.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
I/O formatting auxiliaries.
#define MAKE_CSTRING(A)
Make C-string.
Utility class to parse parameter values.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
Auxiliary class to define a range between two values.
Scanning of objects from a single file according a format that follows from the extension of each fil...
Direct access to string in detector data structure.
Auxiliary class for map of PMT parameters.
Data structure for PMT parameters.
Utility class to parse parameter values.
Template definition of a multi-dimensional oscillation probability interpolation table.
static double TEROSTAT_R1
scaling factor
static const char *const _2F
Name extension for 2F rate fitted.
@ FIT_PMTS_QE_FIXED_t
fit parameters of PMTs with QE fixed
@ FIT_PMTS_AND_ANGULAR_DEPENDENCE_t
fit parameters of PMTs and angular dependence of K40 rate
@ FIT_MODEL_t
fit parameters of K40 rate and TTSs of PMTs
@ FIT_PMTS_AND_BACKGROUND_t
fit parameters of PMTs and background
@ FIT_PMTS_t
fit parameters of PMTs
static const char *const _2R
Name extension for 2D rate measured.
static double TEROSTAT_DZ
maximal PMT inclination
static double BELL_SHAPE
Bell shape.
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
floor_range getRangeOfFloors(const JDetector &detector)
Get range of floors.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
double getSurvivalProbability(const JPMTParameters ¶meters)
Get model dependent probability that a one photo-electron hit survives the simulation of the PMT assu...
void model(JModel_t &value)
Auxiliary function to constrain model during fit.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
KM3NeT DAQ data structures and auxiliaries.
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Auxiliary data structure for sequence of same character.
Auxiliary data structure for floating point format specification.
Type definition of range.
Model for fit to acoustics data.
Fit parameters for two-fold coincidence rate due to K40.
static const JK40Parameters & getInstance()
Get default values.
static const JPMTParameters_t & getInstance()
Get default values.
Auxiliary class for TDC constraints.
range_type equal_range(const int id)
Get range of constraints for given module.
void reverse()
Reverse constraints.
bool is_valid(const bool option=false) const
Check validity of TDC constrants.
Data structure for measured coincidence rates of all pairs of PMTs in optical module.
Data structure for measured coincidence rate of pair of PMTs.
Router for mapping of string identifier to index.
void store(const char *file_name) const
Store to output file.
void load(const char *file_name)
Load from input file.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...