4 #include "KVRTGIDManager.h"
6 #include "KVTGIDGrid.h"
7 #include "KVIDGridManager.h"
8 #include "KVMultiDetArray.h"
9 #include "KVIDTelescope.h"
35 fIDList.SetOwner(kFALSE);
52 if (fIDGlobalList && !fIDGlobalList->GetEntries()) SafeDelete(fIDGlobalList);
68 AddTGIDToGlobalList(_tgid);
85 const Char_t* id_type,
86 const Char_t* grid_type)
98 Char_t cname[9] =
"KVTGIDZ";
99 TString buff = id_type;
101 if (buff.Contains(
"A")) strcpy(cname,
"KVTGIDZA");
103 buff.Form(
"_%s_%s", id_type, grid_type);
105 TIter next(&fIDList);
110 while ((tgid = (
KVTGID*)next())) {
111 name = tgid->GetName();
112 if (name.Contains(buff))
return tgid;
113 if (!tgid2 && !strcmp(tgid->ClassName(), cname)) tgid2 = tgid;
142 if (!(tgid = (
KVTGID*)fIDList.FindObject(tgid)))
return;
143 fIDList.Remove(tgid);
149 while ((t = (
KVTGID*)n())) fID_max = TMath::Max(fID_max, t->
GetIDmax());
159 if (!fIDGlobalList)
return;
165 if (!(tgid = (
KVTGID*)fIDGlobalList->FindObject(name)))
return;
166 fIDGlobalList->Remove(tgid);
168 if (!fIDGlobalList->GetEntries()) SafeDelete(fIDGlobalList);
184 if (!gIDGridManager)
return kFALSE;
186 tgid_list->SetOwner(kFALSE);
190 TIter next_g(grid_list);
193 while ((obj = next_g())) {
194 if (obj->InheritsFrom(
"KVTGIDGrid")) {
197 tgid_list->Add(tgid);
215 ifstream fitfile(filename);
216 if (!fitfile.good()) {
217 Error(
"KVRTGIDManager::ReadAsciiFile",
"File %s cannot be opened", filename);
221 while (fitfile.good()) {
225 if (s.BeginsWith(
"#"))
continue;
226 if (s.BeginsWith(
"++")) {
231 cname.Remove(s.Index(
"::"));
232 TClass* cl = TClass::GetClass(cname.Data());
233 if (cl && cl->InheritsFrom(
"KVTGID")) {
235 s.Remove(0, s.Index(
"::") + 2);
240 AddTGIDToGlobalList(fit);
246 fitz->SetTitle(Form(
"COPY from %p", fit));
247 AddTGIDToGlobalList(fitz);
278 if (!fIDGlobalList) {
279 fIDGlobalList =
new KVList;
282 fIDGlobalList->Add(tgid);
326 if (!fIDGlobalList)
return;
331 GetTGIDfromIDGridManager(&tgid_list);
336 grid_list->Disconnect(
"Modified()", gm,
"Modified()");
340 TIter next(fIDGlobalList);
341 Bool_t IDtypeOK = strcmp(idtype,
"");
343 while ((tgid = (
KVTGID*)next())) {
344 if (tgid_list.FindObject(tgid))
continue;
348 TSeqCollection* idt_list = (TSeqCollection*)GetIDTelescopesForTGID(tgid);
349 if (!idt_list)
continue;
350 if (!(idt = (
KVBase*)idt_list->First()))
continue;
351 SafeDelete(idt_list);
352 if (strcmp(idtype, idt->
GetLabel()))
continue;
355 TString tmp = tgid->GetTitle();
356 if (tmp.Contains(
"COPY")) {
357 tmp.Remove(0, tmp.Index(
"0x"));
358 KVTGID* tmp_tgid =
reinterpret_cast<KVTGID*
>((Int_t)tmp.Atof());
359 Warning(
"KVRTGIDManager::BuildGridForAllTGID",
"No grid built for %s (%s, %p) because it is a copy of %s (%s, %p)"
360 , tgid->GetName(), tgid->ClassName(), tgid
361 , tmp_tgid->GetName(), tmp_tgid->ClassName(), tmp_tgid);
367 grid->
Generate(xmax, xmin, ID_min, ID_max, npoints, logscale);
368 Info(
"KVRTGIDManager::BuildGridForAllTGID",
"grid built from its TGID function %s (%s, %p)"
369 , tgid->GetName(), tgid->ClassName(), tgid);
371 if (grid_list) grid_list->Connect(
"Modified()",
"KVIDGridManager", gm,
"Modified()");
386 SafeDelete(fIDGlobalList);
400 TIter next(fIDGlobalList);
403 while ((tgid = (
KVTGID*)next())) {
408 TCollection* lidtel = GetIDTelescopesForTGID(tgid);
409 TIter nextidt(lidtel);
413 while ((idt = nextidt())) {
414 if (!idt->InheritsFrom(
"KVRTGIDManager")) {
415 Error(
"KVRTGIDManager::SetIDFuncInTelescopes",
"The IDtelescope %s does not inherit from KVRTGIDManager", idt->GetName());
418 tgidm = (
KVRTGIDManager*)idt->IsA()->DynamicCast(KVRTGIDManager::Class(), idt);
439 if (!GetTGIDfromIDGridManager(&tgid_list))
return 0;
443 TIter next(&tgid_list);
446 while ((tgid = (
KVTGID*)next())) {
447 if (!fIDGlobalList) {
448 AddTGIDToGlobalList(tgid);
452 if (fIDGlobalList->FindObject(tgid))
continue;
453 AddTGIDToGlobalList(tgid);
476 if (update) UpdateListFromIDGridManager();
477 if (!fIDGlobalList) {
478 Warning(
"KVRTGIDManager::WriteAsciiFile",
"No listed identification functions to write");
482 ofstream tgidfile(filename);
483 if (!tgidfile.is_open()) {
484 Error(
"KVRTGIDManager::WriteAsciiFile",
"No write permission for file %s", filename);
488 const TCollection* list_tgid = (selection ? selection : fIDGlobalList);
489 TIter next(list_tgid);
493 while ((tgid = (
KVTGID*)next())) {
496 TString tmp = tgid->GetTitle();
497 if (tmp.Contains(
"COPY")) {
498 tmp.Remove(0, tmp.Index(
"0x"));
499 KVTGID* tmp_tgid =
reinterpret_cast<KVTGID*
>((Int_t)tmp.Atof());
500 Warning(
"KVRTGIDManager::WriteAsciiFile",
"The function %s (%s, %p) is not written because it is a copy of %s (%s, %p)"
501 , tgid->GetName(), tgid->ClassName(), tgid
502 , tmp_tgid->GetName(), tmp_tgid->ClassName(), tmp_tgid);
506 Info(
"KVRTGIDManager::WriteAsciiFile",
"%s (%s, %p) saved", tgid->GetName(), tgid->ClassName(), tgid);
529 TList* list =
new TList;
Base class for KaliVeda framework.
const Char_t * GetLabel() const
void SetMassFormula(Int_t)
virtual void SetOnlyZId(Bool_t yes=kTRUE)
Handles a stock of identification grids to be used by one or more identification telescopes.
Extended TList class which owns its objects by default.
KVIDTelescope * GetIDTelescope(const Char_t *name) const
Return pointer to DeltaE-E ID Telescope with "name".
Run-dependant KVTGIDManager.
static void BuildGridForAllTGID(const Char_t *idtype="", Double_t xmin=0., Double_t xmax=4096., Int_t ID_min=0, Int_t ID_max=0, Int_t npoints=50, Bool_t logscale=kTRUE)
static void SetIDFuncInTelescopes(UInt_t run)
virtual ~KVRTGIDManager()
static Int_t WriteAsciiFile(const Char_t *filename, const TCollection *selection=0, Bool_t update=kTRUE)
static Int_t UpdateListFromIDGridManager()
virtual KVTGID * GetTGID(const Char_t *idt_name, const Char_t *id_type, const Char_t *grid_type)
static TCollection * GetIDTelescopesForTGID(KVTGID *)
static Bool_t ReadAsciiFile(const Char_t *filename)
virtual void SetTGID(KVTGID *)
Add an identification object to the local list (fIDList).
virtual void RemoveTGID(const Char_t *name)
Remove the identification object with name from the local list.
virtual void AddTGID(KVTGID *)
static Bool_t GetTGIDfromIDGridManager(TList *tgid_list)
virtual void RemoveAllTGID()
Remove all identification objects of the local list.
static void DeleteTGID(const Char_t *name)
static KVList * fIDGlobalList
Global list of TGID of all the KVRTGIDManager.
static void AddTGIDToGlobalList(KVTGID *)
----— static methods -----------------------—//
virtual void SetCleanup(Bool_t enable=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
Grid representing result of fit.
virtual void Generate(Double_t xmax, Double_t xmin, Int_t ID_min=0, Int_t ID_max=0, Int_t npoints=50, Bool_t logscale=kTRUE)
virtual void AddTGID(KVTGID *)
Abstract base class for charged particle Z identfication using functionals developed by L....
Abstract base class for particle identfication using functionals developed by L. Tassan-Got (IPN Orsa...
Bool_t IsValidForRun(Int_t run) const
const KVString & GetIDTelescopes() const
Double_t GetIDmax() const
void WriteToAsciiFile(std::ofstream &) const
Write parameters of LTG fit in file.
static KVTGID * ReadFromAsciiFile(const Char_t *name, std::ifstream &)
Int_t GetMassFormula() const