1 #ifndef __JRUNANALYZER__
2 #define __JRUNANALYZER__
16 using namespace KM3NETDAQ ;
58 numberOfTimeslices (nTimeslices),
59 numberOfSummaryslices (nSummaryslices),
60 numberOfEvents (nEvents),
61 pmt_analysis (pmtanalysis)
67 cerr <<
"FATAL ERROR. Could not open detector file '" << detectorFile <<
"'." << endl;
89 while (scanner.hasNext()) {
93 histograms.h_trigger.h_Snapshot_hits -> Fill((Double_t) event.size<
JDAQSnapshotHit > ());
94 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);
106 int counter_3dmuon = 0;
110 int trigger_mask =
event.getTriggerMask(*hit);
112 if(trigger_mask == 16 || trigger_mask == 18 ||
113 trigger_mask == 20 || trigger_mask == 22 || trigger_mask == 2.147e+09) counter_3dmuon++;
115 if (router->hasModule(hit->getModuleID())) {
117 const JModule& module = router->getModule (hit->getModuleID());
119 histograms.h_trigger.h_pmt_distribution_triggered_hits->Fill(hit->getPMT());
120 histograms.h_trigger.h_tot_distribution_triggered_hits->Fill(hit->getToT());
125 histograms.h_trigger.h_Triggered_hits_per_module -> Fill(String , Floor);
127 if(trigger_mask == 16 || trigger_mask == 18 ||
128 trigger_mask == 20 || trigger_mask == 22 || trigger_mask == 2.147e+09){
130 histograms.h_trigger.h_Triggered_hits_3dmuon_per_module -> Fill(String , Floor);
135 if (hit -> hasTriggerBit(i)) {
137 histograms.h_trigger.h_Trigger_bit_hit->Fill((Double_t) i);
141 FATAL(
"JModuleRouter trying to access non existing identifier: "<< hit->getModuleID());
145 if(counter_3dmuon != 0) histograms.h_trigger.h_Triggered_hits_3dmuon->Fill(counter_3dmuon);
149 if (router->hasModule(hit->getModuleID())) {
151 const JModule& module = router->getModule (hit->getModuleID());
155 int pmt = hit-> getPMT();
157 if(pmt_analysis ==
true){
159 (*histograms.h_trigger.m_Snapshot_hits_per_pmt)[
MAKE_STRING(
"Detector/DU" +
to_string(String))] -> Fill(pmt, Floor);
163 histograms.h_trigger.h_pmt_distribution_snapshot_hits -> Fill(hit->getPMT());
164 histograms.h_trigger.h_tot_distribution_snapshot_hits -> Fill(hit->getToT());
165 histograms.h_trigger.h_Snapshot_hits_per_module -> Fill(String, Floor);
169 FATAL(
"JModuleRouter trying to access non existing identifier: "<< hit->getModuleID());
186 while (scanner.hasNext()){
190 for (JDAQSummaryslice::const_iterator frame = slice.begin() ; frame != slice.end() ; ++ frame) {
192 if (router->hasModule(frame->getModuleID())) {
194 const JModule& module = router->getModule (frame->getModuleID());
206 histograms.h_summary.h_hrv_per_dom->Fill(
string , floor, nHRVcount);
210 histograms.h_summary.h_daq_status_per_dom->Fill(
string , floor);
213 histograms.h_summary.h_fifo_per_dom->Fill(
string , floor , nFIFOcount);
215 if(pmt_analysis ==
true){
223 rate += frame->getRate(i);
225 h2->Fill(i , frame->getRate(i) * 1e-3);
227 PMT_rate_quantiles[string][floor-1][i].put(frame->getRate(i)*1e-3);
231 DOM_rate_quantiles[string].resize(modulesPerString);
233 DOM_rate_quantiles[string][floor-1].put(rate * 1e-3);
240 rate += frame->getRate(i);
241 histograms.h_summary.h_pmt_rate_distribution->Fill(frame->getRate(i)*1e-3);
244 histograms.h_summary.h_dom_rate_distribution->Fill(rate*1e-3);
246 DOM_rate_quantiles[string].resize(modulesPerString);
248 DOM_rate_quantiles[string][floor-1].put(rate * 1e-3);
253 FATAL(
"JModuleRouter trying to access non existing identifier: "<< frame->getModuleID());
259 for (
std::map<
int ,
vector<JQuantile> >::const_iterator i = DOM_rate_quantiles.begin() ; i!= DOM_rate_quantiles.end() ; ++i) {
261 for (
int j=1 ;
j < modulesPerString + 1 ;
j++) {
263 if (i->second[
j-1].getCount() > 0) histograms.h_summary.h_rate_summary->Fill(i->first,
j, i->second[
j-1].getMean());
268 if(pmt_analysis ==
true){
272 for (
int j=0 ;
j < modulesPerString ;
j++){
278 (*histograms.h_summary.m_mean_summary_rate) [
MAKE_STRING(
"Detector/DU" +
to_string(i->first))]->Fill(
k,
j+1, i->second[
j][
k].getMean());
279 (*histograms.h_summary.m_mean_summary_rate_distribution)[
MAKE_STRING(
"Detector/DU" +
to_string(i->first))]->Fill( i->second[
j][
k].getMean());
300 double inverseFrameTimeSec = 1. / (1.0e-9 *
getFrameTime());
302 while (scanner.hasNext()){
304 T slice = *(scanner.next());
306 for(
auto & frame : slice) {
307 if (router->hasModule(frame.getModuleID())) {
309 const JModule& module = router->getModule (frame.getModuleID());
310 double rate = frame.numberOfHits * inverseFrameTimeSec;
314 DOM_rate_quantiles[string][floor].put(rate);
318 if(pmt_analysis ==
true){
324 h2 -> Fill(hit->getPMT() , hit->getToT()) ;
326 pmt_hit_count[hit->getPMT()]++;
332 (*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);
339 FATAL(
"JModuleRouter trying to access non existing identifier: "<< frame.getModuleID());
349 if (
j->second.getCount() > 0) histograms.h_timeslice.h_dom_mean_rates[ts_type] -> Fill (i->first ,
j->first ,
j->second.getMean() ) ;
363 if (scanner.hasNext()) {
364 histograms.initialize_summary_histograms();
366 iterateSummarysliceTree(scanner);
380 if(scanner.hasNext()) {
382 histograms.initialize_timeslice_histograms <
T>();
384 iterateTimesliceTree(scanner);
398 if(scanner.hasNext()) {
400 histograms.initialize_trigger_histograms();
402 iterateEventTree(scanner);
then fatal No hydrophone data file $HYDROPHONE_TXT fi sort gr k
void iterateTimesliceTree(JTreeScanner< T > &scanner)
ROOT TTree parameter settings of various packages.
static const unsigned int NUMBER_OF_TRIGGER_BITS
Number of trigger bits.
int countFIFOStatus() const
Count FIFO status.
JRunAnalyzer(string file, string detectorFile, JLimit_t nTimeslices, JLimit_t nSummaryslices, JLimit_t nEvents, bool pmtanalysis)
Constructor.
int getFloor() const
Get floor number.
Data structure for a composite optical module.
JRA_Histograms histograms
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
JLimit_t numberOfTimeslices
Dynamic ROOT object management.
void iterateSummarysliceTree(JTreeScanner< JDAQSummaryslice > &scanner)
Class dedicated to the analysis of KM3NeT runs.
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.
JRunAnalyzer()
Default constructor.
~JRunAnalyzer()
Destructor.
double getFrameTime()
Get frame time duration.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
void iterateEventTree(JTreeScanner< JDAQEvent > &scanner)
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.
JLimit_t numberOfSummaryslices
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.
JRA_Histograms getHistograms()
int getNumberOfModules(const JDetector &detector)
Get number of modules.