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 KVError::Error(
this,
"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...");
173 if (GetProofMode() != KVDataAnalyser::EProofMode::None)
dynamic_cast<TChain*
>(theChain)->SetProof(
kTRUE);
179 if (GetAnalysisTask()->WithUserClass()) analysis_class.
Form(
"%s%s", GetUserClass().full_path_imp().Data(), GetACliCMode());
180 else analysis_class = GetUserClassName();
182 if (GetNbEventToRead()) {
183 theChain->Process(analysis_class,
option.Data(), GetNbEventToRead());
186 theChain->Process(analysis_class,
option.Data());
191 fOldSelector =
nullptr;
213 GetBatchInfoFile()->SetValue(
"UserClassAlternativeBaseClass",
"KVOldINDRASelector,KVReconEventSelector");
214 if (save) GetBatchInfoFile()->SaveLevel(
kEnvUser);
249 if (fSelector) fSelector->SetBranchName(
"INDRAReconEvent");
250 else KVError::Warning(
this,
"preInitAnalysis",
"could not set branch name correctly");
260 if (fSelector->InheritsFrom(
"KVINDRAEventSelector"))
263 else if (fSelector->InheritsFrom(
"KVReconEventSelector"))
267 fOldSelector->SetCurrentRun(CurrentRun);
307 if (fSelector->IsOptGiven(
"WithCalibInfos"))
308 physics_parameters_only = (fSelector->GetOpt(
"WithCalibInfos") !=
"yes");
313 SetCurrentRun(CurrentRun);
314 SetSelectorCurrentRun(CurrentRun);
315 cout << endl <<
" =================== New Run =================== " <<
325 cout << endl <<
" ================================================= " <<
328 ConnectRawDataTree();
329 ConnectGeneDataTree();
331 Info(
"preInitRun",
"Data written with series %s, release %d", GetDataSeries().Data(),
332 GetDataReleaseNumber());
333 fRustines.InitializePatchList(GetDataSet()->GetName(),
GetDataType(), run, GetDataSeries(),
334 GetDataReleaseNumber(), theChain->GetCurrentFile()->GetStreamerInfoCache());
344 Long64_t rawEntry = (fSelector ? fSelector->GetEventNumber() - 1
345 : fOldSelector->GetEventNumber() - 1);
356 return (fSelector ?
dynamic_cast<KVReconstructedEvent*
>(fSelector->GetEvent()) : fOldSelector->GetEvent());
384 if (!theRawData)
return;
386 Long64_t rawEntry = GetRawEntryNumber();
387 theRawData->GetEntry(rawEntry);
389 for (
int i = 0; i < NbParFired; i++)
396 if(
event->HasRandomAngles())
398 nuc.GetAnglesFromReconstructionTrajectory(
"random");
402 if (fRustines.HasActivePatches()) fRustines.Apply(
event);
414 void KVINDRAReconDataAnalyser::ConnectRawDataTree()
422 theRawData = (
TTree*)theChain->GetCurrentFile()->Get(
"RawData");
424 KVError::Warning(
this,
"ConnectRawDataTree",
"RawData tree not found in file; raw data parameters of detectors will not be available in analysis");
428 Info(
"ConnectRawDataTree",
"Found RawData tree in file");
429 Int_t maxNopar = theRawData->GetMaximum(
"NbParFired");
430 if (ParVal)
delete [] ParVal;
431 if (ParNum)
delete [] ParNum;
433 ParNum =
new UInt_t[maxNopar];
434 parList = (
TObjArray*)theRawData->GetUserInfo()->FindObject(
"ParameterList");
435 theRawData->SetBranchAddress(
"NbParFired", &NbParFired);
436 theRawData->SetBranchAddress(
"ParNum", ParNum);
437 theRawData->SetBranchAddress(
"ParVal", ParVal);
438 Info(
"ConnectRawDataTree",
"Connected raw data parameters");
449 void KVINDRAReconDataAnalyser::ConnectGeneDataTree()
455 theGeneData = (
TTree*)theChain->GetCurrentFile()->Get(
"GeneData");
457 cout <<
" --> No pulser & laser data for this run !!!" << endl << endl;
460 cout <<
" --> Pulser & laser data tree contains " << theGeneData->GetEntries()
461 <<
" events" << endl << endl;
471 return (
TEnv*)theChain->GetTree()->GetUserInfo()->
FindObject(
"TEnv");
482 TEnv* treeInfos = GetReconDataTreeInfos();
483 if (!treeInfos)
return;
484 cout << endl <<
"----------------------------------------------------------------------------------------------------" << endl;
485 cout <<
"INFORMATIONS ON VERSION OF KALIVEDA USED TO GENERATE FILE:" << endl << endl;
486 fDataVersion = treeInfos->
GetValue(
"KVBase::GetKVVersion()",
"(unknown)");
487 cout <<
"version = " << fDataVersion << endl ;
488 cout <<
"build date = " << treeInfos->
GetValue(
"KVBase::GetKVBuildDate()",
"(unknown)") << endl ;
489 cout <<
"source directory = " << treeInfos->
GetValue(
"KVBase::GetKVSourceDir()",
"(unknown)") << endl ;
490 cout <<
"KVROOT = " << treeInfos->
GetValue(
"KVBase::GetKVRoot()",
"(unknown)") << endl ;
491 cout <<
"BZR branch name = " << treeInfos->
GetValue(
"KVBase::bzrBranchNick()",
"(unknown)") << endl ;
492 cout <<
"BZR revision #" << treeInfos->
GetValue(
"KVBase::bzrRevisionNumber()",
"(unknown)") << endl ;
493 cout <<
"BZR revision ID = " << treeInfos->
GetValue(
"KVBase::bzrRevisionId()",
"(unknown)") << endl ;
494 cout <<
"BZR revision date = " << treeInfos->
GetValue(
"KVBase::bzrRevisionDate()",
"(unknown)") << endl ;
495 cout << endl <<
"INFORMATIONS ON GENERATION OF FILE:" << endl << endl;
496 cout <<
"Generated by : " << treeInfos->
GetValue(
"gSystem->GetUserInfo()->fUser",
"(unknown)") << endl ;
497 cout <<
"Analysis task : " << treeInfos->
GetValue(
"AnalysisTask",
"(unknown)") << endl ;
498 cout <<
"Job name : " << treeInfos->
GetValue(
"BatchSystem.JobName",
"(unknown)") << endl ;
499 cout <<
"Job submitted from : " << treeInfos->
GetValue(
"LaunchDirectory",
"(unknown)") << endl ;
500 cout <<
"Runs : " << treeInfos->
GetValue(
"Runs",
"(unknown)") << endl ;
501 cout <<
"Number of events requested : " << treeInfos->
GetValue(
"NbToRead",
"(unknown)") << endl ;
502 cout << endl <<
"----------------------------------------------------------------------------------------------------" << endl;
508 if (fDataVersion !=
"(unknown)") {
509 if (sscanf(fDataVersion.Data(),
"%d.%d.%d", &
a, &
b, &
c) == 3) {
510 fDataSeries.Form(
"%d.%d",
a,
b);
516 fDataReleaseNum = -1;
526 if (theRawData) theRawData->CloneTree(-1,
"fast");
527 if (theGeneData) theGeneData->CloneTree(-1,
"fast");
546 return KVDataAnalyser::CheckIfUserClassIsValid(
"KVOldINDRASelector,KVReconEventSelector");
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 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
std::optional< run_index_t > GetRunNumberFromFileName(const TString &datatype, const TString &filename)
FileType * OpenRunfile(const KVString &type, const run_index_t &run)
ValType GetDataSetEnv(const Char_t *type, const ValType &defval={}) const
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 preAnalysis() override
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)
void Error(UserClass p, const char *location, const char *va_(fmt),...)
void Warning(UserClass p, const char *location, const char *va_(fmt),...)
BinData::ErrorType GetDataType(const TGraph *gr, DataOptions &fitOpt)