KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVTGIDGrid.cpp
Go to the documentation of this file.
1 /*
2 $Id: KVTGIDGrid.cpp,v 1.2 2009/03/03 14:27:15 franklan Exp $
3 $Revision: 1.2 $
4 $Date: 2009/03/03 14:27:15 $
5 */
6 
7 //Created by KVClassFactory on Fri Apr 25 15:55:08 2008
8 //Author: franklan
9 
10 #include "KVTGIDGrid.h"
11 #include "KVTGID.h"
12 #include "KVIDGridManager.h"
13 
14 using namespace std;
15 
17 
18 
19 
23 {
24  // Default constructor
25  fTGID = 0;
26 }
27 
28 
29 
33 
35  : KVIDZAGrid()
36 {
37  // Create a grid in order to visualize the results of a fit of an identification grid.
38  // We keep any "cuts" from the original grid and add them to the fitted grid
39 
40  fTGID = tgid;
41  SetVarX(fTGID->GetVarX());
42  SetVarY(fTGID->GetVarY());
44 
45 // TList *idtels = (TList *)fTGID->GetIDTelescopes();
46 // TObject *idt = NULL;
47 // TIter next_idt( idtels );
48 // while( (idt = next_idt()) ) fTelescopes.Add( idt );
49 // delete idtels;
50 
51  TString name(fTGID->GetName());
52  Int_t ver = 1;
53  if (gIDGridManager->GetGrid(name.Data())) {
54  do {
55  name.Form("%s_%d", fTGID->GetName(), ver);
56  ver++;
57  }
58  while (gIDGridManager->GetGrid(name.Data()));
59  }
60  SetName(name.Data());
61  if (original) original->GetCuts()->Copy(fCuts);
62 
63  GetParameters()->SetValue("HasTGID", 1);
65 }
66 
67 
68 
71 
73 {
74  // Destructor
75 }
76 
77 
78 
79 
82 
83 void KVTGIDGrid::WriteToAsciiFile(ofstream& gridfile)
84 {
85  // Write parameters of LTG fit used to generate grid in gridfile.
87  if (fTGID) fTGID->WriteToAsciiFile(gridfile);
88 }
89 
90 
91 
92 
95 
96 void KVTGIDGrid::ReadFromAsciiFile(ifstream& gridfile)
97 {
98  // Read grid and parameters of LTG fit used to generate grid in gridfile.
100  KVString line;
101  if (fPar.GetIntValue("HasTGID")) {
102  line.ReadLine(gridfile);
103  if (line.BeginsWith("++KVTGID")) fTGID = KVTGID::ReadFromAsciiFile(GetName(), gridfile);
104  }
105  FindAxisLimits();
106 }
107 
108 
109 
110 
130 
131 void KVTGIDGrid::Generate(Double_t xmax, Double_t xmin, Int_t ID_min, Int_t ID_max, Int_t npoints, Bool_t logscale)
132 {
133  //(Re)generate ID grid from the functional using current values of parameters.
134  //
135  // xmin, xmax - min and max values of 'x' coordinate used in corresponding
136  // identification map
137  // ID_min, ID_max - min and max 'ID' of lines in grid
138  // npoints - number of points in each line
139  //
140  //DEFAULT ARGUMENT VALUES:
141  //=========================
142  // xmin = 0.
143  // If the grid gets "ugly" for small x, you might try setting xmin = fitted X-pedestal
144  // This is the value of parameter 7 in most cases....
145  //
146  // ID_min, ID_max = min and max ID of lines on which functional was fitted
147  // npoints = 100
148  //
149  // if logscale=kTRUE (default is kFALSE) lines are generated with more points at
150  // the beginning of the lines than at the end.
151 
152  if (!GetTGID()) {
153  Error("Generate", "No parameter stored to initialize a functional !");
154  return;
155  }
156 
157  ID_min = (ID_min ? ID_min : (Int_t) fTGID->GetIDmin());
158  ID_max = (ID_max ? ID_max : (Int_t) fTGID->GetIDmax());
159 
160  // clear existing lines
161  Bool_t was_drawn = kFALSE;
162  TVirtualPad* last_pad = fPad;
163  if (fPad) {
164  UnDraw();
165  was_drawn = kTRUE;
166  }
167 
168  // delete all previous identification lines
170  fXmin = fYmin = fXmax = fYmax = 0;
171 
172  for (Int_t ID = ID_min; ID <= ID_max; ID++) {
173  fTGID->AddLineToGrid(this, ID, npoints, xmin, xmax, logscale);
174  }
175  if (was_drawn) {
176  last_pad->cd();
177  Draw();
178  }
179  FindAxisLimits();
180 }
181 
182 
183 
186 
188 {
189  // a completer mais j'ai la fleme...
190  return fTGID;
191 }
192 
193 
194 
196 
198 {
199  id->SetLineColor(kGray + 2);
200  id->SetLineStyle(2);
202 }
203 
204 
int Int_t
KVIDGridManager * gIDGridManager
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
const Bool_t kFALSE
bool Bool_t
double Double_t
const Bool_t kTRUE
kGray
float xmin
float xmax
KVNameValueList fPar
parameters associated to grid
Definition: KVIDGraph.h:44
virtual void SetVarX(const char *v)
Definition: KVIDGraph.h:524
KVList fCuts
cuts used to define area in which identification is possible
Definition: KVIDGraph.h:40
KVList fIdentifiers
list of identification objects
Definition: KVIDGraph.h:39
virtual void SetName(const char *name)
Definition: KVIDGraph.h:139
virtual void WriteToAsciiFile(std::ofstream &gridfile)
Definition: KVIDGraph.cpp:442
void Draw(Option_t *opt="")
Definition: KVIDGraph.cpp:888
Axis_t fXmin
Definition: KVIDGraph.h:42
const KVList * GetCuts() const
Definition: KVIDGraph.h:307
void UnDraw()
Definition: KVIDGraph.cpp:966
virtual void ReadFromAsciiFile(std::ifstream &gridfile)
Definition: KVIDGraph.cpp:601
void FindAxisLimits()
Calculate X/Y min/max of all objects in graph.
Definition: KVIDGraph.cpp:1073
virtual void SetVarY(const char *v)
Definition: KVIDGraph.h:528
const KVNameValueList * GetParameters() const
Definition: KVIDGraph.h:287
const Char_t * GetName() const
Definition: KVIDGraph.cpp:1332
virtual void AddIdentifier(KVIDentifier *id)
Definition: KVIDGraph.h:339
TVirtualPad * fPad
pad in which graph is drawn
Definition: KVIDGraph.h:47
Axis_t fYmax
min/max Y coordinates of graph
Definition: KVIDGraph.h:43
void SetRuns(const KVNumberList &nl)
Set list of runs for which grid is valid.
Definition: KVIDGraph.cpp:1316
Axis_t fXmax
min/max X coordinates of graph
Definition: KVIDGraph.h:42
Axis_t fYmin
Definition: KVIDGraph.h:43
KVIDGraph * GetGrid(const Char_t *name)
Return pointer to grid with name "name".
Identification grid with lines corresponding to different nuclear isotopes (KVIDZALine)
Definition: KVIDZAGrid.h:65
Base class for graphical cuts used in particle identification.
Definition: KVIDentifier.h:27
Int_t GetIntValue(const Char_t *name) const
void SetValue(const Char_t *name, value_type value)
virtual void Copy(TObject &obj) const
virtual void Delete(Option_t *option="")
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:72
Grid representing result of fit.
Definition: KVTGIDGrid.h:23
virtual ~KVTGIDGrid()
Destructor.
Definition: KVTGIDGrid.cpp:72
void WriteToAsciiFile(std::ofstream &)
Write parameters of LTG fit used to generate grid in gridfile.
Definition: KVTGIDGrid.cpp:83
KVTGIDGrid()
Default constructor.
Definition: KVTGIDGrid.cpp:22
void ReadFromAsciiFile(std::ifstream &)
Read grid and parameters of LTG fit used to generate grid in gridfile.
Definition: KVTGIDGrid.cpp:96
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)
Definition: KVTGIDGrid.cpp:131
const KVTGID * GetTGID() const
a completer mais j'ai la fleme...
Definition: KVTGIDGrid.cpp:187
virtual void AddIdentifier(KVIDentifier *id)
Definition: KVTGIDGrid.cpp:197
KVTGID * fTGID
KVTGID used to generate grid.
Definition: KVTGIDGrid.h:25
Abstract base class for particle identfication using functionals developed by L. Tassan-Got (IPN Orsa...
Definition: KVTGID.h:43
virtual void AddLineToGrid(KVIDGrid *g, Int_t ID, Int_t npoints, Double_t xmin, Double_t xmax, Bool_t log_scale=kFALSE)
Definition: KVTGID.cpp:241
Double_t GetIDmin() const
Definition: KVTGID.h:128
const Char_t * GetVarX() const
Definition: KVTGID.h:266
Double_t GetIDmax() const
Definition: KVTGID.h:120
const KVNumberList & GetValidRuns() const
Definition: KVTGID.h:252
void WriteToAsciiFile(std::ofstream &) const
Write parameters of LTG fit in file.
Definition: KVTGID.cpp:758
static KVTGID * ReadFromAsciiFile(const Char_t *name, std::ifstream &)
Definition: KVTGID.cpp:813
const Char_t * GetVarY() const
Definition: KVTGID.h:274
virtual const char * GetName() const
virtual void Error(const char *method, const char *msgfmt,...) const
const char * Data() const
void Form(const char *fmt,...)
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
TLine * line