127 using namespace KM3NETDAQ;
151 JParser<> zap(
"Auxiliary program to determine PMT parameters from K40 data.");
153 zap[
'f'] =
make_field(inputFile,
"input file.");
155 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
156 zap[
'a'] =
make_field(detectorFile,
"detector file.");
157 zap[
'T'] =
make_field(TMax_ns,
"time window [ns].") = 20.0;
160 zap[
'b'] =
make_field(background,
"background estimation method.") = rates_t, count_t, tails_t, rndms_t;
163 zap[
'D'] =
make_field(deadTime_us,
"L1 dead time (us)") = 0.0;
164 zap[
'C'] =
make_field(selector,
"timeslice selector, e.g. JDAQTimesliceL1.") = getROOTClassSelection<JDAQTimesliceTypes_t>();
165 zap[
'O'] =
make_field(option,
"hit pre-processing option.") = JPreprocessor::getOptions();
170 catch(
const exception &error) {
171 FATAL(error.what() << endl);
180 if (selector == JDAQTimesliceL2::Class_Name() ||
181 selector == JDAQTimesliceSN::Class_Name()) {
182 FATAL(
"Option -C <selector> " << selector <<
" not compatible with calibration method." << endl);
185 if (selector == JDAQTimeslice ::Class_Name() ||
186 selector == JDAQTimesliceL1::Class_Name()) {
194 FATAL(
"No trigger parameters from input:" << error.
what() << endl);
197 if ((selector == JDAQTimeslice ::Class_Name() && parameters.writeL1.prescale > 0) ||
198 (selector == JDAQTimesliceL1::Class_Name())) {
200 if (parameters.TMaxLocal_ns < TMax_ns) {
201 FATAL(
"Option -T <TMax_ns> = " << TMax_ns <<
" is larger than in the trigger " << parameters.TMaxLocal_ns << endl);
204 if (background == rndms_t ||
205 background == count_t) {
206 FATAL(
"Option -C <selector> " << selector <<
" incompatible with option -b <background> " << background << endl);
211 if (!multiplicity.is_valid() || multiplicity.getLowerLimit() < 2) {
212 FATAL(
"Invalid option -M <multiplicity> " << multiplicity << endl);
215 if (!totRange_ns.is_valid()) {
216 FATAL(
"Invalid option -t <totRange_ns> " << totRange_ns << endl);
219 if (background == tails_t) {
221 if (!Tail_ns.is_valid()) {
222 FATAL(
"Invalid option -B <Tail_ns> " << Tail_ns << endl);
225 if (Tail_ns.getUpperLimit() > TMax_ns) {
226 FATAL(
"Invalid option -B <Tail_ns> " << Tail_ns <<
"; upper limit larger than option -T <TMax_ns> " << TMax_ns << endl);
244 FATAL(
"Empty detector." << endl);
257 t0.push_back(i * 2 * TMax_ns);
267 const double RTU = (cpu.getIntegralOfChargeProbability(cpu.getNPE(totRange_ns.getLowerLimit()), cpu.getNPE(totRange_ns.getUpperLimit()), NPE)
269 cpu.getIntegralOfChargeProbability(cpu.getNPE(0.0), cpu.getNPE(ToTmax_ns), NPE));
284 weights_hist.GetXaxis()->SetBinLabel(2,
WS_t);
285 weights_hist.GetXaxis()->SetBinLabel(3,
WB_t);
287 const int nx = combinatorics.getNumberOfPairs();
288 const double xmin = -0.5;
289 const double xmax = nx - 0.5;
291 const double ymin = -floor(TMax_ns) + 0.5;
292 const double ymax = +floor(TMax_ns) - 0.5;
293 const int ny = (int) ((ymax - ymin) / 1.0);
296 for (JDetector::iterator module =
detector.begin(); module !=
detector.end(); ++module) {
298 const JModuleAddress& address = router.getAddress(module->getID());
300 NOTICE(
"Booking histograms for module " << module->getID() << endl);
316 const double deadTime_ns = deadTime_us * 1e3;
322 for ( ;
in.hasNext() && counter != inputFile.getLimit(); ++counter) {
324 STATUS(
"event: " << setw(10) << counter <<
'\r');
DEBUG(endl);
328 if (background == rates_t) {
330 const Long64_t index = summaryFile.find(*timeslice);
336 summaryRouter.update(summaryFile.getEntry(index));
338 if (timeslice->
getFrameIndex() != summaryRouter.getFrameIndex()) {
340 ERROR(
"Frame indices do not match "
341 <<
"[counter=" << counter <<
"]"
343 <<
"[summaryslice=" << summaryRouter.getFrameIndex() <<
"]" << endl);
348 FATAL(
"ROOT TTrees not aligned; Run number " << timeslice->
getRunNumber() << endl);
353 for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
355 if (router.hasModule(frame->getModuleID())) {
357 const JModule& module = router.getModule(frame->getModuleID());
368 if (background == count_t) {
376 }
else if (background == tails_t) {
380 }
else if (background == rndms_t) {
384 }
else if (background == rates_t) {
386 if (!summaryRouter.hasSummaryFrame(frame->getModuleID())) {
387 FATAL(
"Summary frame not found " << timeslice->
getFrameIndex() <<
":" << frame->getModuleID() << endl);
390 const JDAQSummaryFrame& summary_frame = summaryRouter.getSummaryFrame(frame->getModuleID());
395 rate_Hz[i] = RTU * summary_frame.
getRate(i);
413 const JModuleAddress& address = router.getAddress(frame->getModuleID());
415 combinatorics.configure(module.size());
419 TH2D* h2s = zmap[address.
first].h2s;
420 TH1D* h1b = zmap[address.
first].h1b;
421 TH1D* h1L = zmap[address.
first].h1L;
427 for (
size_t i = 0; i < combinatorics.getNumberOfPairs(); ++i) {
429 const int pmt1 = combinatorics.getPair(i).
first;
430 const int pmt2 = combinatorics.getPair(i).second;
432 if (!veto[pmt1] && rateRange_Hz(rate_Hz[pmt1]) &&
433 !veto[pmt2] && rateRange_Hz(rate_Hz[pmt2]) ) {
443 JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*frame, module);
445 buffer.preprocess(option, match);
447 for (JSuperFrame2D_t::iterator i = buffer.begin(); i != buffer.end(); ++i) {
449 const int pmt = i->getPMTAddress();
451 if ( veto[pmt] || !rateRange_Hz(rate_Hz[pmt]) ) {
456 JSuperFrame1D_t& data = JSuperFrame1D_t::multiplex(buffer);
460 DEBUG(
"Number of hits " << timeslice->
getFrameIndex() <<
":" << frame->getModuleID() <<
' ' << frame->size() <<
' ' << data.size() << endl);
469 double t1 = -numeric_limits<double>::max();
475 while (++q != data.end() && q->getT() - p->getT() <= TMax_ns) {}
479 if (multiplicity(N)) {
481 if (p->getT() > t1 + deadTime_ns) {
486 if (totRange_ns( __p->getToT()) && totRange_ns(__q->getToT())) {
487 h2s->Fill((
double) combinatorics.getIndex(__p->getPMT(),__q->getPMT()),
488 JCombinatorics::getSign(__p->getPMT(),__q->getPMT()) * (__q->getT() - __p->getT()));
503 if (background == rndms_t) {
506 *i = hit_type(i->getPMT(),
JHit(i->getT() + t0[i->getPMT()], i->getToT()));
509 sort(data.begin(), data.end());
515 while (++q != data.end() && q->getT() - p->getT() <= TMax_ns) {}
519 if (multiplicity(N)) {
524 if (totRange_ns(__p->getToT()) && totRange_ns(__q->getToT())) {
525 h1b->Fill((
double) combinatorics.getIndex(p->getPMT(),q->getPMT()), 1.0);
534 }
else if (background == rates_t ||
535 background == count_t) {
541 const Double_t
R1 = rate_Hz[i];
543 if (!veto[i] && rateRange_Hz(R1)) {
551 const Double_t R1 = rate_Hz[i];
552 const Double_t R2 = rate_Hz[
j];
554 if (!veto[i] && rateRange_Hz(R1) &&
555 !veto[
j] && rateRange_Hz(R2)) {
558 const double ED = (Rs - rate_Hz[i] - rate_Hz[
j]) * 2 * TMax_ns * 1e-9;
559 const double E1 = rate_Hz[i] * 2 * TMax_ns * 1e-9;
560 const double E2 = rate_Hz[
j] * 2 * TMax_ns * 1e-9;
564 multiplicity.getLowerLimit(),
565 multiplicity.getUpperLimit()) *
getFrameTime() / (2*TMax_ns);
567 h1b->Fill((
double) combinatorics.getIndex(i,
j),
N);
577 if (background == tails_t ) {
581 TH2D* h2s = hist->h2s;
582 TH1D* h1b = hist->h1b;
590 int k = combinatorics.getIndex(i,
j);
592 for (
int l = 1; l <= h2s->GetYaxis()->GetNbins(); ++l) {
594 const Double_t dt = h2s->GetYaxis()->GetBinCenter(l) ;
596 if (Tail_ns(fabs(dt))) {
597 Y += h2s->GetBinContent(k+1,l);
598 W += h2s->GetBinError(k+1,l) * h2s->GetBinError(k+1,l);
603 h1b->SetBinContent(k+1, Y / N * (2.0*TMax_ns) / ((ymax - ymin)/ny) );
604 h1b->SetBinError (k+1, sqrt(W/N) * (2.0*TMax_ns) / ((ymax - ymin)/ny) );
615 weights_hist.Fill(
WS_t, (ymax - ymin)/ny);
616 weights_hist.Fill(
WB_t, 2.0*TMax_ns);
623 weights_hist.Write() ;
*fatal Wrong number of arguments esac JCookie sh JRuns D $DETECTOR d sort n k
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.
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.
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
*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.
Long64_t counter_type
Type definition for counter.
Auxiliary class for multiplexing object iterators.
int getRunNumber() const
Get run number.
int getFrameIndex() const
Get frame index.
esac $JPP_DIR examples JDetector JTransitTime o $OUTPUT_FILE n N $NPE T $TTS_NS d $DEBUG for HISTOGRAM in tts tt2 pmt
1-dimensional frame with time calibrated data from one optical module.
int first
index of module in detector data structure
Auxiliary class for defining the range of iterations of objects.
static const char *const WS_t
Named bin for time residual bin width.
Auxiliary class to sort pairs of PMT addresses within optical module.
Reduced data structure for L0 hit.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
static const char *const _1B
Name extension for 1D background.
double getFrameTime()
Get frame time duration.
Data storage class for rate measurements of all PMTs in one module.
Address of module in detector data structure.
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
Router for fast addressing of summary data in JDAQSummaryslice data structure as a function of the op...
PMT analogue signal processor.
static const char *const weights_hist_t
Histogram naming.
static const char *const _1L
Name extension for 1D live time.
bool getPMTStatus(const JStatus &status)
Test status of PMT.
General purpose class for object reading from a list of file names.
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.
const JLimit & getLimit() const
Get limit.
double coincidenceP(double E1, double E2, double ED, int M_min, int M_max)
Coincidence probability of two PMTs.
virtual const char * what() const
Get error message.
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 usage $script[input file[working directory[option]]] nWhere option can be N
JTriggerParameters getTriggerParameters(const JMultipleFileScanner_t &file_list)
Get trigger parameters.
static const char *const _2S
Name extension for 2D counts.
#define DEBUG(A)
Message macros.
bool putObject(TDirectory *dir, const T &object)
Write object to ROOT directory.