KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVDP2toCsIGridConvertor.cpp
Go to the documentation of this file.
1 /*
2 $Id: KVDP2toCsIGridConvertor.cpp,v 1.2 2009/03/06 08:59:18 franklan Exp $
3 $Revision: 1.2 $
4 $Date: 2009/03/06 08:59:18 $
5 */
6 
7 //Created by KVClassFactory on Thu Oct 9 17:23:14 2008
8 //Author: franklan
9 
11 #include "TList.h"
12 #include "KVIDGrid.h"
13 #include "KVIDGridManager.h"
14 #include "KVError.h"
15 
16 using namespace std;
17 
19 
20 
21 
25 {
26  // Default constructor
27 }
28 
29 
30 
33 
35 {
36  // Destructor
37 }
38 
39 
41 
42 
46 
47 void KVDP2toCsIGridConvertor::Convert(const Char_t* id_and_imf_file, const Char_t* gamma_file)
48 {
49  //Read ID and Gamma-line files for CsI R-L identifications.
50  //Initialise grids in KVIDCsI telescopes
51 
52  if (fGrids) fGrids->Clear();
53  else fGrids = new TList;
54  ReadFile(id_and_imf_file);
55  // set name of all IMF lines
56  TIter nextGrid(fGrids);
57  KVIDGrid* grid;
59  while ((grid = (KVIDGrid*)nextGrid())) {
60  TIter nextOK(grid->GetCuts());
61  while ((line = (KVIDentifier*) nextOK())) {
62  line->SetName("IMF_line");
63  }
64  }
65  ReadGammaFile(gamma_file);
67  else Error(KV__ERROR(Convert), "gIDGridManager=0x0: create an ID grid manager first!");
68 }
69 
70 
72 
73 
75 
77 {
78  ifstream gamfile;
79  gamfile.open(gammafile);
80 
81  if (!gamfile.good()) {
82  Error(KV__ERROR(ReadGammaFile),
83  "Problem reading file %s", gammafile);
84  return;
85  }
86  KVString s;
87 
88  s.ReadLine(gamfile);
89 
90  while (gamfile.good()) {
91 
92  if (s == "") {
93  s.ReadLine(gamfile);
94  continue;
95  }
96 
97  if (!s.BeginsWith('#')) { //'#' sign signals comments
98  int ring, modu, frun, lrun;
99  if (sscanf(s.Data(), "%d %d %d %d", &ring, &modu, &frun, &lrun) !=
100  4) {
101  Error(KV__ERROR(ReadGammaFile), "Problem reading file %s\nLast line read: %s",
102  gammafile, s.Data());
103  return;
104  };
105  //get grid for this ring,mod
106  TString name;
107  name.
108  Form
109  ("CsI R-L Grid First run=%d Last run=%d Ring min=%d Ring max=%d Mod min=%d Mod max=%d",
110  frun, lrun, ring, ring, modu, modu);
111  KVIDGrid* grid = (KVIDGrid*)fGrids->FindObject(name.Data());
112  if (!grid) {
113  Error(KV__ERROR(ReadGammaFile), "Can't find grid %s", name.Data());
114  }
115  int npoints;
116  gamfile >> npoints;
117  //found gamma line
118  KVIDLine* line = 0;
119  if (grid) {
120  line = grid->NewLine("ok");
121  line->SetName("gamma_line");
122  line->Set(npoints);
123  grid->Add("ok", line);
124  }
125  //read in points
126  for (int i = 0; i < npoints; i++) {
127  Double_t x, y;
128  gamfile >> x >> y;
129  if (grid)
130  line->SetPoint(i, x, y);
131  }
132  }
133  s.ReadLine(gamfile);
134  }
135  gamfile.close();
136 }
137 
138 
Defines macros for standard error messages.
#define KV__ERROR(method)
Definition: KVError.h:30
KVIDGridManager * gIDGridManager
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
char Char_t
double Double_t
char * Form(const char *fmt,...)
Converts dp2-format CsI R-L grids to KVIDGrids.
virtual ~KVDP2toCsIGridConvertor()
Destructor.
virtual void ReadGammaFile(const Char_t *gammafile)
void Convert(const Char_t *id_and_imf_file, const Char_t *gamma_file)
void Add(TString, KVIDentifier *)
Definition: KVIDGraph.cpp:838
const KVList * GetCuts() const
Definition: KVIDGraph.h:307
KVList * GetGrids()
Abstract base class for 2D identification grids in e.g. (dE,E) maps.
Definition: KVIDGrid.h:73
KVIDLine * NewLine(const Char_t *idline_class="")
Definition: KVIDGrid.cpp:90
Base class for lines/cuts used for particle identification in 2D data maps.
Definition: KVIDLine.h:142
Base class for graphical cuts used in particle identification.
Definition: KVIDentifier.h:27
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:72
virtual void AddAll(const TCollection *col)
virtual TObject * FindObject(const char *name) const
const char * Data() const
TLine * line
Double_t y[n]
Double_t x[n]
const long double s
Definition: KVUnits.h:94
void Error(const char *location, const char *va_(fmt),...)