11 #include "KVINDRAReconDataAnalyser.h"
12 #include "KVINDRADBRun.h"
13 #include "KVINDRADB.h"
14 #include "KVDataAnalysisTask.h"
15 #include "KVDataSet.h"
19 #include "KVAvailableRunsFile.h"
24 #include "KVINDRATriggerConditions.h"
25 #include "KVINDRAEventSelector.h"
27 #include <KVReconEventSelector.h>
37 : fSelector(
nullptr), fOldSelector(
nullptr), theChain(
nullptr),
38 theRawData(
nullptr), theGeneData(
nullptr),
39 ParVal(
nullptr), ParNum(
nullptr), parList(
nullptr)
54 theGeneData =
nullptr;
58 fOldSelector =
nullptr;
59 TotalEntriesToRead = 0;
76 cout <<
"============> Analysis summary <=============" << endl;
77 cout <<
"Analysis of runs " << GetRunList().
78 GetList() <<
" with the class ";
79 cout <<
"\"" << GetUserClassName() <<
"\"." << endl;
80 if (GetNbEventToRead()) {
81 cout << GetNbEventToRead() <<
" events will be processed." << endl;
84 cout <<
"All events will be processed." << endl;
86 cout <<
"=============================================" << endl;
107 fOldSelector =
nullptr;
109 theChain =
new TChain(
"ReconstructedEvents");
110 theChain->SetDirectory(0);
115 for (
auto& run : GetRunList()) {
117 cout <<
"Opening file " << fullPathToRunfile << endl;
119 cout <<
"Adding file " << fullPathToRunfile;
120 cout <<
" to the TChain." << endl;
121 dynamic_cast<TChain*
>(theChain)->
Add(fullPathToRunfile);
122 if (
f && !
f->IsZombie()) {
126 if (!((
TTree*)
f->Get(
"ReconstructedEvents"))) {
127 Error(
"SubmitTask",
"No tree named ReconstructedEvents is present in the current file");
134 TString username = treeInfos->
GetValue(
"gSystem->GetUserInfo()->fUser",
"");
138 Info(
"SubmitTask",
"No TEnv object associated to the tree");
143 TotalEntriesToRead = theChain->GetEntries();
148 option +=
Form(
"FullRunList=%s", GetFullRunList().GetList().Data());
151 if (GetUserClassOptions() !=
"") {
153 option += GetUserClassOptions();
156 set_up_analyser_for_task(
this);
161 TObject* new_selector = GetInstanceOfUserClass(
"KVOldINDRASelector,KVReconEventSelector");
163 if (!new_selector || !new_selector->
InheritsFrom(
"TSelector")) {
164 cout <<
"The selector \"" << GetUserClassName() <<
"\" is not valid." << endl;
165 cout <<
"Process aborted." << endl;
170 Info(
"SubmitTask",
"Beginning TChain::Process...");
172 if (GetProofMode() != KVDataAnalyser::EProofMode::None)
dynamic_cast<TChain*
>(theChain)->SetProof(
kTRUE);
177 if (GetAnalysisTask()->WithUserClass()) analysis_class.
Form(
"%s%s", GetUserClass().full_path_imp().Data(), GetACliCMode());
178 else analysis_class = GetUserClassName();
180 if (GetNbEventToRead()) {
181 theChain->Process(analysis_class,
option.Data(), GetNbEventToRead());
184 theChain->Process(analysis_class,
option.Data());
189 fOldSelector =
nullptr;
211 GetBatchInfoFile()->SetValue(
"UserClassAlternativeBaseClass",
"KVOldINDRASelector,KVReconEventSelector");
212 if (save) GetBatchInfoFile()->SaveLevel(
kEnvUser);
247 if (fSelector) fSelector->SetBranchName(
"INDRAReconEvent");
248 else Warning(
"preInitAnalysis",
"could not set branch name correctly");
258 if (fSelector->InheritsFrom(
"KVINDRAEventSelector"))
261 else if (fSelector->InheritsFrom(
"KVReconEventSelector"))
265 fOldSelector->SetCurrentRun(CurrentRun);
305 if (fSelector->IsOptGiven(
"WithCalibInfos"))
306 physics_parameters_only = (fSelector->GetOpt(
"WithCalibInfos") !=
"yes");
308 Int_t run = GetRunNumberFromFileName(theChain->GetCurrentFile()->GetName());
311 SetCurrentRun(CurrentRun);
312 SetSelectorCurrentRun(CurrentRun);
313 cout << endl <<
" =================== New Run =================== " <<
323 cout << endl <<
" ================================================= " <<
326 ConnectRawDataTree();
327 ConnectGeneDataTree();
329 Info(
"preInitRun",
"Data written with series %s, release %d", GetDataSeries().Data(),
330 GetDataReleaseNumber());
331 fRustines.InitializePatchList(GetDataSet()->GetName(),
GetDataType(), run, GetDataSeries(),
332 GetDataReleaseNumber(), theChain->GetCurrentFile()->GetStreamerInfoCache());
342 Long64_t rawEntry = (fSelector ? fSelector->GetEventNumber() - 1
343 : fOldSelector->GetEventNumber() - 1);
354 return (fSelector ?
dynamic_cast<KVReconstructedEvent*
>(fSelector->GetEvent()) : fOldSelector->GetEvent());
380 if (!theRawData)
return;
382 Long64_t rawEntry = GetRawEntryNumber();
383 theRawData->GetEntry(rawEntry);
385 for (
int i = 0; i < NbParFired; i++)
391 if (fRustines.HasActivePatches()) fRustines.Apply(
event);
411 theRawData = (
TTree*)theChain->GetCurrentFile()->Get(
"RawData");
413 Warning(
"ConnectRawDataTree",
"RawData tree not found in file; raw data parameters of detectors will not be available in analysis");
417 Info(
"ConnectRawDataTree",
"Found RawData tree in file");
418 Int_t maxNopar = theRawData->GetMaximum(
"NbParFired");
419 if (ParVal)
delete [] ParVal;
420 if (ParNum)
delete [] ParNum;
422 ParNum =
new UInt_t[maxNopar];
423 parList = (
TObjArray*)theRawData->GetUserInfo()->FindObject(
"ParameterList");
424 theRawData->SetBranchAddress(
"NbParFired", &NbParFired);
425 theRawData->SetBranchAddress(
"ParNum", ParNum);
426 theRawData->SetBranchAddress(
"ParVal", ParVal);
427 Info(
"ConnectRawDataTree",
"Connected raw data parameters");
444 theGeneData = (
TTree*)theChain->GetCurrentFile()->Get(
"GeneData");
446 cout <<
" --> No pulser & laser data for this run !!!" << endl << endl;
449 cout <<
" --> Pulser & laser data tree contains " << theGeneData->GetEntries()
450 <<
" events" << endl << endl;
460 return (
TEnv*)theChain->GetTree()->GetUserInfo()->
FindObject(
"TEnv");
471 TEnv* treeInfos = GetReconDataTreeInfos();
472 if (!treeInfos)
return;
473 cout << endl <<
"----------------------------------------------------------------------------------------------------" << endl;
474 cout <<
"INFORMATIONS ON VERSION OF KALIVEDA USED TO GENERATE FILE:" << endl << endl;
475 fDataVersion = treeInfos->
GetValue(
"KVBase::GetKVVersion()",
"(unknown)");
476 cout <<
"version = " << fDataVersion << endl ;
477 cout <<
"build date = " << treeInfos->
GetValue(
"KVBase::GetKVBuildDate()",
"(unknown)") << endl ;
478 cout <<
"source directory = " << treeInfos->
GetValue(
"KVBase::GetKVSourceDir()",
"(unknown)") << endl ;
479 cout <<
"KVROOT = " << treeInfos->
GetValue(
"KVBase::GetKVRoot()",
"(unknown)") << endl ;
480 cout <<
"BZR branch name = " << treeInfos->
GetValue(
"KVBase::bzrBranchNick()",
"(unknown)") << endl ;
481 cout <<
"BZR revision #" << treeInfos->
GetValue(
"KVBase::bzrRevisionNumber()",
"(unknown)") << endl ;
482 cout <<
"BZR revision ID = " << treeInfos->
GetValue(
"KVBase::bzrRevisionId()",
"(unknown)") << endl ;
483 cout <<
"BZR revision date = " << treeInfos->
GetValue(
"KVBase::bzrRevisionDate()",
"(unknown)") << endl ;
484 cout << endl <<
"INFORMATIONS ON GENERATION OF FILE:" << endl << endl;
485 cout <<
"Generated by : " << treeInfos->
GetValue(
"gSystem->GetUserInfo()->fUser",
"(unknown)") << endl ;
486 cout <<
"Analysis task : " << treeInfos->
GetValue(
"AnalysisTask",
"(unknown)") << endl ;
487 cout <<
"Job name : " << treeInfos->
GetValue(
"BatchSystem.JobName",
"(unknown)") << endl ;
488 cout <<
"Job submitted from : " << treeInfos->
GetValue(
"LaunchDirectory",
"(unknown)") << endl ;
489 cout <<
"Runs : " << treeInfos->
GetValue(
"Runs",
"(unknown)") << endl ;
490 cout <<
"Number of events requested : " << treeInfos->
GetValue(
"NbToRead",
"(unknown)") << endl ;
491 cout << endl <<
"----------------------------------------------------------------------------------------------------" << endl;
497 if (fDataVersion !=
"(unknown)") {
498 if (sscanf(fDataVersion.Data(),
"%d.%d.%d", &
a, &
b, &
c) == 3) {
499 fDataSeries.Form(
"%d.%d",
a,
b);
505 fDataReleaseNum = -1;
515 if (theRawData) theRawData->CloneTree(-1,
"fast");
516 if (theGeneData) theGeneData->CloneTree(-1,
"fast");
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 b
R__EXTERN TProof * gProof
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
void Print(Option_t *opt="") const override
Handles lists of available runs for different datasets and types of data.
Bool_t InfosNeedUpdate(const run_index_t &run, const KVString &filename)
void UpdateInfos(const run_index_t &run, const KVString &filename, const KVString &kvversion, const KVString &username)
void Print(Option_t *option="") const override
KVDBSystem * GetSystem() const
KV2Body * GetKinematics()
virtual Bool_t CheckIfUserClassIsValid(const KVString &alternative_base_class="")
virtual Bool_t CheckTaskVariables()
void WriteBatchEnvFile(const TString &jobname, Bool_t save=kTRUE) override
TString GetFullPathToRunfile(const KVString &type, const run_index_t &run) const
KVAvailableRunsFile * GetAvailableRunsFile(const Char_t *type) const
KVString GetDataSetEnv(const Char_t *type, const Char_t *defval="") const
FileType * OpenRunfile(const KVString &type, const run_index_t &run)
Database entry for each run of an INDRA experiment.
KVINDRADBRun * GetRun(Int_t run) const
Base class for analysis of reconstructed INDRA events.
Manage analysis of reconstructed INDRA data.
void preInitAnalysis() override
void SetTriggerConditionsForRun(int) override
void SetSelectorCurrentRun(KVINDRADBRun *CurrentRun)
void SubmitTask() override
void CloneRawAndGeneTrees()
void WriteBatchEnvFile(const TString &, Bool_t sav=kTRUE) override
TEnv * GetReconDataTreeInfos() const
void preInitRun() override
void PrintTreeInfos()
Print informations on currently analysed TTree.
KVReconstructedEvent * GetReconstructedEvent()
void ConnectRawDataTree()
void preAnalysis() override
void ConnectGeneDataTree()
Bool_t CheckIfUserClassIsValid(const KVString &="") override
Bool_t CheckTaskVariables(void) override
Checks the task variables.
void Reset() override
Reset task variables.
Long64_t GetRawEntryNumber()
Event reconstructed from energy losses in INDRA multidetector.
Set trigger conditions for analysis of reconstructed INDRA data.
void SetTriggerConditionsForRun(KVEventSelector *, Int_t, Bool_t=kFALSE) override
void handle_ebyedat_raw_data_parameter(const char *param_name, uint16_t val)
static KVMultiDetArray * MakeMultiDetector(const Char_t *dataset_name, Int_t run=-1, TString classname="KVMultiDetArray", KVExpDB *db=nullptr)
void prepare_to_handle_new_raw_data()
reset acquisition parameters etc. before reading new raw data event
virtual void SetParameters(UInt_t n, Bool_t physics_parameters_only=kFALSE)
Base class for user analysis of reconstructed data.
void SetCurrentRun(KVDBRun *r) override
Event containing KVReconstructedNucleus nuclei reconstructed from hits in detectors.
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
virtual void SetProof(Bool_t on=kTRUE, Bool_t refresh=kFALSE, Bool_t gettreeheader=kFALSE)
virtual const char * GetValue(const char *name, const char *dflt) const
virtual TObject * FindObject(const char *name) const
virtual Bool_t InheritsFrom(const char *classname) const
void Form(const char *fmt,...)
virtual const char * BaseName(const char *pathname)
BinData::ErrorType GetDataType(const TGraph *gr, DataOptions &fitOpt)