63{
   64 
   67 
   69  JLimit_t&              numberOfEvents = inputFile.getLimit();
 
   71  string                 detectorFile;
   72  double                 TMax_ns;
   73  double                 TVeto_ns;
   74  JToTRange_t            totRange_ns;
   77  bool                   timeDifferences;
   79  int                    preTriggerThreshold;
   80 
   81  
   82 
   83  try { 
   84 
   85    JParser<> zap(
"Example application to study supernova detection background");
 
   86    
   96    zap[
'P'] = 
make_field(preTriggerThreshold) = 4;
 
   98    
   99    zap(argc, argv);
  100  }
  101  catch(const exception &error) {
  102    FATAL(error.what() << endl);
 
  103  }
  104 
  105 
  107 
  108  try {
  110  }
  113  }
  114 
  115  
  116  
  117  
  118 
  119  
  120 
  122 
  124 
  126 
  127  pts->configure(inputFile);
  128 
  129  
  130 
  131  
  132  int    fEnd   = pts->rbegin()->getFrameIndex();
  133  int    fStart = pts->begin( )->getFrameIndex(); 
  134 
  135 
  136  
  137  if (fEnd > inputFile.getUpperLimit()) {
  138    fEnd = fStart + inputFile.getUpperLimit();
  139  }
  140 
  141  int fLength = 1 + fEnd - fStart;
  142 
  143  NOTICE(
"begin | end | length = " << fStart << 
" | " << fEnd << 
" | " << fLength << endl);
 
  144 
  145 
  146  if (fStart > fEnd) {
  147    FATAL(
"FATAL: inconsistent TTree indexing" << endl);
 
  148  }  
  149 
  150  
  151 
  153  
  155 
  156  
  157 
  158  const int    nx   = fLength;
  159  const double xmin = fStart;
 
  160  const double xmax = fEnd + 1;
 
  161 
  162  const int    ny   = NUMBER_OF_PMTS + 1; 
  163  const double ymin = -0.5;
  164  const double ymax = ymin + ny;
  165 
  166  typedef JManager <string, TH2D>  JManager2D_t;
  167  typedef JManager <string, TH1D>  JManager1D_t;
  168 
  169  JManager2D_t MT(
new TH2D(
mul_p   , NULL, nx, xmin, xmax, ny, ymin, ymax));
 
  170  JManager1D_t ST(
new TH1D(
status_p, NULL, nx, xmin, xmax));
 
  171 
  172  
  173  
  174  
  175 
  176  int runNumber = 0;
  177 
  178  TH1D* h_vtr = new TH1D("VetoTimeRange","VetoTimeRange", 10000, 0, 10000);
  179 
  181 
  183 
  184  for (; evIn.hasNext(); ) {
  185 
  186    STATUS(
"event: " << setw(10) << evIn.getCounter() << 
'\r'); 
DEBUG(endl);
 
  187    
  189 
  190    if (!runNumber) { runNumber = event->getRunNumber(); }
  191 
  192    JVeto vp(*event, hitRouter);
 
  193 
  194    triggeredEvents[event->getFrameIndex()].push_back(vp);
  195 
  196    h_vtr->Fill(vp.getLength());
  197 
  198  } 
  199 
  200  STATUS(triggeredEvents.size() << 
" JDAQEvents loaded in veto buffer." << endl);
 
  201 
  202  TParameter<int> RUNNR("RUNNR", runNumber);
  203  
  204 
  205  
  206  
  207  
  208 
  210 
  211  for ( ; pts->hasNext() && counter != inputFile.getLimit(); ++counter) {
  212 
  213    STATUS(
"timeslice: " << setw(10) << counter << 
'\r'); 
DEBUG(endl);
 
  214 
  216 
  218 
  219    if (counter == 0) {
  221    }
  222        
  224    
  225    if (triggeredEvents.count(fIndex)) { 
  226      veto = triggeredEvents.at(fIndex);
  227    }
  228 
  229    
  230 
  232      
  234 
  236 
  238 
  239    double fractionActivePMTs = 0;
  240    
  241    int nDOMs = timeslice->size();
  242 
  243    for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
  244 
  245        int moduleID = frame->getModuleID();
  246 
  247        fractionActivePMTs += ((double) frame->countActiveChannels());
  248 
  249        JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*frame,
  250                                                               moduleRouter.getModule(moduleID));
  251        
  252 
  254 
  255        JSuperFrame1D_t& 
