35 cout <<
"The pad showing graph " << GetName() <<
" has been closed !" << endl;
38 fPad->Disconnect(
"Closed()",
this,
"ResetPad()");
39 if (fPad->GetCanvas()) fPad->GetCanvas()->Disconnect(
"Cleared(TVirtualPad*)",
this,
"ClearPad(TVirtualPad*)");
52 cout <<
"The pad showing graph " << GetName() <<
" has been cleared" << endl;
53 fPad->Disconnect(
"Closed()",
this,
"ResetPad()");
54 if (fPad->GetCanvas()) fPad->GetCanvas()->Disconnect(
"Cleared(TVirtualPad*)",
this,
"ClearPad(TVirtualPad*)");
77 fInfoZones->SetCleanup();
78 fXmin = fYmin = fXmax = fYmax = 0;
88 fLastSavedVersion = NULL;
115 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
130 ((
TCutG&)obj).SetVarX(GetVarX());
131 ((
TCutG&)obj).SetVarY(GetVarY());
139 if (fLastScaleX != 1 || fLastScaleY != 1)
140 const_cast < KVIDGraph*
>(
this)->Scale(1. / fLastScaleX,
150 for (
int i = 0; i < fPar->GetNpar(); i++) {
151 par = fPar->GetParameter(i);
153 if (!parname.
Contains(
"ScaleFactor"))
157 if (fLastScaleX != 1 || fLastScaleY != 1) {
158 const_cast < KVIDGraph*
>(
this)->Scale(fLastScaleX, fLastScaleY);
187 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
335 TIter next(isotopes.get());
425 ofstream gridfile(filename);
486 gridfile <<
"# ASCII file generated by " <<
ClassName() <<
487 "::WriteToAsciiFile" << endl;
488 gridfile <<
"# ID Graph Name : " <<
GetName() << endl;
489 gridfile <<
"# This file can be read using " <<
ClassName() <<
490 "::ReadFromAsciiFile" << endl;
491 gridfile <<
"# " << endl;
497 gridfile <<
"<VARX> " <<
GetVarX() << endl;
498 gridfile <<
"<VARY> " <<
GetVarY() << endl;
504 gridfile <<
"<PARAMETER> " << par->
GetName() <<
"=" << par->
GetString() << endl;
518 line->WriteAsciiFile(gridfile,
"ID");
523 line->WriteAsciiFile(gridfile,
"OK");
528 line->WriteAsciiFile(gridfile,
"INFO");
535 gridfile <<
"!" << endl;
578 Info(
"RevertToLastSavedVersion",
"No saved version to revert to! (Sorry)");
641 Int_t mass_formula = -1;
643 while (gridfile.good()) {
645 s.ReadLine(gridfile);
646 if (
s.BeginsWith(
'!')) {
650 else if (
s.BeginsWith(
"++")) {
655 Warning(
"ReadFromAsciiFile(ofstream&)",
656 "Class name in file %s does not correspond to this class (%s)",
659 else if (
s.BeginsWith(
"<NAME>")) {
665 else if (
s.BeginsWith(
"<VARX>")) {
671 else if (
s.BeginsWith(
"<VARY>")) {
677 else if (
s.BeginsWith(
"<PARAMETER>")) {
688 if (name !=
"" && value !=
"") {
699 else if (
s.BeginsWith(
"<LIST>")) {
716 else if (
s.BeginsWith(
"OnlyZId")) {
718 s.ReplaceAll(
"OnlyZId",
"");
721 mass_formula =
s.Atoi();
725 else if (
s.BeginsWith(
'+')) {
732 s.ReadLine(gridfile);
742 "In graph : %s\nIdentifier with no name. Identifier type = %s. Line number in graph = %d",
778 line->ReadAsciiFile(gridfile);
805 ifstream gridfile(filename);
807 if (gridfile.good()) {
811 Warning(
"ReadAsciiFile",
"Could not find file %s. Check filename.", filename);
830 "%s is not a valid classname. No known class.", id_class);
835 "%s is not a valid class deriving from KVIDentifier",
928 if (!
gPad->GetListOfPrimitives()->GetSize()) {
1036 cout <<
"Title : " <<
GetTitle() << endl;
1067 for (
int i = 0; i <
line->GetN(); i++) {
1077 for (
int i = 0; i <
line->GetN(); i++) {
1175 Warning(
"DrawAndAdd",
"Changed active pad to pad containing this graph");
1184 line->WaitForPrimitive();
1227 if (
line->GetID() >= id1_min &&
line->GetID() <= id1_max)
1234 if (
line->GetID() >= id2_min &&
line->GetID() <= id2_max)
1270 if (rejected_by) *rejected_by =
"";
1273 if (rejected_by) *rejected_by =
id->GetName();
1332 tel_list.
Begin(
",");
1397 if (version == -1) cout <<
"no file " +
fPattern +
"_v%d.grid" << endl;
1398 else cout <<
"no file " +
fPattern +
Form(
"_v%d.grid", version) << endl;
1424 pbis = ((
TObjString*)(*tok)[nb - 1])->GetString();
1426 for (
Int_t ii = 0; ii < nb - 1; ii += 1) chemin += ((
TObjString*)(*tok)[ii])->GetString();
1429 gROOT->ProcessLine(
".! ls " +
fPattern +
"_v*.grid >> " + chemin +
"listKVIDGraph_" + pbis);
1430 ifstream f_in(chemin +
"listKVIDGraph_" + pbis);
1433 while (f_in.good() && num != version) {
1434 line.ReadLine(f_in);
1436 tok =
line.Tokenize(
".");
1439 tok =
line.Tokenize(
"template");
1440 num = ((
TObjString*)(*tok)[0])->GetString().Atoi();
1441 if (num > temoin) temoin = num;
1445 gROOT->ProcessLine(
".! rm -f " + chemin +
"listKVIDGraph_" + pbis);
1447 if (version == -1)
return temoin;
1448 else if (temoin != version) {
1610 return tel_list.
Data();
1615 if (
id) tel_list =
id->GetName();
1616 while ((
id = next())) tel_list +=
Form(
",%s", id->
GetName());
1627 void KVIDGraph::Streamer(
TBuffer& R__b)
1638 while ((
id = (
KVIDentifier*)nxt_cut()))
id->fParent =
this;
1640 while ((
id = (
KVIDentifier*)nxt_info()))
id->fParent =
this;
1658 void fill(
const char* name,
double x,
double y = 0.,
double w = 0.)
1721 Int_t events_read = 0;
1722 Int_t percent = 0, cumul = 0;
1725 for (
int i = 1; i <= data->
GetNbinsX(); i++) {
1726 for (
int j = 1; j <= data->
GetNbinsY(); j++) {
1741 Double_t weight = (kmax == 20 ? poids / 20. : 1.);
1742 for (
int k = 0; k < kmax; k++) {
1750 if (idr.
Aident) PID = (idr.
Z + 0.1 * (idr.
PID - 2. * idr.
Z));
1754 idresults.
fill(
"ID_REAL", PID, weight);
1755 idresults.
fill(
"ID_REAL_VS_ERES",
x, PID, weight);
1757 idresults.
fill(
"Z_A_REAL", RealA - RealZ,
gRandom->
Gaus(RealZ, 0.15), weight);
1758 idresults.
fill(
"ZADIST_AIDENT", idr.
Z, idr.
A, weight);
1761 idresults.
fill(
"AIDENT_ICODE0",
x,
y, weight);
1766 idresults.
fill(
"AIDENT_ICODE123",
x,
y, weight);
1775 idresults.
fill(
"ZIDENT_ICODE0",
x,
y, weight);
1780 idresults.
fill(
"ZIDENT_ICODE123",
x,
y, weight);
1791 idresults.
fill(
"AIDENT_ICODE4",
x,
y, weight);
1794 idresults.
fill(
"AIDENT_ICODE5",
x,
y, weight);
1797 idresults.
fill(
"AIDENT_ICODE6",
x,
y, weight);
1800 idresults.
fill(
"AIDENT_ICODE7",
x,
y, weight);
1809 idresults.
fill(
"ZIDENT_ICODE4",
x,
y, weight);
1812 idresults.
fill(
"ZIDENT_ICODE5",
x,
y, weight);
1815 idresults.
fill(
"ZIDENT_ICODE6",
x,
y, weight);
1818 idresults.
fill(
"ZIDENT_ICODE7",
x,
y, weight);
1828 events_read += (
Int_t) poids;
1829 percent = (1. * events_read / tot_events) * 100.;
1830 if (percent > cumul) {
KVIDGridManager * gIDGridManager
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
R__EXTERN TRandom * gRandom
char * Form(const char *fmt,...)
char * Strip(const char *str, char c=' ')
R__EXTERN TSystem * gSystem
Base class for KaliVeda framework.
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
Extended version of ROOT THashList.
Base class for particle identification in a 2D map.
KVNumberList fRunList
runs for which grid is valid
void Add(TString, KVIDentifier *)
Double_t GetYScaleFactor()
TString fDyName
dynamically generated name
virtual void ReadAsciiFile_WP(Int_t version=-1)
lecture des grilles avec version suivant un modele de fichier
KVIDGraph * fLastSavedVersion
copy of last save version of grid, used for 'undo'
Int_t GetNumberOfCuts() const
virtual void SetVarX(const char *v)
void ReadAsciiFile(const Char_t *filename)
void RemoveIdentifier(KVIDentifier *)
Remove and destroy identifier.
Double_t GetXScaleFactor()
virtual void TestIdentification(TH2F *data, KVHashList &histos, KVNameValueList &histo_names)
Double_t fLastScaleY
last applied scaling factor on Y
Double_t fLastScaleX
last applied scaling factor on X
void UpdateLastSavedVersion()
update last saved version. mkae copy of current state of graph.
virtual void SetName(const char *name)
void Scale(Double_t sx=-1, Double_t sy=-1)
Called by SetX/YScaleFactor methods to rescale every point of every object in the grid.
void RemoveInfo(KVIDentifier *)
Remove and destroy cut.
virtual void WriteToAsciiFile(std::ofstream &gridfile)
static void SetAutoAdd(Bool_t yes=kTRUE)
virtual void AddInfo(KVIDentifier *info)
void Increment(Float_t x)
void Draw(Option_t *opt="")
void AddIDTelescope(KVBase *t)
Int_t GetNumberOfIdentifiers() const
virtual void Copy(TObject &) const
virtual void Browse(TBrowser* b);
virtual void ReadIdentifierFromAsciiFile(TString &name, TString &type, TString &cl, std::ifstream &gridfile)
Read in new identifier object from file.
Int_t GetMassFormula() const
KVNameValueList * fPar
parameters associated to grid
void RevertToLastSavedVersion()
virtual void ReadFromAsciiFile(std::ifstream &gridfile)
void ClearPad(TVirtualPad *)
void WriteParameterListOfIDTelescopes()
virtual void Identify(Double_t, Double_t, KVIdentificationResult *) const =0
TString fPattern
pattern of filenames used to write or read grid
void SetLineColor(Color_t lcolor)
KVList * fIdentifiers
list of identification objects
void Print(Option_t *opt="") const
Print out all objects in graph.
KVList * fCuts
cuts used to define area in which identification is possible
virtual void WriteAsciiFile_WP(Int_t version=-1)
KVIDentifier * GetIdentifier(Int_t Z, Int_t A) const
KVList * GetInfos() const
KVList * fInfoZones
contours/lines used to add info to particles (ex: punch-through)
virtual ~KVIDGraph()
Destructor.
virtual Bool_t IsIdentifiable(Double_t, Double_t, TString *rejected_by=nullptr) const
void FindAxisLimits()
Calculate X/Y min/max of all objects in graph.
virtual void SetVarY(const char *v)
static KVIDGraph * AddGraphs(KVIDGraph *g1, Int_t id1_min, Int_t id1_max, KVIDGraph *g2, Int_t id2_min, Int_t id2_max)
virtual void DrawAndAdd(const Char_t *type="ID", const Char_t *classname="KVIDentifier")
virtual void AddCut(KVIDentifier *cut)
void SetMassFormula(Int_t)
const Char_t * GetName() const
TList fTelescopes
ID telescopes for which grid is valid.
static Bool_t fAutoAddGridManager
if =kTRUE, grids are automatically added to ID grid manager on creation (default)
void WriteAsciiFile(const Char_t *filename)
Open, write and close ascii file containing this grid.
virtual KVIDentifier * New(const Char_t *)
Create new object of class "id_class" which derives from KVIDentifier.
virtual void BackwardsCompatibilityFix()
void AddIDTelescopes(const TList *)
Associate this graph with all ID telescopes in list.
virtual void AddIdentifier(KVIDentifier *id)
virtual void SetInfos(Double_t, Double_t, KVIdentificationResult *) const
loop over KVIDGraph::fInfoZones to set flags in KVIdentificationResult
static KVIDGraph * MakeIDGraph(const Char_t *)
const Char_t * GetNamesOfIDTelescopes() const
void SetXScaleFactor(Double_t=0)
Int_t GetNumberOfInfos() const
TVirtualPad * fPad
pad in which graph is drawn
virtual Bool_t AcceptIDForTest(const KVIdentificationResult &idr)
Axis_t fYmax
min/max Y coordinates of graph
void SetRuns(const KVNumberList &nl)
Set list of runs for which grid is valid.
virtual Int_t CheckVersion(Int_t version)
virtual void SetEditable(Bool_t editable=kTRUE)
void SetYScaleFactor(Double_t=0)
virtual void Initialize()=0
Axis_t fXmax
min/max X coordinates of graph
Bool_t fOnlyZId
set to kTRUE when only to be used to give Z identification of nuclei, no mass info
virtual void Clear(Option_t *opt="")
Int_t fMassFormula
OPTION={GetMethod="GetMassFormula";SetMethod="SetMassFormula";Items=(0="Beta-stability",...
void SetPattern(TString pattern)
KVList * GetIdentifiers() const
void RemoveCut(KVIDentifier *)
Remove and destroy cut.
virtual void SetOnlyZId(Bool_t yes=kTRUE)
void AddGrid(KVIDGraph *)
Add a grid to the collection. It will be deleted by the manager.
Base class for graphical cuts used in particle identification.
KVIDGraph * fParent
parent identification map or grid
virtual Int_t GetA() const
virtual Int_t GetZ() const
virtual Bool_t TestPoint(Double_t, Double_t)
Full result of one attempted particle identification.
void AddFlag(std::string grid_name, TString flag)
Bool_t Aident
= kTRUE if A of particle established
Double_t PID
= "real" Z if Zident==kTRUE and Aident==kFALSE, "real" A if Zident==Aident==kTRUE
Int_t A
A of particle found (if Aident==kTRUE)
Int_t Z
Z of particle found (if Zident==kTRUE)
Int_t IDquality
specific quality code returned by identification procedure
Bool_t Zident
=kTRUE if Z of particle established
Extended TList class which owns its objects by default.
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
virtual void Print(Option_t *opt="") const
KVNamedParameter * GetParameter(Int_t idx) const
return the parameter object with index idx
Int_t GetIntValue(const Char_t *name) const
Double_t GetDoubleValue(const Char_t *name) const
void SetValue(const Char_t *name, value_type value)
void RemoveParameter(const Char_t *name)
virtual void Clear(Option_t *opt="")
Int_t GetNpar() const
return the number of stored parameters
const Char_t * GetStringValue(const Char_t *name) const
Bool_t HasParameter(const Char_t *name) const
A generic named parameter storing values of different types.
const Char_t * GetString() const
Strings used to represent a set of ranges of values.
void SetMinMax(Int_t min, Int_t max, Int_t pas=1)
Set list with all values from 'min' to 'max'.
const Char_t * AsString(Int_t maxchars=0) const
KVSeqCollection * GetSubListWithMethod(const Char_t *retvalue, const Char_t *method) const
T * get_object(const char *name) const
virtual void Execute(const char *method, const char *params, Int_t *error=0)
virtual void SetCleanup(Bool_t enable=kTRUE)
virtual TObject * Remove(TObject *obj)
Remove object from list.
virtual void Delete(Option_t *option="")
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 Copy(TAttFill &attfill) const
void Copy(TAttLine &attline) const
void Copy(TAttMarker &attmarker) const
virtual Double_t GetBinCenter(Int_t bin) const
virtual Double_t GetBinWidth(Int_t bin) const
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
static TClass * GetClass(Bool_t load=kTRUE, Bool_t silent=kFALSE)
Bool_t InheritsFrom(const char *cl) const
virtual Int_t GetEntries() const
const char * GetVarY() const
const char * GetVarX() const
Bool_t GetEditable() const
virtual void SetEditable(Bool_t editable=kTRUE)
virtual Int_t GetNbinsY() const
virtual Int_t GetNbinsX() const
virtual Int_t Fill(const char *name, Double_t w)
virtual Double_t GetBinContent(Int_t bin) const
virtual void ls(Option_t *option="") const
virtual TObject * At(Int_t idx) const
virtual const char * GetName() const
virtual void Copy(TObject &named) const
virtual const char * GetTitle() const
TObject * At(Int_t idx) const
virtual const char * GetName() const
virtual TObject * Clone(const char *newname="") const
virtual const char * ClassName() const
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Error(const char *method, const char *msgfmt,...) const
virtual void Info(const char *method, const char *msgfmt,...) const
Longptr_t ExecPlugin(int nargs, const T &... params)
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
virtual Double_t Uniform(Double_t x1, Double_t x2)
TObjArray * Tokenize(const TString &delim) const
const char * Data() const
TString & Remove(EStripType s, char c)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual Bool_t ProcessEvents()
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
Double_t Min(Double_t a, Double_t b)
void fill(const char *name, double x, double y=0., double w=0.)
KVNameValueList & histo_names
kvidgraph_idresult_filler(KVHashList &h, KVNameValueList &n)