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

#include <hcalInf.h>

Inheritance diagram for hcalInf:
Collaboration diagram for hcalInf:

Public Member Functions

 hcalInf ()
 
Double_t GetXPos () const
 
Double_t GetYPos () const
 
Double_t GetZPos () const
 
Double_t GetModuleSize () const
 
Int_t GetNLayers () const
 
Int_t GetN1Layers () const
 
Double_t GetAbsorber () 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 GetHcalSize (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 hcalInfGetInstance (const char *filename)
 

Protected Member Functions

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

Static Protected Attributes

static hcalInffInf =NULL
 
static Int_t fRefCount =0
 

Private Member Functions

void InitVariables ()
 
Bool_t ExcludeParameter (TString parname)
 
 hcalInf (const hcalInf &)
 
hcalInfoperator= (const hcalInf &)
 
 ClassDef (hcalInf, 2)
 

Private Attributes

TMap * fVariables
 
TObjArray fHcalStr
 
Double_t fXPos
 
Double_t fYPos
 
Double_t fZPos
 
Int_t fNLayers
 
Int_t fN1Layers
 
Int_t fXSize
 
Int_t fYSize
 
Double_t fModuleSize
 
Double_t fAbsorber
 
Double_t fScin
 
Double_t fTyveec
 
Double_t fThicknessLayer
 
Double_t fCellSize
 
Double_t fHcalSize [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 hcalInf.h.

Constructor & Destructor Documentation

◆ hcalInf() [1/3]

hcalInf::hcalInf ( )
inline

This is ROOT requirement

Definition at line 23 of file hcalInf.h.

23 : TObject(), fVariables(NULL), fHcalStr(), fXPos(0.), fYPos(0.),
24 fZPos(0.), fNLayers(0), fXSize(0), fYSize(0), fModuleSize(0.), fAbsorber(0.),
25 fScin(0.), fTyveec(0.), fThicknessLayer(0.), fCellSize(0.), fHcalSize(),
26 fECut(0.), fHCut(0.), fSemiX(0.0), fSemiY(0.0), fFastMC(-1),
27 fSuccess(-1), fFileName("")
28 {};
Double_t fXPos
Definition hcalInf.h:105
Double_t fScin
Definition hcalInf.h:127
Int_t fNLayers
Definition hcalInf.h:112
TObjArray fHcalStr
Definition hcalInf.h:103
Double_t fSemiY
Definition hcalInf.h:142
Int_t fFastMC
Definition hcalInf.h:145
Int_t fYSize
Definition hcalInf.h:119
Double_t fThicknessLayer
Definition hcalInf.h:131
Double_t fAbsorber
Definition hcalInf.h:125
Double_t fYPos
Definition hcalInf.h:107
Double_t fHCut
Definition hcalInf.h:139
Double_t fModuleSize
Definition hcalInf.h:122
Int_t fXSize
Definition hcalInf.h:117
TMap * fVariables
Definition hcalInf.h:100
Double_t fECut
Definition hcalInf.h:137
TString fFileName
Definition hcalInf.h:150
Double_t fZPos
Definition hcalInf.h:109
Double_t fTyveec
Definition hcalInf.h:129
Double_t fHcalSize[3]
Definition hcalInf.h:135
Double_t fSemiX
Definition hcalInf.h:141
Double_t fCellSize
Definition hcalInf.h:133
Int_t fSuccess
Definition hcalInf.h:148

◆ hcalInf() [2/3]

hcalInf::hcalInf ( 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 HCAL geometry container

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

Definition at line 139 of file hcalInf.cxx.

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

◆ ~hcalInf()

hcalInf::~hcalInf ( )
protectedvirtual

Definition at line 28 of file hcalInf.cxx.

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

◆ hcalInf() [3/3]

hcalInf::hcalInf ( const hcalInf )
private

Member Function Documentation

◆ AddVariable()

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

Definition at line 128 of file hcalInf.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 hcalInf::CalculateHoleSize ( )
protected

◆ ClassDef()

hcalInf::ClassDef ( hcalInf  ,
 
)
private

◆ DumpContainer()

void hcalInf::DumpContainer ( ) const

Definition at line 363 of file hcalInf.cxx.

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

◆ ExcludeParameter()

Bool_t hcalInf::ExcludeParameter ( TString  parname)
private

Ignore a parameter during comparision

Definition at line 261 of file hcalInf.cxx.

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

◆ FreeInstance()

void hcalInf::FreeInstance ( )
inline

Definition at line 168 of file hcalInf.h.

169{
170 fRefCount--;
171 if (fRefCount==0)
172 {
173 delete this;
174 fInf=NULL;
175 }
176}
static hcalInf * fInf
Definition hcalInf.h:88
static Int_t fRefCount
Definition hcalInf.h:89

◆ GetAbsorber()

Double_t hcalInf::GetAbsorber ( ) const
inline

Definition at line 40 of file hcalInf.h.

40{return fAbsorber;}

◆ GetContainerXSemiAxiss()

Double_t hcalInf::GetContainerXSemiAxiss ( ) const
inline

Definition at line 48 of file hcalInf.h.

48{return fSemiX;}

◆ GetContainerYSemiAxiss()

Double_t hcalInf::GetContainerYSemiAxiss ( ) const
inline

Definition at line 49 of file hcalInf.h.

49{return fSemiY;}

◆ GetElectronCut()

Double_t hcalInf::GetElectronCut ( ) const
inline

Geant cuts information

Definition at line 52 of file hcalInf.h.

52{return fECut;}

◆ GetFastMC()

Int_t hcalInf::GetFastMC ( ) const
inline

Definition at line 60 of file hcalInf.h.

60{return fFastMC;}

◆ GetHadronCut()

Double_t hcalInf::GetHadronCut ( ) const
inline

Definition at line 53 of file hcalInf.h.

53{return fHCut;}

◆ GetHcalSize()

Double_t hcalInf::GetHcalSize ( Int_t  num) const
inline

Definition at line 55 of file hcalInf.h.

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

◆ GetInstance()

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

Definition at line 35 of file hcalInf.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 << "hcalInf: Trying create ";
52 cerr << "instance of hcalInf with";
53 cerr << " name " << filename;
54 cerr << ", which is different from ";
55 cerr << fInf->fFileName << "." << endl;
56 return NULL;
57 }
58 }
59 fInf=new hcalInf(newname);
60 //Is something wrong?
61 if (fInf->fSuccess==0)
62 {
63 delete fInf;
64 return NULL;
65 }
66 fRefCount++;
67 return fInf;
68}
hcalInf()
Definition hcalInf.h:23

