64 using namespace KM3NETDAQ;
76 bool overwriteDetector;
97 JParser<> zap(
"Auxiliary program to fit PMT parameters from JMergeCalibrateK40 output.");
100 zap[
'f'] =
make_field(inputFile,
"input file (output from JMergeCalibrateK40).");
102 zap[
'a'] =
make_field(detectorFile,
"detector file.");
103 zap[
'P'] =
make_field(pmtFile,
"specify PMT file name that can be given to JTriggerEfficiency.") =
"";
105 "Fix time offset(s) of PMT(s) of certain module(s), e.g."
106 "\n-! \"808969848 0 808982077 23\" will fix time offsets of PMT 0 of module 808969848 and of PMT 23 of module 808982077."
107 "\nSame PMT offset can be fixed for all optical modules, e.g."
108 "\n-! \"-1 0 -1 23\" will fix time offsets of PMTs 0 and 23 of all optical modules.") =
JPARSER::initialised();
109 zap[
'r'] =
make_field(reverse,
"reverse TDC constraints due to option -! <TDC>.");
110 zap[
'A'] =
make_field(overwriteDetector,
"overwrite detector file provided through '-a' with fitted time offsets.");
111 zap[
'w'] =
make_field(writeFits,
"write fit results.");
112 zap[
'D'] =
make_field(fitAngle,
"fit angular distribution; fix normalisation.");
113 zap[
'M'] =
make_field(fitModel,
"fit angular distribution as well as normalisation; fix PMT QEs = 1.0.");
120 catch(
const exception &error) {
121 FATAL(error.what() << endl);
133 for (JTDC_t::const_iterator
i =
TDC.begin();
i !=
TDC.end(); ++
i) {
134 DEBUG(
"PMT " << setw(10) <<
i->first <<
' ' << setw(2) <<
i->second <<
" constrain t0." << endl);
140 catch(
const exception &error) {
141 FATAL(error.what() << endl);
160 catch(
const exception& error) {}
166 TFile*
in = TFile::Open(inputFile.c_str(),
"exist");
168 if (
in == NULL || !
in->IsOpen()) {
169 FATAL(
"File: " << inputFile <<
" not opened." << endl);
175 TH1D h0(
"chi2", NULL, 500, 0.0, 5.0);
176 TH1D hn(
"hn", NULL, 501, -0.5, 500.0);
177 TH1D hr(
"rate", NULL, 500, 0.0, 25.0);
178 TH1D h1(
"p1", NULL, 500, -5.0, +5.0);
179 TH1D h2(
"p2", NULL, 500, -5.0, +5.0);
180 TH1D h3(
"p3", NULL, 500, -5.0, +5.0);
181 TH1D h4(
"p4", NULL, 500, -5.0, +5.0);
182 TH1D hb(
"bg", NULL, 500, -0.1, +0.1);
183 TH1D hc(
"cc", NULL, 500, -0.1, +0.1);
188 TH2D H2(
"detector", NULL,
189 string.size() + 0, -0.5,
string.size() - 0.5,
190 range.getLength() + 1,
range.getLowerLimit() - 0.5,
range.getUpperLimit() + 0.5);
192 for (Int_t
i = 1;
i <= H2.GetXaxis()->GetNbins(); ++
i) {
195 for (Int_t
i = 1;
i <= H2.GetYaxis()->GetNbins(); ++
i) {
202 for (JDetector::iterator module =
detector.begin(); module !=
detector.end(); ++module) {
204 if (module->getFloor() == 0) {
210 NOTICE(
"Module " << setw(10) << module->getID() <<
' ' <<
getLabel(module->getLocation()) <<
" !" <<
distance(range.first, range.second) << endl);
214 if (h2d == NULL || h2d->GetEntries() == 0) {
216 NOTICE(
"No data for module " << module->getID() <<
" -> set QEs to 0." << endl);
231 for (
int ix = 1; ix <= h2d->GetXaxis()->GetNbins(); ++ix) {
235 auto& buffer = data[pair];
240 for (
int iy = 1; iy <= h2d->GetYaxis()->GetNbins(); ++iy) {
242 const double x = h2d->GetXaxis()->GetBinCenter(ix);
243 const double y = h2d->GetYaxis()->GetBinCenter(iy);
247 double value = h2d->GetBinContent(ix,iy);
248 double error = h2d->GetBinError (ix,iy);
250 buffer.push_back(
rate_type(y, value, error));
252 double width = h2d->GetYaxis()->GetBinWidth(iy);
262 if (V <= MINIMAL_RATE_HZ + STDEV*sqrt(W)) {
263 count[pair.first] += 1;
264 count[pair.second] += 1;
272 WARNING(
"PMT " << setw(10) << module->getID() <<
'.' <<
FILL(2,
'0') << pmt <<
FILL() <<
' ' <<
"all rates to low -> disable" << endl);
274 model.parameters[pmt].disable();
278 DEBUG(
"Start value:" << endl <<
model << endl);
290 if (fit.value.parameters[pmt].QE() < QE_MIN && fit.value.parameters[pmt].status) {
292 WARNING(
"PMT " << setw(10) << module->getID() <<
'.' <<
FILL(2,
'0') << pmt <<
FILL() <<
' ' <<
FIXED(5,3) << fit.value.parameters[pmt].QE() <<
" < " <<
FIXED(5,3) << QE_MIN <<
" -> disable" << (!refit ?
" and refit" :
"") << endl);
294 fit.value.parameters[pmt].disable();
304 NOTICE(
"Fit result " << setw(10) << module->getID() <<
" chi2 / NDF " <<
FIXED(10,2) <<
result.chi2 <<
" / " << setw(5) <<
result.ndf <<
' ' << setw(5) << fit.numberOfIterations << endl);
311 hn.Fill(fit.numberOfIterations);
312 hr.Fill(fit.value.R );
313 h1.Fill(fit.value.p1);
314 h2.Fill(fit.value.p2);
315 h3.Fill(fit.value.p3);
316 h4.Fill(fit.value.p4);
317 hb.Fill(fit.value.bg);
318 hc.Fill(fit.value.cc);
320 for (
int ix = 1; ix <= h2d->GetXaxis()->GetNbins(); ++ix) {
322 const pair_type pair = fit.value.getPair(ix - 1);
324 for (
int iy = 1; iy <= h2d->GetYaxis()->GetNbins(); ++iy) {
326 const double dt_ns = h2d->GetYaxis()->GetBinCenter(iy);
328 h2d->SetBinContent(ix, iy, fit.value.getValue(pair, dt_ns));
329 h2d->SetBinError (ix, iy, 0.0);
336 H2.Fill((
double)
string.
getIndex(module->getString()), (
double) module->getFloor(),
result.chi2 /
result.ndf);
339 const double t0 = (fit.value.hasFixedTimeOffset() ? fit.value.getFixedTimeOffset() : 0.0);
348 data.
QE = fit.value.parameters[pmt].QE /
P;
352 module->getPMT(pmt).addT0(fit.value.parameters[pmt].t0.get() - t0);
355 catch(
const exception& error) {
357 ERROR(
"Module " << setw(10) << module->getID() <<
' ' << error.what() <<
" -> set QEs to 0." << endl);
380 if (overwriteDetector) {
382 NOTICE(
"Store calibration data on file " << detectorFile << endl);
401 out << h0 << hn << hr << h1 << h2 << h3 << h4 << hb << hc << H2;
Data structure for measured coincidence rate of pair of PMTs.
Utility class to parse command line options.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
Auxiliary class for TDC constraints.
Utility class to parse parameter values.
*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
#define MAKE_CSTRING(A)
Make C-string.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
then fatal Wrong number of arguments fi set_variable STRING $argv[1] set_variable DETECTORXY_TXT $WORKDIR $DETECTORXY_TXT tail read X Y CHI2 RMS printf optimum n $X $Y $CHI2 $RMS awk v Y
Auxiliary data structure for floating point format specification.
V(JDAQEvent-JTriggerReprocessor)*1.0/(JDAQEvent+1.0e-10)
floor_range getRangeOfFloors(const JDetector &detector)
Get range of floors.
Implementation of object output from STD container.
Model for fit to acoustics data.
Type definition of range.
static const char *const _2F
Name extension for 2F rate fitted.
Fit parameters for two-fold coincidence rate due to K40.
T & getInstance(const T &object)
Get static instance from temporary object.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
fit parameters of PMTs and angular dependence of K40 rate
static const char *const _2R
Name extension for 2D rate measured.
Auxiliary class for map of PMT parameters.
int getIndex()
Get index for user I/O manipulation.
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
Auxiliary data structure for sequence of same character.
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Router for mapping of string identifier to index.
fit parameters of K40 rate and TTSs of PMTs
double getSurvivalProbability(const JPMTParameters ¶meters)
Get model dependent probability that a one photo-electron hit survives the simulation of the PMT assu...
Data structure for measured coincidence rates of all pairs of PMTs in optical module.
no fit printf nominal n $STRING awk v X
Object reading from a list of files.
Data structure for PMT parameters.
do set_variable DETECTOR_TXT $WORKDIR detector
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
double QE
relative quantum efficiency
#define DEBUG(A)
Message macros.