1 #ifndef __NEWRUNANALYZER__
2 #define __NEWRUNANALYZER__
23 using namespace KM3NETDAQ ;
24 using namespace JDETECTOR ;
25 using namespace JLANG ;
84 cerr <<
"FATAL ERROR. Could not open detector file '" << detector_file <<
"'." << endl ;
118 while (scanner.hasNext()){
130 if (
event.hasTriggerBit(i)) {
132 histograms.h_trigger.h_Trigger_bit_event->Fill((Double_t) i);
134 (*histograms.h_trigger.m_trigger_rates)[
getTriggerName(i)] -> Fill (starting_frame_index - frame_index_range.
first) ;
144 histograms.h_trigger.h_pmt_distribution_triggered_hits -> Fill (hit -> getPMT()) ;
146 histograms.h_trigger.h_tot_distribution_triggered_hits -> Fill (hit ->
getToT()) ;
152 (*histograms.h_trigger.m_Trigger_map)[
MAKE_STRING(
"Detector/DU" +
to_string(String))] -> Fill (starting_frame_index , Floor) ;
154 histograms.h_trigger.h_Triggered_hits_per_module -> Fill (String , Floor) ;
158 if (hit -> hasTriggerBit(i)) {
160 histograms.h_trigger.h_Trigger_bit_hit->Fill((Double_t) i);
174 int pmt = hit -> getPMT() ;
176 histograms.h_trigger.h_Snapshot_hits_per_module -> Fill (String , Floor) ;
178 (*histograms.h_trigger.m_Snapshot_hits_per_pmt)[
MAKE_STRING(
"Detector/DU" +
to_string(String))] -> Fill (pmt , Floor) ;
180 histograms.h_trigger.h_pmt_distribution_snapshot_hits -> Fill (hit -> getPMT()) ;
182 histograms.h_trigger.h_tot_distribution_snapshot_hits -> Fill (hit ->
getToT()) ;
203 while (scanner.hasNext()){
213 for (JDAQSummaryslice::const_iterator s_frame = slice.begin() ; s_frame != slice.end() ; ++ s_frame){
223 HRV_quantile.
put ( nHRVcount ) ;
225 FIFO_quantile.
put ( nFIFOcount ) ;
227 int string = module_router ->
getModule (s_frame->getModuleID()).getString() ;
229 int floor = module_router ->
getModule (s_frame->getModuleID()).getFloor() ;
231 if ( nHRVcount > 0 ){
233 histograms.h_summary.h_hrv_per_dom -> Fill (module_router ->
getModule (s_frame->getModuleID()).getString() , module_router ->
getModule (s_frame->getModuleID()).getFloor() ) ;
239 histograms.h_summary.h_daq_status -> Fill(slice.
getFrameIndex() - frame_index_range.
first) ;
241 histograms.h_summary.h_daq_status_per_dom -> Fill(module_router ->
getModule (s_frame->getModuleID()).getString() , module_router ->
getModule (s_frame->getModuleID()).getFloor()) ;
245 histograms.h_summary.h_fifo_per_dom -> Fill (module_router ->
getModule (s_frame->getModuleID()).getString() , module_router ->
getModule (s_frame->getModuleID()).getFloor() , nFIFOcount ) ;
251 (*histograms.h_summary.m_summary_rate_vs_time)[
MAKE_STRING(
"Detector/DU" +
to_string(
string) +
"/F" +
to_string(floor))] -> Fill(time_since_run_start , i , s_frame -> getRate(i)) ;
253 (*histograms.h_summary.m_summary_rate_distribution)[
MAKE_STRING(
"Detector/DU" +
to_string(
string) +
"/F" +
to_string(floor))] -> Fill(s_frame -> getRate(i) * 1e-3 , i) ;
259 rate += s_frame -> getRate(i) ;
261 histograms.h_summary.h_pmt_rate_distribution -> Fill (s_frame -> getRate(i) * 1e-3) ;
263 PMT_rate_quantiles[module_router ->
getModule (s_frame->getModuleID()).getString()][module_router ->
getModule (s_frame->getModuleID()).getFloor()-1][i].put(s_frame ->getRate(i) * 1e-3) ;
267 DOM_rate_quantiles[module_router ->
getModule (s_frame->getModuleID()).getString()].resize(modules_per_string) ;
269 DOM_rate_quantiles[module_router ->
getModule (s_frame->getModuleID()).getString()][module_router ->
getModule (s_frame->getModuleID()).getFloor()-1].put(rate * 1e-3) ;
271 (*histograms.h_summary.m_module_rates_vs_time)[
MAKE_STRING(
"Detector/DU" +
to_string(
string) +
"/F" +
to_string(floor))] -> Fill(time_since_run_start , rate ) ;
281 for (
std::map<
int ,
vector<JQuantile> >::const_iterator i = DOM_rate_quantiles.begin() ; i!= DOM_rate_quantiles.end() ; ++i){
283 for (
int j=1 ; j < modules_per_string + 1 ; j++){
285 if (i -> second[j-1].
getCount() > 0) histograms.h_summary.h_rate_summary ->Fill (i -> first , j , i -> second[j-1].getMean() ) ;
293 for (
int j = 0 ; j < modules_per_string ; j++){
297 if (i -> second[j][k].
getCount() > 0){
299 (*histograms.h_summary.m_mean_summary_rate)[
MAKE_STRING(
"Detector/DU" +
to_string(i->first))] -> Fill(k , j+1 , i -> second[j][k].
getMean()) ;
324 if( scanner.hasNext() ){
326 range =
JFrameIndexRange (scanner.begin()->getFrameIndex() , scanner.rbegin()->getFrameIndex()) ;
328 histograms.initialize_summary_histograms (range) ;
332 iterate_summaryslice_tree (scanner , range) ;
353 while (scanner.hasNext()){
355 T slice = *(scanner.next()) ;
357 double time_since_run_start = (slice.getFrameIndex() - frame_index_range.
first) *
getFrameTime() * 1.0e-9 ;
365 for(
auto & s_frame : slice){
369 double rate = s_frame.numberOfHits / (1.0e-9 *
getFrameTime()) ;
375 DOM_rate_quantiles[string][floor].put(rate) ;
377 detector_rate_quantile.
put (rate) ;
379 (*histograms.h_timeslice.m_module_rates_vs_time[ts_type])[
MAKE_STRING(
"Detector/DU" +
to_string(
string) +
"/F" +
to_string(floor))] -> Fill(time_since_run_start , rate ) ;
383 active_DOM_quantile.
put ( 1 ) ;
385 active_DOM_DU_quantiles [string].put(1) ;
399 (*histograms.h_timeslice.m_pmt_tot_distributions[ts_type])[
MAKE_STRING(
"Detector/DU" +
to_string(
string) +
"/F" +
to_string(floor) +
"/" +
to_string(s_frame.getModuleID()))] -> Fill(hit->getPMT() , hit->getToT()) ;
401 hit_time_buffers[hit->getPMT()].push_back (hit->getT()) ;
403 tot_quantiles[hit->getPMT()].put (hit->getToT()) ;
405 pmt_rate_quantiles[hit->getPMT()].put (1) ;
407 if (hit->getToT() == 255) {
409 (*histograms.h_timeslice.m_ToT_255[ts_type])[
MAKE_STRING(
"Detector/DU" +
to_string(
string))] -> Fill(floor , hit->getPMT()) ;
411 histograms.h_timeslice.h_ToT_255_vs_time[ts_type] -> Fill(hit -> getT()) ;
413 histograms.h_timeslice.h_ToT_255_Floor_vs_time[ts_type] -> Fill(hit -> getT() , floor) ;
415 histograms.h_timeslice.h_ToT_255_Floor_vs_time_2[ts_type] -> Fill(hit -> getT() , floor) ;
423 (*histograms.h_timeslice.m_pmt_rates_vs_time[ts_type])[
MAKE_STRING(
"Detector/DU" +
to_string(
string) +
"/F" +
to_string(floor))] -> Fill(time_since_run_start , pmt - pmt_rate_quantiles.begin() , pmt->getCount()/
getFrameTime()/1.0e-9 ) ;
429 if (pmt->second.getCount() > 0){
431 (*histograms.h_timeslice.m_pmt_rate_distributions[ts_type])[
MAKE_STRING(
"Detector/DU" +
to_string(
string) +
"/F" +
to_string(floor))] -> Fill(1e-3 * pmt->second.getCount()/
getFrameTime()/1.0e-9 , pmt->first ) ;
433 (*histograms.h_timeslice.m_pmt_tot_vs_time[ts_type])[
MAKE_STRING(
"Detector/DU" +
to_string(
string) +
"/F" +
to_string(floor))] -> Fill (time_since_run_start , pmt->first , pmt->second.getMean() ) ;
437 for (
int i=1 ; i < (int)hit_time_buffers[pmt->first].size() ; i++){
439 (*histograms.h_timeslice.m_pmt_dt_consecutive_hits[ts_type])[
MAKE_STRING(
"Detector/DU" +
to_string(
string) +
"/F" +
to_string(floor))] -> Fill ( log10(hit_time_buffers[pmt->first][i] - hit_time_buffers[pmt->first][i-1]) , pmt->first) ;
447 histograms.h_timeslice.h_rate[ts_type] -> Fill ( slice.getFrameIndex() - frame_index_range.
first , detector_rate_quantile.
getMean() ) ;
449 histograms.h_timeslice.h_slice_start_time[ts_type] -> Fill ( slice.getFrameIndex() - frame_index_range.
first , time_since_run_start ) ;
455 histograms.h_timeslice.h_du_active_modules[ts_type] -> Fill(slice.getFrameIndex() - frame_index_range.
first , i->first , i->second.getCount() ) ;
465 if (j->second.getCount() > 0) histograms.h_timeslice.h_dom_mean_rates[ts_type] -> Fill (i->first , j->first , j->second.getMean() ) ;
485 if( scanner.hasNext() ){
487 range =
JFrameIndexRange (scanner.begin()->getFrameIndex() , scanner.rbegin()->getFrameIndex()) ;
489 histograms.initialize_timeslice_histograms < T > (range) ;
493 iterate_timeslice_tree (scanner , range) ;
512 if( scanner.hasNext() ){
514 range =
JFrameIndexRange (scanner.begin()->getFrameIndex() , scanner.rbegin()->getFrameIndex()) ;
516 histograms.initialize_trigger_histograms (range) ;
520 iterate_daqevent_tree (scanner , range) ;
JRA_Histograms histograms
JTOOLS::JRange< int > JFrameIndexRange
Type definition for frame index range.
void read_daqevents_from_file()
void read_summaryslices_from_file()
static const unsigned int NUMBER_OF_TRIGGER_BITS
Number of trigger bits.
int countFIFOStatus() const
Count FIFO status.
void iterate_timeslice_tree(JTreeScanner< T, JDAQEvaluator > &scanner, JFrameIndexRange frame_index_range)
Data structure for a composite optical module.
int getNumberOfStrings(const JDetector &detector)
Get number of strings.
RunAnalyzer(string file, string detector_file)
Constructor.
double getCount(TH1D *hptr, int muon_threshold)
Router for direct addressing of module data in detector data structure.
std::set< int > getStringIDs(const JDetector &detector)
Get list of strings IDs.
Structure to store the ToT mean and standard deviation of the hits produced by a nanobeacon in a sour...
void read_timeslices_from_file()
Dynamic ROOT object management.
JModuleLocation default_module_location
Template definition for direct access of elements in ROOT TChain.
double getMean(vector< double > &v)
get mean of vector content
#define MAKE_STRING(A)
Make string.
int getFrameIndex() const
Get frame index.
double getToT(const T &tot, const JCalibration &cal)
Get calibrated time-over-threshold of hit.
int getFloor() const
Get floor number.
int getString() const
Get string number.
~RunAnalyzer()
Destructor.
JModuleRouter * module_router
Class dedicated to the analysis of KM3NeT runs.
double getFrameTime()
Get frame time duration.
JRA_Histograms getHistograms()
void iterate_daqevent_tree(JTreeScanner< JDAQEvent, JDAQEvaluator > &scanner, JFrameIndexRange frame_index_range)
void iterate_summaryslice_tree(JTreeScanner< JDAQSummaryslice, JDAQEvaluator > &scanner, JFrameIndexRange frame_index_range)
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
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.
bool testHighRateVeto() const
Test high-rate veto status.
int countHighRateVeto() const
Count high-rate veto status.
const char * getTriggerName(JTriggerbit_t bit)
Get trigger name.
General purpose string class.
ROOT TTree parameter settings.
std::string to_string(const T &value)
Convert value to string.
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.
const JModule & getModule(const JDetector &detector, const JModuleLocation &location)
find module with a given string and floor number
Logical location of module.
bool testFIFOStatus() const
Test FIFO status.