1 #define KVOldINDRASelector_cxx
54 dataselector_lock.SetTimeout(60);
55 dataselector_lock.SetSuspend(5);
56 dataselector_lock.SetSleeptime(1);
66 KVOldINDRASelector::~KVOldINDRASelector()
71 if (gvlist && TestBit(kDeleteGVList)) {
74 ResetBit(kDeleteGVList);
99 fChain->SetMakeClass(1);
101 if (fChain->InheritsFrom(
"TChain"))
102 fTreeOffset = ((
TChain*) fChain)->GetTreeOffset();
108 fChain->SetBranchAddress(fBranchName.Data(), &data, &b_data);
114 if (fKVDataSelector) {
115 fKVDataSelector->Init();
139 cout <<
"Analyse du fichier " << fChain->GetCurrentFile()->GetName()
140 <<
" : " << fChain->GetTree()->GetEntries() << endl;
141 NbTreeEntry = (
Int_t) fChain->GetTree()->GetEntries();
142 fCurrentTreeNumber = fChain->GetTreeNumber();
144 needToCallEndRun =
kTRUE;
147 needToSelect = !(fTEVLexist[fCurrentTreeNumber]);
154 if (!fKVDataSelector) {
157 fKVDataSelector->Reset(fCurrentRun->GetNumber());
158 cout <<
" Building new TEventList : " << fKVDataSelector->
159 GetTEventList()->GetName()
183 if (IsOptGiven(
"DataSelector")) SetDataSelector(GetOpt(
"DataSelector"));
190 fTimer->Start(
kTRUE);
215 #ifdef __WITHOUT_TSELECTOR_LONG64_T
249 Abort(
Form(
"Aborting analysis after %d events", totentry), kAbortFile);
258 fChain->GetTree()->GetEntry(fTreeEntry);
265 while ((part = (
KVNucleus*)GetEvent()->GetNextParticle(
"ok"))) {
267 part->
SetIsOK(fPartCond->Test(part));
273 if (TestBit(kChangeMasses)) GetEvent()->ChangeFragmentMasses(fNewMassFormula);
278 if (fCurrentRun->GetSystem() && fCurrentRun->GetSystem()->GetKinematics()) {
280 GetEvent()->SetFrame(
"CM",
281 fCurrentRun->GetSystem()->GetKinematics()->GetCMVelocity());
285 RecalculateGlobalVariables();
291 ok_anal = fKVDataSelector->ProcessCurrentEntry();
294 ok_anal = Analysis();
299 TString mes(
"End of run after ");
307 needToCallEndRun =
kFALSE;
311 SaveCurrentDataSelection();
345 if (needToCallEndRun) {
352 SaveCurrentDataSelection();
355 cout << endl <<
" ====================== END ====================== " <<
357 cout <<
" Total number of events read = " << totentry << endl;
358 cout <<
" Real time = " << fTimer->RealTime() <<
" sec." << endl;
359 cout <<
" CPU time = " << fTimer->CpuTime() <<
" sec." << endl;
360 cout <<
" Events/Real sec. = " << totentry /
361 fTimer->RealTime() << endl;
362 cout <<
" Events/CPU sec. = " << totentry /
363 fTimer->CpuTime() << endl;
364 cout << endl <<
" ====================== END ====================== " <<
368 fChain->SetEventList(0);
425 SetBit(kDeleteGVList);
441 Error(
"AddGV(KVVarGlob*)",
"KVVarGlob pointer is null");
443 GetGVList()->Add(vg);
529 Error(
"AddGV(const Char_t*,const Char_t*)",
530 "Called with class_name=%s.\nClass is unknown: not in standard libraries, and plugin (user-defined class) not found",
539 Error(
"AddGV(const Char_t*,const Char_t*)",
540 "%s is not a valid class deriving from KVVarGlob.",
614 if (gvlist) gvlist->CalculateGlobalVariables(GetEvent());
619 #ifdef __WITHOUT_TSELECTOR_LONG64_T
656 if (fKVDataSelector) {
657 delete fKVDataSelector;
665 if (fDataSelector.Length()) {
666 Info(
"BuildEventList()",
667 "Building TEventList for the KVDataSelector \"%s\".",
672 cout <<
"Analysis from a chain of trees." << endl;
673 lof = ((
TChain*) fChain)->GetListOfFiles();
677 cout <<
"Analysis from a single tree." << endl;
681 TNamed(
"SingleRun", fChain->GetCurrentFile()->GetName()));
684 toff[1] = fChain->GetEntries();
688 new TEventList(
"chainEventList",
"TEvent list for this TChain");
692 TString searchname(GetDataSelectorFileName());
694 cout <<
"File to open : " << fname.
Data() << endl;
695 TFile* fileDataSelector = 0;
698 if (dataselector_lock.Lock(fname.
Data())) fileDataSelector =
new TFile(fname.
Data());
701 cout <<
"The file \"" << fname.
702 Data() <<
"\" does not exist." << endl;
709 cout << fname.
Data() << endl;
712 cout <<
"Numero de run " << nrun << endl;
713 cout <<
"Recherche de " <<
Form(
"%s_run%d;1",
717 if (fileDataSelector) {
720 Get(
Form(
"%s_run%d;1", GetDataSelector(), nrun));
723 for (
Int_t i = 0; i < revtList->
GetN(); i++) {
724 fEvtList->Enter(fTreeOffset[tn] + revtList->
GetEntry(i));
726 fTEVLexist[tn] =
kTRUE;
729 cout <<
"Liste introuvable..." << endl;
730 for (
Int_t i = fTreeOffset[tn]; i < fTreeOffset[tn + 1];
737 cout <<
"Run inconnu..." << endl;
740 if (fileDataSelector) {
741 cout <<
"Closing " << fileDataSelector->
GetName() << endl;
742 fileDataSelector->
Close();
743 dataselector_lock.Release();
752 if (!fEvtList->GetN()) {
753 Warning(
"BuildEventList()",
"The TEventList is empty...");
758 fChain->SetEventList(fEvtList);
774 Bool_t ok = (fTreeEntry + 1 == fChain->GetTree()->GetEntries());
779 globEntry = ((
TChain*) fChain)->GetChainEntryNumber(fTreeEntry);
781 globEntry = fTreeEntry;
782 Int_t index = fEvtList->GetIndex(globEntry);
783 Long64_t nextEntry = (fEvtList->GetEntry(index + 1));
784 ok = ok || (nextEntry == -1);
786 ok = ok || (nextEntry >= fTreeOffset[fCurrentTreeNumber + 1]);
805 cout <<
"Loading KVDataSelector..." << endl;
807 if (fDataSelector.Length()) {
809 TClass* clas =
gROOT->GetClass(fDataSelector.Data());
810 cout << clas <<
" / " << fDataSelector.Data() << endl;
814 TString fileC(
Form(
"%s.cpp", fDataSelector.Data()));
817 #ifdef __WITHOUT_TMACRO
819 Warning(
"LoadDataSelector(void)",
821 (
"No implementation and/or declaration file found for \"%s\".",
822 fDataSelector.Data()));
828 TString searchname(GetDataSelectorFileName());
830 TFile* fileDataSelector = 0;
833 if (dataselector_lock.Lock(fname.
Data())) fileDataSelector =
new TFile(fname.
Data());
836 cout <<
"The file \"" << fname.
837 Data() <<
"\" does not exist." << endl;
841 if (fileDataSelector) {
847 cout << fileC.
Data() <<
" re-generated" << endl;
849 cout << fileh.
Data() <<
" re-generated." << endl;
850 deleteSources =
kTRUE;
853 Warning(
"LoadDataSelector(void)",
854 "No implementation and/or declaration file found for \"%s\".",
855 fDataSelector.Data());
857 if (fileDataSelector) {
858 fileDataSelector->
Close();
859 dataselector_lock.Release();
864 cout <<
"Files " << fileC.
Data() <<
" and " << fileh.
Data() <<
868 gROOT->GetPluginManager()->AddHandler(
"KVDataSelector",
869 fDataSelector.Data(),
870 fDataSelector.Data(),
872 fDataSelector.Data()),
874 fDataSelector.Data()));
879 Error(
"LoadDataSelector(void)",
880 "Called with class_name=%s.\nClass is unknown: not in standard libraries, and plugin (user-defined class) not found",
881 fDataSelector.Data());
885 fKVDataSelector->SetKVSelector(
this);
886 cout <<
"Apres Plugin " << fKVDataSelector->IsA()->
887 GetName() <<
" : " << fKVDataSelector->
888 GetKVSelector() << endl;
893 Error(
"LoadDataSelector(void)",
894 "%s is not a valid class deriving from KVDataSelector.",
895 fDataSelector.Data());
899 fKVDataSelector->SetKVSelector(
this);
900 cout <<
"Apres clas->New() " << fKVDataSelector->IsA()->
901 GetName() <<
" : " << fKVDataSelector->
902 GetKVSelector() << endl;
905 cout <<
"Removing files \"" << fDataSelector.
906 Data() <<
"*.*\" ..." << endl;
909 (
"rm %s.[c,h]*", fDataSelector.Data()));
916 fKVDataSelector->Init();
931 if (fKVDataSelector) {
934 TString searchname(GetDataSelectorFileName());
942 cout <<
"File to open : " << fname.
Data() <<
" : " << option.
944 TFile* fileDataSelector = 0;
945 if (dataselector_lock.Lock(fname.
Data())) fileDataSelector =
new TFile(fname.
Data(), option.
Data());
946 if (!fileDataSelector || (fileDataSelector && fileDataSelector->
IsZombie())) {
947 Error(
"SaveCurrentDataSelection(void)",
948 "Opening the file \"%s\" with the option \"%s\" is not possible.\nNothing saved.",
953 cout <<
"Saving the TEventList \"" << fKVDataSelector->
954 GetTEventList()->
GetName() <<
"\"..." << endl;
955 cout << fKVDataSelector->GetTEventList()->
956 GetN() <<
" entries selected." << endl;
957 fKVDataSelector->GetTEventList()->Write();
959 #ifndef __WITHOUT_TMACRO
963 Get(
Form(
"%s.cpp;1", fKVDataSelector->IsA()->GetName()));
966 Get(
Form(
"%s.h;1", fKVDataSelector->IsA()->GetName()));
968 cout <<
"Saving the source files..." << endl;
969 TMacro mC(
Form(
"%s.cpp", fKVDataSelector->IsA()->GetName()));
970 mC.
SetName(
Form(
"%s.cpp", fKVDataSelector->IsA()->GetName()));
972 (
"Implementation file for the KVDataSelector \"%s\".",
973 fKVDataSelector->IsA()->GetName()));
975 TMacro mh(
Form(
"%s.h", fKVDataSelector->IsA()->GetName()));
976 mh.
SetName(
Form(
"%s.h", fKVDataSelector->IsA()->GetName()));
978 (
"Declaration file for the KVDataSelector \"%s\".",
979 fKVDataSelector->IsA()->GetName()));
984 cout <<
"Done" << endl;
985 fileDataSelector->
Close();
986 dataselector_lock.Release();
990 cout <<
"No TEventList to save..." << endl;
1015 gEnv->
GetValue(
"DataSelector.fileName",
"ListOfDataSelector.root");
1016 cout <<
"List Of Data Selectors : " << fname.
Data() << endl;
1017 return fname.
Data();
1053 SetBit(kChangeMasses);
1054 fNewMassFormula = mass_formula;
1121 else *fPartCond = cond;
1169 FillTH3((
TH3*)
h1, one, two, three, four);
1171 FillTProfile2D((
TProfile2D*)
h1, one, two, three, four);
1175 FillTH2((
TH2*)
h1, one, two, three);
1177 FillTProfile((
TProfile*)
h1, one, two, three);
1179 FillTH1(
h1, one, two);
1181 Warning(
"FillHisto",
"%s -> Classe non prevue ...", lhisto->FindObject(sname.
Data())->ClassName());
1184 Warning(
"FillHisto",
"%s introuvable", sname.
Data());
1209 h1->
Fill(one, two, three);
1221 h2->
Fill(one, two, three);
1233 h2->
Fill(one, two, three, four);
1255 h3->
Fill(one, two, three, four);
1267 Warning(
"CreateHistos",
"To be redefined child class");
1288 if (filename ==
"") {
1289 GetHistoList()->Write();
1298 GetHistoList()->Write();
1299 if (IsCreated)
file->Close();
1335 Warning(
"CreateTrees",
"To be redefined child class");
1348 ltree->Execute(
"Fill",
"");
1352 if ((
tt = GetTree(sname.
Data()))) {
1356 Warning(
"FillTree",
"%s introuvable", sname.
Data());
1373 if (filename ==
"") {
1374 GetTreeList()->Write();
1386 GetTreeList()->Write();
1387 if (IsCreated)
file->Close();
1401 fOptionList.SetValue(option, tmp);
1414 return fOptionList.HasParameter(opt);
1429 return fOptionList.GetTStringValue(opt);
1442 fOptionList.RemoveParameter(opt);
1460 fOptionList.Clear();
1463 while (!option.
End()) {
1469 while (!opt.
End()) {
1477 fOptionList.Print();
KVDataAnalyser * gDataAnalyser
KVTemplateParticleCondition< KVNucleus > KVParticleCondition
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
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.
Manage a list of global variables.
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)
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 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()
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
Bool_t Process(Long64_t entry)
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.
KVHashList * GetHistoList()
virtual void CreateTrees()
void SlaveTerminate()
Function called at the end of the event loop in each PROOF slave.
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.
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()
void SlaveBegin(TTree *tree)
virtual void WriteHistoToFile(KVString filename="FileFromKVOldINDRASelector.root", Option_t *option="recreate")
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
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
virtual TObject * FindObject(const char *name) const
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 const char * GetName() const
virtual void SetTitle(const char *title="")
virtual void SetName(const char *name)
TObject * At(Int_t idx) const
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
virtual TObject * FindObject(const char *name) const
R__ALWAYS_INLINE Bool_t IsZombie() const
virtual Bool_t InheritsFrom(const char *classname) const
Longptr_t ExecPlugin(int nargs, const T &... params)
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)
void Add(RHist< DIMENSIONS, PRECISION, STAT_TO... > &to, const RHist< DIMENSIONS, PRECISION, STAT_FROM... > &from)
TH1 * GetHisto(const std::string file, const std::string path, const std::string obj)