Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | List of all members
RunAnalyzer Class Reference

Class dedicated to the analysis of KM3NeT runs. More...

#include <RunAnalyzer.hh>

Public Member Functions

 RunAnalyzer ()
 Default constructor. More...
 
 RunAnalyzer (string file, string detectorFile, JLimit_t nTimeslices, JLimit_t nSummaryslices, JLimit_t nEvents)
 Constructor. More...
 
 ~RunAnalyzer ()
 Destructor. More...
 
void iterateEventTree (JTreeScanner< JDAQEvent > &scanner)
 
void iterateSummarysliceTree (JTreeScanner< JDAQSummaryslice > &scanner)
 
template<class T >
void iterateTimesliceTree (JTreeScanner< T > &scanner)
 
void readSummaryData ()
 
template<class T >
void readTimesliceData ()
 
void readEvents ()
 
JRA_Histograms getHistograms ()
 

Private Attributes

string inputFile
 
JDetector detector
 
JModuleRouterrouter
 
JRA_Histograms histograms
 
int modulesPerString
 
JLimit_t numberOfTimeslices
 
JLimit_t numberOfSummaryslices
 
JLimit_t numberOfEvents
 

Detailed Description

Class dedicated to the analysis of KM3NeT runs.

Author
rgruiz

Definition at line 29 of file RunAnalyzer.hh.

Constructor & Destructor Documentation

RunAnalyzer::RunAnalyzer ( )
inline

Default constructor.

Definition at line 45 of file RunAnalyzer.hh.

45 {}
RunAnalyzer::RunAnalyzer ( string  file,
string  detectorFile,
JLimit_t  nTimeslices,
JLimit_t  nSummaryslices,
JLimit_t  nEvents 
)
inline

Constructor.

Parameters
filePath to the file to be analyzed
detectorFilepath to a detector file
nTimeslicesNumber of timeslices to be read
nSummaryslicesNumber of summary slices to be read
nEventsNumber of frames to be read

Definition at line 56 of file RunAnalyzer.hh.

56  :
57  inputFile (file),
58  router (NULL),
59  numberOfTimeslices (nTimeslices),
60  numberOfSummaryslices (nSummaryslices),
61  numberOfEvents (nEvents)
62  {
63  try {
64  load (detectorFile, detector);
65  }
66  catch(const JException & error) {
67  cerr << "FATAL ERROR. Could not open detector file '" << detectorFile << "'." << endl;
68  exit(1);
69  }
70 
74  }
JLimit_t numberOfSummaryslices
Definition: RunAnalyzer.hh:37
JRA_Histograms histograms
Definition: RunAnalyzer.hh:34
General exception.
Definition: JException.hh:23
JLimit_t numberOfTimeslices
Definition: RunAnalyzer.hh:36
Router for direct addressing of module data in detector data structure.
JLimit_t numberOfEvents
Definition: RunAnalyzer.hh:38
exit
Definition: JPizza.sh:36
string inputFile
Definition: RunAnalyzer.hh:31
Detector file.
Definition: JHead.hh:130
int modulesPerString
Definition: RunAnalyzer.hh:35
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
static const JStringCounter getNumberOfStrings
Function object to count unique strings.
JModuleRouter * router
Definition: RunAnalyzer.hh:33
int getNumberOfModules(const JDetector &detector)
Get number of modules.
RunAnalyzer::~RunAnalyzer ( )
inline

Destructor.

Definition at line 79 of file RunAnalyzer.hh.

79 {}

Member Function Documentation

void RunAnalyzer::iterateEventTree ( JTreeScanner< JDAQEvent > &  scanner)
inline

Definition at line 87 of file RunAnalyzer.hh.

