5 #include "KVReconDataAnalyser.h"
7 #include "KVMultiDetArray.h"
8 #include "KVDataAnalysisTask.h"
13 #include "KVAvailableRunsFile.h"
15 #include <KVClassFactory.h>
16 #include <KVTriggerConditions.h>
26 : fSelector(
nullptr), theChain(
nullptr)
41 TotalEntriesToRead = 0;
58 cout <<
"============> Analysis summary <=============" << endl;
59 cout <<
"Analysis of runs " << GetRunList().GetList() <<
" with the class ";
60 cout <<
"\"" << GetUserClass().name <<
"\"." << endl;
61 if (GetNbEventToRead()) {
62 cout << GetNbEventToRead() <<
" events will be processed." << endl;
65 cout <<
"All events will be processed." << endl;
67 cout <<
"=============================================" << endl;
89 theChain =
new TChain(
"ReconEvents");
90 theChain->SetDirectory(0);
95 for (
auto& run : GetRunList()) {
97 cout <<
"Opening file " << fullPathToRunfile << endl;
99 cout <<
"Adding file " << fullPathToRunfile;
100 cout <<
" to the TChain." << endl;
101 dynamic_cast<TChain*
>(theChain)->
Add(fullPathToRunfile);
102 if (
f && !
f->IsZombie()) {
106 if (!((
TTree*)
f->Get(
"ReconEvents"))) {
107 KVError::Error(
this,
"SubmitTask",
"No tree named ReconEvents is present in the current file");
114 TString username = treeInfos->
GetValue(
"gSystem->GetUserInfo()->fUser",
"");
118 Info(
"SubmitTask",
"No TEnv object associated to the tree");
123 TotalEntriesToRead = theChain->GetEntries();
124 TString option =
Form(
"EventsReadInterval=%lld,", GetAnalysisTask()->GetStatusUpdateInterval());
125 option +=
Form(
"FullRunList=%s", GetFullRunList().GetList().Data());
128 if (GetUserClassOptions() !=
"") {
130 option += GetUserClassOptions();
133 TObject* new_selector = GetInstanceOfUserClass();
135 if (!new_selector || !new_selector->
InheritsFrom(
"TSelector")) {
136 cout <<
"The selector \"" << GetUserClassName() <<
"\" is not valid." << endl;
137 cout <<
"Process aborted." << endl;
142 Info(
"SubmitTask",
"Beginning TChain::Process...");
145 if (GetProofMode() != KVDataAnalyser::EProofMode::None)
dynamic_cast<TChain*
>(theChain)->SetProof(
kTRUE);
151 if (GetAnalysisTask()->WithUserClass())
152 analysis_class.
Form(
"%s%s", GetUserClass().full_path_imp().Data(), GetACliCMode());
153 else analysis_class = GetUserClassName();
155 if (GetNbEventToRead()) {
156 theChain->Process(analysis_class,
option.Data(), GetNbEventToRead());
159 theChain->Process(analysis_class,
option.Data());
228 if (fSelector->IsOptGiven(
"WithCalibInfos"))
229 physics_parameters_only = (fSelector->GetOpt(
"WithCalibInfos") !=
"yes");
232 Int_t run = run_file.value().run();
237 SetCurrentRun(CurrentRun);
238 fSelector->SetCurrentRun(CurrentRun);
239 SetCurrentRunFile(&gExpDB->
GetDBRunFile(run_file.value()));
241 cout << endl <<
" ================= New Run File ================= " <<
244 GetAnalysedRunFile()->Print();
252 cout << endl <<
" ================================================= " <<
256 Info(
"preInitRun",
"Data written with series %s, release %d", GetDataSeries().Data(),
257 GetDataReleaseNumber());
258 fRustines.InitializePatchList(GetDataSet()->GetName(),
GetDataType(), run, GetDataSeries(),
259 GetDataReleaseNumber(), theChain->GetCurrentFile()->GetStreamerInfoCache());
271 if (fRustines.HasActivePatches()) fRustines.Apply(fSelector->GetEvent());
280 return (
TEnv*)theChain->GetTree()->GetUserInfo()->
FindObject(
"TEnv");
320 Info(
"SetTriggerConditionsForRun",
321 "No definition of trigger conditions available for dataset %s",
322 GetDataSet()->GetName());
326 trig->SetTriggerConditionsForRun(fSelector, run);
337 TEnv* treeInfos = GetReconDataTreeInfos();
338 if (!treeInfos)
return;
339 cout << endl <<
"----------------------------------------------------------------------------------------------------" << endl;
340 cout <<
"INFORMATIONS ON VERSION OF KALIVEDA USED TO GENERATE FILE:" << endl << endl;
341 fDataVersion = treeInfos->
GetValue(
"KVBase::GetKVVersion()",
"(unknown)");
342 cout <<
"version = " << fDataVersion << endl ;
343 cout <<
"build date = " << treeInfos->
GetValue(
"KVBase::GetKVBuildDate()",
"(unknown)") << endl ;
344 cout <<
"source directory = " << treeInfos->
GetValue(
"KVBase::GetKVSourceDir()",
"(unknown)") << endl ;
345 cout <<
"KVROOT = " << treeInfos->
GetValue(
"KVBase::GetKVRoot()",
"(unknown)") << endl ;
346 if (strcmp(treeInfos->
GetValue(
"KVBase::bzrBranchNick()",
"(unknown)"),
"(unknown)")) {
347 cout <<
"BZR branch name = " << treeInfos->
GetValue(
"KVBase::bzrBranchNick()",
"(unknown)") << endl ;
348 cout <<
"BZR revision #" << treeInfos->
GetValue(
"KVBase::bzrRevisionNumber()",
"(unknown)") << endl ;
349 cout <<
"BZR revision ID = " << treeInfos->
GetValue(
"KVBase::bzrRevisionId()",
"(unknown)") << endl ;
350 cout <<
"BZR revision date = " << treeInfos->
GetValue(
"KVBase::bzrRevisionDate()",
"(unknown)") << endl ;
352 else if (strcmp(treeInfos->
GetValue(
"KVBase::gitBranch()",
"(unknown)"),
"(unknown)")) {
353 cout <<
"git branch = " << treeInfos->
GetValue(
"KVBase::gitBranch()",
"(unknown)") << endl;
354 cout <<
"git commit = " << treeInfos->
GetValue(
"KVBase::gitCommit()",
"(unknown)") << endl;
356 cout << endl <<
"INFORMATIONS ON GENERATION OF FILE:" << endl << endl;
357 cout <<
"Generated by : " << treeInfos->
GetValue(
"gSystem->GetUserInfo()->fUser",
"(unknown)") << endl ;
358 cout <<
"Analysis task : " << treeInfos->
GetValue(
"AnalysisTask",
"(unknown)") << endl ;
359 cout <<
"Job name : " << treeInfos->
GetValue(
"BatchSystem.JobName",
"(unknown)") << endl ;
360 cout <<
"Job submitted from : " << treeInfos->
GetValue(
"LaunchDirectory",
"(unknown)") << endl ;
361 cout <<
"Runs : " << treeInfos->
GetValue(
"Runs",
"(unknown)") << endl ;
362 cout <<
"Number of events requested : " << treeInfos->
GetValue(
"NbToRead",
"(unknown)") << endl ;
363 cout << endl <<
"----------------------------------------------------------------------------------------------------" << endl;
371 if (fDataVersion !=
"(unknown)") {
372 if (fDataVersion.Contains(
"/")) {
373 if (sscanf(fDataVersion.Data(),
"%d.%d/%d", &
a, &
b, &
c) == 3) {
374 fDataSeries.Form(
"%d.%d",
a,
b);
379 if (sscanf(fDataVersion.Data(),
"%d.%d.%d", &
a, &
b, &
c) == 3) {
380 fDataSeries.Form(
"%d.%d",
a,
b);
387 fDataReleaseNum = -1;
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
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)
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
Description of an experimental run in database ,,.
void Print(Option_t *option="") const override
KVDBSystem * GetSystem() const
KV2Body * GetKinematics()
virtual Bool_t CheckTaskVariables()
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
KVDBRun * GetDBRun(Int_t number) const
const KVDBRunFile & GetDBRunFile(const run_index_t &r) const
static KVMultiDetArray * MakeMultiDetector(const Char_t *dataset_name, Int_t run=-1, TString classname="KVMultiDetArray", KVExpDB *db=nullptr)
static void SetMakeMultiDetectorPhysicsParametersOnly(Bool_t on=kTRUE)
Manages user analysis of reconstructed experimental data.
void preAnalysis() override
apply any required patches to data
TEnv * GetReconDataTreeInfos() const
void PrintTreeInfos()
Print informations on currently analysed TTree.
void preInitRun() override
Bool_t CheckTaskVariables(void) override
Checks the task variables.
virtual void SetTriggerConditionsForRun(int) override
void SubmitTask() override
void Reset() override
Reset task variables.
Set trigger conditions for analysis of reconstructed data.
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
Longptr_t ExecPlugin(int nargs)
void Form(const char *fmt,...)
virtual const char * BaseName(const char *pathname)
void Error(UserClass p, const char *location, const char *va_(fmt),...)
BinData::ErrorType GetDataType(const TGraph *gr, DataOptions &fitOpt)