1 #ifndef __RUNANALYZER__
2 #define __RUNANALYZER__
16 using namespace KM3NETDAQ ;
17 using namespace JDETECTOR ;
18 using namespace JLANG ;
59 numberOfTimeslices (nTimeslices),
60 numberOfSummaryslices (nSummaryslices),
61 numberOfEvents (nEvents)
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> ());
95 histograms.h_trigger.h_Number_of_overlays -> Fill(event.getOverlays());
99 if (event.hasTriggerBit(i)) {
101 histograms.h_trigger.h_Trigger_bit_event -> Fill((Double_t) i);
109 if (router->hasModule(hit->getModuleID())) {
111 const JModule& module = router->getModule (hit->getModuleID());
113 histograms.h_trigger.h_pmt_distribution_triggered_hits->Fill(hit->getPMT());
114 histograms.h_trigger.h_tot_distribution_triggered_hits->Fill(hit->getToT());
119 histograms.h_trigger.h_Triggered_hits_per_module -> Fill(String , Floor);
123 if (hit -> hasTriggerBit(i)) {
125 histograms.h_trigger.h_Trigger_bit_hit->Fill((Double_t) i);
129 FATAL(
"JModuleRouter trying to access non existing identifier: "<< hit->getModuleID());
135 if (router->hasModule(hit->getModuleID())) {
137 const JModule& module = router->getModule (hit->getModuleID());
141 int pmt = hit-> getPMT();
143 (*histograms.h_trigger.m_Snapshot_hits_per_pmt)[
MAKE_STRING(
"Detector/DU" +
to_string(String))] -> Fill(pmt, Floor);
144 histograms.h_trigger.h_Snapshot_hits_per_module -> Fill(String, Floor);
145 histograms.h_trigger.h_pmt_distribution_snapshot_hits -> Fill(hit->getPMT());
146 histograms.h_trigger.h_tot_distribution_snapshot_hits -> Fill(hit->getToT());
149 FATAL(
"JModuleRouter trying to access non existing identifier: "<< hit->getModuleID());
166 while (scanner.hasNext()){
170 for (JDAQSummaryslice::const_iterator frame = slice.begin() ; frame != slice.end() ; ++ frame) {
172 if (router->hasModule(frame->getModuleID())) {
174 const JModule& module = router->getModule (frame->getModuleID());
186 histograms.h_summary.h_hrv_per_dom->Fill(
string , floor);
190 histograms.h_summary.h_daq_status_per_dom->Fill(
string , floor);
193 histograms.h_summary.h_fifo_per_dom->Fill(
string , floor , nFIFOcount);
200 h2->Fill(i , frame->getRate(i) * 1e-3);
202 rate += frame->getRate(i);
203 histograms.h_summary.h_pmt_rate_distribution->Fill(frame->getRate(i)*1e-3);
204 PMT_rate_quantiles[string][floor-1][i].put(frame->getRate(i)*1e-3);
207 histograms.h_summary.h_dom_rate_distribution->Fill(rate*1e-3);
209 DOM_rate_quantiles[string].resize(modulesPerString);
211 DOM_rate_quantiles[string][floor-1].put(rate * 1e-3);
214 FATAL(
"JModuleRouter trying to access non existing identifier: "<< frame->getModuleID());
218 for (
std::map<
int ,
vector<JQuantile> >::const_iterator i = DOM_rate_quantiles.begin() ; i!= DOM_rate_quantiles.end() ; ++i) {
220 for (
int j=1 ;
j < modulesPerString + 1 ;
j++) {
222 if (i->second[
j-1].getCount() > 0) histograms.h_summary.h_rate_summary->Fill(i->first,
j, i->second[
j-1].getMean());
228 for (
int j=0 ;
j < modulesPerString ;
j++){
234 (*histograms.h_summary.m_mean_summary_rate) [
MAKE_STRING(
"Detector/DU" +
to_string(i->first))]->Fill(
k,
j+1, i->second[
j][
k].getMean());
235 (*histograms.h_summary.m_mean_summary_rate_distribution)[
MAKE_STRING(
"Detector/DU" +
to_string(i->first))]->Fill( i->second[
j][
k].getMean());
255 double inverseFrameTimeSec = 1. / (1.0e-9 *
getFrameTime());
257 while (scanner.hasNext()){
259 T slice = *(scanner.next());
261 for(
auto & frame : slice) {
262 if (router->hasModule(frame.getModuleID())) {
264 const JModule& module = router->getModule (frame.getModuleID());
265 double rate = frame.numberOfHits * inverseFrameTimeSec;
269 DOM_rate_quantiles[string][floor].put(rate);
277 h2 -> Fill(hit->getPMT() , hit->getToT()) ;
279 pmt_hit_count[hit->getPMT()]++;
285 (*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);
290 FATAL(
"JModuleRouter trying to access non existing identifier: "<< frame.getModuleID());
299 if (
j->second.getCount() > 0) histograms.h_timeslice.h_dom_mean_rates[ts_type] -> Fill (i->first ,
j->first ,
j->second.getMean() ) ;
313 if (scanner.hasNext()) {
314 histograms.initialize_summary_histograms();
316 iterateSummarysliceTree(scanner);
330 if(scanner.hasNext()) {
332 histograms.initialize_timeslice_histograms <
T>();
334 iterateTimesliceTree(scanner);
348 if(scanner.hasNext()) {
350 histograms.initialize_trigger_histograms();
352 iterateEventTree(scanner);
*fatal Wrong number of arguments esac JCookie sh JRuns D $DETECTOR d sort n k
JLimit_t numberOfSummaryslices
JRA_Histograms histograms
void iterateEventTree(JTreeScanner< JDAQEvent > &scanner)
ROOT TTree parameter settings.
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.
esac $JPP_DIR examples JDetector JTransitTime o $OUTPUT_FILE n N $NPE T $TTS_NS d $DEBUG for HISTOGRAM in tts tt2 pmt
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
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
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.
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.