data = JSuperFrame1D_t::multiplex(buffer);
 
  256 
  257        
  258 
  259        
  260 
  261        TH1D* h2dt = new TH1D("H2DT", "H2DT", 100, -TMax_ns, +TMax_ns); 
  262        
  263        for (vector<JHitR0>::const_iterator p = 
data.begin(); p != 
data.end(); ) {
 
  264 
  265          vector<JHitR0>::const_iterator q = p;
  266        
  267          while (++q != 
data.end() && q->getT() - p->getT() <= TMax_ns) {}
 
  268            
  270 
  271          
  272 
  273          MT["RAW"]->Fill(fIndex, m);
  274 
  275          
  276            
  277          if (selector != "JDAQTimesliceSN" && timeDifferences && m > 1) { 
  279            for (vector<JHitR0>::const_iterator __p = p; __p != q; ++__p) {
  280              for (vector<JHitR0>::const_iterator __q = __p; ++__q != q; ) {
  282                h2dt->Fill(dt, 1.0/W);
  283              }
  284            }
  285          }
  286          
  287          
  288          
  289          p = q;
  290            
  291        } 
  292        
  293        if (h2dt->GetEntries() > 0) {
  294          
  295          TF1 f("f", "[0]*exp(-0.5*(x-[1])*(x-[1])/([2]*[2]))/(TMath::Sqrt(2*TMath::Pi())*[2]) + [3]");
  296 
  297          f.SetParameter(0, h2dt->GetMaximum());
  298          f.SetParameter(1, h2dt->GetMean());
  299          f.SetParameter(2, h2dt->GetRMS() * 0.25);
  300          f.SetParameter(3, h2dt->GetMinimum());
  301          
  302          h2dt->Fit(&f, "Q", "same");
  303 
  304          double nb = h2dt->GetNbinsX();
  305          double bg_v = f.GetParameter(3) * nb;
  306          double sg = h2dt->GetSumOfWeights() - bg_v;
  307          
  308          
  309          
  310          MT["FIT"]->Fill(fIndex, 2, sg);
  311          
  312        }
  313 
  314        delete h2dt;
  315 
  316    }
  317 
  318    
  319 
  320    fractionActivePMTs /= (NUMBER_OF_PMTS * nDOMs);
  321 
  322    ST["PMT"]->Fill(fIndex, fractionActivePMTs);
  323 
  324    
  325 
  326    JDataSN preTrigger(TMax_ns, preTriggerThreshold);
 
  327 
  328    preTrigger(timeslice, moduleRouter, totSelector_ns);
  329 
  331 
  333 
  334    
  335    
  336    
  337 
  339 
  340    
  342 
  343    
  345    
  347 
  348    for (vector<double>::const_iterator p = m_a1.begin(); p != m_a1.end(); p++) {
  349      MT["TA1"]->Fill(fIndex, *p);
  350    }
  351 
  353 
  354    for (vector<double>::const_iterator p = m_av.begin(); p != m_av.end(); p++) {
  355      MT["TAV"]->Fill(fIndex, *p);
  356    }
  357    
  358  }
  359 
  360  
  361  
  362  
  363 
  365 
  367 
  369 
  370    RUNNR.Write();
  371    
  372 
  373    h_vtr->Write();
  374        
  375    MT.Write(out);
  376    ST.Write(out);
  377 
  378    out.Close();
  379 
  380  }
  381 
  382}
static const char * status_p
static const char * mul_p
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Simple wrapper around JModuleRouter class for direct addressing of PMT data in detector data structur...
Router for direct addressing of module data in detector data structure.
Utility class to parse command line options.
Auxiliary class to build the supernova trigger dataset.
SN filter based on veto window.
SN filter based on multiplicity selection optional suppression of multi-module coincidences WARNING: ...
Auxiliary class to apply the supernova trigger to SN data.
Auxiliary class to manage a set of vetoes.
Auxiliary class to define a veto time window on a set of optical modules.
Auxiliary interface for direct access of elements in ROOT TChain.
Template definition for direct access of elements in ROOT TChain.
Reduced data structure for L0 hit.
1-dimensional frame with time calibrated data from one optical module.
2-dimensional frame with time calibrated data from one optical module.
JDAQUTCExtended getTimesliceStart() const
Get start of timeslice.
int getFrameIndex() const
Get frame index.
JTriggerCounter_t next()
Increment trigger counter.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
long long int factorial(const long long int n)
Determine factorial.
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
std::set< JROOTClassSelector > getROOTClassSelection(const bool option=false)
Get ROOT class selection.
Long64_t counter_type
Type definition for counter.
Type definition of range.
Auxiliary class for a type holder.
Auxiliary class to select ROOT class based on class name.
Auxiliary class to select JTreeScanner based on ROOT class name.
Auxiliary class for defining the range of iterations of objects.
static counter_type max()
Get maximum counter value.
Auxiliary class to select DAQ hits based on time-over-treshold value.
@ join_t
join consecutive hits according match criterion