Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
JRunAnalyzer Class Reference

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

#include <JRunAnalyzer.hh>

Classes

struct  dom_type
 

Public Member Functions

 JRunAnalyzer (const JSingleFileScanner<> &file, const JDetector &detector, TFile *out, JLimit_t nTimeslices, JLimit_t nSummaryslices, JLimit_t nEvents, int analysislevel)
 Constructor.
 
 ~JRunAnalyzer ()
 Destructor.
 
void iterateEventTree (JTreeScanner< JDAQEvent > &scanner)
 
void iterateRecoEventTree (JParallelFileScanner< JTypeList< JDAQEvent, JFIT::JEvt > > &scanner, TFile &f)
 
void iterateSummarysliceTree (JTreeScanner< JDAQSummaryslice > &scanner)
 
template<class T >
void iterateTimesliceTree (JTreeScanner< T > &scanner)
 
void readSummaryData ()
 
template<class T >
void readTimesliceData ()
 
void readEvents ()
 
void readRecoEvents ()
 
void writeToFile (TFile *f, int analysis_level)
 

Private Attributes

JSingleFileScanner inputFile
 
JModuleRouter router
 
TFile * outputFile
 
JRA_Histograms histograms
 
JLimit_t numberOfTimeslices
 
JLimit_t numberOfSummaryslices
 
JLimit_t numberOfEvents
 
int analysis_level
 

Detailed Description

Class dedicated to the analysis of KM3NeT runs.

Definition at line 37 of file JRunAnalyzer.hh.

Constructor & Destructor Documentation

◆ JRunAnalyzer()

JRunAnalyzer::JRunAnalyzer ( const JSingleFileScanner<> & file,
const JDetector & detector,
TFile * out,
JLimit_t nTimeslices,
JLimit_t nSummaryslices,
JLimit_t nEvents,
int analysislevel )
inline

Constructor.

Parameters
filefile name
detectordetector
outpointer to output file
nTimeslicesnumber of timeslices to be read
nSummaryslicesnumber of summary slices to be read
nEventsnumber of events to be read
analysisleveloption for analysis of PMT or reco data

Definition at line 61 of file JRunAnalyzer.hh.

62 :
63 inputFile (file),
65 outputFile (out),
66 numberOfTimeslices (nTimeslices),
67 numberOfSummaryslices (nSummaryslices),
68 numberOfEvents (nEvents),
69 analysis_level (analysislevel)
70 {
71 using namespace JPP;
72 using namespace std;
73
75 }
string outputFile
JSingleFileScanner inputFile
JRA_Histograms histograms
JLimit_t numberOfTimeslices
JLimit_t numberOfEvents
JModuleRouter router
JLimit_t numberOfSummaryslices
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Detector file.
Definition JHead.hh:227

◆ ~JRunAnalyzer()

JRunAnalyzer::~JRunAnalyzer ( )
inline

Destructor.

Definition at line 80 of file JRunAnalyzer.hh.

80{}

Member Function Documentation

◆ iterateEventTree()

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

Definition at line 88 of file JRunAnalyzer.hh.

88 {
89
90 while (scanner.hasNext()) {
91
92 JDAQEvent event = *(scanner.next());
93
94 histograms.h_trigger.h_Snapshot_hits -> Fill((Double_t) event.size<JDAQSnapshotHit> ());
95 histograms.h_trigger.h_Triggered_hits -> Fill((Double_t) event.size<JDAQTriggeredHit> ());
96 histograms.h_trigger.h_Triggered_over_Snapshot_hits -> Fill((Double_t) event.size<JDAQTriggeredHit> () / event.size<JDAQSnapshotHit > ());
97 histograms.h_trigger.h_Number_of_overlays -> Fill(event.getOverlays());
98
99 for (unsigned int i = 0; i != NUMBER_OF_TRIGGER_BITS; ++i) {
100
101 if (event.hasTriggerBit(i)) {
102
103 histograms.h_trigger.h_Trigger_bit_event -> Fill((Double_t) i);
104 }
105 }
106
107 int counter_3dmuon = 0;
108 typedef JRange<double> JRange_t;
109 JRange_t range(JRange_t::DEFAULT_RANGE());
110
111 for (JDAQEvent::const_iterator<JDAQTriggeredHit> hit = event.begin<JDAQTriggeredHit>(); hit != event.end<JDAQTriggeredHit>(); ++hit) {
112
113 const JModule& module = router.getModule(hit->getModuleID());
114 const double t1 = getTime(hit->getT(), module.getPMT(hit->getPMT()));
115
116 range.include(t1);
117
118 JDAQTriggerMask trigger_mask(event.getTriggerMask(*hit));
119
120 if(trigger_mask.hasTriggerBit(getTriggerBit<JTrigger3DMuon>())) counter_3dmuon++;
121
122 if (router.hasModule(hit->getModuleID())) {
123
124 const JModule& module = router.getModule (hit->getModuleID());
125
128
129 int String = module.getString();
130 int Floor = module.getFloor();
131
133
134 if(trigger_mask.hasTriggerBit(getTriggerBit<JTrigger3DMuon>())){
136 }
137
138 for (unsigned int i = 0; i != NUMBER_OF_TRIGGER_BITS; ++i) {
139
140 if (hit -> hasTriggerBit(i)) {
141
142 histograms.h_trigger.h_Trigger_bit_hit->Fill((Double_t) i);
143 }
144 }
145 }else{
146 FATAL("JModuleRouter trying to access non existing identifier: "<< hit->getModuleID());
147 }
148 }
149
150 histograms.h_trigger.h_event_duration->Fill(range.getLength());
151
152 histograms.h_trigger.h_pmt_distribution_triggered_hits->Scale(1. / (Double_t) event.size<JDAQTriggeredHit> ());
153
154 if(counter_3dmuon != 0) histograms.h_trigger.h_Triggered_hits_3dmuon->Fill(counter_3dmuon);
155
156 for (JDAQEvent::const_iterator<JDAQSnapshotHit> hit = event.begin<JDAQSnapshotHit>() ; hit != event.end<JDAQSnapshotHit>() ; ++hit){
157
158 if (router.hasModule(hit->getModuleID())) {
159
160 const JModule& module = router.getModule (hit->getModuleID());
161
162 int String = module.getString();
163 int Floor = module.getFloor();
164 int pmt = hit-> getPMT();
165
166 if(analysis_level == 1){
167
168 (*histograms.h_trigger.m_Snapshot_hits_per_pmt)[MAKE_STRING("Detector/DU" + to_string(String))] -> Fill(pmt, Floor);
169
170 }
171
175
176 }else{
177 FATAL("JModuleRouter trying to access non existing identifier: "<< hit->getModuleID());
178 }
179 }
180 }
181 }
#define FATAL(A)
Definition JMessage.hh:67
#define MAKE_STRING(A)
Make string.
Definition JPrint.hh:63
bool hasModule(const JObjectID &id) const
Has module.
const JModule & getModule(const JObjectID &id) const
Get module parameters.
Data structure for a composite optical module.
Definition JModule.hh:75
const JPMT & getPMT(const int index) const
Get PMT.
Definition JModule.hh:172
TriggerHistograms h_trigger
Range of values.
Definition JRange.hh:42
Template const_iterator.
Definition JDAQEvent.hh:68
Auxiliary class for trigger mask.
std::string to_string(const T &value)
Convert value to string.
const char * getTime()
Get current local time conform ISO-8601 standard.
JTriggerbit_t getTriggerBit()
Get the trigger bit.
static const unsigned int NUMBER_OF_TRIGGER_BITS
Number of trigger bits.
Type definition of range.
Definition JHead.hh:43
General purpose string class.
Definition JHead.hh:152
TH2D * h_Triggered_hits_3dmuon_per_module
TH2D * h_Triggered_hits_per_module
JManager< string, TH2D > * m_Snapshot_hits_per_pmt
TH1D * h_tot_distribution_snapshot_hits
TH1D * h_pmt_distribution_snapshot_hits
TH2D * h_Snapshot_hits_per_module
TH1D * h_pmt_distribution_triggered_hits
TH1D * h_tot_distribution_triggered_hits
TH1D * h_Triggered_over_Snapshot_hits

◆ iterateRecoEventTree()

void JRunAnalyzer::iterateRecoEventTree ( JParallelFileScanner< JTypeList< JDAQEvent, JFIT::JEvt > > & scanner,
TFile & f )
inline

Definition at line 189 of file JRunAnalyzer.hh.

189 {
190
191 TH1D* h_tres = new TH1D("h_tres", ";Time residuals [ns]; Entries", 100, -50, 150);
192 TH1D* h_likelihood = new TH1D ("h_likelihood", " ; Likelihood; Reconstructed Events ", 100, -1000, 1000);
193 TH1D* h_beta0 = new TH1D("h_beta0", "; beta0; Reconstructed Events", 20, 0, 1);
194 TH1D* h_energy = new TH1D ("h_energy", " ; Energy [GeV]; Reconstructed Events ", 65, 0, 9);
195 setLogarithmicX(h_energy);
196 TH1D* h_zenith = new TH1D("h_zenith", "; cosZenith; Reconstructed Events", 20, -1, 1);
197 TH1D* h_azimuth = new TH1D("h_azimuth", "; cosAzimuth; Reconstructed Events", 20, -1, 1);
198 TH1D* h_radial_position = new TH1D ("h_radial_position", "; Radial Position [m]; Reconstructed Events", 60, 0, 4.2);
199 setLogarithmicX(h_radial_position);
200 TH1D* h_z_position = new TH1D ("h_z_position", "; Z Position [m] ; Reconstructed Events", 50, 0, 3.2);
201 setLogarithmicX(h_z_position);
202
203 while (scanner.hasNext()) {
204
205 JParallelFileScanner< JTypeList<JDAQEvent, JFIT::JEvt> >::multi_pointer_type ps = scanner.next();
206
207 JEvt* evt = ps;
208 JDAQEvent* event = ps;
209
210 if (!evt->empty()) {
211
212 JEvt::iterator best = evt->begin();
213 h_energy -> Fill(best->getE());
214 h_likelihood -> Fill(best->getQ());
215 h_z_position -> Fill(best->getZ());
216 h_radial_position -> Fill(sqrt(best->getX()*best->getX() + best->getY()*best->getY()));
217
218 JTrack3D track = getTrack(*best);
219 h_zenith -> Fill(cos(track.getDirection().getTheta()));
220 h_azimuth -> Fill(cos(track.getDirection().getPhi()));
221 h_beta0 -> Fill(best->getW(JGANDALF_BETA0_RAD));
222
223 std::vector<JHitL0> dataL0;
224 const JBuildL0<JHitL0> buildL0;
225 buildL0(JDAQTimeslice(*event, false), router, back_inserter(dataL0));
226
227 for (std::vector<JHitL0>::const_iterator hit = dataL0.begin(); hit != dataL0.end(); ++hit) {
228
229 h_tres -> Fill(hit->getT() - track.getT(hit->getPosition()));
230 }
231 }
232 }
233
234 f.mkdir("Reco");
235 f.cd("Reco");
236
237 h_energy->Write();
238 h_likelihood -> Write();
239 h_z_position -> Write();
240 h_radial_position -> Write();
241 h_zenith -> Write();
242 h_azimuth -> Write();
243 h_beta0 -> Write();
244 h_tres -> Write();
245 }
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
Definition JTrack3D.hh:126
JVersor3D getDirection(const JVector3D &pos) const
Get photon direction of Cherenkov light on PMT.
Definition JTrack3D.hh:147
double getTheta() const
Get theta angle.
Definition JVersor3D.hh:128
double getPhi() const
Get phi angle.
Definition JVersor3D.hh:144
General purpose class for parallel reading of objects from a single file or multiple files.
virtual const multi_pointer_type & next() override
Get next element.
virtual bool hasNext() override
Check availability of next element.
Template L0 hit builder.
Definition JBuildL0.hh:38
static const int JGANDALF_BETA0_RAD
KM3NeT Data Definitions v3.6.0 https://git.km3net.de/common/km3net-dataformat.
JTrack3E getTrack(const Trk &track)
Get track.
void setLogarithmicX(TList *list)
Make x-axis of objects in list logarithmic (e.g. after using log10()).
Acoustic event fit.

◆ iterateSummarysliceTree()

void JRunAnalyzer::iterateSummarysliceTree ( JTreeScanner< JDAQSummaryslice > & scanner)
inline

Definition at line 260 of file JRunAnalyzer.hh.

260 {
261
262 using namespace std;
263 using namespace JPP;
264
265 map<int, map<int, dom_type> > PMT_rate_quantiles;
266 map<int, map<int, JQuantile> > DOM_rate_quantiles;
267
268 while (scanner.hasNext()){
269
270 JDAQSummaryslice slice = *(scanner.next());
271
272 for (JDAQSummaryslice::const_iterator frame = slice.begin() ; frame != slice.end() ; ++ frame) {
273
274 if (router.hasModule(frame->getModuleID())) {
275
276 const JModule& module = router.getModule (frame->getModuleID());
277
278 int string = module.getString();
279 int floor = module.getFloor ();
280
281 JDAQFrameStatus status = frame -> getDAQFrameStatus();
282 int nFIFOcount = status.countFIFOStatus();
283 int nHRVcount = status.countHighRateVeto();
284
285 if (nHRVcount > 0) {
286 histograms.h_summary.h_hrv_per_dom->Fill(string , floor, nHRVcount);
287 }
288
289 if (status.testDAQStatus() == false) {
290 histograms.h_summary.h_daq_status_per_dom->Fill(string , floor, (1./distance(scanner.begin(), scanner.end()))*100);
291 }
292
293 histograms.h_summary.h_fifo_per_dom->Fill(string , floor , nFIFOcount);
294
295 if(analysis_level == 1){
296
297 TH2D* h2 = (*histograms.h_summary.m_summary_rate_distribution)[MAKE_STRING("Detector/DU" + to_string(string) + "/F" + to_string(floor))];
298
299 double rate = 0;
300 const double factor = 1.0e-3; // [kHz]
301
302 for (int i = 0 ; i < NUMBER_OF_PMTS ; i++){
303
304 rate += frame->getRate(i, factor);
305
306 h2->Fill(i , frame->getRate(i, factor));
307
308 PMT_rate_quantiles[string][floor][i].put(frame->getRate(i, factor));
309
310 histograms.h_summary.h_pmt_rate_distribution->Fill(frame->getRate(i, factor), frame->getWeight(i, factor));
311
312 }
313
315
316 DOM_rate_quantiles[string][floor].put(rate);
317
318 } else {
319
320 double rate = 0;
321 const double factor = 1.0e-3; // [kHz]
322
323 for (int i = 0 ; i < NUMBER_OF_PMTS ; i++){
324
325 rate += frame->getRate(i, factor);
326
327 histograms.h_summary.h_pmt_rate_distribution->Fill(frame->getRate(i, factor), frame->getWeight(i, factor));
328 }
329
331
332 DOM_rate_quantiles[string][floor].put(rate);
333
334 }
335
336 }else{
337 FATAL("JModuleRouter trying to access non existing identifier: "<< frame->getModuleID());
338 }
339 }
340 }
341
342 for (const auto& i1 : DOM_rate_quantiles) {
343 for (const auto& i2 : i1.second) {
344 if (i2.second.getCount() > 0) {
345 histograms.h_summary.h_rate_summary->Fill(i1.first, i2.first, i2.second.getMean());
346 }
347 }
348 }
349
350 if (analysis_level == 1){
351 for (const auto& i1 : PMT_rate_quantiles){
352
353 TH2D* h2 = (*histograms.h_summary.m_mean_summary_rate) [MAKE_STRING("Detector/DU" + to_string(i1.first))];
354 TH1D* h1 = (*histograms.h_summary.m_mean_summary_rate_distribution)[MAKE_STRING("Detector/DU" + to_string(i1.first))];
355
356 for (const auto& i2 : i1.second) {
357 for (int i3 = 0 ; i3 != NUMBER_OF_PMTS ; ++i3) {
358 if (i2.second[i3].getCount() > 0){
359 h2->Fill(i3, i2.first, i2.second[i3].getMean());
360 h1->Fill(i2.second[i3].getMean());
361 }
362 }
363 }
364 }
365 }
366 }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
SummaryHistograms h_summary
int countHighRateVeto() const
Count high-rate veto status.
int countFIFOStatus() const
Count FIFO status.
bool testDAQStatus() const
Test DAQ status of packets.
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition JDAQ.hh:26
JManager< string, TH1D > * m_mean_summary_rate_distribution
JManager< string, TH2D > * m_mean_summary_rate
JManager< string, TH2D > * m_summary_rate_distribution

◆ iterateTimesliceTree()

template<class T >
void JRunAnalyzer::iterateTimesliceTree ( JTreeScanner< T > & scanner)
inline

Definition at line 374 of file JRunAnalyzer.hh.

374 {
375
377
378 std::map < int , std::map <int , JQuantile> > DOM_rate_quantiles;
379
380 double inverseFrameTimeSec = 1. / (1.0e-9 * getFrameTime());
381
382 while (scanner.hasNext()){
383
384 T slice = *(scanner.next());
385
386 for(auto & frame : slice) {
387 if (router.hasModule(frame.getModuleID())) {
388
389 const JModule& module = router.getModule (frame.getModuleID());
390 double rate = frame.numberOfHits * inverseFrameTimeSec;
391 int string = module.getString();
392 int floor = module.getFloor ();
393
394 DOM_rate_quantiles[string][floor].put(rate);
395
396 vector <int> pmt_hit_count (NUMBER_OF_PMTS , 0) ;
397
398 if(analysis_level == 1){
399
400 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()))];
401
402 for (JDAQSuperFrame::const_iterator hit = frame.begin() ; hit != frame.end() ; ++hit){
403
404 h2 -> Fill(hit->getPMT() , hit->getToT()) ;
405
406 pmt_hit_count[hit->getPMT()]++;
407
408 }
409
410 for (int pmt = 0 ; pmt != NUMBER_OF_PMTS ; ++pmt) {
411
412 (*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);
413
414 }
415
416 }
417
418 }else{
419 FATAL("JModuleRouter trying to access non existing identifier: "<< frame.getModuleID());
420 }
421 }
422 }
423
424 for (std::map< int , std::map<int,JQuantile>>::const_iterator i = DOM_rate_quantiles.begin() ; i != DOM_rate_quantiles.end() ; i++){
425
426 for (std::map<int , JQuantile>::const_iterator j = i->second.begin() ; j != i->second.end() ; j++){
427
428 if (j->second.getCount() > 0) histograms.h_timeslice.h_dom_mean_rates[ts_type] -> Fill (i->first , j->first , j->second.getMean() ) ;
429 }
430 }
431 }
TimesliceHistograms h_timeslice
Hit data structure.
Definition JDAQHit.hh:35
int j
Definition JPolint.hh:801
double getFrameTime()
Get frame time duration.
Definition JDAQClock.hh:162
Indexing of data type in type list.
Definition JTypeList.hh:310
vector< JManager< string, TH2D > * > m_pmt_tot_distributions
vector< JManager< string, TH2D > * > m_pmt_rate_distributions
vector< TH2D * > h_dom_mean_rates

◆ readSummaryData()

void JRunAnalyzer::readSummaryData ( )
inline

Definition at line 438 of file JRunAnalyzer.hh.

438 {
439
440 JTreeScanner <JDAQSummaryslice> scanner(inputFile, numberOfSummaryslices);
441 if (scanner.hasNext()) {
443 scanner.rewind();
445 }
446 }
void initialize_summary_histograms()
void iterateSummarysliceTree(JTreeScanner< JDAQSummaryslice > &scanner)

◆ readTimesliceData()

template<class T >
void JRunAnalyzer::readTimesliceData ( )
inline

Definition at line 454 of file JRunAnalyzer.hh.

454 {
455
456 JTreeScanner <T> scanner(inputFile, numberOfTimeslices);
457 if(scanner.hasNext()) {
458
460 scanner.rewind();
461 iterateTimesliceTree(scanner);
462 }
463 }
void initialize_timeslice_histograms()
void iterateTimesliceTree(JTreeScanner< T > &scanner)

◆ readEvents()

void JRunAnalyzer::readEvents ( )
inline

Definition at line 470 of file JRunAnalyzer.hh.

470 {
471
472 JTreeScanner <JDAQEvent> scanner(inputFile, numberOfEvents);
473
474 if(scanner.hasNext()) {
475
477 scanner.rewind();
478 iterateEventTree(scanner);
479 }
480 }
void initialize_trigger_histograms()
void iterateEventTree(JTreeScanner< JDAQEvent > &scanner)

◆ readRecoEvents()

void JRunAnalyzer::readRecoEvents ( )
inline

Definition at line 486 of file JRunAnalyzer.hh.

486 {
487
488 JParallelFileScanner< JTypeList<JDAQEvent, JFIT::JEvt> > scanner(inputFile, numberOfEvents);
489
490 if(scanner.hasNext()) {
491
492 scanner.rewind();
494 }
495 }
void iterateRecoEventTree(JParallelFileScanner< JTypeList< JDAQEvent, JFIT::JEvt > > &scanner, TFile &f)

◆ writeToFile()

void JRunAnalyzer::writeToFile ( TFile * f,
int analysis_level )
inline

Definition at line 501 of file JRunAnalyzer.hh.

501 {
502
503 f->mkdir("Detector");
504 f->cd("Detector");
505
512
514
515 for (typename vector < JManager < string , TH2D >* >::const_iterator i = histograms.h_timeslice.m_pmt_tot_distributions.begin();
517
518 if ((*i)){
519
520 for (typename JManager < string , TH2D >::const_iterator j = (*i) -> begin() ; j != (*i) -> end() ; ++j){
521
522 j->second->Scale(1., "width");
523 }
524 }
525 }
526
529
531
534
536
539
540 f->mkdir ( MAKE_STRING ("JDAQEvent").c_str());
541 f->cd ("JDAQEvent");
542
559
560 }
void Write_manager_table_in_key_dir(TFile &f, vector< JManager< T, V > * > table)
void Write_manager_in_key_dir(TFile &f, JManager< T, V > *manager)
void Write_histogram_table_to_file(TFile &f, string dirname, vector< vector< T * > > table)
vector< JManager< string, TH2D > * > m_mean_ToT
vector< JManager< string, TH1D > * > m_mean_ToT_distribution

Member Data Documentation

◆ inputFile

JSingleFileScanner JRunAnalyzer::inputFile
private

Definition at line 39 of file JRunAnalyzer.hh.

◆ router

JModuleRouter JRunAnalyzer::router
private

Definition at line 40 of file JRunAnalyzer.hh.

◆ outputFile

TFile* JRunAnalyzer::outputFile
private

Definition at line 41 of file JRunAnalyzer.hh.

◆ histograms

JRA_Histograms JRunAnalyzer::histograms
private

Definition at line 42 of file JRunAnalyzer.hh.

◆ numberOfTimeslices

JLimit_t JRunAnalyzer::numberOfTimeslices
private

Definition at line 43 of file JRunAnalyzer.hh.

◆ numberOfSummaryslices

JLimit_t JRunAnalyzer::numberOfSummaryslices
private

Definition at line 44 of file JRunAnalyzer.hh.

◆ numberOfEvents

JLimit_t JRunAnalyzer::numberOfEvents
private

Definition at line 45 of file JRunAnalyzer.hh.

◆ analysis_level

int JRunAnalyzer::analysis_level
private

Definition at line 46 of file JRunAnalyzer.hh.


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