204 using namespace KM3NETDAQ;
223 JParser<> zap(
"Auxiliary program to determine PMT parameters from K40 data.");
225 zap[
'f'] =
make_field(inputFile,
"input file.");
227 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
228 zap[
'a'] =
make_field(detectorFile,
"detector file.");
229 zap[
'T'] =
make_field(TMax_ns,
"time window [ns].") = 20.0;
231 zap[
't'] =
make_field(totRange_ns,
"PMT time-over-threshold range [ns].") = { 4.0, 7.0, ToTmax_ns };
232 zap[
'b'] =
make_field(background,
"background estimation method.") = rates_t, count_t, tails_t, rndms_t;
235 zap[
'D'] =
make_field(deadTime_us,
"L1 dead time (us)") = 0.0;
236 zap[
'C'] =
make_field(selector,
"timeslice selector, e.g. JDAQTimesliceL1.") = getROOTClassSelection<JDAQTimesliceTypes_t>();
237 zap[
'O'] =
make_field(option,
"hit pre-processing option.") = JPreprocessor::getOptions(JPreprocessor::filter_t);
242 catch(
const exception &error) {
243 FATAL(error.what() << endl);
251 if (selector == JDAQTimesliceL2::Class_Name() ||
252 selector == JDAQTimesliceSN::Class_Name()) {
253 FATAL(
"Option -C <selector> " << selector <<
" not compatible with calibration method." << endl);
256 if (selector == JDAQTimeslice ::Class_Name() ||
257 selector == JDAQTimesliceL1::Class_Name()) {
265 FATAL(
"No trigger parameters from input:" << error.
what() << endl);
268 if ((selector == JDAQTimeslice ::Class_Name() && parameters.writeL1.prescale > 0) ||
269 (selector == JDAQTimesliceL1::Class_Name())) {
271 if (parameters.TMaxLocal_ns < TMax_ns) {
272 FATAL(
"Option -T <TMax_ns> = " << TMax_ns <<
" is larger than in the trigger " << parameters.TMaxLocal_ns << endl);
275 if (background == rndms_t ||
276 background == count_t) {
277 FATAL(
"Option -C <selector> " << selector <<
" incompatible with option -b <background> " << background << endl);
282 if (!multiplicity.is_valid() || multiplicity.getLowerLimit() < 2 || multiplicity.getUpperLimit() >
NUMBER_OF_PMTS) {
283 FATAL(
"Invalid option -M <multiplicity> " << multiplicity << endl);
286 if (totRange_ns[0] > totRange_ns[1] ||
287 totRange_ns[1] > totRange_ns[2]) {
288 FATAL(
"Invalid option -t <totRange_ns> " <<
JEEPZ() << totRange_ns << endl);
291 if (background == tails_t) {
293 if (!Tail_ns.is_valid()) {
294 FATAL(
"Invalid option -B <Tail_ns> " << Tail_ns << endl);
297 if (Tail_ns.getUpperLimit() > TMax_ns) {
298 FATAL(
"Invalid option -B <Tail_ns> " << Tail_ns <<
"; upper limit larger than option -T <TMax_ns> " << TMax_ns << endl);
316 FATAL(
"Empty detector." << endl);
328 t0.push_back(
i * 2 * TMax_ns);
338 const double RTU = (cpu.getIntegralOfChargeProbability(cpu.getNPE(totRange_ns[0]), cpu.getNPE(totRange_ns[2]), NPE)
340 cpu.getIntegralOfChargeProbability(cpu.getNPE(0.0), cpu.getNPE(ToTmax_ns), NPE));
349 const Double_t ymin = -floor(TMax_ns) + 0.5;
350 const Double_t ymax = +floor(TMax_ns) - 0.5;
351 const Int_t ny = (Int_t) ((ymax - ymin) / 1.0);
353 for (JDetector::iterator module =
detector.begin(); module !=
detector.end(); ++module) {
355 const JModuleAddress& address = router.getAddress(module->getID());
357 if (!module->empty()) {
359 NOTICE(
"Booking histograms for module " << module->getID() << endl);
372 const double deadTime_ns = deadTime_us * 1e3;
381 for (JMultipleFileScanner_t::const_iterator
i = inputFile.begin();
i != inputFile.end(); ++
i) {
383 STATUS(
"Processing: " << *
i << endl);
390 for (
JDAQHeader header;
in.hasNext() && counter != numberOfEvents; ++counter) {
392 STATUS(
"event: " << setw(10) << counter <<
'\r');
DEBUG(endl);
404 if (background == rates_t) {
408 if (timeslice->
getFrameIndex() != summary.getSummaryslice()->getFrameIndex()) {
410 ERROR(
"Frame indices do not match at "
411 <<
"[counter = " << counter <<
"]"
413 <<
"[summaryslice = " << summary.getSummaryslice()->getFrameIndex() <<
"]" << endl);
419 for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
421 if (router.hasModule(frame->getModuleID())) {
423 const JModule& module = router.getModule(frame->getModuleID());
432 if (background == count_t) {
438 }
else if (background == tails_t) {
442 }
else if (background == rndms_t) {
446 }
else if (background == rates_t) {
448 if (summary.hasSummaryFrame(frame->getModuleID())) {
450 const JDAQSummaryFrame& sum = summary.getSummaryFrame(frame->getModuleID());
459 FATAL(
"Summary frame of module " << frame->getModuleID() <<
" not found at frame index " << timeslice->
getFrameIndex() << endl);
471 !rateRange_Hz(rate_Hz[
i])) {
477 const JCombinatorics& combinatorics = histogram.getCombinatorics();
479 TH2D* h2s = histogram.h2s;
480 TH1D* h1b = histogram.h1b;
481 TH1D* h1L = histogram.h1L;
487 JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*frame, module);
489 buffer.preprocess(option, match);
491 for (JSuperFrame2D_t::iterator
i = buffer.begin();
i != buffer.end(); ++
i) {
492 if (veto[
i->getPMTAddress()]) {
497 JSuperFrame1D_t&
data = JSuperFrame1D_t::multiplex(buffer);
499 DEBUG(
"Number of hits " << timeslice->
getFrameIndex() <<
":" << frame->getModuleID() <<
' ' << frame->size() <<
' ' << data.size() << endl);
504 size_t numberOfSignalEvents = 0;
506 double t1 = numeric_limits<double>::lowest();
512 while (++q != data.end() && q->getT() - p->getT() <= TMax_ns) {}
516 if (multiplicity(N)) {
518 numberOfSignalEvents += 1;
520 if (p->getT() > t1 + deadTime_ns) {
525 if ((__p->getToT() >= totRange_ns[0]) &&
526 (__q->getToT() >= totRange_ns[0]) &&
527 (__p->getToT() >= totRange_ns[1] ||
528 __q->getToT() >= totRange_ns[1]) &&
529 (__p->getToT() <= totRange_ns[2]) &&
530 (__q->getToT() <= totRange_ns[2])) {
532 h2s->Fill((
double) combinatorics.getIndex(__p->getPMT(),__q->getPMT()),
533 JCombinatorics::getSign(__p->getPMT(),__q->getPMT()) * (__q->getT() - __p->getT()));
548 if (background == rndms_t) {
554 sort(data.begin(), data.end());
556 double t1 = numeric_limits<double>::lowest();
562 while (++q != data.end() && q->getT() - p->getT() <= TMax_ns) {}
566 if (multiplicity(N)) {
568 if (p->getT() > t1 + deadTime_ns) {
573 if ((__p->getToT() >= totRange_ns[0]) &&
574 (__q->getToT() >= totRange_ns[0]) &&
575 (__p->getToT() >= totRange_ns[1] ||
576 __q->getToT() >= totRange_ns[1]) &&
577 (__p->getToT() <= totRange_ns[2]) &&
578 (__q->getToT() <= totRange_ns[2])) {
580 h1b->Fill((
double) combinatorics.getIndex(p->getPMT(),q->getPMT()), 1.0);
592 }
else if (background == rates_t ||
593 background == count_t) {
606 if (!veto[
i] && !veto[
j]) {
608 const double R1 = rate_Hz[
i];
609 const double R2 = rate_Hz[
j];
616 const double N =
getP((R1) * 2 * TMax_ns * 1e-9,
617 (R2) * 2 * TMax_ns * 1e-9,
618 (Rs - R1 - R2) * 2 * TMax_ns * 1e-9,
619 multiplicity.getLowerLimit(),
620 multiplicity.getUpperLimit()) *
getFrameTime() / (2*TMax_ns);
622 h1b->Fill((
double) combinatorics.getIndex(
i,j),
N);
634 for (
size_t i = 0;
i < combinatorics.getNumberOfPairs(); ++
i) {
636 const int pmt1 = combinatorics.getPair(
i).first;
637 const int pmt2 = combinatorics.getPair(
i).second;
639 if (!veto[pmt1] && !veto[pmt2]) {
640 h1L->Fill(
i, livetime_s);
649 if (background == tails_t ) {
651 const double R = (2.0*TMax_ns) / ((ymax - ymin)/ny);
655 if (hr->is_valid()) {
660 for (
int ix = 1; ix <= h1b->GetXaxis()->GetNbins(); ++ix) {
666 for (
int iy = 1; iy <= h2s->GetYaxis()->GetNbins(); ++iy) {
668 const double y = h2s->GetYaxis()->GetBinCenter(iy) ;
670 if (Tail_ns(fabs(y))) {
671 Y += h2s->GetBinContent(ix,iy);
672 W += h2s->GetBinError (ix,iy) * h2s->GetBinError(ix,iy);
677 h1b->SetBinContent(ix, Y/N * R);
678 h1b->SetBinError (ix, sqrt(W/N) * R);
691 weights_hist.GetXaxis()->SetBinLabel(2,
WS_t);
692 weights_hist.GetXaxis()->SetBinLabel(3,
WB_t);
695 weights_hist.Fill(
WS_t, (ymax - ymin)/ny);
696 weights_hist.Fill(
WB_t, 2.0*TMax_ns);
Utility class to parse command line options.
double getRate(const int tdc, const double factor=1.0) const
Get count rate.
Data structure for a composite optical module.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
int getDetectorID() const
Get detector identifier.
static const char *const WB_t
Named bin for value of TMax_ns in JCalibrateK40.
Auxiliary class to select ROOT class based on class name.
Router for direct addressing of module data in detector data structure.
*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
Long64_t counter_type
Type definition for counter.
then warning Cannot perform comparison test for histogram
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 class for multiplexing object iterators.
int getRunNumber() const
Get run number.
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
int getFrameIndex() const
Get frame index.
1-dimensional frame with time calibrated data from one optical module.
int first
index of module in detector data structure
static const char *const WS_t
Named bin for time residual bin width.
Reduced data structure for L0 hit.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
double getFrameTime()
Get frame time duration.
Data storage class for rate measurements of all PMTs in one module.
File router for fast addressing of summary data.
Address of module in detector data structure.
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
Auxiliary data structure for streaming of STL containers.
double getP(const double expval, bool hit)
Get Poisson probability to observe a hit or not for given expectation value for the number of hits...
PMT analogue signal processor.
static const char *const weights_hist_t
Histogram naming.
then JCookie sh JDataQuality D $DETECTOR_ID R
Auxiliary base class for list of file names.
virtual const char * what() const override
Get error message.
bool getPMTStatus(const JStatus &status)
Test status of PMT.
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
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
static const char *const W1_overall_t
Named bin for duration of the run.
2-dimensional frame with time calibrated data from one optical module.
Object reading from a list of files.
do set_variable DETECTOR_TXT $WORKDIR detector
bool getDAQStatus(const JDAQFrameStatus &frame, const JStatus &status)
Test status of DAQ.
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Auxiliary class for specifying the way of pre-processing of hits.
const JDAQFrameStatus & getDAQFrameStatus() const
Get DAQ frame status.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable STRING $argv[2] set_array QUANTILES set_variable FORMULA *[0] exp(-0.5 *(x-[1])*(x-[1])/([2]*[2]))" set_variable MODULE `getModule -a $DETECTOR -L "$STRING 0"` source JAcousticsToolkit.sh typeset -A TRIPODS get_tripods $WORKDIR/tripod.txt TRIPODS XMEAN
JTriggerParameters getTriggerParameters(const JMultipleFileScanner_t &file_list)
Get trigger parameters.
double getValue(const int tdc) const
Get value.
#define DEBUG(A)
Message macros.