KaliVeda
Toolkit for HIC analysis
KVIDZALine.cpp
1 /***************************************************************************
2 $Id: KVIDZALine.cpp,v 1.10 2009/05/05 15:57:52 franklan Exp $
3  KVIDZALine.cpp - description
4  -------------------
5  begin : Nov 10 2004
6  copyright : (C) 2004 by J.D. Frankland
7  email : frankland@ganil.fr
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 #include "KVIDZALine.h"
20 #include "TVector2.h"
21 #include "Riostream.h"
22 #include "TMath.h"
23 #include "KVIDGraph.h"
24 
25 using namespace std;
26 
28 
29 
30 
36 {
37  // Default ctor
38  // Line width is set to zero
39  // Default identification is set to proton
40 
41  SetWidth(0.);
42  fLineWithWidth = 0;
43  SetTitle("Z & A line");
44 }
45 
46 
47 
50 
52  : KVIDLine()
53 {
54  // copy constructor
55  fLineWithWidth = 0;
56  obj.Copy(*this);
57  SetTitle("Z & A line");
58 }
59 
60 
63 
64 void KVIDZALine::Copy(TObject& obj) const
65 {
66  // copy 'this' to 'obj'
67  KVIDLine::Copy(obj);
68  ((KVIDZALine&)obj).SetWidth(fWidth);
69 }
70 
71 
72 
75 
76 KVIDZALine::~KVIDZALine()
77 {
78  //Default dtor
79 }
80 
81 
82 
83 
86 
88  const Char_t* name_prefix)
89 {
90  // Write Z & A of line
91 
93  file << GetZ() << "\t" << GetA() << endl;
94 }
95 
96 
97 
98 
101 
103 {
104  // Read Z & A of line
105 
107  Int_t Z, A;
108  file >> Z >> A;
109  SetZ(Z);
110  SetA(A);
111 }
112 
113 
114 
115 
128 
130 {
131  //************ BACKWARDS COMPATIBILITY FIX *************
132  // special read method for old KVIDZLines
133  //
134  //Read coordinates of line in file buffer stream
135  //Format is :
136  //Z
137  //number_of_points
138  //x1 y1
139  //x2 y2
140  //...
141  //etc. etc.
142  Int_t N, Z;
143  file >> Z;
144  SetZ(Z);
145  file >> N;
146  for (Int_t i = 0; i < N; i++) {
147  Double_t x, y;
148  file >> x >> y;
149  SetPoint(i, x, y);
150  }
151 }
152 
153 
154 
157 
159 {
160  // returns true if there are multi-gaussian mass fit parameters associated with this line
161 
162  return GetParent() && GetParent()->GetParameters()->HasParameter(Form("MASSFIT_%d",GetZ()));
163 }
164 
165 
166 
167 
173 
174 void KVIDZALine::Print(Option_t* opt) const
175 {
176  //Print out for line
177  //The optional "opt" string, if given, is printed in parentheses after the line's name
178  //This is used by KVIDGrid in order to show which lines are "ID" lines and which are
179  //"OK" lines (i.e. used to define an identifiable area in a data map).
180  cout << ClassName() << " : " << GetName() << "(" << opt << ")" << endl;
181  cout << "Z=" << GetZ() << " A=" << GetA() << endl;
182  if (GetWidth() > 0.0) cout << "Natural Line Width : " << GetWidth() << endl;
183  TGraph::Print();
184 }
185 
186 
187 
188 
193 
195 {
196  //Return pointer to TGraphError object which can be used to visualise the natural width
197  //of this identification line.
198  //If line width = 16000, the error bar is set to 0
199 
200  if (fLineWithWidth) {
201  delete fLineWithWidth;
202  }
203  fLineWithWidth = new TGraphErrors(GetN(), GetX(), GetY());
212  for (int i = 0; i < GetN(); i++) {
213  fLineWithWidth->SetPointError(i, 0., 0.5 * (GetWidth() < 16000 ? GetWidth() : 0));
214  }
215  return fLineWithWidth;
216 }
217 
218 
219 
220 
228 
230 {
231  // Set the natural width of the line depending on its asymptotic separation
232  // a gauche (d_l) and a droite (d_r) from a neighbouring line.
233  // This method is used by KVIDGrid::CalculateLineWidths
234  //
235  // For ordinary Z/(Z,A) lines in a dE-E grid, this is just the average of
236  // the two asymptotic distances.
237 
238  SetWidth((d_l + d_r) / 2.);
239 }
240 
241 
242 
245 
246 void KVIDZALine::Streamer(TBuffer& R__b)
247 {
248  // Stream an object of class KVIDZALine.
249 
250  UInt_t R__s, R__c;
251  if (R__b.IsReading()) {
252  Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
253  if (R__v < 2) {
254  R__b.ReadVersion(&R__s, &R__c);// read version of KVIDZLine
255  KVIDLine::Streamer(R__b);
256  UShort_t z;
257  R__b >> z;
258  R__b >> fWidth;
259  SetZ(z);
260  UShort_t a;
261  R__b >> a;
262  SetA(a);
263  }
264  else {
265  R__b.ReadClassBuffer(KVIDZALine::Class(), this, R__v, R__s, R__c);
266  }
267  }
268  else {
269  R__b.WriteClassBuffer(KVIDZALine::Class(), this);
270  }
271 }
272 
273 
275 
277 
278 // This class is for backwards compatibility only
280 // and must not be used.
282 
283 
284 
288 {
289  // This class is for backwards compatibility only
290 }
291 
292 
293 
296 
297 void KVIDZLine::Streamer(TBuffer& R__b)
298 {
299  // Stream an object of class KVIDZLine
300 
301  UInt_t R__s, R__c;
302  if (R__b.IsReading()) {
303  Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
304  if (R__v != 2) {
305  KVError::Warning(this, "Streamer", "Reading KVIDZLine with version=%d", R__v);
306  }
307  KVIDLine::Streamer(R__b);
308  UShort_t z;
309  R__b >> z;
310  R__b >> fWidth;
311  SetZ(z);
312  }
313 }
314 
315 
int Int_t
unsigned int UInt_t
bool Bool_t
unsigned short UShort_t
short Version_t
char Char_t
constexpr Bool_t kFALSE
double Double_t
const char Option_t
#define N
char * Form(const char *fmt,...)
const KVNameValueList * GetParameters() const
Definition: KVIDGraph.h:357
Base class for lines/cuts used for particle identification in 2D data maps.
Definition: KVIDLine.h:143
Base class for identification ridge lines corresponding to different nuclear species.
Definition: KVIDZALine.h:33
void Copy(TObject &obj) const override
copy 'this' to 'obj'
Definition: KVIDZALine.cpp:64
void ReadAsciiFile_KVIDZLine(std::ifstream &)
Definition: KVIDZALine.cpp:129
virtual void SetAsymWidth(Double_t d_l, Double_t d_r)
Definition: KVIDZALine.cpp:229
void Print(Option_t *opt="") const override
Definition: KVIDZALine.cpp:174
TGraphErrors * GetLineWithWidth()
Definition: KVIDZALine.cpp:194
void SetWidth(Double_t w)
Definition: KVIDZALine.h:65
void ReadAsciiFile_extras(std::ifstream &) override
Read Z & A of line.
Definition: KVIDZALine.cpp:102
TGraphErrors * fLineWithWidth
used to display width of line
Definition: KVIDZALine.h:40
Double_t GetWidth() const
Definition: KVIDZALine.h:61
Bool_t HasMassFits() const override
virtual Int_t GetID() const { return GetA();}
Definition: KVIDZALine.cpp:158
Double_t fWidth
the "width" of the line
Definition: KVIDZALine.h:39
void WriteAsciiFile_extras(std::ofstream &, const Char_t *name_prefix="") override
Write Z & A of line.
Definition: KVIDZALine.cpp:87
virtual void ReadAsciiFile_extras(std::ifstream &)
Definition: KVIDentifier.h:46
virtual Int_t GetA() const
Definition: KVIDentifier.h:76
virtual void WriteAsciiFile_extras(std::ofstream &, const Char_t *="")
Definition: KVIDentifier.h:42
void Copy(TObject &obj) const override
Copy attributes of this identifier into 'obj'.
virtual Int_t GetZ() const
Definition: KVIDentifier.h:80
void SetTitle(const char *title="") override
Definition: KVIDentifier.h:154
virtual void SetA(Int_t atnum)
Definition: KVIDentifier.h:89
KVIDGraph * GetParent() const
Get pointer to parent ID graph.
virtual void SetZ(Int_t ztnum)
Definition: KVIDentifier.h:84
Bool_t HasParameter(const Char_t *name) const
virtual void SetFillColor(Color_t fcolor)
virtual void SetFillStyle(Style_t fstyle)
virtual void SetLineStyle(Style_t lstyle)
virtual void SetLineWidth(Width_t lwidth)
virtual void SetMarkerStyle(Style_t mstyle=1)
virtual void SetMarkerSize(Size_t msize=1)
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
Bool_t IsReading() const
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
void Streamer(TBuffer &) override
static TClass * Class()
virtual void SetPointError(Double_t ex, Double_t ey)
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Double_t * GetY() const
void Print(Option_t *chopt="") const override
Int_t GetN() const
Double_t * GetX() const
void SetName(const char *name="") override
virtual void SetEditable(Bool_t editable=kTRUE)
const char * GetName() const override
virtual const char * ClassName() const
Double_t y[n]
Double_t x[n]
void Warning(UserClass p, const char *location, const char *va_(fmt),...)
Definition: KVError.h:125
TArc a
ClassImp(TPyArg)