1 #ifndef __RUNANALYZER__
2 #define __RUNANALYZER__
16 using namespace KM3NETDAQ ;
57 numberOfTimeslices (nTimeslices),
58 numberOfSummaryslices (nSummaryslices),
59 numberOfEvents (nEvents)
65 cerr <<
"FATAL ERROR. Could not open detector file '" << detectorFile <<
"'." << endl;
87 while (scanner.hasNext()) {
91 histograms.h_trigger.h_Snapshot_hits -> Fill((Double_t) event.size<
JDAQSnapshotHit > ());
92 histograms.h_trigger.h_Triggered_hits -> Fill((Double_t) event.size<
JDAQTriggeredHit> ());
93 histograms.h_trigger.h_Number_of_overlays -> Fill(event.getOverlays());
97 if (event.hasTriggerBit(i)) {
99 histograms.h_trigger.h_Trigger_bit_event -> Fill((Double_t) i);
107 if (router->hasModule(hit->getModuleID())) {
109 const JModule& module = router->getModule (hit->getModuleID());
111 histograms.h_trigger.h_pmt_distribution_triggered_hits->Fill(hit->getPMT());
112 histograms.h_trigger.h_tot_distribution_triggered_hits->Fill(hit->getToT());
117 histograms.h_trigger.h_Triggered_hits_per_module -> Fill(String , Floor);
121 if (hit -> hasTriggerBit(i)) {
123 histograms.h_trigger.h_Trigger_bit_hit->Fill((Double_t) i);
127 FATAL(
"JModuleRouter trying to access non existing identifier: "<< hit->getModuleID());
133 if (router->hasModule(hit->getModuleID())) {
135 const JModule& module = router->getModule (hit->getModuleID());
139 int pmt = hit-> getPMT();
141 (*histograms.h_trigger.m_Snapshot_hits_per_pmt)[
MAKE_STRING(
"Detector/DU" +
to_string(String))] -> Fill(pmt, Floor);
142 histograms.h_trigger.h_Snapshot_hits_per_module -> Fill(String, Floor);
143 histograms.h_trigger.h_pmt_distribution_snapshot_hits -> Fill(hit->getPMT());
144 histograms.h_trigger.h_tot_distribution_snapshot_hits -> Fill(hit->getToT());
147 FATAL(
"JModuleRouter trying to access non existing identifier: "<< hit->getModuleID());
164 while (scanner.hasNext()){
168 for (JDAQSummaryslice::const_iterator frame = slice.begin() ; frame != slice.end() ; ++ frame) {
170 if (router->hasModule(frame->getModuleID())) {
172 const JModule& module = router->getModule (frame->getModuleID());
184 histograms.h_summary.h_hrv_per_dom->Fill(
string , floor);
188 histograms.h_summary.h_daq_status_per_dom->Fill(
string , floor);
191 histograms.h_summary.h_fifo_per_dom->Fill(
string , floor , nFIFOcount);
198 h2->Fill(i , frame->getRate(i) * 1e-3);
200 rate += frame->getRate(i);
201 histograms.h_summary.h_pmt_rate_distribution->Fill(frame->getRate(i)*1e-3);
202 PMT_rate_quantiles[string][floor-1][i].put(frame->getRate(i)*1e-3);
205 histograms.h_summary.h_dom_rate_distribution->Fill(rate*1e-3);
207 DOM_rate_quantiles[string].resize(modulesPerString);
209 DOM_rate_quantiles[string][floor-1].put(rate * 1e-3);
212 FATAL(
"JModuleRouter trying to access non existing identifier: "<< frame->getModuleID());
216 for (
std::map<
int ,
vector<JQuantile> >::const_iterator i = DOM_rate_quantiles.begin() ; i!= DOM_rate_quantiles.end() ; ++i) {
218 for (
int j=1 ;
j < modulesPerString + 1 ;
j++) {
220 if (i->second[
j-1].getCount() > 0) histograms.h_summary.h_rate_summary->Fill(i->first,
j, i->second[
j-1].getMean());
226 for (
int j=0 ;
j < modulesPerString ;
j++){
232 (*histograms.h_summary.m_mean_summary_rate) [
MAKE_STRING(
"Detector/DU" +
to_string(i->first))]->Fill(
k,
j+1, i->second[
j][
k].getMean());
233 (*histograms.h_summary.m_mean_summary_rate_distribution)[
MAKE_STRING(
"Detector/DU" +
to_string(i->first))]->Fill( i->second[
j][
k].getMean());
253 double inverseFrameTimeSec = 1. / (1.0e-9 *
getFrameTime());
255 while (scanner.hasNext()){
257 T slice = *(scanner.next());
259 for(
auto & frame : slice) {
260 if (router->hasModule(frame.getModuleID())) {
262 const JModule& module = router->getModule (frame.getModuleID());
263 double rate = frame.numberOfHits * inverseFrameTimeSec;
267 DOM_rate_quantiles[string][floor].put(rate);
275 h2 -> Fill(hit->getPMT() , hit->getToT()) ;
277 pmt_hit_count[hit->getPMT()]++;
283 (*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);
288 FATAL(
"JModuleRouter trying to access non existing identifier: "<< frame.getModuleID());
297 if (
j->second.getCount() > 0) histograms.h_timeslice.h_dom_mean_rates[ts_type] -> Fill (i->first ,
j->first ,
j->second.getMean() ) ;
311 if (scanner.hasNext()) {
312 histograms.initialize_summary_histograms();
314 iterateSummarysliceTree(scanner);
328 if(scanner.hasNext()) {
330 histograms.initialize_timeslice_histograms <
T>();
332 iterateTimesliceTree(scanner);
346 if(scanner.hasNext()) {
348 histograms.initialize_trigger_histograms();
350 iterateEventTree(scanner);
JLimit_t numberOfSummaryslices
JRA_Histograms histograms
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.
RunAnalyzer(string file, string detectorFile, JLimit_t nTimeslices, JLimit_t nSummaryslices, JLimit_t nEvents)
Constructor.
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)
JTDC_t getT() const
Get time.
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.
then usage $script< string identifier >< detectorfile > event file(toashort file)+" "\nNote that the event files and toashort files should be one-to-one related." fi if (( $