87  {
88 
89  while (scanner.hasNext()) {
90 
91  JDAQEvent event = *(scanner.next());
92 
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());
96 
97  for (unsigned int i = 0; i != NUMBER_OF_TRIGGER_BITS; ++i) {
98 
99  if (event.hasTriggerBit(i)) {
100 
101  histograms.h_trigger.h_Trigger_bit_event -> Fill((Double_t) i);
102  }
103  }
104 
105  histograms.h_trigger.h_Trigger_time->Fill(event.begin<JDAQTriggeredHit>()->getT() * 1e-6);
106 
107  for (JDAQEvent::const_iterator<JDAQTriggeredHit> hit = event.begin<JDAQTriggeredHit>(); hit != event.end<JDAQTriggeredHit>(); ++hit) {
108 
109  if (router->hasModule(hit->getModuleID())) {
110 
111  const JModule& module = router->getModule (hit->getModuleID());
112 
115 
116  int String = module.getString();
117  int Floor = module.getFloor();
118 
119  histograms.h_trigger.h_Triggered_hits_per_module -> Fill(String , Floor);
120 
121  for (unsigned int i = 0; i != NUMBER_OF_TRIGGER_BITS; ++i) {
122 
123  if (hit -> hasTriggerBit(i)) {
124 
125  histograms.h_trigger.h_Trigger_bit_hit->Fill((Double_t) i);
126  }
127  }
128  }else{
129  FATAL("JModuleRouter trying to access non existing identifier: "<< hit->getModuleID());
130  }
131  }
132 
133  for (JDAQEvent::const_iterator<JDAQSnapshotHit> hit = event.begin<JDAQSnapshotHit>() ; hit != event.end<JDAQSnapshotHit>() ; ++hit){
134 
135  if (router->hasModule(hit->getModuleID())) {
136 
137  const JModule& module = router->getModule (hit->getModuleID());
138 
139  int String = module.getString();
140  int Floor = module.getFloor();
141  int pmt = hit-> getPMT();
142 
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());
147 
148  }else{
149  FATAL("JModuleRouter trying to access non existing identifier: "<< hit->getModuleID());
150  }
151  }
152  }
153  }
TH1D * h_pmt_distribution_snapshot_hits
JRA_Histograms histograms
Definition: RunAnalyzer.hh:34
TH2D * h_Snapshot_hits_per_module
DAQ key hit.
Definition: JDAQKeyHit.hh:19
static const unsigned int NUMBER_OF_TRIGGER_BITS
Number of trigger bits.
TH1D * h_pmt_distribution_triggered_hits
int getFloor() const
Get floor number.
Definition: JLocation.hh:145
const JModule & getModule(const JObjectID &id) const
Get module parameters.
Data structure for a composite optical module.
Definition: JModule.hh:50
TH2D * h_Triggered_hits_per_module
Template const_iterator.
Definition: JDAQEvent.hh:68
JTDC_t getT() const
Get time.
Definition: JDAQHit.hh:86
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:699
esac $JPP_DIR examples JDetector JTransitTime o $OUTPUT_FILE n N $NPE T $TTS_NS d $DEBUG for HISTOGRAM in tts tt2 pmt
Definition: JTransitTime.sh:36
TH1D * h_tot_distribution_snapshot_hits
TriggerHistograms h_trigger
#define FATAL(A)
Definition: JMessage.hh:67
int getString() const
Get string number.
Definition: JLocation.hh:134
General purpose string class.
Definition: JHead.hh:102
std::string to_string(const T &value)
Convert value to string.
bool hasModule(const JObjectID &id) const
Has module.
TH1D * h_tot_distribution_triggered_hits
JModuleRouter * router
Definition: RunAnalyzer.hh:33
JManager< string, TH2D > * m_Snapshot_hits_per_pmt
void RunAnalyzer::iterateSummarysliceTree ( JTreeScanner< JDAQSummaryslice > &  scanner)
inline

Definition at line 161 of file RunAnalyzer.hh.

