1 #include "KVNucleusEvent.h"
2 #define KVEventSelector_cxx
3 #include "KVEventSelector.h"
4 #include <KVClassMonitor.h>
8 #include "KVDataRepositoryManager.h"
9 #include "KVDataRepository.h"
10 #include "KVDataSetManager.h"
14 #include "KVDataSetAnalyser.h"
30 if (IsOptGiven(
"CombinedOutputFile")) {
31 fCombinedOutputFile = GetOpt(
"CombinedOutputFile");
39 fDisableCreateTreeFile =
kTRUE;
46 fDisableCreateTreeFile =
kFALSE;
55 if (IsOptGiven(
"AuxFiles")) {
57 if (GetInputList()) GetInputList()->Add(fAuxChain);
67 if (GetInputList() && GetInputList()->FindObject(
"JobDescriptionList")) {
72 if (!gDataRepositoryManager) {
74 gDataRepositoryManager->
Init();
81 if (!gDataSetManager) {
83 gDataSetManager->
Init();
88 if (gDataSet && gDataAnalyser->
InheritsFrom(
"KVDataSetAnalyser"))
98 if (IsOptGiven(
"CombinedOutputFile")) {
99 fCombinedOutputFile = GetOpt(
"CombinedOutputFile");
100 Info(
"SlaveBegin",
"Output file name = %s", fCombinedOutputFile.Data());
109 fDisableCreateTreeFile =
kFALSE;
113 if (IsOptGiven(
"AuxFiles")) {
115 if (GetInputList()) {
116 fAuxChain = (
TTree*)GetInputList()->FindObject(GetOpt(
"AuxTreeName"));
117 InitFriendTree(fAuxChain, GetOpt(
"AuxBranchName"));
120 Info(
"SlaveBegin",
"fOutput->ls()");
121 GetOutputList()->ls();
132 Abort(
Form(
"Job received KILL signal from batch system after %lld events - batch job probably needs more CPU time (see end of job statistics)", fEventsRead), kAbortFile);
147 if (fPartCond.IsSet()) {
149 part.SetIsOK(fPartCond.Test(part));
155 for (
auto p : fGlobalVariables)
dynamic_cast<KVGVList*
>(
p)->
Init();
158 RecalculateGlobalVariables();
162 if (!fGlobalVariableAbortEventAnalysis) {
165 ok_anal = Analysis();
180 Info(
"Process",
"End of file reached after %lld events", fEventsRead);
181 if (gDataAnalyser) gDataAnalyser->
preEndRun();
183 if (gDataAnalyser) gDataAnalyser->
postEndRun();
199 if (lhisto.GetEntries()) {
200 lhisto.R__FOR_EACH(
TH1, Write)();
202 if (ltree.GetEntries()) {
207 if (gDataAnalyser->
GetProofMode() != KVDataAnalyser::EProofMode::None) {
208 fOutput->Add(mergeFile);
222 Info(
"Terminate",
"Analysis ends at %s", now.
AsString());
228 if (GetInputList() && fAuxChain) GetInputList()->Remove(fAuxChain);
258 fGlobalVariableAbortEventAnalysis =
false;
259 for (
auto p : fGlobalVariables) {
263 if (gvl->AbortEventAnalysis()) {
264 fGlobalVariableAbortEventAnalysis =
true;
282 if (fDisableCreateTreeFile)
return;
287 else create_output_file();
301 if (fDisableCreateTreeFile)
return;
306 if (writeFile)
tree->SetDirectory(writeFile);
307 else create_output_file();
323 if (fCombinedOutputFile ==
"")
return;
326 if (gDataAnalyser->
GetProofMode() == KVDataAnalyser::EProofMode::None) {
328 writeFile =
TFile::Open(fCombinedOutputFile,
"RECREATE");
334 mergeFile->SetOutputFileName(fCombinedOutputFile);
335 writeFile = mergeFile->OpenFile(
"RECREATE");
336 if (writeFile && writeFile->IsZombie())
SafeDelete(writeFile);
343 ClassName(), fCombinedOutputFile.Data());
344 Abort(amsg, kAbortProcess);
348 if (lhisto.GetEntries()) {
349 lhisto.R__FOR_EACH(
TH1, SetDirectory)(writeFile);
351 if (ltree.GetEntries()) {
352 ltree.R__FOR_EACH(
TTree, SetDirectory)(writeFile);
362 Deprecate(
"Calling this method is no longer required, and any filename given will be ignored."
363 " Call SetJobOutputFileName() to define the output filename.");
377 if ((
h1 = GetHisto(histo_name))) {
379 FillTH3((
TH3*)
h1, one, two, three, four);
383 FillTH2((
TH2*)
h1, one, two, three);
387 FillTH1(
h1, one, two);
389 Warning(
"FillHisto",
"%s -> Classe non prevue ...", lhisto.FindObject(histo_name)->ClassName());
392 Warning(
"FillHisto",
"%s introuvable", histo_name);
403 if ((
h1 = GetHisto(histo_name))) {
407 Warning(
"FillHisto",
"%s introuvable", histo_name);
431 h1->
Fill(one, two, three);
443 h2->
Fill(one, two, three);
455 h2->
Fill(one, two, three, four);
466 h3->
Fill(one, two, three, four);
492 if (!IsOptGiven(
"AuxDir") || !IsOptGiven(
"AuxTreeName") || !IsOptGiven(
"AuxBranchName")) {
493 Error(
"SetUpAuxEventChain",
"if AuxFiles option given, you must define AuxDir, AuxTreeName and AuxBranchName");
496 KVString filelist = GetOpt(
"AuxFiles");
497 KVString filedir = GetOpt(
"AuxDir");
498 if (!filedir.
EndsWith(
"/")) filedir +=
"/";
501 while (!filelist.
End()) {
505 InitFriendTree(auxchain, GetOpt(
"AuxBranchName"));
515 ltree.R__FOR_EACH(
TTree, Fill)();
555 fOptionList.ParseOptions(GetOption());
558 if (IsOptGiven(
"BranchName")) SetBranchName(GetOpt(
"BranchName"));
560 if (IsOptGiven(
"EventsReadInterval")) SetEventsReadInterval(GetOpt(
"EventsReadInterval").Atoi());
573 fChain->SetMakeClass(1);
575 if (gDataAnalyser->
GetProofMode() != KVDataAnalyser::EProofMode::None) {
579 if (strcmp(GetBranchName(),
"") && fChain->GetBranch(GetBranchName())) {
580 Info(
"Init",
"Analysing data in branch : %s", GetBranchName());
581 fChain->SetBranchAddress(GetBranchName(), &
Event, &b_Event);
584 Error(
"Init",
"Failed to link KVEvent object with a branch. Expected branch name=%s",
588 SetAdditionalBranchAddress();
630 fAuxChain->SetBranchAddress(branchname, &AuxEvent);
632 fAuxChain->GetEntry(0);
633 fAuxChain->GetTree()->GetEntry(0);
642 if (fNotifyCalled)
return kTRUE;
643 fNotifyCalled =
kTRUE;
645 Info(
"Notify",
"Beginning analysis of file %s (%lld events)", fChain->GetCurrentFile()->GetName(), fChain->GetTree()->GetEntries());
647 if (gDataAnalyser) gDataAnalyser->
preInitRun();
winID h TVirtualViewer3D TVirtualGLPainter p
R__EXTERN TProof * gProof
char * Form(const char *fmt,...)
Class for iterating over "OK" nuclei in events accessed through base pointer/reference.
static KVClassMonitor * GetInstance()
Return pointer to unique instance of class monitor class.
virtual void SetAnalysedTree(TTree *)
virtual void postEndRun()
void DoStatusUpdate(Long64_t nevents) const
Print infos on events treated, disk usage, memory usage.
virtual void AddJobDescriptionList(TList *)
virtual void preInitAnalysis()
virtual void postAnalysis()
void SetAnalysisTask(KVDataAnalysisTask *at)
void SetProofMode(EProofMode e)
virtual Bool_t CheckStatusUpdateInterval(Long64_t nevents) const
virtual void preAnalysis()
static KVDataAnalyser * GetAnalyser(const Char_t *plugin)
EProofMode GetProofMode() const
virtual void postInitRun()
static Bool_t AbortProcessingLoop()
virtual void postEndAnalysis()
virtual void preEndAnalysis()
virtual void preInitRun()
virtual void RegisterUserClass(TObject *)
virtual void postInitAnalysis()
Define and manage data analysis tasks.
virtual const Char_t * GetDataAnalyser() const
Manages access to one or more data repositories.
KVDataRepository * GetRepository(const Char_t *name) const
Pilots user analysis of experimental data.
Manage all datasets contained in a given data repository.
virtual Bool_t Init(KVDataRepository *=0)
KVDataAnalysisTask * GetAnalysisTaskAny(const Char_t *keywords) const
KVDataSet * GetDataSet(Int_t) const
Return pointer to DataSet using index in list of all datasets, index>=0.
KVDataAnalysisTask * GetAnalysisTask(Int_t) const
General purpose analysis base class for TTree containing KVEvent objects.
Bool_t Process(Long64_t entry) override
void FillTProfile2D(TProfile2D *h2, Double_t one, Double_t two, Double_t three, Double_t four)
void SetUpAuxEventChain()
void InitFriendTree(TTree *tree, const TString &branchname)
void Init(TTree *tree) override
virtual void CheckEndOfRun()
void FillTH2(TH2 *h2, Double_t one, Double_t two, Double_t three)
void create_output_file()
Bool_t CreateTreeFile(const Char_t *filename="")
void add_histo(TH1 *histo)
output file for trees and histos
void FillHisto(const Char_t *sname, Double_t one, Double_t two=1, Double_t three=1, Double_t four=1)
void FillTProfile(TProfile *h1, Double_t one, Double_t two, Double_t three)
void SlaveTerminate() override
void FillTH1(TH1 *h1, Double_t one, Double_t two)
void add_tree(TTree *tree)
void SlaveBegin(TTree *tree) override
void RecalculateGlobalVariables()
virtual void ParseOptions()
void FillTH3(TH3 *h3, Double_t one, Double_t two, Double_t three, Double_t four)
void FillTree(const Char_t *tree_name="")
void Terminate() override
#define KVGVLIST_OPTIMIZE_GVLIST
void CalculateGlobalVariables(KVEvent *e)
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
Int_t GetIntValue(const Char_t *name) const
const Char_t * GetStringValue(const Char_t *name) const
Bool_t HasParameter(const Char_t *name) const
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
void Begin(TString delim) const
KVString Next(Bool_t strip_whitespace=kFALSE) const
virtual Int_t Add(const char *name, Long64_t nentries=TTree::kMaxEntries)
const char * AsString() const
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
virtual void SetDirectory(TDirectory *dir)
virtual Int_t Fill(const char *name, Double_t w)
virtual Int_t Fill(const char *namex, const char *namey, Double_t w)
virtual Int_t Fill(const char *namex, const char *namey, const char *namez, Double_t w)
virtual Bool_t InheritsFrom(const char *classname) const
virtual Int_t Fill(const char *namex, const char *namey, Double_t z, Double_t w=1.)
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
static TString Format(const char *fmt,...)
RooCmdArg ClassName(const char *name)