67 JLimit_t& numberOfEvents = inputFile.getLimit();
72 JToTRange_t totRange_ns;
77 int preTriggerThreshold;
83 JParser<> zap(
"Example application to study supernova detection background");
86 zap[
'o'] =
make_field(outputFile) =
"kexing2D.root";
87 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
92 zap[
'C'] =
make_field(selector) = getROOTClassSelection<JDAQTimesliceTypes_t>();
94 zap[
'P'] =
make_field(preTriggerThreshold) = 4;
99 catch(
const exception &error) {
100 FATAL(error.what() << endl);
107 load(detectorFile, detector);
125 pts->configure(inputFile);
130 int fEnd = pts->rbegin()->getFrameIndex();
131 int fStart = pts->begin( )->getFrameIndex();
135 if (fEnd > inputFile.getUpperLimit()) {
136 fEnd = fStart + inputFile.getUpperLimit();
139 int fLength = 1 + fEnd - fStart;
141 NOTICE(
"begin | end | length = " << fStart <<
" | " << fEnd <<
" | " << fLength << endl);
145 FATAL(
"FATAL: inconsistent TTree indexing" << endl);
156 const int nx = fLength;
157 const double xmin = fStart;
158 const double xmax = fEnd + 1;
161 const double ymin = -0.5;
162 const double ymax = ymin + ny;
167 JManager2D_t MT(
new TH2D(
mul_p , NULL, nx, xmin, xmax, ny, ymin, ymax));
168 JManager1D_t ST(
new TH1D(
status_p, NULL, nx, xmin, xmax));
176 TH1D* h_vtr =
new TH1D(
"VetoTimeRange",
"VetoTimeRange", 10000, 0, 10000);
182 for (; evIn.hasNext(); ) {
184 STATUS(
"event: " << setw(10) << evIn.getCounter() <<
'\r');
DEBUG(endl);
188 if (!runNumber) { runNumber =
event->getRunNumber(); }
190 JVeto vp(*event, hitRouter);
192 triggeredEvents[
event->getFrameIndex()].push_back(vp);
194 h_vtr->Fill(vp.getLength());
198 STATUS(triggeredEvents.size() <<
" JDAQEvents loaded in veto buffer." << endl);
200 TParameter<int> RUNNR(
"RUNNR", runNumber);
209 for ( ; pts->hasNext() && counter != inputFile.getLimit(); ++counter) {
211 STATUS(
"timeslice: " << setw(10) << counter <<
'\r');
DEBUG(endl);
223 if (triggeredEvents.count(fIndex)) {
224 veto = triggeredEvents.at(fIndex);
237 double fractionActivePMTs = 0;
239 int nDOMs = timeslice->size();
241 for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) {
243 int moduleID = frame->getModuleID();
245 fractionActivePMTs += ((double) frame->countActiveChannels());
247 JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*frame,
248 moduleRouter.getModule(moduleID));
251 buffer.preprocess(JPreprocessor::join_t, match);
253 JSuperFrame1D_t&
data = JSuperFrame1D_t::multiplex(buffer);
259 TH1D* h2dt =
new TH1D(
"H2DT",
"H2DT", 100, -TMax_ns, +TMax_ns);
265 while (++q != data.end() && q->getT() - p->getT() <= TMax_ns) {}
271 MT[
"RAW"]->Fill(fIndex, m);
275 if (selector !=
"JDAQTimesliceSN" && timeDifferences && m > 1) {
279 double dt = JCombinatorics::getSign(__p->getPMT(), __q->getPMT()) * (__q->getT() - __p->getT());
280 h2dt->Fill(dt, 1.0/W);
291 if (h2dt->GetEntries() > 0) {
293 TF1
f(
"f",
"[0]*exp(-0.5*(x-[1])*(x-[1])/([2]*[2]))/(TMath::Sqrt(2*TMath::Pi())*[2]) + [3]");
295 f.SetParameter(0, h2dt->GetMaximum());
296 f.SetParameter(1, h2dt->GetMean());
297 f.SetParameter(2, h2dt->GetRMS() * 0.25);
298 f.SetParameter(3, h2dt->GetMinimum());
300 h2dt->Fit(&
f,
"Q",
"same");
302 double nb = h2dt->GetNbinsX();
303 double bg_v =
f.GetParameter(3) * nb;
304 double sg = h2dt->GetSumOfWeights() - bg_v;
308 MT[
"FIT"]->Fill(fIndex, 2, sg);
320 ST[
"PMT"]->Fill(fIndex, fractionActivePMTs);
324 JDataSN preTrigger(TMax_ns, preTriggerThreshold);
326 preTrigger(timeslice, moduleRouter, totSelector_ns);
336 JRange_t
A = JRange_t(4,31);
347 MT[
"TA1"]->Fill(fIndex, *p);
353 MT[
"TAV"]->Fill(fIndex, *p);
362 if (outputFile !=
"") {
364 TFile out(outputFile.c_str(),
"RECREATE");
Utility class to parse command line options.
JDAQUTCExtended getTimesliceStart() const
Get start of timeslice.
Auxiliary class to define a veto time window on a set of optical modules.
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 * mul_p
static const char * status_p
Auxiliary class to select ROOT class based on class name.
SN filter based on veto window.
Router for direct addressing of module data in detector data structure.
Auxiliary interface for direct access of elements in ROOT TChain.
o $QUALITY_ROOT d $DEBUG!CHECK_EXIT_CODE JPlot1D f
Long64_t counter_type
Type definition for counter.
Auxiliary class for a type holder.
Template definition for direct access of elements in ROOT TChain.
long long int factorial(const long long int n)
Determine factorial.
Simple wrapper around JModuleRouter class for direct addressing of PMT data in detector data structur...
int getFrameIndex() const
Get frame index.
1-dimensional frame with time calibrated data from one optical module.
Auxiliary class for defining the range of iterations of objects.
Type definition of range.
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys...
Reduced data structure for L0 hit.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Auxiliary class to apply the supernova trigger to SN data.
SN filter based on multiplicity selection optional suppression of multi-module coincidences WARNING: ...
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
Auxiliary class to select JTreeScanner based on ROOT class name.
Auxiliary class to build the supernova trigger dataset.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
2-dimensional frame with time calibrated data from one optical module.
Auxiliary class to select DAQ hits based on time-over-treshold value.
do set_variable DETECTOR_TXT $WORKDIR detector
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
source $JPP_DIR setenv csh $JPP_DIR &dev null eval JShellParser o a A
JTriggerCounter_t next()
Increment trigger counter.
#define DEBUG(A)
Message macros.
Auxiliary class to manage a set of vetoes.