1 #define KVEventSelector_cxx
33 if (IsOptGiven(
"CombinedOutputFile")) {
34 fCombinedOutputFile = GetOpt(
"CombinedOutputFile");
41 fDisableCreateTreeFile =
kTRUE;
48 fDisableCreateTreeFile =
kFALSE;
57 if (IsOptGiven(
"AuxFiles")) {
59 if (GetInputList()) GetInputList()->Add(fAuxChain);
94 if (GetInputList() && GetInputList()->FindObject(
"JobDescriptionList")) {
125 if (IsOptGiven(
"CombinedOutputFile")) {
126 fCombinedOutputFile = GetOpt(
"CombinedOutputFile");
127 Info(
"SlaveBegin",
"Output file name = %s", fCombinedOutputFile.Data());
136 fDisableCreateTreeFile =
kFALSE;
140 if (ltree->GetEntries() > 0) {
141 for (
Int_t ii = 0; ii < ltree->GetEntries(); ii += 1) {
143 tt->SetDirectory(writeFile);
148 if (IsOptGiven(
"AuxFiles")) {
150 if (GetInputList()) {
151 fAuxChain = (
TTree*)GetInputList()->FindObject(GetOpt(
"AuxTreeName"));
152 InitFriendTree(fAuxChain, GetOpt(
"AuxBranchName"));
155 Info(
"SlaveBegin",
"fOutput->ls()");
156 GetOutputList()->ls();
171 if (fDisableCreateTreeFile)
return kTRUE;
174 if (!strcmp(filename,
""))
177 tree_file_name = filename;
180 mergeFile->SetOutputFileName(tree_file_name.
Data());
183 writeFile = mergeFile->OpenFile(
"RECREATE");
184 if (writeFile && writeFile->IsZombie())
SafeDelete(writeFile);
189 Info(
"CreateTreeFile",
"could not create '%s': instance is invalid!", filename);
241 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);
256 if (fPartCond.IsSet()) {
258 GetEvent()->ResetGetNextParticle();
259 while ((part = GetEvent()->GetNextParticle(
"ok"))) {
260 part->
SetIsOK(fPartCond.Test(part));
263 GetEvent()->ResetGetNextParticle();
267 if (fFirstEvent && !gvlist.IsEmpty()) {
271 RecalculateGlobalVariables();
275 if (gvlist.IsEmpty() || !gvlist.AbortEventAnalysis()) {
278 ok_anal = Analysis();
295 Info(
"Process",
"End of file reached after %lld events", fEventsRead);
323 if (ltree->GetEntries() > 0) {
328 for (
Int_t ii = 0; ii < ltree->GetEntries(); ii += 1) {
334 fOutput->Add(mergeFile);
336 for (
Int_t ii = 0; ii < ltree->GetEntries(); ii += 1) {
372 Info(
"Terminate",
"Analysis ends at %s", now.
AsString());
374 if (fCombinedOutputFile !=
"") {
375 Info(
"Terminate",
"combine = %s", fCombinedOutputFile.Data());
380 GetOutputList()->ls();
381 if (GetOutputList()->FindObject(
"ThereAreHistos")) {
382 if (GetOutputList()->FindObject(file2)) {
383 Info(
"Terminate",
"both");
389 Info(
"Terminate",
"histo");
390 SaveHistos(fCombinedOutputFile);
393 else if (GetOutputList()->FindObject(file2)) {
395 Info(
"Terminate",
"tree");
398 else Info(
"Terminate",
"none");
405 if (GetInputList() && fAuxChain) GetInputList()->Remove(fAuxChain);
475 KVVarGlob* vg = GetGVList()->AddGV(class_name, name);
503 if (!gvlist.IsEmpty()) gvlist.CalculateGlobalVariables(GetEvent());
540 else if (fPartName !=
"") fPartCond.SetParticleClassName(fPartName);
565 return lhisto->get_object<
TH1>(histo_name);
581 if (fDisableCreateTreeFile)
return;
585 if (!fOutput->FindObject(
"ThereAreHistos")) fOutput->Add(
new TNamed(
"ThereAreHistos",
"...so save them!"));
597 auto t =
new TTree(name, title, splitLevel, dir);
621 FillTH3((
TH3*)
h1, one, two, three, four);
625 FillTH2((
TH2*)
h1, one, two, three);
629 FillTH1(
h1, one, two);
631 Warning(
"FillHisto",
"%s -> Classe non prevue ...", lhisto->FindObject(histo_name)->ClassName());
634 Warning(
"FillHisto",
"%s introuvable", histo_name);
652 Warning(
"FillHisto",
"%s introuvable", histo_name);
677 h1->
Fill(one, two, three);
689 h2->
Fill(one, two, three);
701 h2->
Fill(one, two, three, four);
712 h3->
Fill(one, two, three, four);
738 if (!IsOptGiven(
"AuxDir") || !IsOptGiven(
"AuxTreeName") || !IsOptGiven(
"AuxBranchName")) {
739 Error(
"SetUpAuxEventChain",
"if AuxFiles option given, you must define AuxDir, AuxTreeName and AuxBranchName");
742 KVString filelist = GetOpt(
"AuxFiles");
743 KVString filedir = GetOpt(
"AuxDir");
744 if (!filedir.
EndsWith(
"/")) filedir +=
"/";
747 while (!filelist.
End()) {
751 InitFriendTree(auxchain, GetOpt(
"AuxBranchName"));
789 if (!strcmp(filename,
""))
790 histo_file_name.
Form(
"HistoFileFrom%s.root", GetName());
792 histo_file_name = filename;
806 TIter next(GetOutputList());
808 while ((obj = next())) {
811 if (((
TH1*)obj)->GetEntries() > 0) {
848 TTree* t = ltree->get_object<
TTree>(tree_name);
849 if (!t)
Fatal(
"GetTree",
"Tree %s not found: is this the right name?", tree_name);
870 if (!strcmp(tree_name,
"")) {
871 ltree->Execute(
"Fill",
"");
875 if ((
tt = GetTree(tree_name))) {
879 Warning(
"FillTree",
"%s introuvable", tree_name);
894 fOptionList.SetValue(option, tmp);
907 return fOptionList.HasParameter(opt);
924 return fOptionList.GetTStringValue(opt);
937 fOptionList.RemoveParameter(opt);
985 while (!option.
End()) {
1001 if (IsOptGiven(
"BranchName")) SetBranchName(GetOpt(
"BranchName"));
1003 if (IsOptGiven(
"EventsReadInterval")) SetEventsReadInterval(GetOpt(
"EventsReadInterval").Atoi());
1033 fChain->SetMakeClass(1);
1035 if (strcmp(GetBranchName(),
"") && fChain->GetBranch(GetBranchName())) {
1036 Info(
"Init",
"Analysing data in branch : %s", GetBranchName());
1037 fChain->SetBranchAddress(GetBranchName(), &
Event, &b_Event);
1040 Error(
"Init",
"Failed to link KVEvent object with a branch. Expected branch name=%s",
1044 SetAdditionalBranchAddress();
1080 fAuxChain->SetBranchAddress(branchname, &AuxEvent);
1082 fAuxChain->GetEntry(0);
1083 fAuxChain->GetTree()->GetEntry(0);
1103 if (fNotifyCalled)
return kTRUE;
1104 fNotifyCalled =
kTRUE;
1106 Info(
"Notify",
"Beginning analysis of file %s (%lld events)", fChain->GetCurrentFile()->GetName(), fChain->GetTree()->GetEntries());
KVDataAnalyser * gDataAnalyser
KVDataRepositoryManager * gDataRepositoryManager
KVDataSetManager * gDataSetManager
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
R__EXTERN TProof * gProof
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
static void CombineFiles(const Char_t *file1, const Char_t *file2, const Char_t *newfilename, Bool_t keep=kTRUE)
static KVClassMonitor * GetInstance()
Return pointer to unique instance of class monitor class.
virtual void SetTriggerConditionsForRun(int)
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)
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.
virtual KVDataAnalysisTask * GetAnalysisTask(Int_t) const
General purpose analysis class for TTree containing KVEvent objects.
virtual void SaveHistos(const Char_t *filename="", Option_t *option="recreate", Bool_t onlyfilled=kFALSE)
void FillTProfile2D(TProfile2D *h2, Double_t one, Double_t two, Double_t three, Double_t four)
void AddGV(KVVarGlob *vg)
const KVHashList * GetTreeList() const
return the list of created trees
void SetUpAuxEventChain()
TH1 * GetHisto(const Char_t *name) const
void SetParticleConditions(const KVParticleCondition &, const KVString &="")
void FillTree(const Char_t *sname="")
void InitFriendTree(TTree *tree, const TString &branchname)
virtual void SetOpt(const Char_t *option, const Char_t *value)
Set a value for an option.
const KVHashList * GetHistoList() const
return the list of created trees
TTree * GetTree(const Char_t *name) const
return the tree named tree_name
virtual void CheckEndOfRun()
Testing whether EndRun() should be called.
void FillTH2(TH2 *h2, Double_t one, Double_t two, Double_t three)
Bool_t CreateTreeFile(const Char_t *filename="")
void AddTree(TTree *tree)
virtual void SlaveBegin(TTree *tree)
virtual void SlaveTerminate()
void add_histo(TH1 *histo)
void FillHisto(const Char_t *sname, Double_t one, Double_t two=1, Double_t three=1, Double_t four=1)
virtual Bool_t IsOptGiven(const Char_t *option)
Returns kTRUE if the option 'opt' has been set.
void FillTProfile(TProfile *h1, Double_t one, Double_t two, Double_t three)
void SetTriggerConditionsForRun(int)
void FillTH1(TH1 *h1, Double_t one, Double_t two)
virtual void Init(TTree *tree)
virtual void RecalculateGlobalVariables()
virtual Bool_t Process(Long64_t entry)
virtual TString GetOpt(const Char_t *option) const
virtual void ParseOptions()
void FillTH3(TH3 *h3, Double_t one, Double_t two, Double_t three, Double_t four)
virtual void UnsetOpt(const Char_t *opt)
Removes the option 'opt' from the internal lists, as if it had never been set.
Extended version of ROOT THashList.
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
Description of properties and kinematics of atomic nuclei.
Handles particle selection criteria for data analysis classes ,.
void SetParticleClassName(const Char_t *cl)
void SetIsOK(Bool_t flag=kTRUE)
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
Base class for all global variable implementations.
virtual Int_t Add(const char *name, Long64_t nentries=TTree::kMaxEntries)
const char * AsString() const
virtual void Close(Option_t *option="")
virtual Bool_t cd(const char *path=nullptr)
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 Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
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
const char * Data() const
void Form(const char *fmt,...)
virtual int Rename(const char *from, const char *to)
RooCmdArg ClassName(const char *name)
TH1 * GetHisto(const std::string file, const std::string path, const std::string obj)