SND@LHC Software
Loading...
Searching...
No Matches
ecalInf Class Reference

#include <ecalInf.h>

Inheritance diagram for ecalInf:
Collaboration diagram for ecalInf:

Public Member Functions

 ecalInf ()
 
Double_t GetXPos () const
 
Double_t GetYPos () const
 
Double_t GetZPos () const
 
Double_t GetModuleSize () const
 
Int_t GetNLayers () const
 
Double_t GetLead () const
 
Double_t GetScin () const
 
Double_t GetTyveec () const
 
Double_t GetThicknessLayer () const
 
Int_t GetXSize () const
 
Int_t GetYSize () const
 
Double_t GetContainerXSemiAxiss () const
 
Double_t GetContainerYSemiAxiss () const
 
Double_t GetElectronCut () const
 
Double_t GetHadronCut () const
 
Double_t GetEcalSize (Int_t num) const
 
char GetType (Int_t x, Int_t y) const
 
Int_t GetFastMC () const
 
void DumpContainer () const
 
void FreeInstance ()
 
Double_t GetVariable (const char *key)
 
Double_t GetVariableStrict (const char *key)
 
TString GetStringVariable (const char *key)
 
void AddVariable (const char *key, const char *value)
 

Static Public Member Functions

static ecalInfGetInstance (const char *filename)
 

Protected Member Functions

 ecalInf (const char *filename)
 
void CalculateHoleSize ()
 
virtual ~ecalInf ()
 

Static Protected Attributes

static ecalInffInf =NULL
 
static Int_t fRefCount =0
 

Private Member Functions

void InitVariables ()
 
Bool_t ExcludeParameter (TString parname)
 
 ecalInf (const ecalInf &)
 
ecalInfoperator= (const ecalInf &)
 
 ClassDef (ecalInf, 2)
 

Private Attributes

TMap * fVariables
 
TObjArray fEcalStr
 
Double_t fXPos
 
Double_t fYPos
 
Double_t fZPos
 
Int_t fNLayers
 
Int_t fXSize
 
Int_t fYSize
 
Double_t fModuleSize
 
Double_t fLead
 
Double_t fScin
 
Double_t fTyveec
 
Double_t fThicknessLayer
 
Double_t fCellSize
 
Double_t fEcalSize [3]
 
Double_t fECut
 
Double_t fHCut
 
Double_t fSemiX
 
Double_t fSemiY
 
Int_t fFastMC
 
Int_t fSuccess
 
TString fFileName
 

Detailed Description

Definition at line 19 of file ecalInf.h.

Constructor & Destructor Documentation

◆ ecalInf() [1/3]

ecalInf::ecalInf ( )
inline

This is ROOT requirement

Definition at line 23 of file ecalInf.h.

23 : TObject(), fVariables(NULL), fEcalStr(), fXPos(0.), fYPos(0.),
24 fZPos(0.), fNLayers(0), fXSize(0), fYSize(0), fModuleSize(0.), fLead(0.),
25 fScin(0.), fTyveec(0.), fThicknessLayer(0.), fCellSize(0.), fEcalSize(),
26 fECut(0.), fHCut(0.), fSemiX(0.0), fSemiY(0.0), fFastMC(-1),
27 fSuccess(-1), fFileName("")
28 {};
TMap * fVariables
Definition ecalInf.h:99
Int_t fYSize
Definition ecalInf.h:116
Int_t fXSize
Definition ecalInf.h:114
Double_t fTyveec
Definition ecalInf.h:126
Double_t fECut
Definition ecalInf.h:134
TString fFileName
Definition ecalInf.h:147
Double_t fThicknessLayer
Definition ecalInf.h:128
Int_t fSuccess
Definition ecalInf.h:145
Int_t fFastMC
Definition ecalInf.h:142
Double_t fSemiY
Definition ecalInf.h:139
Double_t fYPos
Definition ecalInf.h:106
Double_t fXPos
Definition ecalInf.h:104
Double_t fHCut
Definition ecalInf.h:136
Double_t fEcalSize[3]
Definition ecalInf.h:132
Int_t fNLayers
Definition ecalInf.h:111
TObjArray fEcalStr
Definition ecalInf.h:102
Double_t fSemiX
Definition ecalInf.h:138
Double_t fScin
Definition ecalInf.h:124
Double_t fCellSize
Definition ecalInf.h:130
Double_t fLead
Definition ecalInf.h:122
Double_t fModuleSize
Definition ecalInf.h:119
Double_t fZPos
Definition ecalInf.h:108

