11 #include "KVINDRAReconDataAnalyser.h"
12 #include "KVINDRADBRun.h"
13 #include "KVINDRADB.h"
14 #include "KVDataAnalysisTask.h"
15 #include "KVDataSet.h"
19 #include "KVAvailableRunsFile.h"
22 #include "KVINDRATriggerConditions.h"
23 #include "KVINDRAEventSelector.h"
25 #include <KVReconEventSelector.h>
35 : fSelector(
nullptr), fOldSelector(
nullptr), theChain(
nullptr),
36 theRawData(
nullptr), theGeneData(
nullptr),
37 ParVal(
nullptr), ParNum(
nullptr), parList(
nullptr)
52 theGeneData =
nullptr;
56 fOldSelector =
nullptr;
57 TotalEntriesToRead = 0;
74 cout <<
"============> Analysis summary <=============" << endl;
75 cout <<
"Analysis of runs " << GetRunList().
76 GetList() <<
" with the class ";
77 cout <<
"\"" << GetUserClassName() <<
"\"." << endl;
78 if (GetNbEventToRead()) {
79 cout << GetNbEventToRead() <<
" events will be processed." << endl;
82 cout <<
"All events will be processed." << endl;
84 cout <<
"=============================================" << endl;
105 fOldSelector =
nullptr;
107 theChain =
new TChain(
"ReconstructedEvents");
108 theChain->SetDirectory(0);
113 for (
auto& run : GetRunList()) {
115 cout <<
"Opening file " << fullPathToRunfile << endl;
117 cout <<
"Adding file " << fullPathToRunfile;
118 cout <<
" to the TChain." << endl;
119 dynamic_cast<TChain*
>(theChain)->
Add(fullPathToRunfile);
120 if (
f && !
f->IsZombie()) {
124 if (!((
TTree*)
f->Get(
"ReconstructedEvents"))) {
125 Error(
"SubmitTask",
"No tree named ReconstructedEvents is present in the current file");
132 TString username = treeInfos->
GetValue(
"gSystem->GetUserInfo()->fUser",
"");
136 Info(
"SubmitTask",
"No TEnv object associated to the tree");
141 TotalEntriesToRead = theChain->GetEntries();
146 option +=
Form(
"FullRunList=%s", GetFullRunList().GetList().Data());
149 if (GetUserClassOptions() !=
"") {
151 option += GetUserClassOptions();
154 set_up_analyser_for_task(
this);
159 TObject* new_selector = GetInstanceOfUserClass(
"KVOldINDRASelector,KVReconEventSelector");
161 if (!new_selector || !new_selector->
InheritsFrom(
"TSelector")) {
162 cout <<
"The selector \"" << GetUserClassName() <<
"\" is not valid." << endl;
163 cout <<
"Process aborted." << endl;
168 Info(
"SubmitTask",
"Beginning TChain::Process...");
170 if (GetProofMode() != KVDataAnalyser::EProofMode::None)
dynamic_cast<TChain*
>(theChain)->SetProof(
kTRUE);
175 if (GetAnalysisTask()->WithUserClass()) analysis_class.
Form(
"%s%s", GetUserClass().full_path_imp().Data(), GetACliCMode());
176 else analysis_class = GetUserClassName();
178 if (GetNbEventToRead()) {
179 theChain->Process(analysis_class,
option.Data(), GetNbEventToRead());
182 theChain->Process(analysis_class,
option.Data());
187 fOldSelector =
nullptr;
209 GetBatchInfoFile()->SetValue(
"UserClassAlternativeBaseClass",
"KVOldINDRASelector,KVReconEventSelector");
210 if (save) GetBatchInfoFile()->SaveLevel(
kEnvUser);
243 if (fSelector) fSelector->SetBranchName(
"INDRAReconEvent");
244 else Warning(
"preInitAnalysis",
"could not set branch name correctly");
254 if (fSelector->InheritsFrom(
"KVINDRAEventSelector"))
257 else if (fSelector->InheritsFrom(
"KVReconEventSelector"))
261 fOldSelector->SetCurrentRun(CurrentRun);
301 if (fSelector->IsOptGiven(
"WithCalibInfos"))
302 physics_parameters_only = (fSelector->GetOpt(
"WithCalibInfos") !=
"yes");
304 Int_t run = GetRunNumberFromFileName(theChain->GetCurrentFile()->GetName());
307 SetCurrentRun(CurrentRun);
308 SetSelectorCurrentRun(CurrentRun);
309 cout << endl <<
" =================== New Run =================== " <<
319 cout << endl <<
" ================================================= " <<
322 ConnectRawDataTree();
323 ConnectGeneDataTree();
325 Info(
"preInitRun",
"Data written with series %s, release %d", GetDataSeries().Data(),
326 GetDataReleaseNumber());
327 fRustines.InitializePatchList(GetDataSet()->GetName(),
GetDataType(), run, GetDataSeries(),
328 GetDataReleaseNumber(), theChain->GetCurrentFile()->GetStreamerInfoCache());
338 Long64_t rawEntry = (fSelector ? fSelector->GetEventNumber() - 1
339 : fOldSelector->GetEventNumber() - 1);
350 return (fSelector ?
dynamic_cast<KVReconstructedEvent*
>(fSelector->GetEvent()) : fOldSelector->GetEvent());
376 if (!theRawData)
return;
378 Long64_t rawEntry = GetRawEntryNumber();
379 theRawData->GetEntry(rawEntry);
381 for (
int i = 0; i < NbParFired; i++)
387 if (fRustines.HasActivePatches()) fRustines.Apply(
event);
407 theRawData = (
TTree*)theChain->GetCurrentFile()->Get(
"RawData");
409 Warning(
"ConnectRawDataTree",
"RawData tree not found in file; raw data parameters of detectors will not be available in analysis");
413 Info(
"ConnectRawDataTree",
"Found RawData tree in file");
414 Int_t maxNopar = theRawData->GetMaximum(
"NbParFired");
415 if (ParVal)
delete [] ParVal;
416 if (ParNum)
delete [] ParNum;
418 ParNum =
new UInt_t[maxNopar];
419 parList = (
TObjArray*)theRawData->GetUserInfo()->FindObject(
"ParameterList");
420 theRawData->SetBranchAddress(
"NbParFired", &NbParFired);
421 theRawData->SetBranchAddress(
"ParNum", ParNum);
422 theRawData->SetBranchAddress(
"ParVal", ParVal);
423 Info(
"ConnectRawDataTree",
"Connected raw data parameters");
440 theGeneData = (
TTree*)theChain->GetCurrentFile()->Get(
"GeneData");
442 cout <<
" --> No pulser & laser data for this run !!!" << endl << endl;
445 cout <<
" --> Pulser & laser data tree contains " << theGeneData->GetEntries()
446 <<
" events" << endl << endl;
456 return (
TEnv*)theChain->GetTree()->GetUserInfo()->
FindObject(
"TEnv");
467 TEnv* treeInfos = GetReconDataTreeInfos();
468 if (!treeInfos)
return;
469 cout << endl <<
"----------------------------------------------------------------------------------------------------" << endl;
470 cout <<
"INFORMATIONS ON VERSION OF KALIVEDA USED TO GENERATE FILE:" << endl << endl;
471 fDataVersion = treeInfos->
GetValue(
"KVBase::GetKVVersion()",
"(unknown)");
472 cout <<
"version = " << fDataVersion << endl ;
473 cout <<
"build date = " << treeInfos->
GetValue(
"KVBase::GetKVBuildDate()",
"(unknown)") << endl ;
474 cout <<
"source directory = " << treeInfos->
GetValue(
"KVBase::GetKVSourceDir()",
"(unknown)") << endl ;
475 cout <<
"KVROOT = " << treeInfos->
GetValue(
"KVBase::GetKVRoot()",
"(unknown)") << endl ;
476 cout <<
"BZR branch name = " << treeInfos->
GetValue(
"KVBase::bzrBranchNick()",
"(unknown)") << endl ;
477 cout <<
"BZR revision #" << treeInfos->
GetValue(
"KVBase::bzrRevisionNumber()",
"(unknown)") << endl ;
478 cout <<
"BZR revision ID = " << treeInfos->
GetValue(
"KVBase::bzrRevisionId()",
"(unknown)") << endl ;
479 cout <<
"BZR revision date = " << treeInfos->
GetValue(
"KVBase::bzrRevisionDate()",
"(unknown)") << endl ;
480 cout << endl <<
"INFORMATIONS ON GENERATION OF FILE:" << endl << endl;
481 cout <<
"Generated by : " << treeInfos->
GetValue(
"gSystem->GetUserInfo()->fUser",
"(unknown)") << endl ;
482 cout <<
"Analysis task : " << treeInfos->
GetValue(
"AnalysisTask",
"(unknown)") << endl ;
483 cout <<
"Job name : " << treeInfos->
GetValue(
"BatchSystem.JobName",
"(unknown)") << endl ;
484 cout <<
"Job submitted from : " << treeInfos->
GetValue(
"LaunchDirectory",
"(unknown)") << endl ;
485 cout <<
"Runs : " << treeInfos->
GetValue(
"Runs",
"(unknown)") << endl ;
486 cout <<
"Number of events requested : " << treeInfos->
GetValue(
"NbToRead",
"(unknown)") << endl ;
487 cout << endl <<
"----------------------------------------------------------------------------------------------------" << endl;
493 if (fDataVersion !=
"(unknown)") {
494 if (sscanf(fDataVersion.Data(),
"%d.%d.%d", &
a, &
b, &
c) == 3) {
495 fDataSeries.Form(
"%d.%d",
a,
b);
501 fDataReleaseNum = -1;
511 if (theRawData) theRawData->CloneTree(-1,
"fast");
512 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)
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)
static KVMultiDetArray * MakeMultiDetector(const Char_t *dataset_name, Int_t run=-1, TString classname="KVMultiDetArray")
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)