18#include "KVIDGridManager.h"
24#include "KVIdentificationResult.h"
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;
145 if (!parname.
Contains(
"ScaleFactor"))
318 TIter next(isotopes.get());
469 gridfile <<
"# ASCII file generated by " <<
ClassName() <<
470 "::WriteToAsciiFile" << endl;
471 gridfile <<
"# ID Graph Name : " <<
GetName() << endl;
472 gridfile <<
"# This file can be read using " <<
ClassName() <<
473 "::ReadFromAsciiFile" << endl;
474 gridfile <<
"# " << endl;
480 gridfile <<
"<VARX> " <<
GetVarX() << endl;
481 gridfile <<
"<VARY> " <<
GetVarY() << endl;
487 gridfile <<
"<PARAMETER> " << par->
GetName() <<
"=" << par->
GetString() << endl;
501 line->WriteAsciiFile(gridfile,
"ID");
506 line->WriteAsciiFile(gridfile,
"OK");
511 line->WriteAsciiFile(gridfile,
"INFO");
518 gridfile <<
"!" << endl;
563 Info(
"RevertToLastSavedVersion",
"No saved version to revert to! (Sorry)");
626 Int_t mass_formula = -1;
628 while (gridfile.good()) {
630 s.ReadLine(gridfile);
631 if (s.BeginsWith(
'!')) {
635 else if (s.BeginsWith(
"++")) {
638 s.Remove(TString::kBoth,
' ');
640 Warning(
"ReadFromAsciiFile(ofstream&)",
641 "Class name in file %s does not correspond to this class (%s)",
644 else if (s.BeginsWith(
"<NAME>")) {
647 s.Remove(TString::kBoth,
' ');
650 else if (s.BeginsWith(
"<VARX>")) {
653 s.Remove(TString::kBoth,
' ');
656 else if (s.BeginsWith(
"<VARY>")) {
659 s.Remove(TString::kBoth,
' ');
662 else if (s.BeginsWith(
"<PARAMETER>")) {
670 Strip(TString::kBoth);
672 value.Remove(TString::kBoth,
' ');
676 else if (
value.IsDigit())
684 else if (s.BeginsWith(
"<LIST>")) {
691 Strip(TString::kBoth);
701 else if (s.BeginsWith(
"OnlyZId")) {
703 s.ReplaceAll(
"OnlyZId",
"");
704 s.Remove(TString::kBoth,
' ');
706 mass_formula = s.Atoi();
710 else if (s.BeginsWith(
'+')) {
717 s.ReadLine(gridfile);
727 "In graph : %s\nIdentifier with no name. Identifier type = %s. Line number in graph = %d",
763 line->ReadAsciiFile(gridfile);
792 if (gridfile.good()) {
796 Warning(
"ReadAsciiFile",
"Could not find file %s. Check filename.",
filename);
812 TClass* clas = TClass::GetClass(id_class);
815 "%s is not a valid classname. No known class.", id_class);
820 "%s is not a valid class deriving from KVIDentifier",
913 if (!
gPad->GetListOfPrimitives()->GetSize()) {
1052 cout <<
"Title : " <<
GetTitle() << endl;
1083 for (
int i = 0; i <
line->GetN(); i++) {
1093 for (
int i = 0; i <
line->GetN(); i++) {
1187 Warning(
"DrawAndAdd",
"Changed active pad to pad containing this graph");
1196 line->WaitForPrimitive();
1239 if (
line->GetID() >= id1_min &&
line->GetID() <= id1_max)
1246 if (
line->GetID() >= id2_min &&
line->GetID() <= id2_max)
1282 if (rejected_by) *rejected_by =
"";
1284 if (!
id->TestPoint(
x,
y)) {
1285 if (rejected_by) *rejected_by =
id->GetName();
1304 if (
id->TestPoint(
x,
y)) {
1344 tel_list.
Begin(
",");
1409 if (version == -1) cout <<
"no file " +
fPattern +
"_v%d.grid" << endl;
1410 else cout <<
"no file " +
fPattern +
Form(
"_v%d.grid", version) << endl;
1436 pbis = ((
TObjString*)(*tok)[nb - 1])->GetString();
1438 for (
Int_t ii = 0; ii < nb - 1; ii += 1) chemin += ((
TObjString*)(*tok)[ii])->GetString();
1441 gROOT->ProcessLine(
".! ls " +
fPattern +
"_v*.grid >> " + chemin +
"listKVIDGraph_" + pbis);
1442 ifstream f_in(chemin +
"listKVIDGraph_" + pbis);
1445 while (f_in.good() && num != version) {
1446 line.ReadLine(f_in);
1448 tok =
line.Tokenize(
".");
1451 tok =
line.Tokenize(
"template");
1452 num = ((
TObjString*)(*tok)[0])->GetString().Atoi();
1453 if (num > temoin) temoin = num;
1457 gROOT->ProcessLine(
".! rm -f " + chemin +
"listKVIDGraph_" + pbis);
1459 if (version == -1)
return temoin;
1460 else if (temoin != version) {
1524 if (gIDGridManager) gIDGridManager->
Modified();
1622 return tel_list.
Data();
1627 if (
id) tel_list =
id->GetName();
1628 while ((
id = next())) tel_list +=
Form(
",%s",
id->GetName());
1648 while ((
id = (
KVIDentifier*)nxt_id()))
id->fParent =
this;
1650 while ((
id = (
KVIDentifier*)nxt_cut()))
id->fParent =
this;
1652 while ((
id = (
KVIDentifier*)nxt_info()))
id->fParent =
this;
1670 void fill(
const char* name,
double x,
double y = 0.,
double w = 0.)
1741 Int_t events_read = 0;
1746 for (
int i = 1; i <=
data->GetNbinsX(); ++i) {
1747 for (
int j = 1; j <=
data->GetNbinsY(); j++) {
1753 Axis_t x0 =
data->GetXaxis()->GetBinCenter(i);
1754 Axis_t y0 =
data->GetYaxis()->GetBinCenter(j);
1755 Axis_t wx =
data->GetXaxis()->GetBinWidth(i);
1756 Axis_t wy =
data->GetYaxis()->GetBinWidth(j);
1762 Double_t weight = (kmax == 20 ? poids / 20. : 1.);
1763 for (
int k = 0; k < kmax; k++) {
1771 if (idr.
Aident) PID = (idr.
Z + 0.1 * (idr.
PID - 2. * idr.
Z));
1775 idresults.
fill(
"ID_REAL", PID, weight);
1776 idresults.
fill(
"ID_REAL_VS_DE",
y, PID, weight);
1777 idresults.
fill(
"ID_REAL_VS_ERES",
x, PID, weight);
1779 idresults.
fill(
"Z_A_REAL", RealA - RealZ,
gRandom->
Gaus(RealZ, 0.15), weight);
1780 idresults.
fill(
"ZADIST_AIDENT", idr.
Z, idr.
A, weight);
1781 idresults.
fill(
"ID_REAL_AIDENT", PID, weight);
1782 idresults.
fill(
"ID_REAL_VS_DE_AIDENT",
y, PID, weight);
1783 idresults.
fill(
"ID_REAL_VS_ERES_AIDENT",
x, PID, weight);
1786 idresults.
fill(
"ID_REAL_ZIDENT", PID, weight);
1787 idresults.
fill(
"ID_REAL_VS_DE_ZIDENT",
y, PID, weight);
1788 idresults.
fill(
"ID_REAL_VS_ERES_ZIDENT",
x, PID, weight);
1793 events_read += (
Int_t) poids;
1794 percent = (1. * events_read / tot_events) * 100.;
winID h TVirtualViewer3D vv
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 id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint percent
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 Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
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
void ExtendBeginningAllIdentLines(Double_t, Option_t *="")
KVNameValueList fPar
parameters associated to grid
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)
KVList fCuts
cuts used to define area in which identification is possible
KVList fIdentifiers
list of identification objects
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 ExtendEndAllIdentLines(Double_t, Option_t *="")
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
Copy this to 'obj'.
virtual void ReadIdentifierFromAsciiFile(TString &name, TString &type, TString &cl, std::ifstream &gridfile)
Read in new identifier object from file.
Int_t GetMassFormula() const
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)
void Print(Option_t *opt="") const
Print out all objects in graph.
virtual void WriteAsciiFile_WP(Int_t version=-1)
KVIDentifier * GetIdentifier(Int_t Z, Int_t A) const
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.
const KVList * GetIdentifiers() const
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)
void RemoveCut(KVIDentifier *)
Remove and destroy cut.
KVList fInfoZones
contours/lines used to add info to particles (ex: punch-through)
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.
Full result of one attempted particle identification.
void AddFlag(std::string grid_name, TString flag)
void Clear(Option_t *opt="")
Reset to initial values.
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)
Bool_t Zident
=kTRUE if Z of particle established
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
virtual void Copy(TObject &obj) const
KVSeqCollection * GetSubListWithMethod(const Char_t *retvalue, const Char_t *method) const
virtual void Execute(const char *method, const char *params, Int_t *error=0)
virtual void SetCleanup(Bool_t enable=kTRUE)
T * get_object(const TString &name) const
virtual TObject * Remove(TObject *obj)
Remove object from list.
virtual void Delete(Option_t *option="")
virtual void RecursiveRemove(TObject *obj)
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
virtual void Streamer(TBuffer &)
void Copy(TAttFill &attfill) const
void Copy(TAttLine &attline) const
void Copy(TAttMarker &attmarker) const
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Bool_t InheritsFrom(const char *cl) const override
virtual Int_t GetEntries() const
const char * GetVarX() const
TClass * IsA() const override
const char * GetVarY() const
Bool_t GetEditable() const
virtual void SetEditable(Bool_t editable=kTRUE)
virtual Int_t Fill(const char *name, Double_t w)
void ls(Option_t *option="") const override
TObject * At(Int_t idx) const override
void Copy(TObject &named) const override
const char * GetName() const override
const char * GetTitle() const override
Int_t GetEntries() const override
TObject * At(Int_t idx) const override
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)
Bool_t Disconnect(const char *signal=nullptr, void *receiver=nullptr, const char *slot=nullptr)
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
virtual Double_t Uniform(Double_t x1, Double_t x2)
const char * Data() const
TObjArray * Tokenize(const TString &delim) const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual Bool_t ProcessEvents()
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
virtual TCanvas * GetCanvas() const=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)