◆ ecalInf() [2/3]

ecalInf::ecalInf ( const char *  filename)
protected

If data from Parameter file differs from ours TODO: should understand a way of storring parameters in SHIP Text file constructor

Constructor reads and parses the ascii file, and fill 
the ECAL geometry container

FairRunAna* ana = FairRunAna::Instance(); if (ana!=NULL) { FairRuntimeDb* rtdb=ana->GetRuntimeDb(); rtdb->getContainer("CbmGeoEcalPar"); }

Definition at line 139 of file ecalInf.cxx.

140 : TObject(),
141 fVariables(new TMap(200)),
142 fEcalStr(),
143 fXPos(0.),
144 fYPos(0.),
145 fZPos(0.),
146 fNLayers(0),
147 fXSize(0),
148 fYSize(0),
149 fModuleSize(0.),
150 fLead(0.),
151 fScin(0.),
152 fTyveec(0.),
153 fThicknessLayer(0.),
154 fCellSize(0.),
155 fEcalSize(),
156 fECut(0.),
157 fHCut(0.),
158 fSemiX(0.),
159 fSemiY(0.),
160 fFastMC(-1),
161 fSuccess(1),
162 fFileName(filename)
163{
175 std::ifstream file(filename);
176 Int_t linenum;
177 Double_t val;
178 string buffer;
179 string message;
180 string variable;
181 string value;
182 TObjString* str=NULL;
183 char** err=NULL;
184 char winend[2]={13, 0};
185 int ssize=-1;
186
187 if (!file) {
188 cerr << "ecalInf: Can't open information file " << filename << "!" << endl;
189 cerr << "ecalInf: Ecal will not be constructed correctly." << endl;
190 fSuccess=0;
191 return;
192 }
193
194 linenum=0;
195 while(getline(file,buffer)) {
196 linenum++;
197 message=buffer.substr(buffer.find_first_not_of(" ")); //Skiping initial spaces
198 message=message.substr(0,message.find("#")); //Removing comments
199 // Threat windows end of strings correctly
200 message=message.substr(0,message.find(winend));
201 if (message.empty()) continue; //This was just a comment
202 variable=message.substr(0,message.find("="));
203 if (variable=="structure") {
204 while(getline(file,buffer)) {
205 linenum++;
206 if (buffer.empty()) break;
207 message=buffer.substr(buffer.find_first_not_of(" ")); //Skiping initial spaces
208 message=message.substr(0,message.find("#")); //Removing comments
209 message=message.substr(0,message.find_last_not_of(" ")+1); //Skiping ending spaces
210
211 // Threat windows end of strings correctly
212 message=message.substr(0,message.find(winend));
213
214 if (!message.empty()) {
215 if (-1==ssize)
216 ssize=message.size();
217 else
218 if (ssize!=(Int_t)message.size()) {
219 cerr << "Error in ECAL structure at line " << linenum;
220 cerr << "." << endl;
221 cerr << "Line length differs from previous one" << endl;
222 fSuccess=0;
223 file.close();
224 return;
225
226 }
227
228 str=new TObjString(message.c_str());
229 fEcalStr.Add(str);
230 }
231 }
232 break;
233 }
234 if (variable==message) {
235 cerr << "Syntax error: File " << filename << ".Line " << linenum << "." << endl;
236 fSuccess=0;
237 file.close();
238 return;
239 }
240 variable=variable.substr(0,variable.find_first_of(" "));
241 value=message.substr(message.find("=")+1);
242 value=value.substr(value.find_first_not_of(" ")); //Skiping initial spaces
243 value=value.substr(0,value.find_first_of(" "));
244/*
245 value=value.substr(0,value.find_first_not_of("1234567890-+e."));
246 val=strtod(value.c_str(),err);
247 if (err) {
248 cerr << "Syntax error after =: File " << filename << ".Line " << linenum << "." << endl;
249 fSuccess=0;
250 file.close();
251 return;
252 }
253*/
254 AddVariable(variable.c_str(), value.c_str());
255 }
256 file.close();
258}
void AddVariable(const char *key, const char *value)
Definition ecalInf.cxx:128
void InitVariables()
Definition ecalInf.cxx:324

