197   using namespace KM3NETDAQ;
 
  216     JParser<> zap(
"Auxiliary program to determine PMT parameters from K40 data.");
 
  218     zap[
'f'] = 
make_field(inputFile,      
"input file.");
 
  220     zap[
'n'] = 
make_field(numberOfEvents)                                                = JLimit::max();
 
  221     zap[
'a'] = 
make_field(detectorFile,   
"detector file.");
 
  222     zap[
'T'] = 
make_field(TMax_ns,        
"time window [ns].")                           = 20.0;
 
  225     zap[
'b'] = 
make_field(background,     
"background estimation method.")               = rates_t, count_t, tails_t, rndms_t;
 
  228     zap[
'D'] = 
make_field(deadTime_us,    
"L1 dead time (us)")                           = 0.0;
 
  229     zap[
'C'] = 
make_field(selector,       
"timeslice selector, e.g. JDAQTimesliceL1.")   = getROOTClassSelection<JDAQTimesliceTypes_t>();
 
  230     zap[
'O'] = 
make_field(option,         
"hit pre-processing option.")                  = JPreprocessor::getOptions();
 
  235   catch(
const exception &error) {
 
  236     FATAL(error.what() << endl);
 
  245   if (selector == JDAQTimesliceL2::Class_Name() ||
 
  246       selector == JDAQTimesliceSN::Class_Name()) {
 
  247     FATAL(
"Option -C <selector> " << selector << 
" not compatible with calibration method." << endl);
 
  250   if (selector == JDAQTimeslice  ::Class_Name() ||
 
  251       selector == JDAQTimesliceL1::Class_Name()) {
 
  259       FATAL(
"No trigger parameters from input:" << error.
what() << endl);
 
  262     if ((selector == JDAQTimeslice  ::Class_Name() && parameters.writeL1.prescale > 0) ||
 
  263         (selector == JDAQTimesliceL1::Class_Name())) {
 
  265       if (parameters.TMaxLocal_ns < TMax_ns) {
 
  266         FATAL(
"Option -T <TMax_ns> = " << TMax_ns << 
" is larger than in the trigger " << parameters.TMaxLocal_ns << endl);
 
  269       if (background == rndms_t ||
 
  270           background == count_t) {
 
  271         FATAL(
"Option -C <selector> " << selector << 
" incompatible with option -b <background> " << background << endl);
 
  276   if (!multiplicity.is_valid() || multiplicity.getLowerLimit() < 2 || multiplicity.getUpperLimit() > 
NUMBER_OF_PMTS) {
 
  277     FATAL(
"Invalid option -M <multiplicity> " << multiplicity << endl);
 
  280   if (!totRange_ns.is_valid()) {
 
  281     FATAL(
"Invalid option -t <totRange_ns> " << totRange_ns << endl);
 
  284   if (background == tails_t) {
 
  286     if (!Tail_ns.is_valid()) {
 
  287       FATAL(
"Invalid option -B <Tail_ns> " << Tail_ns << endl);
 
  290     if (Tail_ns.getUpperLimit() > TMax_ns) {
 
  291       FATAL(
"Invalid option -B <Tail_ns> " << Tail_ns << 
"; upper limit larger than option -T <TMax_ns> " << TMax_ns << endl);
 
  309     FATAL(
"Empty detector." << endl);
 
  321     t0.push_back(i * 2 * TMax_ns);
 
  331   const double RTU = (cpu.getIntegralOfChargeProbability(cpu.getNPE(totRange_ns.getLowerLimit()), cpu.getNPE(totRange_ns.getUpperLimit()), NPE) 
 
  333                       cpu.getIntegralOfChargeProbability(cpu.getNPE(0.0),                         cpu.getNPE(ToTmax_ns),                   NPE));
 
  342   const Double_t ymin = -floor(TMax_ns) + 0.5;
 
  343   const Double_t ymax = +floor(TMax_ns) - 0.5;
 
  344   const Int_t    ny   = (Int_t) ((ymax - ymin) / 1.0);
 
  346   for (JDetector::iterator module = 
detector.begin(); module != 
detector.end(); ++module) {
 
  348     const JModuleAddress& address = router.getAddress(module->getID());
 
  350     if (!module->empty()) {
 
  352       NOTICE(
"Booking histograms for module " << module->getID() << endl);
 
  365   const double deadTime_ns  =  deadTime_us * 1e3;
 
  374   for (JMultipleFileScanner_t::const_iterator i = inputFile.begin(); i != inputFile.end(); ++i) {
 
  376     STATUS(
"Processing: " << *i << endl);
 
  383     for (
JDAQHeader header; 
in.hasNext() && counter != numberOfEvents; ++counter) {
 
  385       STATUS(
"event: " << setw(10) << counter << 
'\r'); 
DEBUG(endl);
 
  397       if (background == rates_t) {
 
  401         if (timeslice->
getFrameIndex() != summary.getSummaryslice()->getFrameIndex()) {
 
  403           ERROR(
"Frame indices do not match at "  
  404                 << 
"[counter = "      << counter                                    << 
"]"  
  406                 << 
"[summaryslice = " << summary.getSummaryslice()->getFrameIndex() << 
"]" << endl);
 
  412       for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
 
  414         if (router.hasModule(frame->getModuleID())) {
 
  416           const JModule& module = router.getModule(frame->getModuleID());
 
  425           if        (background == count_t) {
 
  431           } 
else if (background == tails_t) {
 
  435           } 
else if (background == rndms_t) {
 
  439           } 
else if (background == rates_t) {
 
  441             if (summary.hasSummaryFrame(frame->getModuleID())) {
 
  443               const JDAQSummaryFrame& sum = summary.getSummaryFrame(frame->getModuleID());
 
  446                 rate_Hz[i] = RTU * sum.
getRate(i);
 
  451               FATAL(
"Summary frame of module " << frame->getModuleID() << 
" not found at frame index " << timeslice->
getFrameIndex() << endl);
 
  463                 !rateRange_Hz(rate_Hz[i])) {
 
  468           const JHistogram&     histogram     = zmap[router.getAddress(frame->getModuleID()).
first];
 
  469           const JCombinatorics& combinatorics = histogram.getCombinatorics();
 
  471           TH2D* h2s = histogram.h2s;
 
  472           TH1D* h1b = histogram.h1b;
 
  473           TH1D* h1L = histogram.h1L;
 
  479           JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*frame, module);
 
  481           buffer.preprocess(option, match);
 
  483           for (JSuperFrame2D_t::iterator i = buffer.begin(); i != buffer.end(); ++i) {
 
  484             if (veto[i->getPMTAddress()]) {
 
  489           JSuperFrame1D_t& data = JSuperFrame1D_t::multiplex(buffer);
 
  491           DEBUG(
"Number of hits " << timeslice->
getFrameIndex() << 
":" << frame->getModuleID() << 
' ' << frame->size() << 
' ' << data.size() << endl);
 
  496           size_t numberOfSignalEvents = 0;
 
  498           double t1 = numeric_limits<double>::lowest();
 
  504             while (++q != data.end() && q->getT() - p->getT() <= TMax_ns) {}
 
  508             if (multiplicity(N)) {
 
  510               numberOfSignalEvents += 1;
 
  512               if (p->getT() > t1 + deadTime_ns) {
 
  517                     if (totRange_ns( __p->getToT()) && totRange_ns(__q->getToT())) {
 
  518                       h2s->Fill((
double) combinatorics.getIndex(__p->getPMT(),__q->getPMT()), 
 
  519                                 JCombinatorics::getSign(__p->getPMT(),__q->getPMT()) * (__q->getT() - __p->getT()));
 
  534           if        (background == rndms_t) {
 
  537               *i = 
hit_type(i->getPMT(), 
JHit(i->getT() + t0[i->getPMT()], i->getToT()));
 
  540             sort(data.begin(), data.end());
 
  542             double t1 = numeric_limits<double>::lowest();
 
  548               while (++q != data.end() && q->getT() - p->getT() <= TMax_ns) {}
 
  552               if (multiplicity(N)) {
 
  554                 if (p->getT() > t1 + deadTime_ns) {
 
  559                       if (totRange_ns(__p->getToT()) && totRange_ns(__q->getToT())) {
 
  560                         h1b->Fill((
double) combinatorics.getIndex(p->getPMT(),q->getPMT()), 1.0);
 
  572           } 
else if (background == rates_t ||
 
  573                      background == count_t) {
 
  586                 if (!veto[i] && !veto[
j]) {
 
  588                   const double R1 = rate_Hz[i];                    
 
  589                   const double R2 = rate_Hz[
j];                    
 
  596                   const double N = 
getP((R1)           * 2 * TMax_ns * 1e-9,
 
  597                                         (R2)           * 2 * TMax_ns * 1e-9,
 
  598                                         (Rs - R1 - R2) * 2 * TMax_ns * 1e-9,
 
  599                                         multiplicity.getLowerLimit(), 
 
  600                                         multiplicity.getUpperLimit()) * 
getFrameTime() / (2*TMax_ns);
 
  602                   h1b->Fill((
double) combinatorics.getIndex(i,j), 
N);
 
  614           for (
size_t i = 0; i < combinatorics.getNumberOfPairs(); ++i) {
 
  616             const int pmt1 = combinatorics.getPair(i).first;
 
  617             const int pmt2 = combinatorics.getPair(i).second;
 
  619             if (!veto[pmt1] && !veto[pmt2]) {
 
  620               h1L->Fill(i, livetime_s);
 
  629   if (background == tails_t ) {
 
  633       if (hist->is_valid()) {
 
  637         TH2D* h2s = hist->h2s;
 
  638         TH1D* h1b = hist->h1b;
 
  648             for (
int l = 1; l <= h2s->GetYaxis()->GetNbins(); ++l) {
 
  650               const Double_t dt = h2s->GetYaxis()->GetBinCenter(l) ;
 
  652               if (Tail_ns(fabs(dt))) { 
 
  653                 Y += h2s->GetBinContent(k+1,l);
 
  654                 W += h2s->GetBinError(k+1,l) * h2s->GetBinError(k+1,l);
 
  659             h1b->SetBinContent(k+1, Y / N     * (2.0*TMax_ns) / ((ymax - ymin)/ny) );
 
  660             h1b->SetBinError  (k+1, sqrt(W/N) * (2.0*TMax_ns) / ((ymax - ymin)/ny) );
 
  674   weights_hist.GetXaxis()->SetBinLabel(2, 
WS_t);                 
 
  675   weights_hist.GetXaxis()->SetBinLabel(3, 
WB_t);                 
 
  678   weights_hist.Fill(
WS_t,         (ymax - ymin)/ny);             
 
  679   weights_hist.Fill(
WB_t,         2.0*TMax_ns);                  
 
Utility class to parse command line options. 
 
then fatal No hydrophone data file $HYDROPHONE_TXT fi sort gr k
 
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. 
 
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
 
*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 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. 
 
then JCookie sh JDataQuality D $DETECTOR_ID R $RUNS[*] o $QUALITY_TXT d $DEBUG!fi fi JDataQuality f $QUALITY_TXT Q livetime_s
 
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. 
 
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. 
 
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. 
 
void load(const std::string &file_name, JDetector &detector)
Load detector from input file. 
 
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. 
 
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
 
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. 
 
#define DEBUG(A)
Message macros.