KaliVeda  1.12/06
Heavy-Ion Analysis Toolkit
KVIDZALine.cpp
Go to the documentation of this file.
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 
24 using namespace std;
25 
27 
28 
29 
35 {
36  // Default ctor
37  // Line width is set to zero
38  // Default identification is set to proton
39 
40  SetWidth(0.);
41  fLineWithWidth = 0;
42 }
43 
44 
45 
48 
50  : KVIDLine()
51 {
52  // copy constructor
53  fLineWithWidth = 0;
54  obj.Copy(*this);
55 }
56 
57 
60 
61 void KVIDZALine::Copy(TObject& obj) const
62 {
63  // copy 'this' to 'obj'
64  KVIDLine::Copy(obj);
65  ((KVIDZALine&)obj).SetWidth(fWidth);
66 }
67 
68 
69 
72 
73 KVIDZALine::~KVIDZALine()
74 {
75  //Default dtor
76 }
77 
78 
79 
80 
83 
85  const Char_t* name_prefix)
86 {
87  // Write Z & A of line
88 
90  file << GetZ() << "\t" << GetA() << endl;
91 }
92 
93 
94 
95 
98 
100 {
101  // Read Z & A of line
102 
104  Int_t Z, A;
105  file >> Z >> A;
106  SetZ(Z);
107  SetA(A);
108 }
109 
110 
111 
112 
125 
127 {
128  //************ BACKWARDS COMPATIBILITY FIX *************
129  // special read method for old KVIDZLines
130  //
131  //Read coordinates of line in file buffer stream
132  //Format is :
133  //Z
134  //number_of_points
135  //x1 y1
136  //x2 y2
137  //...
138  //etc. etc.
139  Int_t N, Z;
140  file >> Z;
141  SetZ(Z);
142  file >> N;
143  for (Int_t i = 0; i < N; i++) {
144  Double_t x, y;
145  file >> x >> y;
146  SetPoint(i, x, y);
147  }
148 }
149 
150 
151 
152 
158 
159 void KVIDZALine::Print(Option_t* opt) const
160 {
161  //Print out for line
162  //The optional "opt" string, if given, is printed in parentheses after the line's name
163  //This is used by KVIDGrid in order to show which lines are "ID" lines and which are
164  //"OK" lines (i.e. used to define an identifiable area in a data map).
165  cout << ClassName() << " : " << GetName() << "(" << opt << ")" << endl;
166  cout << "Z=" << GetZ() << " A=" << GetA() << endl;
167  if (GetWidth() > 0.0) cout << "Natural Line Width : " << GetWidth() << endl;
168  TGraph::Print();
169 }
170 
171 
172 
173 
178 
180 {
181  //Return pointer to TGraphError object which can be used to visualise the natural width
182  //of this identification line.
183  //If line width = 16000, the error bar is set to 0
184 
185  if (fLineWithWidth) {
186  delete fLineWithWidth;
187  }
188  fLineWithWidth = new TGraphErrors(GetN(), GetX(), GetY());
197  for (int i = 0; i < GetN(); i++) {
198  fLineWithWidth->SetPointError(i, 0., 0.5 * (GetWidth() < 16000 ? GetWidth() : 0));
199  }
200  return fLineWithWidth;
201 }
202 
203 
204 
205 
213 
215 {
216  // Set the natural width of the line depending on its asymptotic separation
217  // a gauche (d_l) and a droite (d_r) from a neighbouring line.
218  // This method is used by KVIDGrid::CalculateLineWidths
219  //
220  // For ordinary Z/(Z,A) lines in a dE-E grid, this is just the average of
221  // the two asymptotic distances.
222 
223  SetWidth((d_l + d_r) / 2.);
224 }
225 
226 
227 
230 
231 void KVIDZALine::Streamer(TBuffer& R__b)
232 {
233  // Stream an object of class KVIDZALine.
234 
235  UInt_t R__s, R__c;
236  if (R__b.IsReading()) {
237  Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
238  if (R__v < 2) {
239  R__b.ReadVersion(&R__s, &R__c);// read version of KVIDZLine
240  KVIDLine::Streamer(R__b);
241  UShort_t z;
242  R__b >> z;
243  R__b >> fWidth;
244  SetZ(z);
245  UShort_t a;
246  R__b >> a;
247  SetA(a);
248  }
249  else {
250  R__b.ReadClassBuffer(KVIDZALine::Class(), this, R__v, R__s, R__c);
251  }
252  }
253  else {
254  R__b.WriteClassBuffer(KVIDZALine::Class(), this);
255  }
256 }
257 
258 
260 
262 
263 // This class is for backwards compatibility only
265 // and must not be used.
267 
268 
269 
273 {
274  // This class is for backwards compatibility only
275 }
276 
277 
278 
281 
282 void KVIDZLine::Streamer(TBuffer& R__b)
283 {
284  // Stream an object of class KVIDZLine
285 
286  UInt_t R__s, R__c;
287  if (R__b.IsReading()) {
288  Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
289  if (R__v != 2) {
290  Warning("Streamer", "Reading KVIDZLine with version=%d", R__v);
291  }
292  KVIDLine::Streamer(R__b);
293  UShort_t z;
294  R__b >> z;
295  R__b >> fWidth;
296  SetZ(z);
297  }
298 }
299 
300 
int Int_t
unsigned int UInt_t
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
unsigned short UShort_t
short Version_t
char Char_t
const Bool_t kFALSE
double Double_t
const char Option_t
#define N
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:32
virtual void Print(Option_t *opt="") const
Definition: KVIDZALine.cpp:159
void Copy(TObject &obj) const
copy 'this' to 'obj'
Definition: KVIDZALine.cpp:61
void ReadAsciiFile_KVIDZLine(std::ifstream &)
Definition: KVIDZALine.cpp:126
virtual void SetAsymWidth(Double_t d_l, Double_t d_r)
Definition: KVIDZALine.cpp:214
TGraphErrors * GetLineWithWidth()
Definition: KVIDZALine.cpp:179
void SetWidth(Double_t w)
Definition: KVIDZALine.h:64
virtual void ReadAsciiFile_extras(std::ifstream &)
Read Z & A of line.
Definition: KVIDZALine.cpp:99
TGraphErrors * fLineWithWidth
used to display width of line
Definition: KVIDZALine.h:39
Double_t GetWidth() const
Definition: KVIDZALine.h:60
Double_t fWidth
the "width" of the line
Definition: KVIDZALine.h:38
virtual void WriteAsciiFile_extras(std::ofstream &, const Char_t *name_prefix="")
Write Z & A of line.
Definition: KVIDZALine.cpp:84
virtual void ReadAsciiFile_extras(std::ifstream &)
Definition: KVIDentifier.h:45
virtual Int_t GetA() const
Definition: KVIDentifier.h:74
virtual void WriteAsciiFile_extras(std::ofstream &, const Char_t *="")
Definition: KVIDentifier.h:41
void Copy(TObject &obj) const
Copy attributes of this identifier into 'obj'.
virtual Int_t GetZ() const
Definition: KVIDentifier.h:78
virtual void SetA(Int_t atnum)
Definition: KVIDentifier.h:87
virtual void SetZ(Int_t ztnum)
Definition: KVIDentifier.h:82
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 Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
Bool_t IsReading() const
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual void SetPointError(Double_t ex, Double_t ey)
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
virtual void SetName(const char *name="")
Int_t GetN() const
Double_t * GetX() const
virtual void Print(Option_t *chopt="") const
Double_t * GetY() const
virtual void SetEditable(Bool_t editable=kTRUE)
virtual const char * GetName() const
virtual const char * ClassName() const
virtual void Warning(const char *method, const char *msgfmt,...) const
Double_t y[n]
Double_t x[n]
auto * a