◆ GetModuleSize()

Double_t hcalInf::GetModuleSize ( ) const
inline

Definition at line 36 of file hcalInf.h.

36{return fModuleSize;}

◆ GetN1Layers()

Int_t hcalInf::GetN1Layers ( ) const
inline

Definition at line 39 of file hcalInf.h.

39{return fN1Layers;}

◆ GetNLayers()

Int_t hcalInf::GetNLayers ( ) const
inline

Definition at line 38 of file hcalInf.h.

38{return fNLayers;}

◆ GetScin()

Double_t hcalInf::GetScin ( ) const
inline

Definition at line 41 of file hcalInf.h.

41{return fScin;}

◆ GetStringVariable()

TString hcalInf::GetStringVariable ( const char *  key)

Definition at line 103 of file hcalInf.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 hcalInf::GetThicknessLayer ( ) const
inline

Definition at line 43 of file hcalInf.h.

43{return fThicknessLayer;}

◆ GetType()

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

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

Definition at line 158 of file hcalInf.h.

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

◆ GetTyveec()

Double_t hcalInf::GetTyveec ( ) const
inline

Definition at line 42 of file hcalInf.h.

42{return fTyveec;}

◆ GetVariable()

Double_t hcalInf::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 hcalInf.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 hcalInf::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 hcalInf.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 hcalInf::GetXPos ( ) const
inline

Getters

Definition at line 32 of file hcalInf.h.

32{return fXPos;}

◆ GetXSize()

Int_t hcalInf::GetXSize ( ) const
inline

Size of HCAL in super modules

Definition at line 46 of file hcalInf.h.

46{return fXSize;}

◆ GetYPos()

Double_t hcalInf::GetYPos ( ) const
inline

Definition at line 33 of file hcalInf.h.

33{return fYPos;}

◆ GetYSize()

Int_t hcalInf::GetYSize ( ) const
inline

Definition at line 47 of file hcalInf.h.

47{return fYSize;}

◆ GetZPos()

Double_t hcalInf::GetZPos ( ) const
inline

Definition at line 34 of file hcalInf.h.

34{return fZPos;}

◆ InitVariables()

void hcalInf::InitVariables ( )
private

Init all other variables from fVariables and fHcalStr

Definition at line 325 of file hcalInf.cxx.

