| 3 |
* \author Emiliano Mocchiutti |
* \author Emiliano Mocchiutti |
| 4 |
* |
* |
| 5 |
**/ |
**/ |
|
#include <TObject.h> |
|
| 6 |
#include <CaloLevel1.h> |
#include <CaloLevel1.h> |
|
|
|
| 7 |
// |
// |
| 8 |
ClassImp(CaloStrip); |
ClassImp(CaloStrip); |
| 9 |
ClassImp(CaloLevel1); |
ClassImp(CaloLevel1); |
| 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 |
}; |
}; |
| 193 |
**/ |
**/ |
| 194 |
void CaloStrip::Set(Float_t X, Float_t Y, Float_t Z) { |
void CaloStrip::Set(Float_t X, Float_t Y, Float_t Z) { |
| 195 |
// |
// |
| 196 |
// Float_t lShift = 0.; |
fX = X; |
| 197 |
// Float_t lPos = 0.; |
fY = Y; |
| 198 |
// extern struct shift shift; |
fZ = Z; |
| 199 |
// // |
// |
| 200 |
// fView = view++; |
Float_t zplane[22]; |
| 201 |
// fPlane = plane++; |
zplane[0] = 0.; |
| 202 |
// fStrip = strip++; |
Int_t ii = 0; |
| 203 |
// if ( fPlane%2 ){ |
for ( Int_t i = 2; i < 23; i++){ |
| 204 |
// lShift = -0.5; |
ii = i-1; |
| 205 |
// } else { |
if ( i%2 ){ |
| 206 |
// lShift = 0.5; |
zplane[ii] = zplane[ii-1] - 10.09; |
| 207 |
// }; |
} else { |
| 208 |
// // |
zplane[ii] = zplane[ii-1] - 8.09; |
| 209 |
// shift.shift = lShift; |
}; |
| 210 |
// // |
}; |
| 211 |
// Float_t zplane[22]; |
// |
| 212 |
// zplane[0] = 0.; |
Float_t dzx[22]; |
| 213 |
// Int_t ii = 0; |
Float_t dzy[22]; |
| 214 |
// for ( Int_t i = 2; i < 23; i++){ |
for ( Int_t i=0; i < 22; i++){ |
| 215 |
// ii = i-1; |
dzx[i] = fabs(fZ*10. - (zplane[i] - 5.81 + UZal)); |
| 216 |
// if ( i%2 ){ |
dzy[i] = fabs(fZ*10. - (zplane[i] + UZal)); |
| 217 |
// zplane[ii] = zplane[ii-1] - 10.09 + CTZ; |
}; |
| 218 |
// } else { |
// |
| 219 |
// zplane[ii] = zplane[ii-1] - 8.09 + CTZ; |
Float_t minx = TMath::MinElement(22,dzx); |
| 220 |
// }; |
Float_t miny = TMath::MinElement(22,dzy); |
| 221 |
// }; |
// |
| 222 |
// // |
// find view |
| 223 |
// millim_(&fStrip,&lPos); |
// |
| 224 |
// // |
if ( minx < miny ){ |
| 225 |
// if ( fView == 1 ){ |
fView = 1; |
| 226 |
// // |
} else { |
| 227 |
// // X view |
fView = 2; |
| 228 |
// // |
}; |
| 229 |
// fX = lPos; |
// |
| 230 |
// fY = 0.; |
// find plane |
| 231 |
// fZ = zplane[fPlane-1] - 5.81; |
// |
| 232 |
// } else { |
Float_t pos = 0.; |
| 233 |
// // |
// |
| 234 |
// // Y view |
for ( Int_t i=0; i < 22; i++){ |
| 235 |
// // |
if ( fView == 1 ){ |
| 236 |
// fX = 0.; |
if ( dzx[i] == minx ){ |
| 237 |
// fY = lPos; |
fPlane = i+1; |
| 238 |
// fZ = zplane[fPlane-1]; |
pos = fX*10. + UXal; |
| 239 |
// }; |
}; |
| 240 |
|
} else { |
| 241 |
|
if ( dzy[i] == miny ){ |
| 242 |
|
fPlane = i+1; |
| 243 |
|
pos = fY*10. + UYal; |
| 244 |
|
}; |
| 245 |
|
}; |
| 246 |
|
}; |
| 247 |
|
// |
| 248 |
|
// find strip |
| 249 |
|
// |
| 250 |
|
Float_t dxy[96]; |
| 251 |
|
Float_t stpos = 0.; |
| 252 |
|
// |
| 253 |
|
CaloStrip *ca = new CaloStrip(); |
| 254 |
|
// |
| 255 |
|
for ( Int_t i=0; i < 96; i++){ |
| 256 |
|
ca->Set(fView-1,fPlane-1,i); |
| 257 |
|
if ( fView == 1 ){ |
| 258 |
|
stpos = ca->GetX()*10. + UXal; |
| 259 |
|
} else { |
| 260 |
|
stpos = ca->GetY()*10. + UYal; |
| 261 |
|
}; |
| 262 |
|
dxy[i] = fabs(pos - stpos); |
| 263 |
|
}; |
| 264 |
|
// |
| 265 |
|
delete ca; |
| 266 |
// |
// |
| 267 |
|
Float_t mins = TMath::MinElement(96,dxy); |
| 268 |
|
// |
| 269 |
|
for ( Int_t i=0; i < 96; i++){ |
| 270 |
|
if ( dxy[i] == mins ) fStrip = i+1; |
| 271 |
|
}; |
| 272 |
}; |
}; |
|
// DISTY = PIANO(I) |
|
|
// YY(I) = DISTY * TG(2) + CY |
|
|
// BAR(M,I) = YY(I) |
|
|
// CBAR(M,I) = (-YALIG + YY(I))/10. |
|
|
// C |
|
|
// ENDIF |
|
|
// CALL LASTRISCIA(BAR(M,I),IBAR(M,I)) |
|
|
// CIBAR(M,I) = IBAR(M,I) |
|
|
// ENDDO |
|
|
// ENDIF |
|
|
// C |
|
|
// ENDDO |
|
|
|
|
|
|
|
| 273 |
|
|
| 274 |
/** |
/** |
| 275 |
* CaloLevel1 constructor |
* CaloLevel1 constructor |
| 378 |
return(0.); |
return(0.); |
| 379 |
} |
} |
| 380 |
|
|
| 381 |
|
/* |
| 382 |
|
* Returns energy released on plane nplane (where 0<= nplane <= 43, 0 = 1Y, 1 = 1X, 2 = 2Y, 3 = 2X, etc. etc.). |
| 383 |
|
*/ |
| 384 |
|
Float_t CaloLevel1::qtotpl(Int_t nplane){ |
| 385 |
|
// |
| 386 |
|
Int_t sview = 1; |
| 387 |
|
if ( nplane%2 ) sview = 0; |
| 388 |
|
// |
| 389 |
|
Int_t splane = nplane-(sview+1)/2; |
| 390 |
|
// |
| 391 |
|
Float_t totmip = qtotpl(sview,splane); |
| 392 |
|
// |
| 393 |
|
return(totmip); |
| 394 |
|
// |
| 395 |
|
}; |
| 396 |
|
|
| 397 |
|
/* |
| 398 |
|
* Returns energy released on view "view" (0 = X, 1 = Y) and plane "plane" ( 0 <= plane <= 21 ). |
| 399 |
|
*/ |
| 400 |
|
Float_t CaloLevel1::qtotpl(Int_t sview, Int_t splane){ |
| 401 |
|
// |
| 402 |
|
Int_t view = -1; |
| 403 |
|
Int_t plane = -1; |
| 404 |
|
Int_t strip = -1; |
| 405 |
|
// |
| 406 |
|
Float_t mip = 0.; |
| 407 |
|
Float_t totmip = 0.; |
| 408 |
|
// |
| 409 |
|
if ( istrip == 0 ) return(0.); |
| 410 |
|
// |
| 411 |
|
for (Int_t i = 0; i<istrip; i++ ){ |
| 412 |
|
// |
| 413 |
|
mip = DecodeEstrip(i,view,plane,strip); |
| 414 |
|
// |
| 415 |
|
if ( view == sview && splane == plane ) totmip += mip; |
| 416 |
|
// |
| 417 |
|
// entry are ordered by strip, plane and view number. Go out if you pass the input strip |
| 418 |
|
// |
| 419 |
|
if ( view == sview && plane > splane ) return(totmip); |
| 420 |
|
if ( view > sview ) return(totmip); |
| 421 |
|
// |
| 422 |
|
}; |
| 423 |
|
// |
| 424 |
|
return(totmip); |
| 425 |
|
// |
| 426 |
|
}; |