◆ ~ecalInf()

ecalInf::~ecalInf ( )
protectedvirtual

Definition at line 28 of file ecalInf.cxx.

29{
30 for(Int_t i=0;i<fEcalStr.GetSize();i++)
31 delete (TObjString*)(fEcalStr.At(i));
32 fEcalStr.Clear();
33}
int i
Definition ShipAna.py:86

◆ ecalInf() [3/3]

ecalInf::ecalInf ( const ecalInf )
private

Member Function Documentation

◆ AddVariable()

void ecalInf::AddVariable ( const char *  key,
const char *  value 
)

Definition at line 128 of file ecalInf.cxx.

129{
130 TObjString* skey=(TObjString*)fVariables->FindObject(key);
131 //Value for this key already exists!!!
132 if (skey!=NULL) return;
133 skey=new TObjString(key);
134 skey->String().ToLower();
135 TObjString* svalue=new TObjString(value);
136 fVariables->Add(skey, svalue);
137}

◆ CalculateHoleSize()

void ecalInf::CalculateHoleSize ( )
protected

◆ ClassDef()

ecalInf::ClassDef ( ecalInf  ,
 
)
private

◆ DumpContainer()

void ecalInf::DumpContainer ( ) const

Definition at line 361 of file ecalInf.cxx.

362{
363 // Print out the ECAL geometry container
364
365 if (fVariables)
366 {
367 TObjString* key;
368 TIterator* iter=fVariables->MakeIterator();
369 while((key=(TObjString*)iter->Next())!=NULL)
370 {
371 TObjString* str=(TObjString*)fVariables->GetValue(key);
372 cout << key->String() << "=" << str->String() << endl;
373 }
374 }
375 TObjString* key;
376 TIterator* iter=fEcalStr.MakeIterator();
377
378 Int_t modules=0;
379 Int_t channels=0;
380 Int_t i;
381 Int_t j;
382 Int_t m[10];
383 char stri[2]={0, 0};
384 TString st;
385 for(i=0;i<10;i++) m[i]=0;
386
387 while((key=(TObjString*)iter->Next())!=NULL)
388 {
389 st=key->String();
390 cout << key->String() << endl;
391 for(i=0;i<st.Length();i++)
392 {
393 stri[0]=st[i];
394 j=atoi(stri);
395 m[j]++;
396 if (j) modules++;
397 channels+=j*j;
398 }
399 }
400 cout << "Total modules: " << modules << endl;
401 cout << "Total channels: " << channels << endl;
402 for(i=1;i<10;i++)
403 {
404 if (m[i]==0) continue;
405 cout << " Type " << i << " : modules=" << m[i] << ", channels=" << m[i]*i*i << endl;
406 }
407
408}
Double_t m

◆ ExcludeParameter()

Bool_t ecalInf::ExcludeParameter ( TString  parname)
private

Ignore a parameter during comparision

Definition at line 260 of file ecalInf.cxx.

261{
262 if (parname.CompareTo("ecalversion")==0) return kTRUE;
263 return kFALSE;
264}

◆ FreeInstance()

void ecalInf::FreeInstance ( )
inline

Definition at line 165 of file ecalInf.h.

166{
167 fRefCount--;
168 if (fRefCount==0)
169 {
170 delete this;
171 fInf=NULL;
172 }
173}
static Int_t fRefCount
Definition ecalInf.h:88
static ecalInf * fInf
Definition ecalInf.h:87

◆ GetContainerXSemiAxiss()

Double_t ecalInf::GetContainerXSemiAxiss ( ) const
inline