326{
327 TString stri;
328 TObjString* str=(TObjString*)fHcalStr.At(0);
329
330 fXPos=GetVariableStrict("xpos");
331 fYPos=GetVariableStrict("ypos");
332 fZPos=GetVariableStrict("zpos");
333 fNLayers=(Int_t)GetVariableStrict("nlayers");
334 fN1Layers=(Int_t)GetVariableStrict("n1layers");
335 fModuleSize=GetVariableStrict("modulesize");
336 fAbsorber=GetVariableStrict("absorber");
337 fScin=GetVariableStrict("scin");
338 fTyveec=GetVariableStrict("tyveec");
339 fHcalSize[2]=GetVariableStrict("hcalzsize");
340 fECut=GetVariableStrict("ecut");
341 fHCut=GetVariableStrict("hcut");
342 fFastMC=(Int_t)GetVariableStrict("fastmc");
343 fSemiX=GetVariableStrict("xsemiaxis");
344 fSemiY=GetVariableStrict("ysemiaxis");
345
346 stri=""; stri+=str->GetString().Length();
347 AddVariable("xsize", stri);
348 stri=""; stri+=fHcalStr.GetLast()+1;
349 AddVariable("ysize", stri);
350
351 fXSize=(Int_t)GetVariableStrict("xsize");
352 fYSize=(Int_t)GetVariableStrict("ysize");
356 stri=""; stri+=fHcalSize[0];
357 AddVariable("xhcalsize",stri);
358 stri=""; stri+=fHcalSize[1];
359 AddVariable("yhcalsize",stri);
360}
Double_t GetAbsorber() const
Definition hcalInf.h:40
Double_t GetScin() const
Definition hcalInf.h:41
Double_t GetVariableStrict(const char *key)
Definition hcalInf.cxx:82
Double_t GetTyveec() const
Definition hcalInf.h:42
Double_t GetModuleSize() const
Definition hcalInf.h:36
Int_t GetYSize() const
Definition hcalInf.h:47
Int_t GetXSize() const
Definition hcalInf.h:46

◆ operator=()

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

Member Data Documentation

◆ fAbsorber

Double_t hcalInf::fAbsorber
private

Thickness of absorber in one layer [cm]

Definition at line 125 of file hcalInf.h.

◆ fCellSize

Double_t hcalInf::fCellSize
private

transverse size of HCAL cell for simulation [cm]

Definition at line 133 of file hcalInf.h.

◆ fECut

Double_t hcalInf::fECut
private

Electron cut for HCAL

Definition at line 137 of file hcalInf.h.

◆ fFastMC

Int_t hcalInf::fFastMC
private

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

Definition at line 145 of file hcalInf.h.

◆ fFileName

TString hcalInf::fFileName
private

Definition at line 150 of file hcalInf.h.

◆ fHcalSize

Double_t hcalInf::fHcalSize[3]
private

Size of HCAL container [cm]

Definition at line 135 of file hcalInf.h.

◆ fHcalStr

TObjArray hcalInf::fHcalStr
private

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

Definition at line 103 of file hcalInf.h.

◆ fHCut

Double_t hcalInf::fHCut
private

Hadron cut for HCAL

Definition at line 139 of file hcalInf.h.

◆ fInf

hcalInf * hcalInf::fInf =NULL
staticprotected

Definition at line 88 of file hcalInf.h.

◆ fModuleSize

Double_t hcalInf::fModuleSize
private

transverse supermodule size in cm

Definition at line 122 of file hcalInf.h.

◆ fN1Layers

Int_t hcalInf::fN1Layers
private

Number of layers in first hcal section

Definition at line 114 of file hcalInf.h.

◆ fNLayers

Int_t hcalInf::fNLayers
private

Number of HCAL layers

Definition at line 112 of file hcalInf.h.

◆ fRefCount

Int_t hcalInf::fRefCount =0
staticprotected

Definition at line 89 of file hcalInf.h.

◆ fScin

Double_t hcalInf::fScin
private

Thickness of scintillator in one layer [cm]

Definition at line 127 of file hcalInf.h.

◆ fSemiX

Double_t hcalInf::fSemiX
private

Semiaxises of keeping volume

Definition at line 141 of file hcalInf.h.

◆ fSemiY

Double_t hcalInf::fSemiY
private

Definition at line 142 of file hcalInf.h.

◆ fSuccess

Int_t hcalInf::fSuccess
private

1 if evething Ok

Definition at line 148 of file hcalInf.h.

◆ fThicknessLayer

Double_t hcalInf::fThicknessLayer
private

Total thickness of layer [cm]

Definition at line 131 of file hcalInf.h.

◆ fTyveec

Double_t hcalInf::fTyveec
private

Thickness of tyvec in one layer [cm]

Definition at line 129 of file hcalInf.h.

◆ fVariables

TMap* hcalInf::fVariables
private

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

Definition at line 100 of file hcalInf.h.

◆ fXPos

Double_t hcalInf::fXPos
private

x-position of HCAL center [cm]

Definition at line 105 of file hcalInf.h.

◆ fXSize

Int_t hcalInf::fXSize
private

x-size of hcal in supermodules

Definition at line 117 of file hcalInf.h.

◆ fYPos

Double_t hcalInf::fYPos
private

y-position of HCAL center [cm]

Definition at line 107 of file hcalInf.h.

◆ fYSize

Int_t hcalInf::fYSize
private

y-size of hcal in supermodules

Definition at line 119 of file hcalInf.h.

◆ fZPos

Double_t hcalInf::fZPos
private

z-position of HCAL front [cm]

Definition at line 109 of file hcalInf.h.


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