| 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); |
| 19 |
/** |
/** |
| 20 |
* CaloStrip default constructor |
* CaloStrip default constructor |
| 21 |
**/ |
**/ |
| 22 |
|
CaloStrip::CaloStrip(Bool_t mechalig) { |
| 23 |
|
c1 = 0; |
| 24 |
|
this->Clear(); |
| 25 |
|
if ( mechalig ){ |
| 26 |
|
ismech = true; |
| 27 |
|
UXal = MECHCTX; |
| 28 |
|
UYal = MECHCTY; |
| 29 |
|
UZal = MECHCTZ; |
| 30 |
|
} else { |
| 31 |
|
ismech = false; |
| 32 |
|
UseStandardAlig(); |
| 33 |
|
}; |
| 34 |
|
}; |
| 35 |
|
|
| 36 |
|
/** |
| 37 |
|
* CaloStrip default constructor |
| 38 |
|
**/ |
| 39 |
CaloStrip::CaloStrip(CaloLevel1 *calo) { |
CaloStrip::CaloStrip(CaloLevel1 *calo) { |
| 40 |
c1 = calo->GetCaloLevel1(); |
c1 = calo->GetCaloLevel1(); |
| 41 |
this->Clear(); |
this->Clear(); |
| 42 |
|
ismech = false; |
| 43 |
|
UseStandardAlig(); |
| 44 |
|
}; |
| 45 |
|
|
| 46 |
|
/** |
| 47 |
|
* CaloStrip default constructor |
| 48 |
|
**/ |
| 49 |
|
CaloStrip::CaloStrip(CaloLevel1 *calo, Bool_t mechalig) { |
| 50 |
|
c1 = calo->GetCaloLevel1(); |
| 51 |
|
this->Clear(); |
| 52 |
|
if ( mechalig ){ |
| 53 |
|
ismech = true; |
| 54 |
|
UXal = MECHCTX; |
| 55 |
|
UYal = MECHCTY; |
| 56 |
|
UZal = MECHCTZ; |
| 57 |
|
} else { |
| 58 |
|
ismech = false; |
| 59 |
|
UseStandardAlig(); |
| 60 |
|
}; |
| 61 |
}; |
}; |
| 62 |
|
|
| 63 |
/** |
/** |
| 64 |
* Clear variables |
* Clear variables |
| 65 |
**/ |
**/ |
| 66 |
void CaloStrip::Clear() { |
void CaloStrip::Clear() { |
| 67 |
fE = 0.; |
fE = 0.; |
| 68 |
fX = 0.; |
fX = 0.; |
| 69 |
fY = 0.; |
fY = 0.; |
| 74 |
}; |
}; |
| 75 |
|
|
| 76 |
/** |
/** |
| 77 |
|
* Connect to the DB and retrieve alignement parameters |
| 78 |
|
**/ |
| 79 |
|
void CaloStrip::UseStandardAlig(){ |
| 80 |
|
// |
| 81 |
|
ismech = false; |
| 82 |
|
// |
| 83 |
|
stringstream aligfile; |
| 84 |
|
Int_t error = 0; |
| 85 |
|
FILE *f = 0; |
| 86 |
|
ifstream badfile; |
| 87 |
|
GL_PARAM *glparam = new GL_PARAM(); |
| 88 |
|
// |
| 89 |
|
TString host = "mysql://localhost/pamelaprod"; |
| 90 |
|
TString user = "anonymous"; |
| 91 |
|
TString psw = ""; |
| 92 |
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
| 93 |
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
| 94 |
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
| 95 |
|
if ( !pamdbhost ) pamdbhost = ""; |
| 96 |
|
if ( !pamdbuser ) pamdbuser = ""; |
| 97 |
|
if ( !pamdbpsw ) pamdbpsw = ""; |
| 98 |
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
| 99 |
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
| 100 |
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
| 101 |
|
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
| 102 |
|
// |
| 103 |
|
UXal = 0.; |
| 104 |
|
UYal = 0.; |
| 105 |
|
UZal = 0.; |
| 106 |
|
// |
| 107 |
|
if ( dbc ){ |
| 108 |
|
// |
| 109 |
|
// determine where I can find calorimeter ADC to MIP conversion file |
| 110 |
|
// |
| 111 |
|
printf(" Querying DB for calorimeter parameters files...\n"); |
| 112 |
|
// |
| 113 |
|
// |
| 114 |
|
// |
| 115 |
|
error = 0; |
| 116 |
|
error = glparam->Query_GL_PARAM(1000,102,dbc); |
| 117 |
|
if ( error >= 0 ){ |
| 118 |
|
// |
| 119 |
|
aligfile.str(""); |
| 120 |
|
aligfile << glparam->PATH.Data() << "/"; |
| 121 |
|
aligfile << glparam->NAME.Data(); |
| 122 |
|
// |
| 123 |
|
printf("\n Using parameter file: \n %s \n",aligfile.str().c_str()); |
| 124 |
|
f = fopen(aligfile.str().c_str(),"rb"); |
| 125 |
|
if ( f ){ |
| 126 |
|
// |
| 127 |
|
fread(&UXal,sizeof(UXal),1,f); |
| 128 |
|
fread(&UYal,sizeof(UYal),1,f); |
| 129 |
|
fread(&UZal,sizeof(UZal),1,f); |
| 130 |
|
// |
| 131 |
|
fclose(f); |
| 132 |
|
}; |
| 133 |
|
// |
| 134 |
|
}; |
| 135 |
|
dbc->Close(); |
| 136 |
|
}; |
| 137 |
|
if ( !UXal ){ |
| 138 |
|
// |
| 139 |
|
printf(" No able to query DB for calorimeter parameters files\n Using hard-coded parameters \n"); |
| 140 |
|
UXal = CTX; |
| 141 |
|
UYal = CTY; |
| 142 |
|
UZal = CTZ; |
| 143 |
|
}; |
| 144 |
|
// |
| 145 |
|
}; |
| 146 |
|
|
| 147 |
|
|
| 148 |
|
/** |
| 149 |
* Given a strip returns its position in the PAMELA reference system |
* Given a strip returns its position in the PAMELA reference system |
| 150 |
**/ |
**/ |
| 151 |
void CaloStrip::Set(Int_t view, Int_t plane, Int_t strip) { |
void CaloStrip::Set(Int_t view, Int_t plane, Int_t strip) { |
| 177 |
fPlane = plane + 1; |
fPlane = plane + 1; |
| 178 |
fStrip = strip + 1; |
fStrip = strip + 1; |
| 179 |
if ( fPlane%2 ){ |
if ( fPlane%2 ){ |
| 180 |
lShift = -0.5; |
lShift = +0.5; |
| 181 |
} else { |
} else { |
| 182 |
lShift = 0.5; |
lShift = -0.5; |
| 183 |
}; |
}; |
| 184 |
// |
// |
| 185 |
shift_.shift = lShift; |
shift_.shift = lShift; |
| 202 |
// |
// |
| 203 |
// X view |
// X view |
| 204 |
// |
// |
| 205 |
fX = (lPos - CTX)/10.; |
fX = (lPos - UXal)/10.; |
| 206 |
fY = 0.; |
fY = 0.; |
| 207 |
fZ = (zplane[fPlane-1] - 5.81 + CTZ)/10.; |
fZ = (zplane[fPlane-1] - 5.81 + UZal)/10.; |
| 208 |
} else { |
// |
| 209 |
|
} else { |
| 210 |
// |
// |
| 211 |
// Y view |
// Y view |
| 212 |
// |
// |
| 213 |
fX = 0; |
fX = 0; |
| 214 |
fY = (lPos - CTY)/10.; |
fY = (lPos - UYal)/10.; |
| 215 |
fZ = (zplane[fPlane-1] + CTZ)/10.; |
fZ = (zplane[fPlane-1] + UZal)/10.; |
| 216 |
}; |
}; |
| 217 |
// |
// |
| 218 |
}; |
}; |
| 241 |
Float_t dzx[22]; |
Float_t dzx[22]; |
| 242 |
Float_t dzy[22]; |
Float_t dzy[22]; |
| 243 |
for ( Int_t i=0; i < 22; i++){ |
for ( Int_t i=0; i < 22; i++){ |
| 244 |
dzx[i] = fabs(fZ*10. - (zplane[i] - 5.81 + CTZ)); |
dzx[i] = fabs(fZ*10. - (zplane[i] - 5.81 + UZal)); |
| 245 |
dzy[i] = fabs(fZ*10. - (zplane[i] + CTZ)); |
dzy[i] = fabs(fZ*10. - (zplane[i] + UZal)); |
| 246 |
}; |
}; |
| 247 |
// |
// |
| 248 |
Float_t minx = TMath::MinElement(22,dzx); |
Float_t minx = TMath::MinElement(22,dzx); |
| 264 |
if ( fView == 1 ){ |
if ( fView == 1 ){ |
| 265 |
if ( dzx[i] == minx ){ |
if ( dzx[i] == minx ){ |
| 266 |
fPlane = i+1; |
fPlane = i+1; |
| 267 |
pos = fX*10. + CTX; |
pos = fX*10. + UXal; |
| 268 |
}; |
}; |
| 269 |
} else { |
} else { |
| 270 |
if ( dzy[i] == miny ){ |
if ( dzy[i] == miny ){ |
| 271 |
fPlane = i+1; |
fPlane = i+1; |
| 272 |
pos = fY*10. + CTY; |
pos = fY*10. + UYal; |
| 273 |
}; |
}; |
| 274 |
}; |
}; |
| 275 |
}; |
}; |
| 284 |
for ( Int_t i=0; i < 96; i++){ |
for ( Int_t i=0; i < 96; i++){ |
| 285 |
ca->Set(fView-1,fPlane-1,i); |
ca->Set(fView-1,fPlane-1,i); |
| 286 |
if ( fView == 1 ){ |
if ( fView == 1 ){ |
| 287 |
stpos = ca->GetX()*10. + CTX; |
stpos = ca->GetX()*10. + UXal; |
| 288 |
} else { |
} else { |
| 289 |
stpos = ca->GetY()*10. + CTY; |
stpos = ca->GetY()*10. + UYal; |
| 290 |
}; |
}; |
| 291 |
dxy[i] = fabs(pos - stpos); |
dxy[i] = fabs(pos - stpos); |
| 292 |
}; |
}; |
| 397 |
// |
// |
| 398 |
Float_t mip = ((Float_t)(eval - fbi*1000000000 -plom*10000000 -strip*100000))/tim; |
Float_t mip = ((Float_t)(eval - fbi*1000000000 -plom*10000000 -strip*100000))/tim; |
| 399 |
// |
// |
| 400 |
|
// if ( view == 0 ){ |
| 401 |
|
// if ( plane%2 ){ |
| 402 |
|
// plane -= 1; |
| 403 |
|
// } else { |
| 404 |
|
// plane += 1; |
| 405 |
|
// }; |
| 406 |
|
// }; |
| 407 |
|
// |
| 408 |
|
// |
| 409 |
if ( mip > 0. && mip < 99999. ) return(mip); |
if ( mip > 0. && mip < 99999. ) return(mip); |
| 410 |
// |
// |
| 411 |
printf(" WARNING: problems decoding value %i at entry %i \n",estrip.At(entry),entry); |
printf(" WARNING: problems decoding value %i at entry %i \n",estrip.At(entry),entry); |
| 416 |
return(0.); |
return(0.); |
| 417 |
} |
} |
| 418 |
|
|
| 419 |
|
/* |
| 420 |
|
* Returns energy released on plane nplane (where 0<= nplane <= 43, 0 = 1Y, 1 = 1X, 2 = 2Y, 3 = 2X, etc. etc.). |
| 421 |
|
*/ |
| 422 |
|
Float_t CaloLevel1::qtotpl(Int_t nplane){ |
| 423 |
|
// |
| 424 |
|
Int_t sview = 1; |
| 425 |
|
if ( nplane%2 ) sview = 0; |
| 426 |
|
// |
| 427 |
|
Int_t splane = nplane-(sview+1)/2; |
| 428 |
|
// |
| 429 |
|
// if ( sview == 0 ){ |
| 430 |
|
// if ( splane%2 ){ |
| 431 |
|
// splane += 1; |
| 432 |
|
// } else { |
| 433 |
|
// splane -= 1; |
| 434 |
|
// }; |
| 435 |
|
// }; |
| 436 |
|
// |
| 437 |
|
Float_t totmip = qtotpl(sview,splane); |
| 438 |
|
// |
| 439 |
|
return(totmip); |
| 440 |
|
// |
| 441 |
|
}; |
| 442 |
|
|
| 443 |
|
/* |
| 444 |
|
* Returns energy released on view "view" (0 = X, 1 = Y) and plane "plane" ( 0 <= plane <= 21 ). |
| 445 |
|
*/ |
| 446 |
|
Float_t CaloLevel1::qtotpl(Int_t sview, Int_t splane){ |
| 447 |
|
// |
| 448 |
|
Int_t view = -1; |
| 449 |
|
Int_t plane = -1; |
| 450 |
|
Int_t strip = -1; |
| 451 |
|
// |
| 452 |
|
Float_t mip = 0.; |
| 453 |
|
Float_t totmip = 0.; |
| 454 |
|
// |
| 455 |
|
if ( istrip == 0 ) return(0.); |
| 456 |
|
// |
| 457 |
|
for (Int_t i = 0; i<istrip; i++ ){ |
| 458 |
|
// |
| 459 |
|
mip = DecodeEstrip(i,view,plane,strip); |
| 460 |
|
// |
| 461 |
|
if ( view == sview && splane == plane ) totmip += mip; |
| 462 |
|
// |
| 463 |
|
// entry are ordered by strip, plane and view number. Go out if you pass the input strip |
| 464 |
|
// |
| 465 |
|
if ( view == sview && plane > splane ) return(totmip); |
| 466 |
|
if ( view > sview ) return(totmip); |
| 467 |
|
// |
| 468 |
|
}; |
| 469 |
|
// |
| 470 |
|
return(totmip); |
| 471 |
|
// |
| 472 |
|
}; |