1 #include "KVDataSetAnalyser.h"
2 #define KVOldINDRASelector_cxx
3 #include "KVOldINDRASelector.h"
12 #include "KVClassFactory.h"
13 #include "KVDataAnalyser.h"
14 #include <KVINDRADB.h>
15 #ifndef __WITHOUT_TMACRO
47 dataselector_lock.SetTimeout(60);
48 dataselector_lock.SetSuspend(5);
49 dataselector_lock.SetSleeptime(1);
59 KVOldINDRASelector::~KVOldINDRASelector()
64 if (gvlist && TestBit(kDeleteGVList)) {
67 ResetBit(kDeleteGVList);
92 fChain->SetMakeClass(1);
94 if (fChain->InheritsFrom(
"TChain"))
95 fTreeOffset = ((
TChain*) fChain)->GetTreeOffset();
101 fChain->SetBranchAddress(fBranchName.Data(), &
data, &b_data);
107 if (fKVDataSelector) {
108 fKVDataSelector->Init();
132 cout <<
"Analyse du fichier " << fChain->GetCurrentFile()->GetName()
133 <<
" : " << fChain->GetTree()->GetEntries() << endl;
134 NbTreeEntry = (
Int_t) fChain->GetTree()->GetEntries();
135 fCurrentTreeNumber = fChain->GetTreeNumber();
137 needToCallEndRun =
kTRUE;
140 needToSelect = !(fTEVLexist[fCurrentTreeNumber]);
147 if (!fKVDataSelector) {
150 fKVDataSelector->Reset(fCurrentRun->GetNumber());
151 cout <<
" Building new TEventList : " << fKVDataSelector->
152 GetTEventList()->GetName()
176 if (IsOptGiven(
"DataSelector")) SetDataSelector(GetOpt(
"DataSelector"));
183 fTimer->Start(
kTRUE);
208 #ifdef __WITHOUT_TSELECTOR_LONG64_T
242 Abort(
Form(
"Aborting analysis after %d events", totentry), kAbortFile);
251 fChain->GetTree()->GetEntry(fTreeEntry);
258 while ((part = (
KVNucleus*)GetEvent()->GetNextParticle(
"ok"))) {
260 part->
SetIsOK(fPartCond->Test(part));
266 if (TestBit(kChangeMasses)) GetEvent()->ChangeFragmentMasses(fNewMassFormula);
271 if (fCurrentRun->GetSystem() && fCurrentRun->GetSystem()->GetKinematics()) {
273 GetEvent()->SetFrame(
"CM",
274 fCurrentRun->GetSystem()->GetKinematics()->GetCMVelocity());
278 RecalculateGlobalVariables();
284 ok_anal = fKVDataSelector->ProcessCurrentEntry();
287 ok_anal = Analysis();
292 TString mes(
"End of run after ");
300 needToCallEndRun =
kFALSE;
304 SaveCurrentDataSelection();
338 if (needToCallEndRun) {
345 SaveCurrentDataSelection();
348 cout << endl <<
" ====================== END ====================== " <<
350 cout <<
" Total number of events read = " << totentry << endl;
351 cout <<
" Real time = " << fTimer->RealTime() <<
" sec." << endl;
352 cout <<
" CPU time = " << fTimer->CpuTime() <<
" sec." << endl;
353 cout <<
" Events/Real sec. = " << totentry /
354 fTimer->RealTime() << endl;
355 cout <<
" Events/CPU sec. = " << totentry /
356 fTimer->CpuTime() << endl;
357 cout << endl <<
" ====================== END ====================== " <<
361 fChain->SetEventList(0);
418 SetBit(kDeleteGVList);
434 Error(
"AddGV(KVVarGlob*)",
"KVVarGlob pointer is null");
436 GetGVList()->Add(vg);
522 Error(
"AddGV(const Char_t*,const Char_t*)",
523 "Called with class_name=%s.\nClass is unknown: not in standard libraries, and plugin (user-defined class) not found",
532 Error(
"AddGV(const Char_t*,const Char_t*)",
533 "%s is not a valid class deriving from KVVarGlob.",
607 if (gvlist) gvlist->CalculateGlobalVariables(GetEvent());
612 #ifdef __WITHOUT_TSELECTOR_LONG64_T
649 if (fKVDataSelector) {
650 delete fKVDataSelector;
658 if (fDataSelector.Length()) {
659 Info(
"BuildEventList()",
660 "Building TEventList for the KVDataSelector \"%s\".",
665 cout <<
"Analysis from a chain of trees." << endl;
666 lof = ((
TChain*) fChain)->GetListOfFiles();
670 cout <<
"Analysis from a single tree." << endl;
674 TNamed(
"SingleRun", fChain->GetCurrentFile()->GetName()));
677 toff[1] = fChain->GetEntries();
681 new TEventList(
"chainEventList",
"TEvent list for this TChain");
685 TString searchname(GetDataSelectorFileName());
687 cout <<
"File to open : " << fname.
Data() << endl;
688 TFile* fileDataSelector = 0;
691 if (dataselector_lock.Lock(fname.
Data())) fileDataSelector =
new TFile(fname.
Data());
694 cout <<
"The file \"" << fname.
695 Data() <<
"\" does not exist." << endl;
702 cout << fname.
Data() << endl;
705 cout <<
"Numero de run " << nrun << endl;
706 cout <<
"Recherche de " <<
Form(
"%s_run%d;1",
710 if (fileDataSelector) {
713 Get(
Form(
"%s_run%d;1", GetDataSelector(), nrun));
716 for (
Int_t i = 0; i < revtList->
GetN(); i++) {
717 fEvtList->Enter(fTreeOffset[tn] + revtList->
GetEntry(i));
719 fTEVLexist[tn] =
kTRUE;
722 cout <<
"Liste introuvable..." << endl;
723 for (
Int_t i = fTreeOffset[tn]; i < fTreeOffset[tn + 1];
730 cout <<
"Run inconnu..." << endl;
733 if (fileDataSelector) {
734 cout <<
"Closing " << fileDataSelector->
GetName() << endl;
735 fileDataSelector->
Close();
736 dataselector_lock.Release();
745 if (!fEvtList->GetN()) {
746 Warning(
"BuildEventList()",
"The TEventList is empty...");
751 fChain->SetEventList(fEvtList);
767 Bool_t ok = (fTreeEntry + 1 == fChain->GetTree()->GetEntries());
772 globEntry = ((
TChain*) fChain)->GetChainEntryNumber(fTreeEntry);
774 globEntry = fTreeEntry;
777 ok = ok || (nextEntry == -1);
779 ok = ok || (nextEntry >= fTreeOffset[fCurrentTreeNumber + 1]);
798 cout <<
"Loading KVDataSelector..." << endl;
800 if (fDataSelector.Length()) {
802 TClass* clas =
gROOT->GetClass(fDataSelector.Data());
803 cout << clas <<
" / " << fDataSelector.Data() << endl;
807 TString fileC(
Form(
"%s.cpp", fDataSelector.Data()));
810 #ifdef __WITHOUT_TMACRO
812 Warning(
"LoadDataSelector(void)",
813 "No implementation and/or declaration file found for \"%s\".",
814 fDataSelector.Data());
820 TString searchname(GetDataSelectorFileName());
822 TFile* fileDataSelector = 0;
825 if (dataselector_lock.Lock(fname.
Data())) fileDataSelector =
new TFile(fname.
Data());
828 cout <<
"The file \"" << fname.
829 Data() <<
"\" does not exist." << endl;
833 if (fileDataSelector) {
839 cout << fileC.
Data() <<
" re-generated" << endl;
841 cout << fileh.
Data() <<
" re-generated." << endl;
842 deleteSources =
kTRUE;
845 Warning(
"LoadDataSelector(void)",
846 "No implementation and/or declaration file found for \"%s\".",
847 fDataSelector.Data());
849 if (fileDataSelector) {
850 fileDataSelector->
Close();
851 dataselector_lock.Release();
856 cout <<
"Files " << fileC.
Data() <<
" and " << fileh.
Data() <<
860 gROOT->GetPluginManager()->AddHandler(
"KVDataSelector",
861 fDataSelector.Data(),
862 fDataSelector.Data(),
864 fDataSelector.Data()),
866 fDataSelector.Data()));
871 Error(
"LoadDataSelector(void)",
872 "Called with class_name=%s.\nClass is unknown: not in standard libraries, and plugin (user-defined class) not found",
873 fDataSelector.Data());
877 fKVDataSelector->SetKVSelector(
this);
878 cout <<
"Apres Plugin " << fKVDataSelector->IsA()->
879 GetName() <<
" : " << fKVDataSelector->
880 GetKVSelector() << endl;
885 Error(
"LoadDataSelector(void)",
886 "%s is not a valid class deriving from KVDataSelector.",
887 fDataSelector.Data());
891 fKVDataSelector->SetKVSelector(
this);
892 cout <<
"Apres clas->New() " << fKVDataSelector->IsA()->
893 GetName() <<
" : " << fKVDataSelector->
894 GetKVSelector() << endl;
897 cout <<
"Removing files \"" << fDataSelector.
898 Data() <<
"*.*\" ..." << endl;
901 (
"rm %s.[c,h]*", fDataSelector.Data()));
908 fKVDataSelector->Init();
923 if (fKVDataSelector) {
926 TString searchname(GetDataSelectorFileName());
934 cout <<
"File to open : " << fname.
Data() <<
" : " <<
option.
936 TFile* fileDataSelector = 0;
937 if (dataselector_lock.Lock(fname.
Data())) fileDataSelector =
new TFile(fname.
Data(),
option.Data());
938 if (!fileDataSelector || (fileDataSelector && fileDataSelector->
IsZombie())) {
939 Error(
"SaveCurrentDataSelection(void)",
940 "Opening the file \"%s\" with the option \"%s\" is not possible.\nNothing saved.",
945 cout <<
"Saving the TEventList \"" << fKVDataSelector->
946 GetTEventList()->
GetName() <<
"\"..." << endl;
947 cout << fKVDataSelector->GetTEventList()->
948 GetN() <<
" entries selected." << endl;
949 fKVDataSelector->GetTEventList()->Write();
951 #ifndef __WITHOUT_TMACRO
955 Get(
Form(
"%s.cpp;1", fKVDataSelector->IsA()->GetName()));
958 Get(
Form(
"%s.h;1", fKVDataSelector->IsA()->GetName()));
960 cout <<
"Saving the source files..." << endl;
961 TMacro mC(
Form(
"%s.cpp", fKVDataSelector->IsA()->GetName()));
962 mC.
SetName(
Form(
"%s.cpp", fKVDataSelector->IsA()->GetName()));
964 (
"Implementation file for the KVDataSelector \"%s\".",
965 fKVDataSelector->IsA()->GetName()));
967 TMacro mh(
Form(
"%s.h", fKVDataSelector->IsA()->GetName()));
968 mh.
SetName(
Form(
"%s.h", fKVDataSelector->IsA()->GetName()));
970 (
"Declaration file for the KVDataSelector \"%s\".",
971 fKVDataSelector->IsA()->GetName()));
976 cout <<
"Done" << endl;
977 fileDataSelector->
Close();
978 dataselector_lock.Release();
982 cout <<
"No TEventList to save..." << endl;
1007 gEnv->
GetValue(
"DataSelector.fileName",
"ListOfDataSelector.root");
1008 cout <<
"List Of Data Selectors : " << fname.
Data() << endl;
1009 return fname.
Data();
1045 SetBit(kChangeMasses);
1046 fNewMassFormula = mass_formula;
1113 else *fPartCond = cond;
1159 if ((
h1 = GetHisto(sname.
Data()))) {
1161 FillTH3((
TH3*)
h1, one, two, three, four);
1163 FillTProfile2D((
TProfile2D*)
h1, one, two, three, four);
1167 FillTH2((
TH2*)
h1, one, two, three);
1169 FillTProfile((
TProfile*)
h1, one, two, three);
1171 FillTH1(
h1, one, two);
1173 Warning(
"FillHisto",
"%s -> Classe non prevue ...", lhisto->FindObject(sname.
Data())->ClassName());
1176 Warning(
"FillHisto",
"%s introuvable", sname.
Data());
1201 h1->
Fill(one, two, three);
1213 h2->
Fill(one, two, three);
1225 h2->
Fill(one, two, three, four);
1247 h3->
Fill(one, two, three, four);
1259 Warning(
"CreateHistos",
"To be redefined child class");
1281 GetHistoList()->Write();
1290 GetHistoList()->Write();
1291 if (IsCreated)
file->Close();
1327 Warning(
"CreateTrees",
"To be redefined child class");
1340 ltree->Execute(
"Fill",
"");
1344 if ((
tt = GetTree(sname.
Data()))) {
1348 Warning(
"FillTree",
"%s introuvable", sname.
Data());
1366 GetTreeList()->Write();
1378 GetTreeList()->Write();
1379 if (IsCreated)
file->Close();
1393 fOptionList.SetValue(
option, tmp);
1406 return fOptionList.HasParameter(opt);
1421 return fOptionList.GetTStringValue(opt);
1434 fOptionList.RemoveParameter(opt);
1452 fOptionList.Clear();
1461 while (!opt.
End()) {
1469 fOptionList.Print();
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
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 Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
static const Char_t * FindFile(const Char_t *search, TString &wfil)
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
Factory class for generating skeleton files for new classes.
void GenerateCode()
Generate header and implementation file for currently-defined class.
void AddImplIncludeFile(const Char_t *filename)
Fill 3D observables in a dalitz plot ,.
Int_t FillAsDalitz(Double_t a1, Double_t a2, Double_t a3)
virtual void postEndRun()
void DoStatusUpdate(Long64_t nevents) const
Print infos on events treated, disk usage, memory usage.
virtual void preInitAnalysis()
virtual void postAnalysis()
virtual Bool_t CheckStatusUpdateInterval(Long64_t nevents) const
virtual void preAnalysis()
virtual void postInitRun()
static Bool_t AbortProcessingLoop()
virtual void postEndAnalysis()
virtual void preEndAnalysis()
void DeleteBatchStatusFile() const
Delete batch status file (and backup - '.bak') for batch job.
virtual void preInitRun()
virtual void RegisterUserClass(TObject *)
virtual void postInitAnalysis()
Class handling event lists for KVOldINDRASelector analysis of data chains.
Pilots user analysis of experimental data.
#define KVGVLIST_OPTIMIZE_GVLIST
Extended version of ROOT THashList.
Description of properties and kinematics of atomic nuclei.
Former base analysis class for INDRA data.
virtual const Char_t * GetDataSelectorFileName(void)
virtual void WriteTreeToFile(KVString filename="FileFromKVOldINDRASelector.root", Option_t *option="recreate")
If no filename is specified, assume that the current directory is writable.
virtual void UnsetOpt(const Char_t *opt)
Removes the option 'opt' from the internal lists, as if it had never been set.
void FillTH3(TH3 *h3, Double_t one, Double_t two, Double_t three, Double_t four)
void SlaveBegin(TTree *tree) override
virtual TString GetOpt(const Char_t *option) const
TH1 * GetHisto(const Char_t *name)
void FillTH2(TH2 *h2, Double_t one, Double_t two, Double_t three)
virtual void AddGV(KVVarGlob *)
void Terminate() override
void FillHisto(KVString sname, Double_t one, Double_t two=1, Double_t three=1, Double_t four=1)
virtual void SaveCurrentDataSelection(void)
virtual void RecalculateGlobalVariables()
static KVString fBranchName
name of branch which contains KVINDRAReconEvent objects in the TTree
virtual void CreateHistos()
Bool_t Process(Long64_t entry) override
virtual KVGVList * GetGVList(void)
void FillKVDalitz(KVDalitzPlot *h2, Double_t one, Double_t two, Double_t three)
virtual void SetParticleConditions(const KVParticleCondition &)
virtual Bool_t AtEndOfRun(void)
void FillTProfile2D(TProfile2D *h2, Double_t one, Double_t two, Double_t three, Double_t four)
virtual void SetGVList(KVGVList *list)
handling global variables for analysis
void FillTree(KVString sname="")
TTree * GetTree(const Char_t *name)
void FillTH1(TH1 *h1, Double_t one, Double_t two)
virtual void SetOpt(const Char_t *option, const Char_t *value)
Set a value for an option.
void SlaveTerminate() override
Function called at the end of the event loop in each PROOF slave.
KVHashList * GetHistoList()
virtual void CreateTrees()
virtual void ChangeFragmentMasses(UInt_t mass_formula)
virtual Long64_t GetTreeEntry() const
void FillTProfile(TProfile *h1, Double_t one, Double_t two, Double_t three)
static void Make(const Char_t *kvsname="MyOwnKVOldINDRASelector")
Automatic generation of KVOldINDRASelector-derived class for KaliVeda analysis.
void Begin(TTree *tree) override
virtual Bool_t IsOptGiven(const Char_t *option)
Returns kTRUE if the option 'opt' has been set.
virtual void LoadDataSelector(void)
virtual KVVarGlob * GetGV(const Char_t *) const
KVHashList * GetTreeList()
virtual void WriteHistoToFile(KVString filename="FileFromKVOldINDRASelector.root", Option_t *option="recreate")
void Init(TTree *tree) override
virtual void BuildEventList(void)
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
void SetParticleClassName(const Char_t *cl)
Base class for all global variable implementations.
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Bool_t InheritsFrom(const char *cl) const override
virtual void SetOwner(Bool_t enable=kTRUE)
T * Get(const char *namecycle)
virtual const char * GetValue(const char *name, const char *dflt) const
virtual Long64_t GetEntry(Int_t index) const
virtual Int_t GetN() const
void Close(Option_t *option="") override
TObject * FindObject(const char *name) const override
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 void SaveSource(const char *filename)
virtual Int_t ReadFile(const char *filename)
virtual void SetTitle(const char *title="")
const char * GetName() const override
virtual void SetName(const char *name)
Int_t GetEntries() const override
TObject * At(Int_t idx) const override
virtual TObject * FindObject(const char *name) const
R__ALWAYS_INLINE Bool_t IsZombie() const
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
virtual Bool_t InheritsFrom(const char *classname) const
Longptr_t ExecPlugin(int nargs)
virtual Int_t Fill(const char *namex, const char *namey, Double_t z, Double_t w=1.)
const char * Data() const
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
virtual const char * WorkingDirectory()
CPYCPPYY_EXTERN bool Exec(const std::string &cmd)