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"
12 #include "KVDataSetAnalyser.h"
28 if (IsOptGiven(
"CombinedOutputFile")) {
29 fCombinedOutputFile = GetOpt(
"CombinedOutputFile");
36 fDisableCreateTreeFile =
kTRUE;
43 fDisableCreateTreeFile =
kFALSE;
52 if (IsOptGiven(
"AuxFiles")) {
54 if (GetInputList()) GetInputList()->Add(fAuxChain);
64 if (GetInputList() && GetInputList()->FindObject(
"JobDescriptionList")) {
69 if (!gDataRepositoryManager) {
71 gDataRepositoryManager->
Init();
78 if (!gDataSetManager) {
80 gDataSetManager->
Init();
85 if (gDataSet && gDataAnalyser->
InheritsFrom(
"KVDataSetAnalyser"))
95 if (IsOptGiven(
"CombinedOutputFile")) {
96 fCombinedOutputFile = GetOpt(
"CombinedOutputFile");
97 Info(
"SlaveBegin",
"Output file name = %s", fCombinedOutputFile.Data());
106 fDisableCreateTreeFile =
kFALSE;
110 if (IsOptGiven(
"AuxFiles")) {
112 if (GetInputList()) {
113 fAuxChain = (
TTree*)GetInputList()->FindObject(GetOpt(
"AuxTreeName"));
114 InitFriendTree(fAuxChain, GetOpt(
"AuxBranchName"));
117 Info(
"SlaveBegin",
"fOutput->ls()");
118 GetOutputList()->ls();
129 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);
144 if (fPartCond.IsSet()) {
146 part.SetIsOK(fPartCond.Test(part));
152 for (
auto p : fGlobalVariables)
dynamic_cast<KVGVList*
>(
p)->
Init();
155 RecalculateGlobalVariables();
159 if (!fGlobalVariableAbortEventAnalysis) {
162 ok_anal = Analysis();
177 Info(
"Process",
"End of file reached after %lld events", fEventsRead);
178 if (gDataAnalyser) gDataAnalyser->
preEndRun();
180 if (gDataAnalyser) gDataAnalyser->
postEndRun();
196 if (lhisto.GetEntries()) {
197 lhisto.R__FOR_EACH(
TH1, Write)();
199 if (ltree.GetEntries()) {
203 if (gDataAnalyser->
GetProofMode() != KVDataAnalyser::EProofMode::None) {
204 fOutput->Add(mergeFile);
218 Info(
"Terminate",
"Analysis ends at %s", now.
AsString());
224 if (GetInputList() && fAuxChain) GetInputList()->Remove(fAuxChain);
254 fGlobalVariableAbortEventAnalysis =
false;
255 for (
auto p : fGlobalVariables) {
259 if (gvl->AbortEventAnalysis()) {
260 fGlobalVariableAbortEventAnalysis =
true;
287 if (fDisableCreateTreeFile)
return;
292 else create_output_file();
306 if (fDisableCreateTreeFile)
return;
311 if (writeFile)
tree->SetDirectory(writeFile);
312 else create_output_file();
328 if (fCombinedOutputFile ==
"")
return;
331 if (gDataAnalyser->
GetProofMode() == KVDataAnalyser::EProofMode::None) {
333 writeFile =
TFile::Open(fCombinedOutputFile,
"RECREATE");
338 mergeFile->SetOutputFileName(fCombinedOutputFile);
339 writeFile = mergeFile->OpenFile(
"RECREATE");
340 if (writeFile && writeFile->IsZombie())
SafeDelete(writeFile);
346 ClassName(), fCombinedOutputFile.Data());
347 Abort(amsg, kAbortProcess);
351 if (lhisto.GetEntries()) {
352 lhisto.R__FOR_EACH(
TH1, SetDirectory)(writeFile);
354 if (ltree.GetEntries()) {
355 ltree.R__FOR_EACH(
TTree, SetDirectory)(writeFile);
365 Deprecate(
"Calling this method is no longer required, and any filename given will be ignored."
366 " Call SetJobOutputFileName() to define the output filename.");
389 if ((
h1 = GetHisto(histo_name))) {
391 FillTH3((
TH3*)
h1, one, two, three, four);
395 FillTH2((
TH2*)
h1, one, two, three);
399 FillTH1(
h1, one, two);
401 Warning(
"FillHisto",
"%s -> Classe non prevue ...", lhisto.FindObject(histo_name)->ClassName());
404 Warning(
"FillHisto",
"%s introuvable", histo_name);
415 if ((
h1 = GetHisto(histo_name))) {
419 Warning(
"FillHisto",
"%s introuvable", histo_name);
443 h1->
Fill(one, two, three);
455 h2->
Fill(one, two, three);
467 h2->
Fill(one, two, three, four);
478 h3->
Fill(one, two, three, four);
504 if (!IsOptGiven(
"AuxDir") || !IsOptGiven(
"AuxTreeName") || !IsOptGiven(
"AuxBranchName")) {
505 Error(
"SetUpAuxEventChain",
"if AuxFiles option given, you must define AuxDir, AuxTreeName and AuxBranchName");
508 KVString filelist = GetOpt(
"AuxFiles");
509 KVString filedir = GetOpt(
"AuxDir");
510 if (!filedir.
EndsWith(
"/")) filedir +=
"/";
513 while (!filelist.
End()) {
517 InitFriendTree(auxchain, GetOpt(
"AuxBranchName"));
527 ltree.R__FOR_EACH(
TTree, Fill)();
567 fOptionList.ParseOptions(GetOption());
570 if (IsOptGiven(
"BranchName")) SetBranchName(GetOpt(
"BranchName"));
572 if (IsOptGiven(
"EventsReadInterval")) SetEventsReadInterval(GetOpt(
"EventsReadInterval").Atoi());
585 fChain->SetMakeClass(1);
587 if (gDataAnalyser->
GetProofMode() != KVDataAnalyser::EProofMode::None) {
591 if (strcmp(GetBranchName(),
"") && fChain->GetBranch(GetBranchName())) {
592 Info(
"Init",
"Analysing data in branch : %s", GetBranchName());
593 fChain->SetBranchAddress(GetBranchName(), &
Event, &b_Event);
596 Error(
"Init",
"Failed to link KVEvent object with a branch. Expected branch name=%s",
600 SetAdditionalBranchAddress();
642 fAuxChain->SetBranchAddress(branchname, &AuxEvent);
644 fAuxChain->GetEntry(0);
645 fAuxChain->GetTree()->GetEntry(0);
654 if (fNotifyCalled)
return kTRUE;
655 fNotifyCalled =
kTRUE;
657 Info(
"Notify",
"Beginning analysis of file %s (%lld events)", fChain->GetCurrentFile()->GetName(), fChain->GetTree()->GetEntries());
659 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.
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)
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 AddTree(TTree *tree)
virtual void SlaveBegin(TTree *tree)
virtual void SlaveTerminate()
void add_histo(TH1 *histo)
for merging with PROOF
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 FillTH1(TH1 *h1, Double_t one, Double_t two)
virtual void Init(TTree *tree)
void add_tree(TTree *tree)
void RecalculateGlobalVariables()
virtual Bool_t Process(Long64_t entry)
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="")
#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)