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");
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());
382 if (!theRawData)
return;
384 Long64_t rawEntry = GetRawEntryNumber();
385 theRawData->GetEntry(rawEntry);
387 for (
int i = 0; i < NbParFired; i++)
394 if(
event->HasRandomAngles())
396 nuc.GetAnglesFromReconstructionTrajectory(
"random");
400 if (fRustines.HasActivePatches()) fRustines.Apply(
event);
420 theRawData = (
TTree*)theChain->GetCurrentFile()->Get(
"RawData");
422 Warning(
"ConnectRawDataTree",
"RawData tree not found in file; raw data parameters of detectors will not be available in analysis");
426 Info(
"ConnectRawDataTree",
"Found RawData tree in file");
427 Int_t maxNopar = theRawData->GetMaximum(
"NbParFired");
428 if (ParVal)
delete [] ParVal;
429 if (ParNum)
delete [] ParNum;
431 ParNum =
new UInt_t[maxNopar];
432 parList = (
TObjArray*)theRawData->GetUserInfo()->FindObject(
"ParameterList");
433 theRawData->SetBranchAddress(
"NbParFired", &NbParFired);
434 theRawData->SetBranchAddress(
"ParNum", ParNum);
435 theRawData->SetBranchAddress(
"ParVal", ParVal);
436 Info(
"ConnectRawDataTree",
"Connected raw data parameters");
453 theGeneData = (
TTree*)theChain->GetCurrentFile()->Get(
"GeneData");
455 cout <<
" --> No pulser & laser data for this run !!!" << endl << endl;
458 cout <<
" --> Pulser & laser data tree contains " << theGeneData->GetEntries()
459 <<
" events" << endl << endl;
469 return (
TEnv*)theChain->GetTree()->GetUserInfo()->
FindObject(
"TEnv");
480 TEnv* treeInfos = GetReconDataTreeInfos();
481 if (!treeInfos)
return;
482 cout << endl <<
"----------------------------------------------------------------------------------------------------" << endl;
483 cout <<
"INFORMATIONS ON VERSION OF KALIVEDA USED TO GENERATE FILE:" << endl << endl;
484 fDataVersion = treeInfos->
GetValue(
"KVBase::GetKVVersion()",
"(unknown)");
485 cout <<
"version = " << fDataVersion << endl ;
486 cout <<
"build date = " << treeInfos->
GetValue(
"KVBase::GetKVBuildDate()",
"(unknown)") << endl ;
487 cout <<
"source directory = " << treeInfos->
GetValue(
"KVBase::GetKVSourceDir()",
"(unknown)") << endl ;
488 cout <<
"KVROOT = " << treeInfos->
GetValue(
"KVBase::GetKVRoot()",
"(unknown)") << endl ;
489 cout <<
"BZR branch name = " << treeInfos->
GetValue(
"KVBase::bzrBranchNick()",
"(unknown)") << endl ;
490 cout <<
"BZR revision #" << treeInfos->
GetValue(
"KVBase::bzrRevisionNumber()",
"(unknown)") << endl ;
491 cout <<
"BZR revision ID = " << treeInfos->
GetValue(
"KVBase::bzrRevisionId()",
"(unknown)") << endl ;
492 cout <<
"BZR revision date = " << treeInfos->
GetValue(
"KVBase::bzrRevisionDate()",
"(unknown)") << endl ;
493 cout << endl <<
"INFORMATIONS ON GENERATION OF FILE:" << endl << endl;
494 cout <<
"Generated by : " << treeInfos->
GetValue(
"gSystem->GetUserInfo()->fUser",
"(unknown)") << endl ;
495 cout <<
"Analysis task : " << treeInfos->
GetValue(
"AnalysisTask",
"(unknown)") << endl ;
496 cout <<
"Job name : " << treeInfos->
GetValue(
"BatchSystem.JobName",
"(unknown)") << endl ;
497 cout <<
"Job submitted from : " << treeInfos->
GetValue(
"LaunchDirectory",
"(unknown)") << endl ;
498 cout <<
"Runs : " << treeInfos->
GetValue(
"Runs",
"(unknown)") << endl ;
499 cout <<
"Number of events requested : " << treeInfos->
GetValue(
"NbToRead",
"(unknown)") << endl ;
500 cout << endl <<
"----------------------------------------------------------------------------------------------------" << endl;
506 if (fDataVersion !=
"(unknown)") {
507 if (sscanf(fDataVersion.Data(),
"%d.%d.%d", &
a, &
b, &
c) == 3) {
508 fDataSeries.Form(
"%d.%d",
a,
b);
514 fDataReleaseNum = -1;
524 if (theRawData) theRawData->CloneTree(-1,
"fast");
525 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
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
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 TString &type) const
ValType GetDataSetEnv(const Char_t *type, const ValType &defval) const
std::optional< run_index_t > GetRunNumberFromFileName(const TString &datatype, const TString &filename)
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....
Wrapper class for iterating over nuclei in KVReconstructedEvent accessed through base pointer or refe...
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)