KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVFAZIAReconDataAnalyser.cpp
1/*
2$Id: KVFAZIAReconDataAnalyser.cpp,v 1.4 2007/11/15 14:59:45 franklan Exp $
3$Revision: 1.4 $
4$Date: 2007/11/15 14:59:45 $
5*/
6
7//Created by KVClassFactory on Wed Apr 5 23:50:04 2006
8//Author: Eric Bonnet
9
10#include "KVFAZIAReconDataAnalyser.h"
11#include "KVDataSet.h"
12#include "KVMultiDetArray.h"
13
14using namespace std;
15
18// For analysing reconstructed FAZIA data
19//
21
24
26{
27 //Default constructor
28 theTree = 0;
29 fLinkRawData = kFALSE;
30}
31
32
33
36
41
42
43
44
47
49{
50 //Run the interactive analysis
51 if (gDataSet != GetDataSet()) GetDataSet()->cd();
52
55 fLinkRawData = optl.IsOptGiven("ReadRawData");
56
57 //loop over runs
58 GetRunList().Begin();
59 while (!GetRunList().End()) {
61 Info("SubmitTask", "treatment of run# %d", fRunNumber);
62 ProcessRun();
63 }
64}
65
66
67
76
78{
79 // Perform treatment of a given run
80 // Before processing each run, after opening the associated file, user's InitRun() method is called.
81 // After each run, user's EndRun() is called.
82 // For each event of each run, user's Analysis() method is called.
83 //
84 // For further customisation, the pre/post-methods are called just before and just after
85 // each of these methods (preInitRun(), postAnalysis(), etc. etc.)
86 TString fullPathToRunfile = gDataSet->GetFullPathToRunfile(GetDataType(), fRunNumber);
88 if (!(f && !f->IsZombie())) {
89 Error("ProcessRun", "file %s does not exist or is made zombie", fullPathToRunfile.Data());
90 return;
91 }
92
93 theTree = (TTree*)f->Get("ReconstructedEvents");
94
95 TFile* ffriend = 0;
96 if (fLinkRawData) {
97 fullPathToRunfile = gDataSet->GetFullPathToRunfile("raw", fRunNumber);
98 ffriend = gDataSet->OpenRunfile<TFile>("raw", fRunNumber);
99 if (!(ffriend && !ffriend->IsZombie())) {
100 Warning("ProcessRun", "file %s does not exist or is made zombie\n Reading of raw data is not possible", fullPathToRunfile.Data());
101 }
102 else {
103 theTree->AddFriend("FAZIA", ffriend);
104 }
105 }
106
107 TString option("");
108 // Add any user-defined options
109 if (GetUserClassOptions() != "") {
110 if (option != "")
111 option += ",";
113 }
114
115 Info("SubmitTask", "Beginning TTree::Process... Option=%s", option.Data());
116 if (GetNbEventToRead()) {
118 }
119 else {
121 }
122
123 if (ffriend && ffriend->IsOpen())
124 ffriend->Close();
125 f->Close();
126
127}
128
129
130// fSelector = 0;
131//
132// //if (theChain) delete theChain;
133// theChain = new TChain("ReconstructedEvents");
134// theChain->SetDirectory(0); // we handle delete
135//
136// //if (theFriendChain) delete theFriendChain;
137// if (fLinkRawData) {
138// theFriendChain = new TChain("FAZIA");
139// theFriendChain->SetDirectory(0); // we handle delete
140// } else {
141// theFriendChain = 0;
142// }
143//
144// fRunList.Begin();
145// Int_t run;
146//
147// // open and add to TChain all required files
148// // we force the opening of the files to avoid problems with xrootd which sometimes
149// // seems to have a little difficulty
150// while (!fRunList.End()) {
151// run = fRunList.Next();
152//
153// //Add run file
154// TString fullPathToRunfile = gDataSet->GetFullPathToRunfile(fDataType.Data(), run);
155// cout << "Opening file " << fullPathToRunfile << endl;
156// TFile* f = (TFile*)gDataSet->OpenRunfile(fDataType.Data(), run);
157// cout << "Adding file " << fullPathToRunfile;
158// cout << " to the TChain." << endl;
159// theChain->Add(fullPathToRunfile);
160// if (f && !f->IsZombie()) {
161// // update run infos in available runs file if necessary
162// KVAvailableRunsFile* ARF = gDataSet->GetAvailableRunsFile(fDataType.Data());
163// if (ARF->InfosNeedUpdate(run, gSystem->BaseName(fullPathToRunfile))) {
164// if (!((TTree*)f->Get("ReconstructedEvents"))) {
165// Error("SubmitTask", "No tree named ReconstructedEvents is present in the current file");
166// delete theChain;
167// return;
168// }
169// TEnv* treeInfos = (TEnv*)((TTree*)f->Get("ReconstructedEvents"))->GetUserInfo()->FindObject("TEnv");
170// if (treeInfos) {
171// TString kvversion = treeInfos->GetValue("KVBase::GetKVVersion()", "");
172// TString username = treeInfos->GetValue("gSystem->GetUserInfo()->fUser", "");
173// if (kvversion != "") ARF->UpdateInfos(run, gSystem->BaseName(fullPathToRunfile), kvversion, username);
174// } else {
175// Info("SubmitTask", "No TEnv object associated to the tree");
176// }
177// }
178// }
179//
180// //Add run file
181// if (theFriendChain) {
182// fullPathToRunfile = gDataSet->GetFullPathToRunfile("raw", run);
183// cout << "Opening file " << fullPathToRunfile << endl;
184// f = (TFile*)gDataSet->OpenRunfile("raw", run);
185// cout << "Adding file " << fullPathToRunfile;
186// cout << " to the friend TChain." << endl;
187// theFriendChain->Add(fullPathToRunfile);
188// }
189// }
190//
191// if (theFriendChain) theChain->AddFriend("FAZIA");
192//
193// TotalEntriesToRead = theChain->GetEntries();
194// TString option("");
195// if (fDataSelector.Length()) {
196// option.Form("DataSelector=%s", fDataSelector.Data());
197// cout << "Data Selector : " << fDataSelector.Data() << endl;
198// }
199//
200// // Add any user-defined options
201// if (GetUserClassOptions() != "") {
202// option += ",";
203// option += GetUserClassOptions();
204// }
205//
206// fSelector = (TSelector*)GetInstanceOfUserClass();
207//
208// if (!fSelector || !fSelector->InheritsFrom("TSelector")) {
209// cout << "The selector \"" << GetUserClass() << "\" is not valid." << endl;
210// cout << "Process aborted." << endl;
211// } else {
212// SafeDelete(fSelector);
213// Info("SubmitTask", "Beginning TChain::Process...%s %s", GetUserClass(), option.Data());
214// if (nbEventToRead) {
215// theChain->Process(GetUserClass(), option.Data(), nbEventToRead);
216// } else {
217// theChain->Process(GetUserClass(), option.Data());
218// }
219// }
220//
221// if (theFriendChain) {
222// theChain->RemoveFriend(theFriendChain);
223// delete theFriendChain;
224// theFriendChain = 0;
225// }
226// delete theChain;
227// theChain = 0;
228// fSelector = 0; //deleted by TChain/TTreePlayer
229
230
231
232
239
241{
242 // Called by currently-processed KVFAZIASelector before user's InitAnalysis() method.
243 // We build the multidetector for the current dataset in case informations on
244 // detector are needed e.g. to define histograms in InitAnalysis().
245 // Note that at this stage we are not analysing a given run, so the parameters
246 // of the array are not set (they will be set in preInitRun()).
247
248 Info("preInitAnalysis", "Appel");
249 if (gDataSet && !gMultiDetArray) {
250 Info("preInitAnalysis", "Building of FAZIA array");
252 }
253
254}
255
256
257
258
263
265{
266 // Called by currently-processed KVFAZIASelector when a new file in the TChain is opened.
267 // We call gFazia->SetParameters for the current run.
268
269 // Infos on currently read file/tree are printed.
270
271 Info("preInitRun", "Appel");
272 gMultiDetArray->SetParameters(fRunNumber);
273}
274
275
276
277
#define f(i)
constexpr Bool_t kFALSE
Option_t Option_t option
const KVString & GetUserClassOptions() const
const Char_t * GetUserClass()
const KVString & GetDataType() const
Long64_t GetNbEventToRead(void) const
const KVNumberList & GetRunList() const
const KVDataSet * GetDataSet() const
FileType * OpenRunfile(const Char_t *type, Int_t run)
Definition KVDataSet.h:167
TString GetFullPathToRunfile(const Char_t *type, Int_t run) const
void cd() const
Pilot analysis of reconstructed FAZIA data.
Int_t fRunNumber
run number of current file
void SubmitTask()
Run the interactive analysis.
virtual ~KVFAZIAReconDataAnalyser()
Destructor.
TTree * theTree
tree to be analysed
virtual void SetParameters(UInt_t n, Bool_t physics_parameters_only=kFALSE)
static KVMultiDetArray * MakeMultiDetector(const Char_t *dataset_name, Int_t run=-1, TString classname="KVMultiDetArray")
void Begin(void) const
Int_t Next(void) const
Handle list of options and input parameters for user analyis .
void ParseOptions(const KVString &optlist)
Bool_t IsOptGiven(const Char_t *opt)
virtual Bool_t IsOpen() const
void Close(Option_t *option="") override
const char * GetName() const override
virtual void Warning(const char *method, const char *msgfmt,...) const
R__ALWAYS_INLINE Bool_t IsZombie() const
virtual void Error(const char *method, const char *msgfmt,...) const
virtual void Info(const char *method, const char *msgfmt,...) const
const char * Data() const
virtual TFriendElement * AddFriend(const char *treename, const char *filename="")
virtual Long64_t Process(const char *filename, Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
void End()
ClassImp(TPyArg)