Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JDomAnalyser.cc File Reference
#include <iostream>
#include <iomanip>
#include "JSupport/JSupport.hh"
#include "JSupport/JSupportToolkit.hh"
#include "JSupport/JMeta.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JGizmo/JManager.hh"
#include "Jeep/JParser.hh"
#include "km3net-dataformat/online/JDAQPMTIdentifier.hh"
#include "km3net-dataformat/online/JDAQ.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "TH1D.h"
#include "TMath.h"

Go to the source code of this file.

Functions

void BinLogX (TH1 *h)
 
int main (int argc, char **argv)
 

Function Documentation

void BinLogX ( TH1 *  h)
inline

Definition at line 30 of file JDomAnalyser.cc.

30  {
31 
32  TAxis *axis = h->GetXaxis();
33  int bins = axis->GetNbins();
34  Axis_t min = axis->GetXmin();
35  Axis_t max = axis->GetXmax();
36  Axis_t width = (max - min) / bins;
37  Axis_t *new_bins = new Axis_t[bins + 1];
38 
39  for (int i = 0; i <= bins; i++) {
40  new_bins[i] = TMath::Power(10, min + i * width);
41  }
42 
43  axis->Set(bins, new_bins);
44  delete new_bins;
45 }
int main ( int  argc,
char **  argv 
)

Definition at line 48 of file JDomAnalyser.cc.

48  {
49 
50  string inputFile;
51  JLimit_t nSlices;
52  string outputFile;
53  string detectorFile;
54 
55  try {
56 
57  JParser<> zap;
58 
59  zap['f'] = make_field(inputFile , "Path to input file ");
60  zap['o'] = make_field(outputFile , "Path to output file") = "out.root";
61  zap['s'] = make_field(nSlices , "number of slices" ) = JLimit::max();
62 
63  zap(argc,argv);
64  }
65  catch(const exception &error) {
66  ERROR(error.what() << endl);
67  }
68 
69  JMultipleFileScanner<JDAQTimeslice> scanner(inputFile,nSlices);
70 
71  const double factor = 1./(1.0e-6 * getFrameTime()); // [kHz]
72 
73  TH1D* h1 = new TH1D("rate_%", NULL, 100, -2, 2);
74  TH1D* h2 = new TH1D("time_%", NULL, 1, -0.5, 0.5);
75 
76  if (scanner.hasNext()){
78  h2->SetBins(range.second-range.first+1, -0.5, range.second-range.first + 0.5);
79  }
80 
81  BinLogX(h1);
82 
85 
86  while (scanner.hasNext()) {
87 
88  JDAQTimeslice* slice = scanner.next();
89 
90  for(JDAQTimeslice::const_iterator frame = slice->begin() ; frame != slice->end() ; ++frame) {
91 
92  vector <int> pmt_hit_count (NUMBER_OF_PMTS , 0) ;
93 
94  for (JDAQSuperFrame::const_iterator hit = frame->begin() ; hit != frame->end() ; ++hit){
95  pmt_hit_count[hit->getPMT()]++;
96  }
97 
98  for (int pmt = 0 ; pmt != NUMBER_OF_PMTS ; ++pmt) {
99  r[JDAQPMTIdentifier(frame->getModuleID(),pmt)]->Fill(pmt_hit_count[pmt]*factor);
100  t[JDAQPMTIdentifier(frame->getModuleID(),pmt)]->Fill(slice->getFrameIndex(), pmt_hit_count[pmt]*factor);
101  }
102  }
103  }
104 
105  for (typename JManager < JDAQPMTIdentifier , TH1D >::const_iterator i = r.begin() ; i != r.end() ; ++i){
106 
107  for(int j=1 ; j < i -> second -> GetNbinsX() ; ++j){
108 
109  double width = i->second->GetXaxis()->GetBinWidth(j);
110  i -> second->SetBinContent(j ,i->second->GetBinContent(j)/width);
111  i -> second->SetBinError (j ,i->second->GetBinError (j)/width);
112  }
113  }
114 
115  TFile out(outputFile.c_str(), "recreate");
116  putObject(&out, JMeta(argc, argv));
117  JMeta::copy(inputFile.c_str(), out);
118  r.Write(out);
119  t.Write(out);
120 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:71
Utility class to parse command line options.
Definition: JParser.hh:1493
void BinLogX(T *h)
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
data_type r[M+1]
Definition: JPolint.hh:709
string outputFile
Template definition for direct access of elements in ROOT TChain.
Definition: JTreeScanner.hh:91
int getFrameIndex() const
Get frame index.
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
Auxiliary class to manage set of compatible ROOT objects (e.g.
Definition: JManager.hh:42
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Hit data structure.
Definition: JDAQHit.hh:34
int getFrameIndex(const double t_ns)
Get frame index for a given time in ns.
Definition: JDAQClock.hh:251
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
double getFrameTime()
Get frame time duration.
Definition: JDAQClock.hh:162
#define ERROR(A)
Definition: JMessage.hh:66
Data time slice.
General purpose class for object reading from a list of file names.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:153
int j
Definition: JPolint.hh:634
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Definition: JDAQ.hh:26
bool putObject(TDirectory *dir, const T &object)
Write object to ROOT directory.