1 #ifndef __RUNANALYZER__
2 #define __RUNANALYZER__
16 using namespace KM3NETDAQ ;
59 numberOfTimeslices (nTimeslices),
60 numberOfSummaryslices (nSummaryslices),
61 numberOfEvents (nEvents),
62 pmt_analysis (pmtanalysis)
68 cerr <<
"FATAL ERROR. Could not open detector file '" << detectorFile <<
"'." << endl;
90 while (scanner.hasNext()) {
94 histograms.h_trigger.h_Snapshot_hits -> Fill((Double_t) event.size<
JDAQSnapshotHit > ());
95 histograms.h_trigger.h_Triggered_hits -> Fill((Double_t) event.size<
JDAQTriggeredHit> ());
96 histograms.h_trigger.h_Number_of_overlays -> Fill(event.getOverlays());
100 if (event.hasTriggerBit(
i)) {
102 histograms.h_trigger.h_Trigger_bit_event -> Fill((Double_t)
i);
108 if (router->hasModule(hit->getModuleID())) {
110 const JModule& module = router->getModule (hit->getModuleID());
112 histograms.h_trigger.h_pmt_distribution_triggered_hits->Fill(hit->getPMT());
113 histograms.h_trigger.h_tot_distribution_triggered_hits->Fill(hit->getToT());
118 histograms.h_trigger.h_Triggered_hits_per_module -> Fill(String , Floor);
122 if (hit -> hasTriggerBit(
i)) {
124 histograms.h_trigger.h_Trigger_bit_hit->Fill((Double_t)
i);
128 FATAL(
"JModuleRouter trying to access non existing identifier: "<< hit->getModuleID());
134 if (router->hasModule(hit->getModuleID())) {
136 const JModule& module = router->getModule (hit->getModuleID());
140 int pmt = hit-> getPMT();
142 if(pmt_analysis ==
true){
144 (*histograms.h_trigger.m_Snapshot_hits_per_pmt)[
MAKE_STRING(
"Detector/DU" +
to_string(String))] -> Fill(pmt, Floor);
148 histograms.h_trigger.h_pmt_distribution_snapshot_hits -> Fill(hit->getPMT());
149 histograms.h_trigger.h_tot_distribution_snapshot_hits -> Fill(hit->getToT());
150 histograms.h_trigger.h_Snapshot_hits_per_module -> Fill(String, Floor);
154 FATAL(
"JModuleRouter trying to access non existing identifier: "<< hit->getModuleID());
171 while (scanner.hasNext()){
175 for (JDAQSummaryslice::const_iterator frame = slice.begin() ; frame != slice.end() ; ++ frame) {
177 if (router->hasModule(frame->getModuleID())) {
179 const JModule& module = router->getModule (frame->getModuleID());
191 histograms.h_summary.h_hrv_per_dom->Fill(
string , floor);
195 histograms.h_summary.h_daq_status_per_dom->Fill(
string , floor);
198 histograms.h_summary.h_fifo_per_dom->Fill(
string , floor , nFIFOcount);
200 if(pmt_analysis ==
true){
208 rate += frame->getRate(
i);
210 h2->Fill(
i , frame->getRate(
i) * 1e-3);
212 PMT_rate_quantiles[
string][floor-1][
i].put(frame->getRate(
i)*1e-3);
216 DOM_rate_quantiles[
string].resize(modulesPerString);
218 DOM_rate_quantiles[
string][floor-1].put(rate * 1e-3);
225 rate += frame->getRate(
i);
226 histograms.h_summary.h_pmt_rate_distribution->Fill(frame->getRate(
i)*1e-3);
229 histograms.h_summary.h_dom_rate_distribution->Fill(rate*1e-3);
231 DOM_rate_quantiles[
string].resize(modulesPerString);
233 DOM_rate_quantiles[
string][floor-1].put(rate * 1e-3);
238 FATAL(
"JModuleRouter trying to access non existing identifier: "<< frame->getModuleID());
246 for (
int j=1 ;
j < modulesPerString + 1 ;
j++) {
248 if (
i->second[
j-1].getCount() > 0) histograms.h_summary.h_rate_summary->Fill(
i->first,
j,
i->second[
j-1].getMean());
253 if(pmt_analysis ==
true){
257 for (
int j=0 ;
j < modulesPerString ;
j++){
263 (*histograms.h_summary.m_mean_summary_rate) [
MAKE_STRING(
"Detector/DU" +
to_string(
i->first))]->Fill(
k,
j+1,
i->second[
j][
k].getMean());
264 (*histograms.h_summary.m_mean_summary_rate_distribution)[
MAKE_STRING(
"Detector/DU" +
to_string(
i->first))]->Fill(
i->second[
j][
k].getMean());
285 double inverseFrameTimeSec = 1. / (1.0e-9 *
getFrameTime());
287 while (scanner.hasNext()){
289 T slice = *(scanner.next());
291 for(
auto & frame : slice) {
292 if (router->hasModule(frame.getModuleID())) {
294 const JModule& module = router->getModule (frame.getModuleID());
295 double rate = frame.numberOfHits * inverseFrameTimeSec;
299 DOM_rate_quantiles[
string][floor].put(rate);
303 if(pmt_analysis ==
true){
309 h2 -> Fill(hit->getPMT() , hit->getToT()) ;
311 pmt_hit_count[hit->getPMT()]++;
317 (*histograms.h_timeslice.m_pmt_rate_distributions[ts_type])[
MAKE_STRING(
"Detector/DU" +
to_string(
string) +
"/F" +
to_string(floor))] -> Fill(pmt , 1e-3 * pmt_hit_count[pmt] * inverseFrameTimeSec);
324 FATAL(
"JModuleRouter trying to access non existing identifier: "<< frame.getModuleID());
334 if (
j->second.getCount() > 0) histograms.h_timeslice.h_dom_mean_rates[ts_type] -> Fill (
i->first ,
j->first ,
j->second.getMean() ) ;
348 if (scanner.hasNext()) {
349 histograms.initialize_summary_histograms();
351 iterateSummarysliceTree(scanner);
365 if(scanner.hasNext()) {
367 histograms.initialize_timeslice_histograms <
T>();
369 iterateTimesliceTree(scanner);
383 if(scanner.hasNext()) {
385 histograms.initialize_trigger_histograms();
387 iterateEventTree(scanner);
JLimit_t numberOfSummaryslices
JRA_Histograms histograms
RunAnalyzer(string file, string detectorFile, JLimit_t nTimeslices, JLimit_t nSummaryslices, JLimit_t nEvents, bool pmtanalysis)
Constructor.
then fatal No hydrophone data file $HYDROPHONE_TXT fi sort gr k
void iterateEventTree(JTreeScanner< JDAQEvent > &scanner)
ROOT TTree parameter settings of various packages.
static const unsigned int NUMBER_OF_TRIGGER_BITS
Number of trigger bits.
void iterateSummarysliceTree(JTreeScanner< JDAQSummaryslice > &scanner)
int countFIFOStatus() const
Count FIFO status.
JLimit_t numberOfTimeslices
int getFloor() const
Get floor number.
Data structure for a composite optical module.
then usage $script[< detector identifier >< run range >]< QA/QCfile > nExample script to produce data quality plots nWhen a detector identifier and run range are data are downloaded from the database nand subsequently stored in the given QA QC file
Router for direct addressing of module data in detector data structure.
then set_variable singlesRate set_variable doublesRate set_variable numberOfSlices echo Generating random background echo Singles rate
Dynamic ROOT object management.
void iterateTimesliceTree(JTreeScanner< T > &scanner)
Template definition for direct access of elements in ROOT TChain.
#define MAKE_STRING(A)
Make string.
Auxiliary class for defining the range of iterations of objects.
~RunAnalyzer()
Destructor.
Class dedicated to the analysis of KM3NeT runs.
double getFrameTime()
Get frame time duration.
JRA_Histograms getHistograms()
do set_variable OUTPUT_DIRECTORY $WORKDIR T
static const JStringCounter getNumberOfStrings
Function object to count unique strings.
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Direct access to module in detector data structure.
int getString() const
Get string number.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
int countHighRateVeto() const
Count high-rate veto status.
General purpose string class.
std::string to_string(const T &value)
Convert value to string.
int getCount(const T &hit)
Get hit count.
Indexing of data type in type list.
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
bool testDAQStatus() const
Test DAQ status of packets.
int getNumberOfModules(const JDetector &detector)
Get number of modules.
RunAnalyzer()
Default constructor.