Definition at line 47 of file ecalInf.h.

47{return fSemiX;}

◆ GetContainerYSemiAxiss()

Double_t ecalInf::GetContainerYSemiAxiss ( ) const
inline

Definition at line 48 of file ecalInf.h.

48{return fSemiY;}

◆ GetEcalSize()

Double_t ecalInf::GetEcalSize ( Int_t  num) const
inline

Definition at line 54 of file ecalInf.h.

54 {
55 if (num>-1&&num<3) return fEcalSize[num];
56 return -1;
57 }

◆ GetElectronCut()

Double_t ecalInf::GetElectronCut ( ) const
inline

Geant cuts information

Definition at line 51 of file ecalInf.h.

51{return fECut;}

◆ GetFastMC()

Int_t ecalInf::GetFastMC ( ) const
inline

Definition at line 59 of file ecalInf.h.

59{return fFastMC;}

◆ GetHadronCut()

Double_t ecalInf::GetHadronCut ( ) const
inline

Definition at line 52 of file ecalInf.h.

52{return fHCut;}

◆ GetInstance()

ecalInf * ecalInf::GetInstance ( const char *  filename)
static

Definition at line 35 of file ecalInf.cxx.

36{
37 if (filename==NULL)
38 {
39 if (fInf!=NULL)
40 fRefCount++;
41 return fInf;
42 }
43 TString newname=gSystem->Getenv("VMCWORKDIR");
44 newname+="/geometry/";
45 newname+=filename;
46 if (fInf!=NULL) {
47 if (fInf->fFileName==newname) {
48 fRefCount++;
49 return fInf;
50 } else {
51 cerr << "ecalInf: Trying create ";
52 cerr << "instance of ecalInf with";
53 cerr << " name " << filename;
54 cerr << ", which is different from ";
55 cerr << fInf->fFileName << "." << endl;
56 return NULL;
57 }
58 }
59 fInf=new ecalInf(newname);
60 //Is something wrong?
61 if (fInf->fSuccess==0)
62 {
63 delete fInf;
64 return NULL;
65 }
66 fRefCount++;
67 return fInf;
68}
ecalInf()
Definition ecalInf.h:23

◆ GetLead()

Double_t ecalInf::GetLead ( ) const
inline

Definition at line 39 of file ecalInf.h.

39{return fLead;}

◆ GetModuleSize()

Double_t ecalInf::GetModuleSize ( ) const
inline

Definition at line 36 of file ecalInf.h.

36{return fModuleSize;}

◆ GetNLayers()

Int_t ecalInf::GetNLayers ( ) const
inline

Definition at line 38 of file ecalInf.h.

38{return fNLayers;}

◆ GetScin()

Double_t ecalInf::GetScin ( ) const
inline

Definition at line 40 of file ecalInf.h.

40{return fScin;}

◆ GetStringVariable()

TString ecalInf::GetStringVariable ( const char *  key)

Definition at line 103 of file ecalInf.cxx.

104{
105 TObjString* value=(TObjString*)fVariables->GetValue(key);
106 if (value==NULL)
107 {
108 Fatal("GetStringVariable","Can't find variable named %s.", key);
109 }
110 return value->GetString();
111}

◆ GetThicknessLayer()

Double_t ecalInf::GetThicknessLayer ( ) const
inline

Definition at line 42 of file ecalInf.h.

42{return fThicknessLayer;}

◆ GetType()

char ecalInf::GetType ( Int_t  x,
Int_t  y 
) const
inline

Returns the type of the module with position (x,y)

Definition at line 155 of file ecalInf.h.

156{
158 if (x<0||y<0||y>fEcalStr.GetLast()) return 0;
159 TObjString* str=(TObjString*)fEcalStr.At(y);
160 if (str->GetString().Length()<x) return 0;
161 char stri[2]={str->GetString()[x],0};
162 return atoi(stri);
163}

◆ GetTyveec()

Double_t ecalInf::GetTyveec ( ) const
inline

Definition at line 41 of file ecalInf.h.

41{return fTyveec;}

◆ GetVariable()

Double_t ecalInf::GetVariable ( const char *  key)

key must be lower case. For example, if have in geo file AaaA=90, then you should call GetVariableStrict("aaaa"). If variable not found, will return -1111

Definition at line 115 of file ecalInf.cxx.

116{
117 TObjString* value=(TObjString*)fVariables->GetValue(key);
118 if (value==NULL)
119 return -1111;
120 Double_t val;
121 char* err=NULL;
122 val=strtod(value->GetString(),&err);
123 if (err[0]!='\0')
124 return -1111;
125 return val;
126}

◆ GetVariableStrict()

Double_t ecalInf::GetVariableStrict ( const char *  key)

key must be lower case. For example, if have in geo file AaaA=90, then you should call GetVariableStrict("aaaa"). If variable not found, will generate Fatal

Definition at line 82 of file ecalInf.cxx.

83{
84 TObjString* value=(TObjString*)fVariables->GetValue(key);
85 if (value==NULL)
86 {
87 cerr << "Can't find variable named \"" << key << "\"";
88 Fatal("GetVariableStrict","Exiting...");
89 }
90 Double_t val;
91 char* err=NULL;
92 val=strtod(value->GetString(),&err);
93 if (err[0]!='\0')
94 {
95 cerr << "Can't convert variable named \"" << key ;
96 cerr << "\" to floating point. Value is \"";
97 cerr << value->GetString() << "\"." << endl;
98 Fatal("GetVariableStrict","Exiting...");
99 }
100 return val;
101}

◆ GetXPos()

Double_t ecalInf::GetXPos ( ) const
inline

Getters

Definition at line 32 of file ecalInf.h.

32{return fXPos;}

◆ GetXSize()

Int_t ecalInf::GetXSize ( ) const
inline

Size of ECAL in super modules

Definition at line 45 of file ecalInf.h.

45{return fXSize;}

◆ GetYPos()

Double_t ecalInf::GetYPos ( ) const
inline

Definition at line 33 of file ecalInf.h.

33{return fYPos;}

◆ GetYSize()

Int_t ecalInf::GetYSize ( ) const
inline

Definition at line 46 of file ecalInf.h.

46{return fYSize;}

◆ GetZPos()

Double_t ecalInf::GetZPos ( ) const
inline

Definition at line 34 of file ecalInf.h.

34{return fZPos;}

◆ InitVariables()

void ecalInf::InitVariables ( )
private

Init all other variables from fVariables and fEcalStr

Definition at line 324 of file ecalInf.cxx.

325{
326 TString stri;
327 TObjString* str=(TObjString*)fEcalStr.At(0);
328
329 fXPos=GetVariableStrict("xpos");
330 fYPos=GetVariableStrict("ypos");
331 fZPos=GetVariableStrict("zpos");
332 fNLayers=(Int_t)GetVariableStrict("nlayers");
333 fModuleSize=GetVariableStrict("modulesize");
334 fLead=GetVariableStrict("lead");
335 fScin=GetVariableStrict("scin");
336 fTyveec=GetVariableStrict("tyveec");
337 fEcalSize[2]=GetVariableStrict("ecalzsize");
338 fECut=GetVariableStrict("ecut");
339 fHCut=GetVariableStrict("hcut");
340 fFastMC=(Int_t)GetVariableStrict("fastmc");
341 fSemiX=GetVariableStrict("xsemiaxis");
342 fSemiY=GetVariableStrict("ysemiaxis");
343
344 stri=""; stri+=str->GetString().Length();
345 AddVariable("xsize", stri);
346 stri=""; stri+=fEcalStr.GetLast()+1;
347 AddVariable("ysize", stri);
348
349 fXSize=(Int_t)GetVariableStrict("xsize");
350 fYSize=(Int_t)GetVariableStrict("ysize");
354 stri=""; stri+=fEcalSize[0];
355 AddVariable("xecalsize",stri);
356 stri=""; stri+=fEcalSize[1];
357 AddVariable("yecalsize",stri);
358}
Double_t GetModuleSize() const
Definition ecalInf.h:36
Int_t GetYSize() const
Definition ecalInf.h:46
Double_t GetTyveec() const
Definition ecalInf.h:41
Int_t GetXSize() const
Definition ecalInf.h:45
Double_t GetScin() const
Definition ecalInf.h:40
Double_t GetVariableStrict(const char *key)
Definition ecalInf.cxx:82
Double_t GetLead() const
Definition ecalInf.h:39

◆ operator=()

ecalInf & ecalInf::operator= ( const ecalInf )
private

Member Data Documentation

◆ fCellSize

Double_t ecalInf::fCellSize
private

transverse size of ECAL cell for simulation [cm]

Definition at line 130 of file ecalInf.h.

◆ fEcalSize

Double_t ecalInf::fEcalSize[3]
private

Size of ECAL container [cm]

Definition at line 132 of file ecalInf.h.

◆ fEcalStr

TObjArray ecalInf::fEcalStr
private

Structure of ECAL as array of strings This variable should be saved in parameter file

Definition at line 102 of file ecalInf.h.

◆ fECut

Double_t ecalInf::fECut
private

Electron cut for ECAL

Definition at line 134 of file ecalInf.h.

◆ fFastMC

Int_t ecalInf::fFastMC
private

Flag to run Fast (1) or Full (0) MC code

Definition at line 142 of file ecalInf.h.

◆ fFileName

TString ecalInf::fFileName
private

Definition at line 147 of file ecalInf.h.

◆ fHCut

Double_t ecalInf::fHCut
private

Hadron cut for ECAL

Definition at line 136 of file ecalInf.h.

◆ fInf

ecalInf * ecalInf::fInf =NULL
staticprotected

Definition at line 87 of file ecalInf.h.

◆ fLead

Double_t ecalInf::fLead
private

Thickness of lead in one layer [cm]

Definition at line 122 of file ecalInf.h.

◆ fModuleSize

Double_t ecalInf::fModuleSize
private

transverse supermodule size in cm

Definition at line 119 of file ecalInf.h.

◆ fNLayers

Int_t ecalInf::fNLayers
private

Number of ECAL layers

Definition at line 111 of file ecalInf.h.

◆ fRefCount

Int_t ecalInf::fRefCount =0
staticprotected

Definition at line 88 of file ecalInf.h.

◆ fScin

Double_t ecalInf::fScin
private

Thickness of scintillator in one layer [cm]

Definition at line 124 of file ecalInf.h.

◆ fSemiX

Double_t ecalInf::fSemiX
private

Semiaxises keeping volume

Definition at line 138 of file ecalInf.h.

◆ fSemiY

Double_t ecalInf::fSemiY
private

Definition at line 139 of file ecalInf.h.

◆ fSuccess

Int_t ecalInf::fSuccess
private

1 if evething Ok

Definition at line 145 of file ecalInf.h.

◆ fThicknessLayer

Double_t ecalInf::fThicknessLayer
private

Total thickness of layer [cm]

Definition at line 128 of file ecalInf.h.

◆ fTyveec

Double_t ecalInf::fTyveec
private

Thickness of tyvec in one layer [cm]

Definition at line 126 of file ecalInf.h.

◆ fVariables

TMap* ecalInf::fVariables
private

A map containing all variables This variable should be saved in parameter file

Definition at line 99 of file ecalInf.h.

◆ fXPos

Double_t ecalInf::fXPos
private

x-position of ECAL center [cm]

Definition at line 104 of file ecalInf.h.

◆ fXSize

Int_t ecalInf::fXSize
private

x-size of ecal in supermodules

Definition at line 114 of file ecalInf.h.

◆ fYPos

Double_t ecalInf::fYPos
private

y-position of ECAL center [cm]

Definition at line 106 of file ecalInf.h.

◆ fYSize

Int_t ecalInf::fYSize
private

y-size of ecal in supermodules

Definition at line 116 of file ecalInf.h.

◆ fZPos

Double_t ecalInf::fZPos
private

z-position of ECAL front [cm]

Definition at line 108 of file ecalInf.h.


The documentation for this class was generated from the following files: