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 <<
"\"" << GetUserClass() <<
"\"." << 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);
110 GetRunList().Begin();
116 while (!GetRunList().
End()) {
117 run = GetRunList().Next();
119 cout <<
"Opening file " << fullPathToRunfile << endl;
121 cout <<
"Adding file " << fullPathToRunfile;
122 cout <<
" to the TChain." << endl;
123 dynamic_cast<TChain*
>(theChain)->
Add(fullPathToRunfile);
124 if (
f && !
f->IsZombie()) {
128 if (!((
TTree*)
f->Get(
"ReconstructedEvents"))) {
129 Error(
"SubmitTask",
"No tree named ReconstructedEvents is present in the current file");
136 TString username = treeInfos->
GetValue(
"gSystem->GetUserInfo()->fUser",
"");
140 Info(
"SubmitTask",
"No TEnv object associated to the tree");
145 TotalEntriesToRead = theChain->GetEntries();
150 option +=
Form(
"FullRunList=%s", GetFullRunList().GetList());
153 if (GetUserClassOptions() !=
"") {
155 option += GetUserClassOptions();
158 set_up_analyser_for_task(
this);
163 TObject* new_selector = GetInstanceOfUserClass(
"KVOldINDRASelector,KVReconEventSelector");
165 if (!new_selector || !new_selector->
InheritsFrom(
"TSelector")) {
166 cout <<
"The selector \"" << GetUserClass() <<
"\" is not valid." << endl;
167 cout <<
"Process aborted." << endl;
172 Info(
"SubmitTask",
"Beginning TChain::Process...");
174 if (GetProofMode() != KVDataAnalyser::EProofMode::None)
dynamic_cast<TChain*
>(theChain)->SetProof(
kTRUE);
179 if (GetAnalysisTask()->WithUserClass()) analysis_class.
Form(
"%s%s", GetUserClassImp().Data(), GetACliCMode());
180 else analysis_class = GetUserClass();
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);
231 GetDataSet()->GetRunList(datatype.
Data(), GetSystem());
235 vector<int> triggers;
237 while (!all_runs.
End()) {
238 dbrun = (
KVINDRADBRun*)GetDataSet()->GetDataBase()->GetDBRun(all_runs.
Next());
239 if (triggers.size() == 0
240 || std::find(triggers.begin(), triggers.end(), dbrun->
GetTrigger()) != triggers.end()) {
245 std::sort(triggers.begin(), triggers.end());
247 for (std::vector<int>::iterator it = triggers.begin(); it != triggers.end(); ++it) {
248 cout <<
" ---> Trigger M>" << *it << endl;
250 while (!all_runs.
End()) {
251 dbrun = (
KVINDRADBRun*)GetDataSet()->GetDataBase()->GetDBRun(all_runs.
Next());
255 cout <<
"\t[File written: " << dbrun->
GetDatime().
296 if (fSelector) fSelector->SetBranchName(
"INDRAReconEvent");
297 else Warning(
"preInitAnalysis",
"could not set branch name correctly");
307 if (fSelector->InheritsFrom(
"KVINDRAEventSelector"))
310 else if (fSelector->InheritsFrom(
"KVReconEventSelector"))
314 fOldSelector->SetCurrentRun(CurrentRun);
354 if (fSelector->IsOptGiven(
"WithCalibInfos"))
355 physics_parameters_only = (fSelector->GetOpt(
"WithCalibInfos") !=
"yes");
357 Int_t run = GetRunNumberFromFileName(theChain->GetCurrentFile()->GetName());
360 SetCurrentRun(CurrentRun);
361 SetSelectorCurrentRun(CurrentRun);
362 cout << endl <<
" =================== New Run =================== " <<
372 cout << endl <<
" ================================================= " <<
375 ConnectRawDataTree();
376 ConnectGeneDataTree();
378 Info(
"preInitRun",
"Data written with series %s, release %d", GetDataSeries().Data(),
379 GetDataReleaseNumber());
380 fRustines.InitializePatchList(GetDataSet()->GetName(),
GetDataType(), run, GetDataSeries(),
381 GetDataReleaseNumber(), theChain->GetCurrentFile()->GetStreamerInfoCache());
391 Long64_t rawEntry = (fSelector ? fSelector->GetEventNumber() - 1
392 : fOldSelector->GetEventNumber() - 1);
403 return (fSelector ?
dynamic_cast<KVReconstructedEvent*
>(fSelector->GetEvent()) : fOldSelector->GetEvent());
429 if (!theRawData)
return;
431 Long64_t rawEntry = GetRawEntryNumber();
432 theRawData->GetEntry(rawEntry);
434 for (
int i = 0; i < NbParFired; i++)
440 if (fRustines.HasActivePatches()) fRustines.Apply(
event);
460 theRawData = (
TTree*)theChain->GetCurrentFile()->Get(
"RawData");
462 Warning(
"ConnectRawDataTree",
"RawData tree not found in file; raw data parameters of detectors will not be available in analysis");
466 Info(
"ConnectRawDataTree",
"Found RawData tree in file");
467 Int_t maxNopar = theRawData->GetMaximum(
"NbParFired");
468 if (ParVal)
delete [] ParVal;
469 if (ParNum)
delete [] ParNum;
471 ParNum =
new UInt_t[maxNopar];
472 parList = (
TObjArray*)theRawData->GetUserInfo()->FindObject(
"ParameterList");
473 theRawData->SetBranchAddress(
"NbParFired", &NbParFired);
474 theRawData->SetBranchAddress(
"ParNum", ParNum);
475 theRawData->SetBranchAddress(
"ParVal", ParVal);
476 Info(
"ConnectRawDataTree",
"Connected raw data parameters");
493 theGeneData = (
TTree*)theChain->GetCurrentFile()->Get(
"GeneData");
495 cout <<
" --> No pulser & laser data for this run !!!" << endl << endl;
498 cout <<
" --> Pulser & laser data tree contains " << theGeneData->GetEntries()
499 <<
" events" << endl << endl;
509 return (
TEnv*)theChain->GetTree()->GetUserInfo()->
FindObject(
"TEnv");
520 TEnv* treeInfos = GetReconDataTreeInfos();
521 if (!treeInfos)
return;
522 cout << endl <<
"----------------------------------------------------------------------------------------------------" << endl;
523 cout <<
"INFORMATIONS ON VERSION OF KALIVEDA USED TO GENERATE FILE:" << endl << endl;
524 fDataVersion = treeInfos->
GetValue(
"KVBase::GetKVVersion()",
"(unknown)");
525 cout <<
"version = " << fDataVersion << endl ;
526 cout <<
"build date = " << treeInfos->
GetValue(
"KVBase::GetKVBuildDate()",
"(unknown)") << endl ;
527 cout <<
"source directory = " << treeInfos->
GetValue(
"KVBase::GetKVSourceDir()",
"(unknown)") << endl ;
528 cout <<
"KVROOT = " << treeInfos->
GetValue(
"KVBase::GetKVRoot()",
"(unknown)") << endl ;
529 cout <<
"BZR branch name = " << treeInfos->
GetValue(
"KVBase::bzrBranchNick()",
"(unknown)") << endl ;
530 cout <<
"BZR revision #" << treeInfos->
GetValue(
"KVBase::bzrRevisionNumber()",
"(unknown)") << endl ;
531 cout <<
"BZR revision ID = " << treeInfos->
GetValue(
"KVBase::bzrRevisionId()",
"(unknown)") << endl ;
532 cout <<
"BZR revision date = " << treeInfos->
GetValue(
"KVBase::bzrRevisionDate()",
"(unknown)") << endl ;
533 cout << endl <<
"INFORMATIONS ON GENERATION OF FILE:" << endl << endl;
534 cout <<
"Generated by : " << treeInfos->
GetValue(
"gSystem->GetUserInfo()->fUser",
"(unknown)") << endl ;
535 cout <<
"Analysis task : " << treeInfos->
GetValue(
"AnalysisTask",
"(unknown)") << endl ;
536 cout <<
"Job name : " << treeInfos->
GetValue(
"BatchSystem.JobName",
"(unknown)") << endl ;
537 cout <<
"Job submitted from : " << treeInfos->
GetValue(
"LaunchDirectory",
"(unknown)") << endl ;
538 cout <<
"Runs : " << treeInfos->
GetValue(
"Runs",
"(unknown)") << endl ;
539 cout <<
"Number of events requested : " << treeInfos->
GetValue(
"NbToRead",
"(unknown)") << endl ;
540 cout << endl <<
"----------------------------------------------------------------------------------------------------" << endl;
546 if (fDataVersion !=
"(unknown)") {
547 if (sscanf(fDataVersion.Data(),
"%d.%d.%d", &
a, &
b, &
c) == 3) {
548 fDataSeries.Form(
"%d.%d",
a,
b);
554 fDataReleaseNum = -1;
564 if (theRawData) theRawData->CloneTree(-1,
"fast");
565 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
Handles lists of available runs for different datasets and types of data.
virtual void UpdateInfos(Int_t run, const Char_t *filename, const Char_t *kvversion, const Char_t *username)
virtual Bool_t InfosNeedUpdate(Int_t run, const Char_t *filename)
virtual Int_t GetNumber() const
ULong64_t GetEvents() const
KVDBSystem * GetSystem() const
const TDatime & GetDatime() const
virtual void Print(Option_t *option="") const
const Char_t * GetComments() 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)
KVAvailableRunsFile * GetAvailableRunsFile(const Char_t *type) const
FileType * OpenRunfile(const Char_t *type, Int_t run)
const Char_t * GetDataSetEnv(const Char_t *type, const Char_t *defval="") const
TString GetFullPathToRunfile(const Char_t *type, Int_t run) 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 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()
virtual KVNumberList PrintAvailableRuns(KVString &datatype) override
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)
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")
Strings used to represent a set of ranges of values.
Base class for user analysis of reconstructed data.
void SetCurrentRun(KVDBRun *r)
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
const char * Data() const
void Form(const char *fmt,...)
virtual const char * BaseName(const char *pathname)
BinData::ErrorType GetDataType(const TGraph *gr, DataOptions &fitOpt)