KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVIDGrid.cpp
1/***************************************************************************
2 KVIDGrid.cpp - description
3 -------------------
4 begin : Nov 10 2004
5 copyright : (C) 2004 by J.D. Frankland
6 email : frankland@ganil.fr
7
8$Id: KVIDGrid.cpp,v 1.60 2009/05/05 15:57:52 franklan Exp $
9***************************************************************************/
10
11/***************************************************************************
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
17 * *
18 ***************************************************************************/
19
20#include "KVIDGrid.h"
21#include "TCanvas.h"
22#include "TObjString.h"
23#include "Riostream.h"
24#include "TObjArray.h"
25#include "TROOT.h"
26#include "KVString.h"
27#include "TVirtualFitter.h"
28#include "TClass.h"
29#include "TContextMenu.h"
30#include "TSystem.h"
31#include "TF1.h"
32#include "KVIDZALine.h"
33#include "KVIDCutLine.h"
34
35
36using namespace std;
37
39
40//________________________________________________________________________________
41
42
43
45
47{
48 //Default constructor
49 init();
50}
51
52
53
54
57
59{
60 //Initialisations, used by constructors
61}
62
63
64
65
67
71
72
73
74
89
90KVIDLine* KVIDGrid::NewLine(const Char_t* idline_class)
91{
92 // Create a new line compatible with this grid.
93 //
94 // If idline_class = "id" or "ID":
95 // create default identification line object for this grid
96 //
97 // If idline_class = "ok" or "OK":
98 // create default 'OK' line object for this grid
99 //
100 // If idline_class = class name:
101 // create line object of given class
102 //
103 // If idline_class = "":
104 // create KVIDLine object
105
106 TString _cl, _type(idline_class);
107 _type.ToUpper();
108 TClass* clas = 0;
109
110 if (_type == "ID") clas = DefaultIDLineClass();
111 else if (_type == "OK") clas = DefaultOKLineClass();
112 else _cl = idline_class;
113
114 if (_cl == "") _cl = "KVIDLine";
115 if (!clas) clas = gROOT->GetClass(_cl.Data());
116
117 KVIDLine* line = 0;
118
119 if (!clas) {
120 Error("AddIDLine",
121 "%s is not a valid classname. No known class.", _cl.Data());
122 }
123 else {
124 if (!clas->InheritsFrom("KVIDLine")) {
125 Error("AddIDLine",
126 "%s is not a valid class deriving from KVIDLine.",
127 _cl.Data());
128 }
129 else {
130 line = (KVIDLine*) clas->New();
131 }
132 }
133 return line;
134}
135
136
137
138
142
143void KVIDGrid::ReadIdentifierFromAsciiFile(TString& name, TString& type, TString& cl, ifstream& gridfile)
144{
145 // Read in new identifier object from file
146 // Backwards-compatibility fixes
147
148 KVIDentifier* line = 0;
149 /************ BACKWARDS COMPATIBILITY FIX *************
150 transform all 'OK' KVIDLines into KVIDCutLines
151 */
152 Bool_t oldcutline = kFALSE;
153 if (type == "OK" && cl == "KVIDLine") {
154 oldcutline = kTRUE;
155 }
156 /************ BACKWARDS COMPATIBILITY FIX *************
157 transform all 'ID' KVIDZLines into KVIDZALines
158 */
159 Bool_t zline = kFALSE;
160 if (type == "ID" && cl == "KVIDZLine") {
161 cl = "KVIDZALine";
162 zline = kTRUE;
163 }
164 line = New(cl.Data());
165 //now use ReadAscii method of class to read coordinates and other informations
166 /************ BACKWARDS COMPATIBILITY FIX *************
167 special read method for old KVIDZLines
168 */
169 if (zline)((KVIDZALine*)line)->ReadAsciiFile_KVIDZLine(gridfile);
170 else {
171 line->ReadAsciiFile(gridfile);
172 line->SetName(name.Data());
173 }
174 if (oldcutline) {
175 KVIDentifier* oldcut = line;
176 line = new KVIDCutLine;
177 line->CopyGraph(oldcut);
178 delete oldcut;
179 }
180 if (type == "OK") line->SetName(name.Data());
181 Add(type, line);
182}
183
184
185
186
190
192{
193 //Replaces contents of fEmbracingLines with subset of ID lines for which IsBetweenEndPoints(x,y,direction) == kTRUE.
194 //nlines = number of lines in list
195
196 TIter next(GetIdentifiers());
197 Int_t nlines = 0;
198 KVIDLine* line;
200 while ((line = (KVIDLine*) next())) {
201 if (line->IsBetweenEndPoints(x, y, direction)) {
203 nlines++;
204 }
205 }
206 return nlines;
207}
208
209
210
211
217
219{
220 // General initialisation method for identification grid.
221 // This method MUST be called once before using the grid for identifications.
222 // The ID lines are sorted.
223 // The natural line widths of all ID lines are calculated.
224
227}
228
229
230
int Int_t
bool Bool_t
char Char_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
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
char name[80]
#define gROOT
Line in ID grid used to delimit regions where no identification is possible.
Definition KVIDCutLine.h:23
void Add(TString, KVIDentifier *)
void SortIdentifiers()
Definition KVIDGraph.h:375
const KVList * GetIdentifiers() const
Definition KVIDGraph.h:298
virtual KVIDentifier * New(const Char_t *)
Create new object of class "id_class" which derives from KVIDentifier.
Abstract base class for 2D identification grids in e.g. (dE,E) maps.
Definition KVIDGrid.h:74
virtual void CalculateLineWidths()
Definition KVIDGrid.h:264
void init()
Initialisations, used by constructors.
Definition KVIDGrid.cpp:58
virtual TClass * DefaultOKLineClass()
Definition KVIDGrid.h:270
KVIDLine * NewLine(const Char_t *idline_class="")
Definition KVIDGrid.cpp:90
Int_t GetIDLinesEmbracingPoint(const Char_t *direction, Double_t x, Double_t y) const
Definition KVIDGrid.cpp:191
virtual TClass * DefaultIDLineClass()
Definition KVIDGrid.h:266
TObjArray fEmbracingLines
temporary array used by GetIDLinesEmbracingPoint
Definition KVIDGrid.h:76
virtual ~KVIDGrid()
Definition KVIDGrid.cpp:68
void ReadIdentifierFromAsciiFile(TString &name, TString &type, TString &cl, std::ifstream &gridfile)
Definition KVIDGrid.cpp:143
void Initialize()
Definition KVIDGrid.cpp:218
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
Base class for graphical cuts used in particle identification.
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Bool_t InheritsFrom(const char *cl) const override
void Clear(Option_t *option="") override
void Add(TObject *obj) override
virtual void Error(const char *method, const char *msgfmt,...) const
const char * Data() const
void ToUpper()
TLine * line
Double_t y[n]
Double_t x[n]
void init()
ClassImp(TPyArg)