161  {
162 
163  std::map <int,vector<vector <JQuantile>>> PMT_rate_quantiles;
164  std::map <int,vector<JQuantile>> DOM_rate_quantiles;
165 
166  while (scanner.hasNext()){
167 
168  JDAQSummaryslice slice = *(scanner.next());
169 
170  for (JDAQSummaryslice::const_iterator frame = slice.begin() ; frame != slice.end() ; ++ frame) {
171 
172  if (router->hasModule(frame->getModuleID())) {
173 
174  const JModule& module = router->getModule (frame->getModuleID());
175 
176  int string = module.getString();
177  int floor = module.getFloor ();
178 
179  PMT_rate_quantiles[string].resize(modulesPerString , vector <JQuantile>(NUMBER_OF_PMTS));
180 
181  JDAQFrameStatus status = frame -> getDAQFrameStatus();
182  int nFIFOcount = status.countFIFOStatus();
183  int nHRVcount = status.countHighRateVeto();
184 
185  if (nHRVcount > 0) {
186  histograms.h_summary.h_hrv_per_dom->Fill(string , floor);
187  }
188 
189  if (status.testDAQStatus() == false) {
190  histograms.h_summary.h_daq_status_per_dom->Fill(string , floor);
191  }
192 
193  histograms.h_summary.h_fifo_per_dom->Fill(string , floor , nFIFOcount);
194 
195  TH2D* h2 = (*histograms.h_summary.m_summary_rate_distribution)[MAKE_STRING("Detector/DU" + to_string(string) + "/F" + to_string(floor))];
196  double rate = 0;
197 
198  for (int i = 0 ; i < NUMBER_OF_PMTS ; i++){
199 
200  h2->Fill(i , frame->getRate(i) * 1e-3);
201 
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);
205  }
206 
208 
209  DOM_rate_quantiles[string].resize(modulesPerString);
210 
211  DOM_rate_quantiles[string][floor-1].put(rate * 1e-3);
212 
213  }else{
214  FATAL("JModuleRouter trying to access non existing identifier: "<< frame->getModuleID());
215  }
216  }
217  }
218  for (std::map<int , vector<JQuantile> >::const_iterator i = DOM_rate_quantiles.begin() ; i!= DOM_rate_quantiles.end() ; ++i) {
219 
220  for (int j=1 ; j < modulesPerString + 1 ; j++) {
221 
222  if (i->second[j-1].getCount() > 0) histograms.h_summary.h_rate_summary->Fill(i->first, j, i->second[j-1].getMean());
223  }
224  }
225 
226  for (std::map<int , vector < vector<JQuantile> > >::const_iterator i = PMT_rate_quantiles.begin() ; i!= PMT_rate_quantiles.end() ; ++i) {
227 
228  for (int j=0 ; j < modulesPerString ; j++){
229 
230  for (int k=0 ; k < NUMBER_OF_PMTS ; k++){
231 
232  if (i -> second[j][k].getCount() > 0){
233 
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());
236  }
237  }
238  }
239  }
240  }
*fatal Wrong number of arguments esac JCookie sh JRuns D $DETECTOR d sort n k
Definition: JRunrange.sh:16
JRA_Histograms histograms
Definition: RunAnalyzer.hh:34
int countFIFOStatus() const
Count FIFO status.
JManager< string, TH1D > * m_mean_summary_rate_distribution
int getFloor() const
Get floor number.
Definition: JLocation.hh:145
const JModule & getModule(const JObjectID &id) const
Get module parameters.
Data structure for a composite optical module.
Definition: JModule.hh:50
then set_variable singlesRate set_variable doublesRate set_variable numberOfSlices echo Generating random background echo Singles rate
JManager< string, TH2D > * m_mean_summary_rate
TH1D * h_dom_rate_distribution
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:699
int modulesPerString
Definition: RunAnalyzer.hh:35
TH1D * h_pmt_rate_distribution
#define FATAL(A)
Definition: JMessage.hh:67
SummaryHistograms h_summary
int getString() const
Get string number.
Definition: JLocation.hh:134
int countHighRateVeto() const
Count high-rate veto status.
JManager< string, TH2D > * m_summary_rate_distribution
std::string to_string(const T &value)
Convert value to string.
bool hasModule(const JObjectID &id) const
Has module.
int getCount(const T &hit)
Get hit count.
JModuleRouter * router
Definition: RunAnalyzer.hh:33
int j
Definition: JPolint.hh:634
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
bool testDAQStatus() const
Test DAQ status of packets.
template<class T >
void RunAnalyzer::iterateTimesliceTree ( JTreeScanner< T > &  scanner)
inline

