KaliVeda
Toolkit for HIC analysis
KVRawDataAnalyser.h
1 
4 #ifndef __KVRAWDATAANALYSER_H
5 #define __KVRAWDATAANALYSER_H
6 
7 #include "KVDataSetAnalyser.h"
8 #include "KVHashList.h"
9 #include "KVRawDataReader.h"
10 #include "KVDBRun.h"
11 #include "KVRawDataPatchList.h"
12 #include <KVUserAnalysisOptionList.h>
13 #include <TH2.h>
14 #include <TH3.h>
15 #include <TProfile.h>
16 #include <TProfile2D.h>
17 
18 class KVDetectorEvent;
19 
44 protected:
45 
56 
58 
59  void ProcessRun();
60 
62 
63  /*** Methods copied from KVEventSelector ***/
64  void add_histo(TH1* histo)
65  {
66  fHistoList.Add(histo);
67  }
69  {
71  if (!fTreeFile) {
72  Error("AddTree", "You must call CreateTreeFile(const Char_t*) before using this method!");
73  return;
74  }
75  tree->SetDirectory(fTreeFile);
76  tree->AutoSave();
78  }
79 
80  void FillTH1(TH1* h1, Double_t one, Double_t two)
81  {
82  h1->Fill(one, two);
83  }
84  void FillTProfile(TProfile* h1, Double_t one, Double_t two, Double_t three)
85  {
86  h1->Fill(one, two, three);
87  }
88  void FillTH2(TH2* h2, Double_t one, Double_t two, Double_t three)
89  {
90  h2->Fill(one, two, three);
91  }
92  void FillTProfile2D(TProfile2D* h2, Double_t one, Double_t two, Double_t three, Double_t four)
93  {
94  h2->Fill(one, two, three, four);
95  }
96  void FillTH3(TH3* h3, Double_t one, Double_t two, Double_t three, Double_t four)
97  {
98  h3->Fill(one, two, three, four);
99  }
100 
101  void SetCombinedOutputFile(const KVString& filename)
102  {
111  }
112  /*** END: Methods copied from KVEventSelector ***/
113 
114 public:
116  {
117  return TotalEntriesToRead;
118  }
119 
121  virtual ~KVRawDataAnalyser();
122 
123  virtual void InitAnalysis() = 0;
124  virtual void InitRun() = 0;
125  virtual Bool_t Analysis() = 0;
126  virtual void EndRun() = 0;
127  virtual void EndAnalysis() = 0;
128 
130  {
131  return fRunNumber.run();
132  }
134  {
137  return fRunNumber;
138  }
140  {
142  return fEventNumber;
143  }
145  {
148  return fCurrentRun;
149  }
151  {
154  return &gExpDB->GetDBRunFile(GetRunIndexNumber());
155  }
156 
157  void SubmitTask() override;
158  static void Make(const Char_t* kvsname = "MyOwnRawDataAnalyser");
159 
161 
163  {
164  return *fRunFile;
165  }
166 
167  /*** Methods copied from KVEventSelector ***/
168 
184  template<typename HistoType, typename... Args>
185  HistoType* AddHisto(Args&& ... args)
186  {
187  auto h = new HistoType(std::forward<Args>(args)...);
188  add_histo(h);
189  return h;
190  }
191  void AddHisto(TH1* histo)
192  {
193  Deprecate(Form("You should use e.g. 'auto h = AddHisto<%s>(\"%s\",\"%s\",%d,...);' to add histograms to your analysis.",
194  histo->ClassName(), histo->GetName(), histo->GetTitle(), histo->GetNbinsX()));
195  add_histo(histo);
196  }
205  TTree* AddTree(const TString& name, const TString& title = "")
206  {
207  CreateTreeFile();
208  auto t = new TTree(name, title);
209  add_tree(t);
210  return t;
211  }
213  {
214  Deprecate(Form("You should use e.g. 'auto t = AddTree(\"%s\", \"%s\");' to add a TTree to your analysis",
215  tree->GetName(), tree->GetTitle()));
216  add_tree(tree);
217  }
218 
219  void FillHisto(const Char_t* sname, Double_t one, Double_t two = 1, Double_t three = 1, Double_t four = 1);
220  void FillHisto(const Char_t* sname, const Char_t* label, Double_t weight = 1);
221  void FillTree(const Char_t* sname = "");
222 
223  const KVHashList* GetHistoList() const
224  {
225  return &fHistoList;
226  }
227  const KVHashList* GetTreeList() const
228  {
229  return &fTreeList;
230  }
231 
232  TH1* GetHisto(const Char_t* name) const
233  {
234  return fHistoList.get_object<TH1>(name);
235  }
236  TTree* GetTree(const Char_t* name) const
237  {
238  return fTreeList.get_object<TTree>(name);
239  }
240 
241  virtual void SaveHistos(const Char_t* filename = "", Option_t* option = "recreate", Bool_t onlyfilled = kFALSE);
242  void SetJobOutputFileName(const TString& filename)
243  {
250 
252  SetCombinedOutputFile(Form("%s.root", GetBatchSystem()->GetJobName()));
253  else
255  }
256  Bool_t CreateTreeFile(const Char_t* filename = "");
257 
258  void SetOpt(const Char_t* option, const Char_t* value)
259  {
261  }
262  Bool_t IsOptGiven(const Char_t* option)
263  {
264  return fOptionList.IsOptGiven(option);
265  }
266  TString GetOpt(const Char_t* option) const
267  {
268  return fOptionList.GetOpt(option);
269  }
270  void UnsetOpt(const Char_t* opt)
271  {
272  fOptionList.UnsetOpt(opt);
273  }
274  /*** END: Methods copied from KVEventSelector ***/
275 
276  ClassDefOverride(KVRawDataAnalyser, 1) //Abstract base class for user analysis of raw data
277 };
278 
279 #endif
int Int_t
bool Bool_t
char Char_t
double Double_t
const char Option_t
#define ClassDefOverride(name, id)
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
char * Form(const char *fmt,...)
A single raw data file associated with an experimental run ,,.
Definition: KVDBRunFile.h:38
Description of an experimental run in database ,,.
Definition: KVDBRun.h:40
virtual const KVBatchSystem * GetBatchSystem()
static Bool_t IsRunningBatchAnalysis()
Pilots user analysis of experimental data.
List of hit groups in a multidetector array.
const KVDBRunFile & GetDBRunFile(const run_index_t &r) const
Definition: KVExpDB.h:93
Extended version of ROOT THashList.
Definition: KVHashList.h:29
Abstract base class for user analysis of raw data.
virtual Bool_t Analysis()=0
const KVHashList * GetTreeList() const
void add_histo(TH1 *histo)
KVHashList fHistoList
list of histograms of user analysis
KVRawDataReader * fRunFile
currently analysed run file
void FillTProfile(TProfile *h1, Double_t one, Double_t two, Double_t three)
void SubmitTask() override
virtual void InitRun()=0
virtual void SaveHistos(const Char_t *filename="", Option_t *option="recreate", Bool_t onlyfilled=kFALSE)
KVRawDataAnalyser()
Default constructor.
void FillTProfile2D(TProfile2D *h2, Double_t one, Double_t two, Double_t three, Double_t four)
KVHashList fTreeList
list of trees of user analysis
Bool_t IsOptGiven(const Char_t *option)
KVString fCombinedOutputFile
optional name for single results file with trees and histos
TTree * AddTree(const TString &name, const TString &title="")
Long64_t fEventNumber
event number in current run
virtual void EndAnalysis()=0
Bool_t CreateTreeFile(const Char_t *filename="")
Long64_t GetEventNumber() const
void FillTree(const Char_t *sname="")
Int_t GetRunNumber() const
void FillTH3(TH3 *h3, Double_t one, Double_t two, Double_t three, Double_t four)
void FillHisto(const Char_t *sname, Double_t one, Double_t two=1, Double_t three=1, Double_t four=1)
KVDBRun * GetCurrentRun() const
void add_tree(TTree *tree)
void SetJobOutputFileName(const TString &filename)
void UnsetOpt(const Char_t *opt)
virtual ~KVRawDataAnalyser()
Destructor.
static void Make(const Char_t *kvsname="MyOwnRawDataAnalyser")
Automatic generation of derived class for raw data analysis.
void FillTH1(TH1 *h1, Double_t one, Double_t two)
HistoType * AddHisto(Args &&... args)
KVRawDataPatchList fRustines
void AddHisto(TH1 *histo)
virtual void InitAnalysis()=0
void CalculateTotalEventsToRead()
loop over runs and calculate total events
const KVRawDataReader & GetRunFileReader() const
KVDBRun * fCurrentRun
poiner to current run
TString GetOpt(const Char_t *option) const
KVUserAnalysisOptionList fOptionList
list of options set by user for analysis
Long64_t GetTotalEntriesToRead() const override
const run_index_t & GetRunIndexNumber() const
const KVHashList * GetHistoList() const
run_index_t fRunNumber
run number of current file
void FillTH2(TH2 *h2, Double_t one, Double_t two, Double_t three)
void SetCombinedOutputFile(const KVString &filename)
virtual void EndRun()=0
TTree * GetTree(const Char_t *name) const
void AddTree(TTree *tree)
TH1 * GetHisto(const Char_t *name) const
KVDBRunFile * GetCurrentRunFile() const
void AbortDuringRunProcessing()
Method called to abort analysis during processing of a run.
void SetOpt(const Char_t *option, const Char_t *value)
List of corrections to be applied to raw data.
Abstract base class for reading raw (DAQ) data.
T * get_object(const TString &name) const
void Add(TObject *obj) override
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:73
Handle list of options and input parameters for user analyis .
void SetOpt(const Char_t *option, const Char_t *value)
TString GetOpt(const Char_t *opt) const
Bool_t IsOptGiven(const Char_t *opt)
void UnsetOpt(const Char_t *opt)
virtual Int_t GetNbinsX() const
virtual Int_t Fill(const char *name, Double_t w)
virtual Int_t Fill(const char *namex, const char *namey, Double_t w)
virtual Int_t Fill(const char *namex, const char *namey, const char *namez, Double_t w)
const char * GetName() const override
const char * GetTitle() const override
virtual const char * ClassName() const
virtual void Error(const char *method, const char *msgfmt,...) const
virtual Int_t Fill(const char *namex, const char *namey, Double_t z, Double_t w=1.)
Specifies a runfile according to run number and file index ,.
Definition: run_index.h:33
int run() const
Definition: run_index.h:52
long long Long64_t
TH1F * h1
TH1 * h