3 |
* \author Emiliano Mocchiutti |
* \author Emiliano Mocchiutti |
4 |
* |
* |
5 |
**/ |
**/ |
|
#include <TObject.h> |
|
|
#include <TMath.h> |
|
6 |
#include <CaloLevel1.h> |
#include <CaloLevel1.h> |
7 |
// |
// |
8 |
ClassImp(CaloStrip); |
ClassImp(CaloStrip); |
14 |
CaloStrip::CaloStrip() { |
CaloStrip::CaloStrip() { |
15 |
c1 = 0; |
c1 = 0; |
16 |
this->Clear(); |
this->Clear(); |
17 |
|
UseStandardAlig(); |
18 |
}; |
}; |
19 |
|
|
20 |
/** |
/** |
23 |
CaloStrip::CaloStrip(CaloLevel1 *calo) { |
CaloStrip::CaloStrip(CaloLevel1 *calo) { |
24 |
c1 = calo->GetCaloLevel1(); |
c1 = calo->GetCaloLevel1(); |
25 |
this->Clear(); |
this->Clear(); |
26 |
|
ismech = false; |
27 |
}; |
}; |
28 |
|
|
29 |
/** |
/** |
30 |
* Clear variables |
* Clear variables |
31 |
**/ |
**/ |
32 |
void CaloStrip::Clear() { |
void CaloStrip::Clear() { |
33 |
fE = 0.; |
fE = 0.; |
34 |
fX = 0.; |
fX = 0.; |
35 |
fY = 0.; |
fY = 0.; |
40 |
}; |
}; |
41 |
|
|
42 |
/** |
/** |
43 |
|
* Connect to the DB and retrieve alignement parameters |
44 |
|
**/ |
45 |
|
void CaloStrip::UseStandardAlig(){ |
46 |
|
// |
47 |
|
ismech = false; |
48 |
|
// |
49 |
|
stringstream aligfile; |
50 |
|
Int_t error = 0; |
51 |
|
FILE *f = 0; |
52 |
|
ifstream badfile; |
53 |
|
GL_PARAM *glparam = new GL_PARAM(); |
54 |
|
// |
55 |
|
TString host = "mysql://localhost/pamelaprod"; |
56 |
|
TString user = "anonymous"; |
57 |
|
TString psw = ""; |
58 |
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
59 |
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
60 |
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
61 |
|
if ( !pamdbhost ) pamdbhost = ""; |
62 |
|
if ( !pamdbuser ) pamdbuser = ""; |
63 |
|
if ( !pamdbpsw ) pamdbpsw = ""; |
64 |
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
65 |
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
66 |
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
67 |
|
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
68 |
|
// |
69 |
|
UXal = 0.; |
70 |
|
UYal = 0.; |
71 |
|
UZal = 0.; |
72 |
|
// |
73 |
|
if ( dbc ){ |
74 |
|
// |
75 |
|
// determine where I can find calorimeter ADC to MIP conversion file |
76 |
|
// |
77 |
|
printf(" Querying DB for calorimeter parameters files...\n"); |
78 |
|
// |
79 |
|
// |
80 |
|
// |
81 |
|
error = 0; |
82 |
|
error = glparam->Query_GL_PARAM(1000,102,dbc); |
83 |
|
if ( error >= 0 ){ |
84 |
|
// |
85 |
|
aligfile.str(""); |
86 |
|
aligfile << glparam->PATH.Data() << "/"; |
87 |
|
aligfile << glparam->NAME.Data(); |
88 |
|
// |
89 |
|
printf("\n Using parameter file: \n %s \n",aligfile.str().c_str()); |
90 |
|
f = fopen(aligfile.str().c_str(),"rb"); |
91 |
|
if ( f ){ |
92 |
|
// |
93 |
|
fread(&UXal,sizeof(UXal),1,f); |
94 |
|
fread(&UYal,sizeof(UYal),1,f); |
95 |
|
fread(&UZal,sizeof(UZal),1,f); |
96 |
|
// |
97 |
|
fclose(f); |
98 |
|
}; |
99 |
|
// |
100 |
|
}; |
101 |
|
dbc->Close(); |
102 |
|
}; |
103 |
|
if ( !UXal ){ |
104 |
|
// |
105 |
|
printf(" No able to query DB for calorimeter parameters files\n Using hard-coded parameters \n"); |
106 |
|
UXal = CTX; |
107 |
|
UYal = CTY; |
108 |
|
UZal = CTZ; |
109 |
|
}; |
110 |
|
// |
111 |
|
}; |
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
/** |
119 |
* Given a strip returns its position in the PAMELA reference system |
* Given a strip returns its position in the PAMELA reference system |
120 |
**/ |
**/ |
121 |
void CaloStrip::Set(Int_t view, Int_t plane, Int_t strip) { |
void CaloStrip::Set(Int_t view, Int_t plane, Int_t strip) { |
152 |
lShift = 0.5; |
lShift = 0.5; |
153 |
}; |
}; |
154 |
// |
// |
155 |
|
if ( fView == 2 ) lShift = - lShift; |
156 |
|
// |
157 |
shift_.shift = lShift; |
shift_.shift = lShift; |
158 |
// |
// |
159 |
Float_t zplane[22]; |
Float_t zplane[22]; |
174 |
// |
// |
175 |
// X view |
// X view |
176 |
// |
// |
177 |
fX = (lPos - CTX)/10.; |
fX = (lPos - UXal)/10.; |
178 |
fY = 0.; |
fY = 0.; |
179 |
fZ = (zplane[fPlane-1] - 5.81 + CTZ)/10.; |
fZ = (zplane[fPlane-1] - 5.81 + UZal)/10.; |
180 |
} else { |
} else { |
181 |
// |
// |
182 |
// Y view |
// Y view |
183 |
// |
// |
184 |
fX = 0; |
fX = 0; |
185 |
fY = (lPos - CTY)/10.; |
fY = (lPos - UYal)/10.; |
186 |
fZ = (zplane[fPlane-1] + CTZ)/10.; |
fZ = (zplane[fPlane-1] + UZal)/10.; |
187 |
}; |
}; |
188 |
// |
// |
189 |
}; |
}; |
212 |
Float_t dzx[22]; |
Float_t dzx[22]; |
213 |
Float_t dzy[22]; |
Float_t dzy[22]; |
214 |
for ( Int_t i=0; i < 22; i++){ |
for ( Int_t i=0; i < 22; i++){ |
215 |
dzx[i] = fabs(fZ*10. - (zplane[i] - 5.81 + CTZ)); |
dzx[i] = fabs(fZ*10. - (zplane[i] - 5.81 + UZal)); |
216 |
dzy[i] = fabs(fZ*10. - (zplane[i] + CTZ)); |
dzy[i] = fabs(fZ*10. - (zplane[i] + UZal)); |
217 |
}; |
}; |
218 |
// |
// |
219 |
Float_t minx = TMath::MinElement(22,dzx); |
Float_t minx = TMath::MinElement(22,dzx); |
235 |
if ( fView == 1 ){ |
if ( fView == 1 ){ |
236 |
if ( dzx[i] == minx ){ |
if ( dzx[i] == minx ){ |
237 |
fPlane = i+1; |
fPlane = i+1; |
238 |
pos = fX*10. + CTX; |
pos = fX*10. + UXal; |
239 |
}; |
}; |
240 |
} else { |
} else { |
241 |
if ( dzy[i] == miny ){ |
if ( dzy[i] == miny ){ |
242 |
fPlane = i+1; |
fPlane = i+1; |
243 |
pos = fY*10. + CTY; |
pos = fY*10. + UYal; |
244 |
}; |
}; |
245 |
}; |
}; |
246 |
}; |
}; |
255 |
for ( Int_t i=0; i < 96; i++){ |
for ( Int_t i=0; i < 96; i++){ |
256 |
ca->Set(fView-1,fPlane-1,i); |
ca->Set(fView-1,fPlane-1,i); |
257 |
if ( fView == 1 ){ |
if ( fView == 1 ){ |
258 |
stpos = ca->GetX()*10. + CTX; |
stpos = ca->GetX()*10. + UXal; |
259 |
} else { |
} else { |
260 |
stpos = ca->GetY()*10. + CTY; |
stpos = ca->GetY()*10. + UYal; |
261 |
}; |
}; |
262 |
dxy[i] = fabs(pos - stpos); |
dxy[i] = fabs(pos - stpos); |
263 |
}; |
}; |