Definition at line 249 of file RunAnalyzer.hh.

249  {
250 
252 
253  std::map < int , std::map <int , JQuantile> > DOM_rate_quantiles;
254 
255  double inverseFrameTimeSec = 1. / (1.0e-9 * getFrameTime());
256 
257  while (scanner.hasNext()){
258 
259  T slice = *(scanner.next());
260 
261  for(auto & frame : slice) {
262  if (router->hasModule(frame.getModuleID())) {
263 
264  const JModule& module = router->getModule (frame.getModuleID());
265  double rate = frame.numberOfHits * inverseFrameTimeSec;
266  int string = module.getString();
267  int floor = module.getFloor ();
268 
269  DOM_rate_quantiles[string][floor].put(rate);
270 
271  vector <int> pmt_hit_count (NUMBER_OF_PMTS , 0) ;
272 
273  TH2D* h2 = (*histograms.h_timeslice.m_pmt_tot_distributions[ts_type])[MAKE_STRING("Detector/DU" + to_string(string) + "/F" + to_string(floor) + "/" + to_string(frame.getModuleID()))];
274 
275  for (JDAQSuperFrame::const_iterator hit = frame.begin() ; hit != frame.end() ; ++hit){
276 
277  h2 -> Fill(hit->getPMT() , hit->getToT()) ;
278 
279  pmt_hit_count[hit->getPMT()]++;
280 
281  }
282 
283  for (int pmt = 0 ; pmt != NUMBER_OF_PMTS ; ++pmt) {
284 
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);
286 
287  }
288 
289  }else{
290  FATAL("JModuleRouter trying to access non existing identifier: "<< frame.getModuleID());
291  }
292  }
293  }
294 
295  for (std::map< int , std::map<int,JQuantile>>::const_iterator i = DOM_rate_quantiles.begin() ; i != DOM_rate_quantiles.end() ; i++){
296 
297  for (std::map<int , JQuantile>::const_iterator j = i->second.begin() ; j != i->second.end() ; j++){
298 
299  if (j->second.getCount() > 0) histograms.h_timeslice.h_dom_mean_rates[ts_type] -> Fill (i->first , j->first , j->second.getMean() ) ;
300  }
301  }
302  }
JRA_Histograms histograms
Definition: RunAnalyzer.hh:34
vector< JManager< string, TH2D > * > m_pmt_tot_distributions
int getFloor() const
Get floor number.
Definition: JLocation.hh:145
const JModule & getModule(const JObjectID &id) const
Get module parameters.
Data structure for a composite optical module.
Definition: JModule.hh:50
vector< TH2D * > h_dom_mean_rates
then set_variable singlesRate set_variable doublesRate set_variable numberOfSlices echo Generating random background echo Singles rate
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:699
esac $JPP_DIR examples JDetector JTransitTime o $OUTPUT_FILE n N $NPE T $TTS_NS d $DEBUG for HISTOGRAM in tts tt2 pmt
Definition: JTransitTime.sh:36
TimesliceHistograms h_timeslice
Hit data structure.
Definition: JDAQHit.hh:34
double getFrameTime()
Get frame time duration.
Definition: JDAQClock.hh:162
do set_variable OUTPUT_DIRECTORY $WORKDIR T
#define FATAL(A)
Definition: JMessage.hh:67
int getString() const
Get string number.
Definition: JLocation.hh:134
std::string to_string(const T &value)
Convert value to string.
vector< JManager< string, TH2D > * > m_pmt_rate_distributions
bool hasModule(const JObjectID &id) const
Has module.
JModuleRouter * router
Definition: RunAnalyzer.hh:33
int j
Definition: JPolint.hh:634
Indexing of data type in type list.
Definition: JTypeList.hh:310
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
void RunAnalyzer::readSummaryData ( )
inline

Definition at line 310 of file RunAnalyzer.hh.

310  {
311 
313  if (scanner.hasNext()) {
315  scanner.rewind();
316  iterateSummarysliceTree(scanner);
317  }
318  }
JLimit_t numberOfSummaryslices
Definition: RunAnalyzer.hh:37
JRA_Histograms histograms
Definition: RunAnalyzer.hh:34
void iterateSummarysliceTree(JTreeScanner< JDAQSummaryslice > &scanner)
Definition: RunAnalyzer.hh:161
void initialize_summary_histograms()
Template definition for direct access of elements in ROOT TChain.
Definition: JTreeScanner.hh:91
string inputFile
Definition: RunAnalyzer.hh:31
template<class T >
void RunAnalyzer::readTimesliceData ( )
inline

Definition at line 327 of file RunAnalyzer.hh.

327  {
328 
330  if(scanner.hasNext()) {
331 
333  scanner.rewind();
334  iterateTimesliceTree(scanner);
335  }
336  }
JRA_Histograms histograms
Definition: RunAnalyzer.hh:34
JLimit_t numberOfTimeslices
Definition: RunAnalyzer.hh:36
void iterateTimesliceTree(JTreeScanner< T > &scanner)
Definition: RunAnalyzer.hh:249
Template definition for direct access of elements in ROOT TChain.
Definition: JTreeScanner.hh:91
string inputFile
Definition: RunAnalyzer.hh:31
do set_variable OUTPUT_DIRECTORY $WORKDIR T
void initialize_timeslice_histograms()
void RunAnalyzer::readEvents ( )
inline

Definition at line 344 of file RunAnalyzer.hh.

344  {
345 
347 
348  if(scanner.hasNext()) {
349 
351  scanner.rewind();
352  iterateEventTree(scanner);
353  }
354  }
JRA_Histograms histograms
Definition: RunAnalyzer.hh:34
void iterateEventTree(JTreeScanner< JDAQEvent > &scanner)
Definition: RunAnalyzer.hh:87
JLimit_t numberOfEvents
Definition: RunAnalyzer.hh:38
Template definition for direct access of elements in ROOT TChain.
Definition: JTreeScanner.hh:91
string inputFile
Definition: RunAnalyzer.hh:31
void initialize_trigger_histograms()
JRA_Histograms RunAnalyzer::getHistograms ( )
inline

Definition at line 359 of file RunAnalyzer.hh.

359  {
360 
361  return histograms ;
362  }
JRA_Histograms histograms
Definition: RunAnalyzer.hh:34

Member Data Documentation

string RunAnalyzer::inputFile
private

Definition at line 31 of file RunAnalyzer.hh.

JDetector RunAnalyzer::detector
private

Definition at line 32 of file RunAnalyzer.hh.

JModuleRouter* RunAnalyzer::router
private

Definition at line 33 of file RunAnalyzer.hh.

JRA_Histograms RunAnalyzer::histograms
private

Definition at line 34 of file RunAnalyzer.hh.

int RunAnalyzer::modulesPerString
private

Definition at line 35 of file RunAnalyzer.hh.

JLimit_t RunAnalyzer::numberOfTimeslices
private

Definition at line 36 of file RunAnalyzer.hh.

JLimit_t RunAnalyzer::numberOfSummaryslices
private

Definition at line 37 of file RunAnalyzer.hh.

JLimit_t RunAnalyzer::numberOfEvents
private

Definition at line 38 of file RunAnalyzer.hh.


The documentation for this class was generated from the following file: