Jpp  test_elongated_shower_pde
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JMergeRunAnalyzer.cc File Reference
#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TH2D.h"
#include "TKey.h"
#include "TString.h"
#include "TMath.h"
#include "TTimeStamp.h"
#include "km3net-dataformat/online/JDAQHeader.hh"
#include "JROOT/JRootFileReader.hh"
#include "JROOT/JRootFileWriter.hh"
#include "JSupport/JMeta.hh"
#include "JTrigger/JTriggerInterface.hh"
#include "JTrigger/JTriggerBits.hh"
#include "JGizmo/JGizmoToolkit.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

void fill2DHistogram (int run, TH1D *h1, TH2D *h2, bool norm=false)
 
int main (int argc, char **argv)
 

Function Documentation

void fill2DHistogram ( int  run,
TH1D *  h1,
TH2D *  h2,
bool  norm = false 
)
inline
Author
adomi Auxiliary program to merge JRunAnalyzer histograms.

Definition at line 38 of file JMergeRunAnalyzer.cc.

38  {
39 
40  double normalisation = 1;
41  if(norm) normalisation = h1->Integral();
42 
43  for(int i = 1; i <= h1->GetNbinsX(); ++i){
44 
45  h2->Fill(run, h1->GetXaxis()->GetBinCenter(i), h1->GetBinContent(i)/normalisation);
46  }
47 }
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
int main ( int  argc,
char **  argv 
)

Definition at line 49 of file JMergeRunAnalyzer.cc.

50 {
51  using namespace std;
52  using namespace JPP;
53  using namespace KM3NETDAQ;
54 
55  vector<string> inputFile;
56  string outputFile;
57  int debug;
58 
59  try {
60 
61  JParser<> zap("Auxiliary program to merge JRunAnalyzer histograms.");
62 
63  zap['f'] = make_field(inputFile, "input file (output from JRunAnalyzer).");
64  zap['o'] = make_field(outputFile, "output file.") = "merge-jra.root";
65  zap['d'] = make_field(debug, "debug.") = 1;
66 
67  zap(argc, argv);
68  }
69  catch(const exception &error) {
70  FATAL(error.what() << endl);
71  }
72 
73  int min_run = numeric_limits<int>::max(), max_run = 0;
74 
75  size_t min_date = numeric_limits<int>::max(), max_date = 0;
76 
77  for (vector<string>::const_iterator i = inputFile.begin(); i != inputFile.end(); ++i) {
78 
79  TFile in(i->c_str(), "read");
80 
81  for (JRootFileReader<JDAQHeader> in(i->c_str()); in.hasNext(); ) {
82 
83  const JDAQHeader* p = in.next();
84 
85  if(p->getTimesliceStart().getUTCseconds() < min_date) min_date = p->getTimesliceStart().getUTCseconds();
86  if(p->getTimesliceStart().getUTCseconds() > max_date) max_date = p->getTimesliceStart().getUTCseconds();
87  if(p->getRunNumber() < min_run) min_run = p->getRunNumber();
88  if(p->getRunNumber() > max_run) max_run = p->getRunNumber();
89 
90  }
91 
92  in.Close();
93  }
94 
95  time_t tmin = min_date, tmax = max_date;
96 
97  TTimeStamp date_min(tmin, 0);
98  TTimeStamp date_max(tmax, 0);
99 
100  cout << "Minimum RUN: " << min_run << ", "; date_min.Print("s");
101  cout << "Maximum RUN: " << max_run << ", "; date_max.Print("s");
102 
103  TFile out(outputFile.c_str(), "recreate");
104 
105  int xbins = (max_run - min_run) + 1;
106  string title = string("Data taken from: ") + date_min.AsString("s") + " - " + date_max.AsString("s");
107 
108  TH2D* h_pmt_rate_distribution = new TH2D("h_pmt_rate_distribution", string(title + "; RUN; PMT Rate Distribution [kHz]").c_str(), xbins, (double) min_run-0.5, (double) max_run+0.5, JDAQRate::getN(), JDAQRate::getData(1.0e-4));
109 
110  TH2D* h_Trigger_bit_hit = new TH2D("h_Trigger_bit_hit", string(title + "; RUN; Hits trigger bit").c_str(), xbins, (double) min_run-0.5, (double) max_run+0.5, NUMBER_OF_TRIGGER_BITS, -0.5, NUMBER_OF_TRIGGER_BITS - 0.5);
111 
112  TH2D* h_Triggered_hits = new TH2D("h_Triggered_hits", string(title + "; RUN; Number of triggered hits").c_str(), xbins, (double) min_run-0.5, (double) max_run+0.5, 50, 0, 4);
113  setLogarithmicY(h_Triggered_hits);
114 
115  TH2D* h_Triggered_hits_3dmuon = new TH2D("h_Triggered_hits_3dmuon", string(title + "; RUN; Number of triggered hits - JTRIGGER3DMUON").c_str(), xbins, (double) min_run-0.5, (double) max_run+0.5, 50, 0, 3);
116  setLogarithmicY(h_Triggered_hits_3dmuon);
117 
118  TH2D* h_Snapshot_hits = new TH2D("h_Snapshot_hits", string(title + "; RUN; Number of snapshot hits").c_str(), xbins, (double) min_run-0.5, (double) max_run+0.5, 50, 0, 4);
119  setLogarithmicY(h_Snapshot_hits);
120 
121  TH2D* h_Triggered_over_Snapshot_hits = new TH2D("h_Triggered_over_Snapshot_hits", string(title + "; RUN; Triggered/Snapshot hits").c_str(), xbins, (double) min_run-0.5, (double) max_run+0.5, 100, 0, 0.5);
122 
123  TH2D* h_Number_of_overlays = new TH2D("h_Number_of_overlays", string(title + "; RUN; Number of Overlays").c_str(), xbins, (double) min_run-0.5, (double) max_run+0.5, 1000, -0.5, 1000 - 0.5);
124 
125  TH2D* h_pmt_distribution_triggered_hits = new TH2D("h_pmt_distribution_triggered_hits", string(title + "; RUN;Normalised PMT Distrib triggered hits (upper PMTs=[0-11])").c_str(), xbins, (double) min_run-0.5, (double) max_run+0.5, NUMBER_OF_PMTS, -0.5 , NUMBER_OF_PMTS - 0.5);
126 
127  TH2D* h_pmt_distribution_snapshot_hits = new TH2D("h_pmt_distribution_snapshot_hits", string(title + "; RUN; Normalised PMT Distrib snapshot hits (upper PMTs=[0-11])").c_str(), xbins, (double) min_run-0.5, (double) max_run+0.5, NUMBER_OF_PMTS, -0.5 , NUMBER_OF_PMTS - 0.5);
128 
129  TH2D* h_event_duration = new TH2D("h_event_duration", string(title + "; RUN; Event Duration [ns]").c_str(), xbins, (double) min_run-0.5, (double) max_run+0.5, 60, 1, 6);
130  setLogarithmicY(h_event_duration);
131 
132  for (vector<string>::const_iterator i = inputFile.begin(); i != inputFile.end(); ++i) {
133 
134  DEBUG("Processing " << *i << endl) ;
135 
136  TFile in(i->c_str(), "read");
137 
138  cout << i->c_str() << endl;
139 
140  int run = 0;
141 
142  for (JRootFileReader<JDAQHeader> in(i->c_str()); in.hasNext(); ) {
143 
144  const JDAQHeader* p = in.next();
145 
146  run = p->getRunNumber();
147 
148  }
149 
150  TH1D* h1d_prd = new TH1D();
151  TH1D* h1d_thb = new TH1D();
152  TH1D* h1d_th = new TH1D();
153  TH1D* h1d_th3D = new TH1D();
154  TH1D* h1d_sh = new TH1D();
155  TH1D* h1d_tosh = new TH1D();
156  TH1D* h1d_noo = new TH1D();
157  TH1D* h1d_pdth = new TH1D();
158  TH1D* h1d_pdsh = new TH1D();
159  TH1D* h1d_ed = new TH1D();
160 
161  in.GetDirectory("Detector")->GetObject("h_pmt_rate_distribution", h1d_prd);
162  fill2DHistogram(run, h1d_prd, h_pmt_rate_distribution);
163 
164  TDirectory* dir = in.GetDirectory("JDAQEvent");
165 
166  dir->GetObject("h_Trigger_bit_hit", h1d_thb);
167  fill2DHistogram(run, h1d_thb, h_Trigger_bit_hit);
168 
169  dir->GetObject("h_Triggered_hits", h1d_th);
170  fill2DHistogram(run, h1d_th, h_Triggered_hits);
171 
172  dir->GetObject("h_Triggered_hits_3dmuon", h1d_th3D);
173  fill2DHistogram(run, h1d_th3D, h_Triggered_hits_3dmuon);
174 
175  dir->GetObject("h_Snapshot_hits", h1d_sh);
176  fill2DHistogram(run, h1d_sh, h_Snapshot_hits);
177 
178  dir->GetObject("h_Triggered_over_Snapshot_hits", h1d_tosh);
179  fill2DHistogram(run, h1d_tosh, h_Triggered_over_Snapshot_hits);
180 
181  dir->GetObject("h_Number_of_overlays", h1d_noo);
182  fill2DHistogram(run, h1d_noo, h_Number_of_overlays);
183 
184  dir->GetObject("h_pmt_distribution_triggered_hits", h1d_pdth);
185  fill2DHistogram(run, h1d_pdth, h_pmt_distribution_triggered_hits);
186 
187  dir->GetObject("h_pmt_distribution_snapshot_hits", h1d_pdsh);
188  fill2DHistogram(run, h1d_pdsh, h_pmt_distribution_snapshot_hits);
189 
190  dir->GetObject("h_event_duration", h1d_ed);
191  fill2DHistogram(run, h1d_ed, h_event_duration);
192 
193  in.Close();
194 
195  }
196 
197  out.Write();
198  out.Close();
199 
200 }
Utility class to parse command line options.
Definition: JParser.hh:1500
double getN(const JRange< T > &range, const double R)
Get expected number of occurrences due to given rate within specified interval.
Definition: JRange.hh:713
JDAQUTCExtended getTimesliceStart() const
Get start of timeslice.
static const unsigned int NUMBER_OF_TRIGGER_BITS
Number of trigger bits.
string outputFile
int getRunNumber() const
Get run number.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:68
JUINT32_t getUTCseconds() const
Get time.
void setLogarithmicY(TList *list)
Make y-axis of objects in list logarithmic (e.g. after using log10()).
#define FATAL(A)
Definition: JMessage.hh:67
void fill2DHistogram(int run, TH1D *h1, TH2D *h2, bool norm=false)
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:42
ROOT file reader.