5 |
* WM dec 2008: Description of "GetdEdx" changed |
* WM dec 2008: Description of "GetdEdx" changed |
6 |
* WM dec 2008: "GetdEdxPaddle" modified: Now includes saturation limit |
* WM dec 2008: "GetdEdxPaddle" modified: Now includes saturation limit |
7 |
* PMTs higher than the saturation limit are not used for dEdx |
* PMTs higher than the saturation limit are not used for dEdx |
8 |
|
* WM apr 2009: bug found by Nicola in method "GetPaddlePlane" |
9 |
*/ |
*/ |
10 |
|
|
11 |
#include <ToFLevel2.h> |
#include <ToFLevel2.h> |
12 |
using namespace std; |
using namespace std; |
13 |
ClassImp(ToFPMT); |
ClassImp(ToFPMT); |
14 |
|
ClassImp(ToFdEdx); |
15 |
|
ClassImp(ToFGeom); |
16 |
ClassImp(ToFTrkVar); |
ClassImp(ToFTrkVar); |
17 |
ClassImp(ToFLevel2); |
ClassImp(ToFLevel2); |
18 |
|
|
891 |
return; |
return; |
892 |
} |
} |
893 |
|
|
894 |
if(7<pad<14){ |
if((7<pad)&&(pad<14)){ |
895 |
plane=1; |
plane=1; |
896 |
paddle=pad-pads11; |
paddle=pad-pads11; |
897 |
return; |
return; |
898 |
} |
} |
899 |
|
|
900 |
if(13<pad<16){ |
if((13<pad)&&(pad<16)){ |
901 |
plane=2; |
plane=2; |
902 |
paddle=pad-pads11-pads12; |
paddle=pad-pads11-pads12; |
903 |
return; |
return; |
904 |
} |
} |
905 |
|
|
906 |
if(15<pad<18){ |
if((15<pad)&&(pad<18)){ |
907 |
plane=3; |
plane=3; |
908 |
paddle=pad-pads11-pads12-pads21; |
paddle=pad-pads11-pads12-pads21; |
909 |
return; |
return; |
910 |
} |
} |
911 |
|
|
912 |
if(17<pad<21){ |
if((17<pad)&&(pad<21)){ |
913 |
plane=4; |
plane=4; |
914 |
paddle=pad-pads11-pads12-pads21-pads22; |
paddle=pad-pads11-pads12-pads21-pads22; |
915 |
return; |
return; |
916 |
} |
} |
917 |
|
|
918 |
if(20<pad<24){ |
if((20<pad)&&(pad<24)){ |
919 |
plane=5; |
plane=5; |
920 |
paddle=pad-pads11-pads12-pads21-pads22-pads31; |
paddle=pad-pads11-pads12-pads21-pads22-pads31; |
921 |
return; |
return; |
1149 |
// |
// |
1150 |
// Copiare qui qualcosa di simile a calonuclei per evitare di riprocessare sempre tutto |
// Copiare qui qualcosa di simile a calonuclei per evitare di riprocessare sempre tutto |
1151 |
// |
// |
1152 |
|
printf("\n\n\n ERROR: NOT IMPLEMENTED ANYMORE, write Emiliano if you need this method (Emiliano.Mocchiutti@ts.infn.it) \n\n\n"); |
1153 |
|
return(-1); |
1154 |
|
// // |
1155 |
|
// // structures to communicate with F77 |
1156 |
|
// // |
1157 |
|
// extern struct ToFInput tofinput_; |
1158 |
|
// extern struct ToFOutput tofoutput_; |
1159 |
|
// // |
1160 |
|
// // DB connection |
1161 |
|
// // |
1162 |
|
// TString host; |
1163 |
|
// TString user; |
1164 |
|
// TString psw; |
1165 |
|
// const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
1166 |
|
// const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
1167 |
|
// const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
1168 |
|
// if ( !pamdbhost ) pamdbhost = ""; |
1169 |
|
// if ( !pamdbuser ) pamdbuser = ""; |
1170 |
|
// if ( !pamdbpsw ) pamdbpsw = ""; |
1171 |
|
// if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
1172 |
|
// if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
1173 |
|
// if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
1174 |
|
// // |
1175 |
|
// // |
1176 |
|
// TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
1177 |
|
// if ( !dbc->IsConnected() ) return 1; |
1178 |
|
// stringstream myquery; |
1179 |
|
// myquery.str(""); |
1180 |
|
// myquery << "SET time_zone='+0:00'"; |
1181 |
|
// dbc->Query(myquery.str().c_str()); |
1182 |
|
// GL_PARAM *glparam = new GL_PARAM(); |
1183 |
|
// glparam->Query_GL_PARAM(1,1,dbc); // parameters stored in DB in GL_PRAM table |
1184 |
|
// trk->LoadField(glparam->PATH+glparam->NAME); |
1185 |
|
// // |
1186 |
|
// Bool_t defcal = true; |
1187 |
|
// Int_t error=glparam->Query_GL_PARAM(run->RUNHEADER_TIME,201,dbc); // parameters stored in DB in GL_PRAM table |
1188 |
|
// if ( error<0 ) { |
1189 |
|
// return(1); |
1190 |
|
// }; |
1191 |
|
// printf(" Reading ToF parameter file: %s \n",(glparam->PATH+glparam->NAME).Data()); |
1192 |
|
// if ( (UInt_t)glparam->TO_TIME != (UInt_t)4294967295UL ) defcal = false; |
1193 |
|
// // |
1194 |
|
// Int_t nlen = (Int_t)(glparam->PATH+glparam->NAME).Length(); |
1195 |
|
// rdtofcal((char *)(glparam->PATH+glparam->NAME).Data(),&nlen); |
1196 |
|
// // |
1197 |
|
// Int_t adc[4][12]; |
1198 |
|
// Int_t tdc[4][12]; |
1199 |
|
// Float_t tdcc[4][12]; |
1200 |
|
// // |
1201 |
|
// // process tof data |
1202 |
|
// // |
1203 |
|
// for (Int_t hh=0; hh<12;hh++){ |
1204 |
|
// for (Int_t kk=0; kk<4;kk++){ |
1205 |
|
// adc[kk][hh] = 4095; |
1206 |
|
// tdc[kk][hh] = 4095; |
1207 |
|
// tdcc[kk][hh] = 4095.; |
1208 |
|
// tofinput_.adc[hh][kk] = 4095; |
1209 |
|
// tofinput_.tdc[hh][kk] = 4095; |
1210 |
|
// }; |
1211 |
|
// }; |
1212 |
|
// Int_t ntrkentry = 0; |
1213 |
|
// Int_t npmtentry = 0; |
1214 |
|
// Int_t gg = 0; |
1215 |
|
// Int_t hh = 0; |
1216 |
|
// Int_t adcf[48]; |
1217 |
|
// memset(adcf, 0, 48*sizeof(Int_t)); |
1218 |
|
// Int_t tdcf[48]; |
1219 |
|
// memset(tdcf, 0, 48*sizeof(Int_t)); |
1220 |
|
// for (Int_t pm=0; pm < this->ntrk() ; pm++){ |
1221 |
|
// ToFTrkVar *ttf = this->GetToFTrkVar(pm); |
1222 |
|
// for ( Int_t nc=0; nc < ttf->npmttdc; nc++){ |
1223 |
|
// if ( (ttf->tdcflag).At(nc) != 0 ) tdcf[(ttf->pmttdc).At(nc)] = 1; |
1224 |
|
// }; |
1225 |
|
// for ( Int_t nc=0; nc < ttf->npmtadc; nc++){ |
1226 |
|
// if ( (ttf->adcflag).At(nc) != 0 ) adcf[(ttf->pmtadc).At(nc)] = 1; |
1227 |
|
// }; |
1228 |
|
// }; |
1229 |
|
// // |
1230 |
|
// for (Int_t pm=0; pm < this->npmt() ; pm++){ |
1231 |
|
// ToFPMT *pmt = this->GetToFPMT(pm); |
1232 |
|
// this->GetPMTIndex(pmt->pmt_id, gg, hh); |
1233 |
|
// if ( adcf[pmt->pmt_id] == 0 ){ |
1234 |
|
// tofinput_.adc[gg][hh] = (int)pmt->adc; |
1235 |
|
// adc[hh][gg] = (int)pmt->adc; |
1236 |
|
// }; |
1237 |
|
// if ( tdcf[pmt->pmt_id] == 0 ){ |
1238 |
|
// tofinput_.tdc[gg][hh] = (int)pmt->tdc; |
1239 |
|
// tdc[hh][gg] = (int)pmt->tdc; |
1240 |
|
// }; |
1241 |
|
// tdcc[hh][gg] = (float)pmt->tdc_tw; |
1242 |
|
// // Int_t pppid = this->GetPMTid(hh,gg); |
1243 |
|
// // printf(" pm %i pmt_id %i pppid %i hh %i gg %i tdcc %f tdc %f adc %f \n",pm,pmt->pmt_id,pppid,hh,gg,pmt->tdc_tw,pmt->tdc,pmt->adc); |
1244 |
|
// }; |
1245 |
|
// // |
1246 |
|
// Int_t unpackError = this->unpackError; |
1247 |
|
// // |
1248 |
|
// for (Int_t hh=0; hh<5;hh++){ |
1249 |
|
// tofinput_.patterntrig[hh]=trg->patterntrig[hh]; |
1250 |
|
// }; |
1251 |
|
// // |
1252 |
|
// this->Clear(); |
1253 |
|
// // |
1254 |
|
// Int_t pmt_id = 0; |
1255 |
|
// ToFPMT *t_pmt = new ToFPMT(); |
1256 |
|
// if(!(this->PMT)) this->PMT = new TClonesArray("ToFPMT",12); //ELENA |
1257 |
|
// TClonesArray &tpmt = *this->PMT; |
1258 |
|
// ToFTrkVar *t_tof = new ToFTrkVar(); |
1259 |
|
// if(!(this->ToFTrk)) this->ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA |
1260 |
|
// TClonesArray &t = *this->ToFTrk; |
1261 |
|
// // |
1262 |
|
// // |
1263 |
|
// // Here we have calibrated data, ready to be passed to the FORTRAN routine which will extract common and track-related variables. |
1264 |
|
// // |
1265 |
|
// npmtentry = 0; |
1266 |
|
// // |
1267 |
|
// ntrkentry = 0; |
1268 |
|
// // |
1269 |
|
// // Calculate tracks informations from ToF alone |
1270 |
|
// // |
1271 |
|
// tofl2com(); |
1272 |
|
// // |
1273 |
|
// memcpy(this->tof_j_flag,tofoutput_.tof_j_flag,6*sizeof(Int_t)); |
1274 |
|
// // |
1275 |
|
// t_tof->trkseqno = -1; |
1276 |
|
// // |
1277 |
|
// // and now we must copy from the output structure to the level2 class: |
1278 |
|
// // |
1279 |
|
// t_tof->npmttdc = 0; |
1280 |
|
// // |
1281 |
|
// for (Int_t hh=0; hh<12;hh++){ |
1282 |
|
// for (Int_t kk=0; kk<4;kk++){ |
1283 |
|
// if ( tofoutput_.tofmask[hh][kk] != 0 ){ |
1284 |
|
// pmt_id = this->GetPMTid(kk,hh); |
1285 |
|
// t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc); |
1286 |
|
// t_tof->tdcflag.AddAt(tofoutput_.tdcflagtof[hh][kk],t_tof->npmttdc); // gf: Jan 09/07 |
1287 |
|
// t_tof->npmttdc++; |
1288 |
|
// }; |
1289 |
|
// }; |
1290 |
|
// }; |
1291 |
|
// for (Int_t kk=0; kk<13;kk++){ |
1292 |
|
// t_tof->beta[kk] = tofoutput_.betatof_a[kk]; |
1293 |
|
// } |
1294 |
|
// // |
1295 |
|
// t_tof->npmtadc = 0; |
1296 |
|
// for (Int_t hh=0; hh<12;hh++){ |
1297 |
|
// for (Int_t kk=0; kk<4;kk++){ |
1298 |
|
// if ( tofoutput_.adctof_c[hh][kk] < 1000 ){ |
1299 |
|
// t_tof->dedx.AddAt(tofoutput_.adctof_c[hh][kk],t_tof->npmtadc); |
1300 |
|
// pmt_id = this->GetPMTid(kk,hh); |
1301 |
|
// t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
1302 |
|
// t_tof->adcflag.AddAt(tofoutput_.adcflagtof[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
1303 |
|
// t_tof->npmtadc++; |
1304 |
|
// }; |
1305 |
|
// }; |
1306 |
|
// }; |
1307 |
|
// // |
1308 |
|
// memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
1309 |
|
// memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
1310 |
|
// memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
1311 |
|
// memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
1312 |
|
// // |
1313 |
|
// new(t[ntrkentry]) ToFTrkVar(*t_tof); |
1314 |
|
// ntrkentry++; |
1315 |
|
// t_tof->Clear(); |
1316 |
|
// // |
1317 |
|
// // |
1318 |
|
// // |
1319 |
|
// t_pmt->Clear(); |
1320 |
|
// // |
1321 |
|
// for (Int_t hh=0; hh<12;hh++){ |
1322 |
|
// for (Int_t kk=0; kk<4;kk++){ |
1323 |
|
// // new WM |
1324 |
|
// if ( tofoutput_.tdc_c[hh][kk] < 4095 || adc[kk][hh] < 4095 || tdc[kk][hh] < 4095 ){ |
1325 |
|
// // if ( tdcc[kk][hh] < 4095. || adc[kk][hh] < 4095 || tdc[kk][hh] < 4095 ){ |
1326 |
|
// // |
1327 |
|
// t_pmt->pmt_id = this->GetPMTid(kk,hh); |
1328 |
|
// t_pmt->tdc_tw = tofoutput_.tdc_c[hh][kk]; |
1329 |
|
// t_pmt->adc = (Float_t)adc[kk][hh]; |
1330 |
|
// t_pmt->tdc = (Float_t)tdc[kk][hh]; |
1331 |
|
// // |
1332 |
|
// new(tpmt[npmtentry]) ToFPMT(*t_pmt); |
1333 |
|
// npmtentry++; |
1334 |
|
// t_pmt->Clear(); |
1335 |
|
// }; |
1336 |
|
// }; |
1337 |
|
// }; |
1338 |
|
// // |
1339 |
|
// // Calculate track-related variables |
1340 |
|
// // |
1341 |
|
// if ( trk->ntrk() > 0 ){ |
1342 |
|
// // |
1343 |
|
// // We have at least one track |
1344 |
|
// // |
1345 |
|
// // |
1346 |
|
// // Run over tracks |
1347 |
|
// // |
1348 |
|
// for(Int_t nt=0; nt < trk->ntrk(); nt++){ |
1349 |
|
// // |
1350 |
|
// TrkTrack *ptt = trk->GetStoredTrack(nt); |
1351 |
|
// // |
1352 |
|
// // Copy the alpha vector in the input structure |
1353 |
|
// // |
1354 |
|
// for (Int_t e = 0; e < 5 ; e++){ |
1355 |
|
// tofinput_.al_pp[e] = ptt->al[e]; |
1356 |
|
// }; |
1357 |
|
// // |
1358 |
|
// // Get tracker related variables for this track |
1359 |
|
// // |
1360 |
|
// toftrk(); |
1361 |
|
// // |
1362 |
|
// // Copy values in the class from the structure (we need to use a temporary class to store variables). |
1363 |
|
// // |
1364 |
|
// t_tof->npmttdc = 0; |
1365 |
|
// for (Int_t hh=0; hh<12;hh++){ |
1366 |
|
// for (Int_t kk=0; kk<4;kk++){ |
1367 |
|
// if ( tofoutput_.tofmask[hh][kk] != 0 ){ |
1368 |
|
// pmt_id = this->GetPMTid(kk,hh); |
1369 |
|
// t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc); |
1370 |
|
// t_tof->tdcflag.AddAt(tofoutput_.tdcflag[hh][kk],t_tof->npmttdc); // gf: Jan 09/07 |
1371 |
|
// t_tof->npmttdc++; |
1372 |
|
// }; |
1373 |
|
// }; |
1374 |
|
// }; |
1375 |
|
// for (Int_t kk=0; kk<13;kk++){ |
1376 |
|
// t_tof->beta[kk] = tofoutput_.beta_a[kk]; |
1377 |
|
// }; |
1378 |
|
// // |
1379 |
|
// t_tof->npmtadc = 0; |
1380 |
|
// for (Int_t hh=0; hh<12;hh++){ |
1381 |
|
// for (Int_t kk=0; kk<4;kk++){ |
1382 |
|
// if ( tofoutput_.adc_c[hh][kk] < 1000 ){ |
1383 |
|
// t_tof->dedx.AddAt(tofoutput_.adc_c[hh][kk],t_tof->npmtadc); |
1384 |
|
// pmt_id = this->GetPMTid(kk,hh); |
1385 |
|
// t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
1386 |
|
// t_tof->adcflag.AddAt(tofoutput_.adcflag[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
1387 |
|
// t_tof->npmtadc++; |
1388 |
|
// }; |
1389 |
|
// }; |
1390 |
|
// }; |
1391 |
|
// // |
1392 |
|
// memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
1393 |
|
// memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
1394 |
|
// memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
1395 |
|
// memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
1396 |
|
// // |
1397 |
|
// // Store the tracker track number in order to be sure to have shyncronized data during analysis |
1398 |
|
// // |
1399 |
|
// t_tof->trkseqno = nt; |
1400 |
|
// // |
1401 |
|
// // create a new object for this event with track-related variables |
1402 |
|
// // |
1403 |
|
// new(t[ntrkentry]) ToFTrkVar(*t_tof); |
1404 |
|
// ntrkentry++; |
1405 |
|
// t_tof->Clear(); |
1406 |
|
// // |
1407 |
|
// }; // loop on all the tracks |
1408 |
|
// // |
1409 |
|
// this->unpackError = unpackError; |
1410 |
|
// if ( defcal ){ |
1411 |
|
// this->default_calib = 1; |
1412 |
|
// } else { |
1413 |
|
// this->default_calib = 0; |
1414 |
|
// }; |
1415 |
|
//}; |
1416 |
|
// return(0); |
1417 |
|
} |
1418 |
|
|
1419 |
|
|
1420 |
|
ToFdEdx::ToFdEdx() |
1421 |
|
{ |
1422 |
|
memset(conn,0,12*sizeof(Bool_t)); |
1423 |
|
memset(ts,0,12*sizeof(UInt_t)); |
1424 |
|
memset(te,0,12*sizeof(UInt_t)); |
1425 |
|
eDEDXpmt = new TArrayF(48); |
1426 |
|
Define_PMTsat(); |
1427 |
|
Clear(); |
1428 |
|
} |
1429 |
|
//------------------------------------------------------------------------ |
1430 |
|
void ToFdEdx::CheckConnectors(UInt_t atime, GL_PARAM *glparam, TSQLServer *dbc) |
1431 |
|
{ |
1432 |
|
for(int i=0; i<12; i++){ |
1433 |
|
if(atime<=ts[i] || atime>te[i]){ |
1434 |
|
Int_t error=glparam->Query_GL_PARAM(atime,210+i,dbc); // parameters stored in DB in GL_PRAM table |
1435 |
|
if ( error<0 ) { |
1436 |
|
conn[i]=false; |
1437 |
|
ts[i]=0; |
1438 |
|
te[i]=numeric_limits<UInt_t>::max(); |
1439 |
|
}; |
1440 |
|
if ( !error ){ |
1441 |
|
conn[i]=true; |
1442 |
|
ts[i]=glparam->FROM_TIME; |
1443 |
|
te[i]=glparam->TO_TIME; |
1444 |
|
} |
1445 |
|
if ( error>0 ){ |
1446 |
|
conn[i]=false; |
1447 |
|
ts[i]=glparam->TO_TIME; |
1448 |
|
TSQLResult *pResult; |
1449 |
|
TSQLRow *row; |
1450 |
|
TString query= Form("SELECT FROM_TIME FROM GL_PARAM WHERE TYPE=%i AND FROM_TIME>=%i ORDER BY FROM_TIME ASC LIMIT 1;",210+i,atime); |
1451 |
|
pResult=dbc->Query(query.Data()); |
1452 |
|
if(!pResult->GetRowCount()){ |
1453 |
|
te[i]=numeric_limits<UInt_t>::max(); |
1454 |
|
}else{ |
1455 |
|
row=pResult->Next(); |
1456 |
|
te[i]=(UInt_t)atoll(row->GetField(0)); |
1457 |
|
} |
1458 |
|
} |
1459 |
|
// |
1460 |
|
|
1461 |
|
} |
1462 |
|
} |
1463 |
|
|
1464 |
|
} |
1465 |
// |
//------------------------------------------------------------------------ |
1466 |
// structures to communicate with F77 |
void ToFdEdx::Clear(Option_t *option) |
1467 |
// |
{ |
|
extern struct ToFInput tofinput_; |
|
|
extern struct ToFOutput tofoutput_; |
|
|
// |
|
|
// DB connection |
|
1468 |
// |
// |
1469 |
TString host; |
// Set arrays and initialize structure |
1470 |
TString user; |
// eDEDXpmt.Set(48); eDEDXpmt.Reset(-1); // Set array size and reset structure |
1471 |
TString psw; |
eDEDXpmt->Set(48); eDEDXpmt->Reset(-1); // Set array size and reset structure |
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
|
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
|
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
|
|
if ( !pamdbhost ) pamdbhost = ""; |
|
|
if ( !pamdbuser ) pamdbuser = ""; |
|
|
if ( !pamdbpsw ) pamdbpsw = ""; |
|
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
|
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
|
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
|
|
// |
|
|
// |
|
|
TSQLServer *dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
|
|
if ( !dbc->IsConnected() ) return 1; |
|
|
stringstream myquery; |
|
|
myquery.str(""); |
|
|
myquery << "SET time_zone='+0:00'"; |
|
|
dbc->Query(myquery.str().c_str()); |
|
|
GL_PARAM *glparam = new GL_PARAM(); |
|
|
glparam->Query_GL_PARAM(1,1,dbc); // parameters stored in DB in GL_PRAM table |
|
|
trk->LoadField(glparam->PATH+glparam->NAME); |
|
|
// |
|
|
Bool_t defcal = true; |
|
|
Int_t error=glparam->Query_GL_PARAM(run->RUNHEADER_TIME,201,dbc); // parameters stored in DB in GL_PRAM table |
|
|
if ( error<0 ) { |
|
|
return(1); |
|
|
}; |
|
|
printf(" Reading ToF parameter file: %s \n",(glparam->PATH+glparam->NAME).Data()); |
|
|
if ( (UInt_t)glparam->TO_TIME != (UInt_t)4294967295UL ) defcal = false; |
|
1472 |
// |
// |
1473 |
Int_t nlen = (Int_t)(glparam->PATH+glparam->NAME).Length(); |
}; |
1474 |
rdtofcal((char *)(glparam->PATH+glparam->NAME).Data(),&nlen); |
|
1475 |
|
//------------------------------------------------------------------------ |
1476 |
|
void ToFdEdx::Print(Option_t *option) |
1477 |
|
{ |
1478 |
// |
// |
1479 |
Int_t adc[4][12]; |
printf("========================================================================\n"); |
1480 |
Int_t tdc[4][12]; |
|
1481 |
Float_t tdcc[4][12]; |
}; |
1482 |
// |
|
1483 |
// process tof data |
//------------------------------------------------------------------------ |
1484 |
// |
void ToFdEdx::Init(pamela::tof::TofEvent *tofl0) |
1485 |
for (Int_t hh=0; hh<12;hh++){ |
{ |
|
for (Int_t kk=0; kk<4;kk++){ |
|
|
adc[kk][hh] = 4095; |
|
|
tdc[kk][hh] = 4095; |
|
|
tdcc[kk][hh] = 4095.; |
|
|
tofinput_.adc[hh][kk] = 4095; |
|
|
tofinput_.tdc[hh][kk] = 4095; |
|
|
}; |
|
|
}; |
|
|
Int_t ntrkentry = 0; |
|
|
Int_t npmtentry = 0; |
|
|
Int_t gg = 0; |
|
|
Int_t hh = 0; |
|
|
Int_t adcf[48]; |
|
|
memset(adcf, 0, 48*sizeof(Int_t)); |
|
|
Int_t tdcf[48]; |
|
|
memset(tdcf, 0, 48*sizeof(Int_t)); |
|
|
for (Int_t pm=0; pm < this->ntrk() ; pm++){ |
|
|
ToFTrkVar *ttf = this->GetToFTrkVar(pm); |
|
|
for ( Int_t nc=0; nc < ttf->npmttdc; nc++){ |
|
|
if ( (ttf->tdcflag).At(nc) != 0 ) tdcf[(ttf->pmttdc).At(nc)] = 1; |
|
|
}; |
|
|
for ( Int_t nc=0; nc < ttf->npmtadc; nc++){ |
|
|
if ( (ttf->adcflag).At(nc) != 0 ) adcf[(ttf->pmtadc).At(nc)] = 1; |
|
|
}; |
|
|
}; |
|
1486 |
// |
// |
1487 |
for (Int_t pm=0; pm < this->npmt() ; pm++){ |
ToFLevel2 tf; |
1488 |
ToFPMT *pmt = this->GetToFPMT(pm); |
for (Int_t gg=0; gg<4;gg++){ |
1489 |
this->GetPMTIndex(pmt->pmt_id, gg, hh); |
for (Int_t hh=0; hh<12;hh++){ |
1490 |
if ( adcf[pmt->pmt_id] == 0 ){ |
// tofinput_.tdc[hh][gg]=tofEvent->tdc[gg][hh]; |
1491 |
tofinput_.adc[gg][hh] = (int)pmt->adc; |
int mm = tf.GetPMTid(gg,hh); |
1492 |
adc[hh][gg] = (int)pmt->adc; |
adc[mm]=tofl0->adc[gg][hh]; |
1493 |
}; |
}; |
|
if ( tdcf[pmt->pmt_id] == 0 ){ |
|
|
tofinput_.tdc[gg][hh] = (int)pmt->tdc; |
|
|
tdc[hh][gg] = (int)pmt->tdc; |
|
|
}; |
|
|
tdcc[hh][gg] = (float)pmt->tdc_tw; |
|
|
// Int_t pppid = this->GetPMTid(hh,gg); |
|
|
// printf(" pm %i pmt_id %i pppid %i hh %i gg %i tdcc %f tdc %f adc %f \n",pm,pmt->pmt_id,pppid,hh,gg,pmt->tdc_tw,pmt->tdc,pmt->adc); |
|
1494 |
}; |
}; |
1495 |
|
|
1496 |
|
}; |
1497 |
|
|
1498 |
|
//------------------------------------------------------------------------ |
1499 |
|
void ToFdEdx::Init(Int_t gg, Int_t hh, Float_t adce) |
1500 |
|
{ |
1501 |
// |
// |
1502 |
Int_t unpackError = this->unpackError; |
ToFLevel2 tf; |
1503 |
// |
// for (Int_t gg=0; gg<4;gg++){ |
1504 |
for (Int_t hh=0; hh<5;hh++){ |
// for (Int_t hh=0; hh<12;hh++){ |
1505 |
tofinput_.patterntrig[hh]=trg->patterntrig[hh]; |
int mm = tf.GetPMTid(gg,hh); |
1506 |
|
adc[mm]=adce; |
1507 |
|
|
1508 |
|
}; |
1509 |
|
//------------------------------------------------------------------------ |
1510 |
|
void ToFdEdx::Process(UInt_t atime, Float_t betamean, Float_t *xtr_tof, Float_t *ytr_tof, Int_t exitat) |
1511 |
|
{ |
1512 |
|
// the parameters should be already initialised by InitPar() |
1513 |
|
// printf(" in process \n"); |
1514 |
|
Clear(); |
1515 |
|
|
1516 |
|
// define angle: |
1517 |
|
double dx = xtr_tof[1] - xtr_tof[5]; |
1518 |
|
double dy = ytr_tof[0] - ytr_tof[4]; |
1519 |
|
double dr = sqrt(dx*dx+dy*dy); |
1520 |
|
double theta=atan(dr/76.81); |
1521 |
|
// |
1522 |
|
if ( xtr_tof[1] > 99. || xtr_tof[5] > 99. || ytr_tof[0] > 99. || ytr_tof[4] > 99. ) theta = 0.; |
1523 |
|
for (Int_t ii=0; ii<6; ii++){ |
1524 |
|
if ( xtr_tof[ii] > 99. ) xtr_tof[ii] = 0.; |
1525 |
|
if ( ytr_tof[ii] > 99. ) ytr_tof[ii] = 0.; |
1526 |
}; |
}; |
1527 |
// |
// |
1528 |
this->Clear(); |
|
1529 |
|
|
1530 |
|
//--------------------- TABLE OF PERIODS WITH HV PROBLEMS ---------------------------- |
1531 |
|
|
1532 |
|
int Aconn=conn[0]; // PMT 0,20,22,24 |
1533 |
|
int Bconn=conn[1]; // PMT 6,12,26,34 |
1534 |
|
int Cconn=conn[2]; // PMT 4,14,28,32 |
1535 |
|
int Dconn=conn[3]; // PMT 2,8,10,30 |
1536 |
|
int Econn=conn[4]; // PMT 42,43,44,47 |
1537 |
|
int Fconn=conn[5]; // PMT 7,19,23,27 |
1538 |
|
int Gconn=conn[6]; // PMT 3,11,25,33 |
1539 |
|
int Hconn=conn[7]; // PMT 1,9,13,21 |
1540 |
|
int Iconn=conn[8]; // PMT 5,29,31,35 |
1541 |
|
int Lconn=conn[9]; // PMT 37,40,45,46 |
1542 |
|
int Mconn=conn[10]; // PMT 15,16,17,18 |
1543 |
|
int Nconn=conn[11]; // PMT 36,38,39,41 |
1544 |
|
if( false ) cout << Gconn << Iconn << Lconn <<endl; // to avoid compilation warnings |
1545 |
|
|
1546 |
|
// printf(" size %i \n",eDEDXpmt.GetSize()); |
1547 |
|
for( int ii=0; ii<48; ii++ ) { |
1548 |
|
// |
1549 |
|
// eDEDXpmt.SetAt(-1.,ii); |
1550 |
|
// printf(" ii %i beta %f atime %u xtr 1 %f ytr 1 %f adc %f \n",ii,betamean,atime,xtr_tof[0],ytr_tof[0],adc[ii]); |
1551 |
|
|
1552 |
|
if( adc[ii] >= 4095. ){ |
1553 |
|
// eDEDXpmt[ii] = 0.; |
1554 |
|
eDEDXpmt->AddAt(0.,ii); |
1555 |
|
continue; // EMILIANO |
1556 |
|
}; |
1557 |
|
|
1558 |
|
if( adc[ii] >= (PMTsat[ii]-5.) && adc[ii] < 4095. ){ |
1559 |
|
eDEDXpmt->AddAt(1000.,ii); |
1560 |
|
continue; // EMILIANO |
1561 |
|
}; |
1562 |
|
|
1563 |
|
if( adc[ii] <= 0. ) { |
1564 |
|
eDEDXpmt->AddAt(1500.,ii); |
1565 |
|
continue; |
1566 |
|
}; |
1567 |
|
// |
1568 |
|
double adcpC = f_adcPC( adc[ii] ); // - adc conversion in pC |
1569 |
|
if ( exitat == 0 ){ |
1570 |
|
eDEDXpmt->AddAt((Float_t)adcpC,ii); |
1571 |
|
continue; |
1572 |
|
} |
1573 |
|
// printf(" e qua? \n"); |
1574 |
|
|
1575 |
|
double adccorr = adcpC*fabs(cos(theta)); |
1576 |
|
if(adccorr<=0.) continue; |
1577 |
|
if ( exitat == 1 ){ |
1578 |
|
eDEDXpmt->AddAt((Float_t)adccorr,ii); |
1579 |
|
continue; |
1580 |
|
} |
1581 |
|
// printf(" e quo? \n"); |
1582 |
|
|
1583 |
|
// int standard=0; |
1584 |
|
int S115B_ok=0; |
1585 |
|
int S115B_break=0; |
1586 |
|
|
1587 |
|
if(atime<1158720000)S115B_ok=1; |
1588 |
|
else S115B_break=1; |
1589 |
|
|
1590 |
|
|
1591 |
|
//------------------------------------------------------------------------ |
1592 |
|
// printf(" e qui? \n"); |
1593 |
|
//---------------------------------------------------- Z reconstruction |
1594 |
|
|
1595 |
|
double adcHe, adcnorm, adclin, dEdx, Zeta; |
1596 |
|
|
1597 |
|
adcHe=-2; |
1598 |
|
adcnorm=-2; |
1599 |
|
adclin=-2; |
1600 |
|
dEdx=-2; |
1601 |
|
Zeta=-2; |
1602 |
|
Double_t correction = 1.; |
1603 |
|
|
1604 |
|
if(Aconn==1 && (ii==0 || ii==20 || ii==22 || ii==24)){ |
1605 |
|
correction = 1.675; |
1606 |
|
} |
1607 |
|
else if(Bconn==1 && (ii==6 || ii==12 || ii==26 || ii==34)){ |
1608 |
|
correction = 2.482; |
1609 |
|
} |
1610 |
|
else if(Cconn==1 && (ii==4 || ii==14 || ii==28 || ii==32)){ |
1611 |
|
correction = 1.464; |
1612 |
|
} |
1613 |
|
else if(Dconn==1 && (ii==2 || ii==8 || ii==10 || ii==30)){ |
1614 |
|
correction = 1.995; |
1615 |
|
} |
1616 |
|
else if(Econn==1 && (ii==42 || ii==43 || ii==44 || ii==47)){ |
1617 |
|
correction = 1.273; |
1618 |
|
} |
1619 |
|
else if(Fconn==1 && (ii==7 || ii==19 || ii==23 || ii==27)){ |
1620 |
|
correction = 1.565; |
1621 |
|
} |
1622 |
|
else if(Mconn==1 && (ii==15 || ii==16 || ii==17 || ii==18)){ |
1623 |
|
correction = 1.565; |
1624 |
|
} |
1625 |
|
else if(Nconn==1 && (ii==36 || ii==38 || ii==39 || ii==41)){ |
1626 |
|
correction = 1.018; |
1627 |
|
} |
1628 |
|
else if(Hconn==1 && (ii==1 || ii==13 || ii==21 || (ii==9&&S115B_ok==1))){ |
1629 |
|
correction = 1.84; |
1630 |
|
} |
1631 |
|
else if(S115B_break==1 && ii==9 && Hconn==1){ |
1632 |
|
correction = 1.64; |
1633 |
|
} |
1634 |
|
else correction = 1.; |
1635 |
|
|
1636 |
|
if( ii==9 && S115B_break==1 ){ |
1637 |
|
adcHe = f_att5B( ytr_tof[0] )/correction; |
1638 |
|
} else { |
1639 |
|
adcHe = Get_adc_he(ii, xtr_tof, ytr_tof)/correction; |
1640 |
|
}; |
1641 |
|
if(adcHe<=0) continue; |
1642 |
|
if ( exitat == 2 ){ |
1643 |
|
if(ii==9 && S115B_break==1) eDEDXpmt->AddAt(36.*(Float_t)adccorr/adcHe,ii); |
1644 |
|
else adclin = 4.*(Float_t)adccorr/adcHe; |
1645 |
|
continue; |
1646 |
|
} |
1647 |
|
|
1648 |
|
if(ii==9 && S115B_break==1) adcnorm = f_pos5B(adccorr); |
1649 |
|
else adcnorm = f_pos( (parPos[ii]), adccorr); |
1650 |
|
if(adcnorm<=0) continue; |
1651 |
|
if(ii==9 && S115B_break==1) adclin = 36.*adcnorm/adcHe; |
1652 |
|
else adclin = 4.*adcnorm/adcHe; |
1653 |
|
if(adclin<=0) continue; |
1654 |
|
if ( exitat == 3 ){ |
1655 |
|
if(ii==9 && S115B_break==1) eDEDXpmt->AddAt((Float_t)adclin,ii); |
1656 |
|
else eDEDXpmt->AddAt((Float_t)adclin,ii); |
1657 |
|
continue; |
1658 |
|
} |
1659 |
|
// |
1660 |
|
if ( betamean > 99. ){ |
1661 |
|
// eDEDXpmt.AddAt((Float_t)adclin,ii); |
1662 |
|
eDEDXpmt->AddAt((Float_t)adclin,ii); |
1663 |
|
// printf(" AAPMT IS %i dedx is %f vector is %f \n",ii,adclin,eDEDXpmt[ii]); |
1664 |
|
continue; |
1665 |
|
}; |
1666 |
|
// |
1667 |
|
double dEdxHe=-2; |
1668 |
|
if(ii==9 && S115B_break==1){ |
1669 |
|
if( betamean <1. ) dEdxHe = f_BB5B( betamean ); |
1670 |
|
else dEdxHe = 33; |
1671 |
|
} else { |
1672 |
|
if( betamean <1. ) dEdxHe = f_BB( (parBBneg[ii]), betamean ); |
1673 |
|
else dEdxHe = parBBpos[ii]; |
1674 |
|
} |
1675 |
|
|
1676 |
|
|
1677 |
|
if(dEdxHe<=0){ |
1678 |
|
eDEDXpmt->AddAt((Float_t)adclin,ii); |
1679 |
|
continue; |
1680 |
|
}; |
1681 |
|
|
1682 |
|
if(ii==9 && S115B_break==1) dEdx = f_desatBB5B( adclin ); |
1683 |
|
else dEdx = f_desatBB((parDesatBB[ii]), adclin ); |
1684 |
|
|
1685 |
|
if(dEdx<=0){ |
1686 |
|
eDEDXpmt->AddAt((Float_t)adclin,ii); |
1687 |
|
continue; |
1688 |
|
}; |
1689 |
|
|
1690 |
|
eDEDXpmt->AddAt((Float_t)dEdx,ii); |
1691 |
|
// eDEDXpmt.AddAt((Float_t)dEdx,ii); |
1692 |
|
|
1693 |
|
// printf(" PMT IS %i dedx is %f vector is %f \n",ii,dEdx,eDEDXpmt[ii]); |
1694 |
|
|
1695 |
|
} //end loop on 48 PMT |
1696 |
|
|
1697 |
|
}; |
1698 |
|
|
1699 |
|
|
1700 |
|
//------------------------------------------------------------------------ |
1701 |
|
void ToFdEdx::Define_PMTsat() |
1702 |
|
{ |
1703 |
|
Float_t sat[48] = { |
1704 |
|
3176.35,3178.19,3167.38,3099.73,3117.00,3126.29,3111.44,3092.27, |
1705 |
|
3146.48,3094.41,3132.13,3115.37,3099.32,3110.97,3111.80,3143.14, |
1706 |
|
3106.72,3153.44,3136.00,3188.96,3104.73,3140.45,3073.18,3106.62, |
1707 |
|
3112.48,3146.92,3127.24,3136.52,3109.59,3112.89,3045.15,3147.26, |
1708 |
|
3095.92,3121.05,3083.25,3123.62,3150.92,3125.30,3067.60,3160.18, |
1709 |
|
3119.36,3108.92,3164.77,3133.64,3111.47,3131.98,3128.87,3135.56 }; |
1710 |
|
PMTsat.Set(48,sat); |
1711 |
|
} |
1712 |
|
|
1713 |
|
//------------------------------------------------------------------------ |
1714 |
|
void ToFdEdx::ReadParBBpos( const char *fname ) |
1715 |
|
{ |
1716 |
|
// printf("read %s\n",fname); |
1717 |
|
parBBpos.Set(48); |
1718 |
|
FILE *fattin = fopen( fname , "r" ); |
1719 |
|
for (int i=0; i<48; i++) { |
1720 |
|
int tid=0; |
1721 |
|
float tp; |
1722 |
|
if(fscanf(fattin,"%d %f", |
1723 |
|
&tid, &tp )!=2) break; |
1724 |
|
parBBpos[i]=tp; |
1725 |
|
} |
1726 |
|
fclose(fattin); |
1727 |
|
} |
1728 |
|
|
1729 |
|
//------------------------------------------------------------------------ |
1730 |
|
void ToFdEdx::ReadParDesatBB( const char *fname ) |
1731 |
|
{ |
1732 |
|
// printf("read %s\n",fname); |
1733 |
|
FILE *fattin = fopen( fname , "r" ); |
1734 |
|
for (int i=0; i<48; i++) { |
1735 |
|
int tid=0; |
1736 |
|
float tp[3]; |
1737 |
|
if(fscanf(fattin,"%d %f %f %f", |
1738 |
|
&tid, &tp[0], &tp[1], &tp[2] )!=4) break; |
1739 |
|
parDesatBB[i].Set(3,tp); |
1740 |
|
} |
1741 |
|
fclose(fattin); |
1742 |
|
} |
1743 |
|
|
1744 |
|
|
1745 |
|
//------------------------------------------------------------------------ |
1746 |
|
void ToFdEdx::ReadParBBneg( const char *fname ) |
1747 |
|
|
1748 |
|
{ |
1749 |
|
// printf("read %s\n",fname); |
1750 |
|
FILE *fattin = fopen( fname , "r" ); |
1751 |
|
for (int i=0; i<48; i++) { |
1752 |
|
int tid=0; |
1753 |
|
float tp[3]; |
1754 |
|
if(fscanf(fattin,"%d %f %f %f", |
1755 |
|
&tid, &tp[0], &tp[1], &tp[2] )!=4) break; |
1756 |
|
parBBneg[i].Set(3,tp); |
1757 |
|
} |
1758 |
|
fclose(fattin); |
1759 |
|
} |
1760 |
|
|
1761 |
|
//------------------------------------------------------------------------ |
1762 |
|
void ToFdEdx::ReadParPos( const char *fname ) |
1763 |
|
{ |
1764 |
|
// printf("read %s\n",fname); |
1765 |
|
FILE *fattin = fopen( fname , "r" ); |
1766 |
|
for (int i=0; i<48; i++) { |
1767 |
|
int tid=0; |
1768 |
|
float tp[4]; |
1769 |
|
if(fscanf(fattin,"%d %f %f %f %f", |
1770 |
|
&tid, &tp[0], &tp[1], &tp[2], &tp[3])!=5) break; |
1771 |
|
parPos[i].Set(4,tp); |
1772 |
|
} |
1773 |
|
fclose(fattin); |
1774 |
|
} |
1775 |
|
|
1776 |
|
//------------------------------------------------------------------------ |
1777 |
|
void ToFdEdx::ReadParAtt( const char *fname ) |
1778 |
|
{ |
1779 |
|
// printf("read %s\n",fname); |
1780 |
|
FILE *fattin = fopen( fname , "r" ); |
1781 |
|
for (int i=0; i<48; i++) { |
1782 |
|
int tid=0; |
1783 |
|
float tp[6]; |
1784 |
|
if(fscanf(fattin,"%d %f %f %f %f %f %f", |
1785 |
|
&tid, &tp[0], &tp[1], &tp[2], &tp[3], &tp[4], &tp[5] )!=7) break; |
1786 |
|
parAtt[i].Set(6,tp); |
1787 |
|
} |
1788 |
|
fclose(fattin); |
1789 |
|
} |
1790 |
|
|
1791 |
|
|
1792 |
|
|
1793 |
|
|
1794 |
|
|
1795 |
|
|
1796 |
|
double ToFdEdx::f_att( TArrayF &p, float x ) |
1797 |
|
{ |
1798 |
|
return |
1799 |
|
p[0] + |
1800 |
|
p[1]*x + |
1801 |
|
p[2]*x*x + |
1802 |
|
p[3]*x*x*x + |
1803 |
|
p[4]*x*x*x*x + |
1804 |
|
p[5]*x*x*x*x*x; |
1805 |
|
} |
1806 |
|
//------------------------------------------------------------------------ |
1807 |
|
double ToFdEdx::f_att5B( float x ) |
1808 |
|
{ |
1809 |
|
return |
1810 |
|
101.9409 + |
1811 |
|
6.643781*x + |
1812 |
|
0.2765518*x*x + |
1813 |
|
0.004617647*x*x*x + |
1814 |
|
0.0006195132*x*x*x*x + |
1815 |
|
0.00002813734*x*x*x*x*x; |
1816 |
|
} |
1817 |
|
|
1818 |
|
|
1819 |
|
double ToFdEdx::f_pos( TArrayF &p, float x ) |
1820 |
|
{ |
1821 |
|
return |
1822 |
|
p[0] + |
1823 |
|
p[1]*x + |
1824 |
|
p[2]*x*x + |
1825 |
|
p[3]*x*x*x; |
1826 |
|
} |
1827 |
|
|
1828 |
|
double ToFdEdx::f_pos5B( float x ) |
1829 |
|
{ |
1830 |
|
return |
1831 |
|
15.45132 + |
1832 |
|
0.8369721*x + |
1833 |
|
0.0005*x*x; |
1834 |
|
} |
1835 |
|
|
1836 |
|
|
1837 |
|
|
1838 |
|
double ToFdEdx::f_adcPC( float x ) |
1839 |
|
{ |
1840 |
|
return 28.12+0.6312*x-5.647e-05*x*x+3.064e-08*x*x*x; |
1841 |
|
} |
1842 |
|
|
1843 |
|
|
1844 |
|
float ToFdEdx::Get_adc_he( int id, float pl_x[6], float pl_y[6]) |
1845 |
|
{ |
1846 |
|
|
1847 |
// |
// |
1848 |
Int_t pmt_id = 0; |
// input: id - pmt [0:47} |
1849 |
ToFPMT *t_pmt = new ToFPMT(); |
// pl_x - coord x of the tof plane |
1850 |
if(!(this->PMT)) this->PMT = new TClonesArray("ToFPMT",12); //ELENA |
// pl_y - coord y |
1851 |
TClonesArray &tpmt = *this->PMT; |
|
1852 |
ToFTrkVar *t_tof = new ToFTrkVar(); |
adc_he = 0; |
1853 |
if(!(this->ToFTrk)) this->ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA |
if( eGeom.GetXY(id)==1 ) adc_he = f_att( (parAtt[id]), pl_x[eGeom.GetPlane(id)] ); |
1854 |
TClonesArray &t = *this->ToFTrk; |
if( eGeom.GetXY(id)==2 ) adc_he = f_att( (parAtt[id]), pl_y[eGeom.GetPlane(id)] ); |
1855 |
// |
return adc_he; |
1856 |
// |
} |
|
// Here we have calibrated data, ready to be passed to the FORTRAN routine which will extract common and track-related variables. |
|
|
// |
|
|
npmtentry = 0; |
|
|
// |
|
|
ntrkentry = 0; |
|
|
// |
|
|
// Calculate tracks informations from ToF alone |
|
|
// |
|
|
tofl2com(); |
|
|
// |
|
|
memcpy(this->tof_j_flag,tofoutput_.tof_j_flag,6*sizeof(Int_t)); |
|
|
// |
|
|
t_tof->trkseqno = -1; |
|
|
// |
|
|
// and now we must copy from the output structure to the level2 class: |
|
|
// |
|
|
t_tof->npmttdc = 0; |
|
|
// |
|
|
for (Int_t hh=0; hh<12;hh++){ |
|
|
for (Int_t kk=0; kk<4;kk++){ |
|
|
if ( tofoutput_.tofmask[hh][kk] != 0 ){ |
|
|
pmt_id = this->GetPMTid(kk,hh); |
|
|
t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc); |
|
|
t_tof->tdcflag.AddAt(tofoutput_.tdcflagtof[hh][kk],t_tof->npmttdc); // gf: Jan 09/07 |
|
|
t_tof->npmttdc++; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
for (Int_t kk=0; kk<13;kk++){ |
|
|
t_tof->beta[kk] = tofoutput_.betatof_a[kk]; |
|
|
} |
|
|
// |
|
|
t_tof->npmtadc = 0; |
|
|
for (Int_t hh=0; hh<12;hh++){ |
|
|
for (Int_t kk=0; kk<4;kk++){ |
|
|
if ( tofoutput_.adctof_c[hh][kk] < 1000 ){ |
|
|
t_tof->dedx.AddAt(tofoutput_.adctof_c[hh][kk],t_tof->npmtadc); |
|
|
pmt_id = this->GetPMTid(kk,hh); |
|
|
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
|
|
t_tof->adcflag.AddAt(tofoutput_.adcflagtof[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
|
|
t_tof->npmtadc++; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
// |
|
|
memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
|
|
memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
|
|
memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
|
|
memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
|
|
// |
|
|
new(t[ntrkentry]) ToFTrkVar(*t_tof); |
|
|
ntrkentry++; |
|
|
t_tof->Clear(); |
|
|
// |
|
|
// |
|
|
// |
|
|
t_pmt->Clear(); |
|
|
// |
|
|
for (Int_t hh=0; hh<12;hh++){ |
|
|
for (Int_t kk=0; kk<4;kk++){ |
|
|
// new WM |
|
|
if ( tofoutput_.tdc_c[hh][kk] < 4095 || adc[kk][hh] < 4095 || tdc[kk][hh] < 4095 ){ |
|
|
// if ( tdcc[kk][hh] < 4095. || adc[kk][hh] < 4095 || tdc[kk][hh] < 4095 ){ |
|
|
// |
|
|
t_pmt->pmt_id = this->GetPMTid(kk,hh); |
|
|
t_pmt->tdc_tw = tofoutput_.tdc_c[hh][kk]; |
|
|
t_pmt->adc = (Float_t)adc[kk][hh]; |
|
|
t_pmt->tdc = (Float_t)tdc[kk][hh]; |
|
|
// |
|
|
new(tpmt[npmtentry]) ToFPMT(*t_pmt); |
|
|
npmtentry++; |
|
|
t_pmt->Clear(); |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
// |
|
|
// Calculate track-related variables |
|
|
// |
|
|
if ( trk->ntrk() > 0 ){ |
|
|
// |
|
|
// We have at least one track |
|
|
// |
|
|
// |
|
|
// Run over tracks |
|
|
// |
|
|
for(Int_t nt=0; nt < trk->ntrk(); nt++){ |
|
|
// |
|
|
TrkTrack *ptt = trk->GetStoredTrack(nt); |
|
|
// |
|
|
// Copy the alpha vector in the input structure |
|
|
// |
|
|
for (Int_t e = 0; e < 5 ; e++){ |
|
|
tofinput_.al_pp[e] = ptt->al[e]; |
|
|
}; |
|
|
// |
|
|
// Get tracker related variables for this track |
|
|
// |
|
|
toftrk(); |
|
|
// |
|
|
// Copy values in the class from the structure (we need to use a temporary class to store variables). |
|
|
// |
|
|
t_tof->npmttdc = 0; |
|
|
for (Int_t hh=0; hh<12;hh++){ |
|
|
for (Int_t kk=0; kk<4;kk++){ |
|
|
if ( tofoutput_.tofmask[hh][kk] != 0 ){ |
|
|
pmt_id = this->GetPMTid(kk,hh); |
|
|
t_tof->pmttdc.AddAt(pmt_id,t_tof->npmttdc); |
|
|
t_tof->tdcflag.AddAt(tofoutput_.tdcflag[hh][kk],t_tof->npmttdc); // gf: Jan 09/07 |
|
|
t_tof->npmttdc++; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
for (Int_t kk=0; kk<13;kk++){ |
|
|
t_tof->beta[kk] = tofoutput_.beta_a[kk]; |
|
|
}; |
|
|
// |
|
|
t_tof->npmtadc = 0; |
|
|
for (Int_t hh=0; hh<12;hh++){ |
|
|
for (Int_t kk=0; kk<4;kk++){ |
|
|
if ( tofoutput_.adc_c[hh][kk] < 1000 ){ |
|
|
t_tof->dedx.AddAt(tofoutput_.adc_c[hh][kk],t_tof->npmtadc); |
|
|
pmt_id = this->GetPMTid(kk,hh); |
|
|
t_tof->pmtadc.AddAt(pmt_id,t_tof->npmtadc); |
|
|
t_tof->adcflag.AddAt(tofoutput_.adcflag[hh][kk],t_tof->npmtadc); // gf: Jan 09/07 |
|
|
t_tof->npmtadc++; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
// |
|
|
memcpy(t_tof->xtofpos,tofoutput_.xtofpos,sizeof(t_tof->xtofpos)); |
|
|
memcpy(t_tof->ytofpos,tofoutput_.ytofpos,sizeof(t_tof->ytofpos)); |
|
|
memcpy(t_tof->xtr_tof,tofoutput_.xtr_tof,sizeof(t_tof->xtr_tof)); |
|
|
memcpy(t_tof->ytr_tof,tofoutput_.ytr_tof,sizeof(t_tof->ytr_tof)); |
|
|
// |
|
|
// Store the tracker track number in order to be sure to have shyncronized data during analysis |
|
|
// |
|
|
t_tof->trkseqno = nt; |
|
|
// |
|
|
// create a new object for this event with track-related variables |
|
|
// |
|
|
new(t[ntrkentry]) ToFTrkVar(*t_tof); |
|
|
ntrkentry++; |
|
|
t_tof->Clear(); |
|
|
// |
|
|
}; // loop on all the tracks |
|
|
// |
|
|
this->unpackError = unpackError; |
|
|
if ( defcal ){ |
|
|
this->default_calib = 1; |
|
|
} else { |
|
|
this->default_calib = 0; |
|
|
}; |
|
|
}; |
|
1857 |
|
|
1858 |
|
//------------------------------------------------------------------------ |
1859 |
|
double ToFdEdx::f_BB( TArrayF &p, float x ) |
1860 |
|
{ |
1861 |
|
return p[0]/(x*x)*(log(x*x/(1-x*x)) - p[1]*x*x - p[2]); |
1862 |
|
} |
1863 |
|
|
1864 |
|
//------------------------------------------------------------------------ |
1865 |
|
double ToFdEdx::f_BB5B( float x ) |
1866 |
|
{ |
1867 |
|
return 0.165797/(x*x)*(log(x*x/(1-x*x)) + 140.481*x*x + 52.9258); |
1868 |
|
} |
1869 |
|
//------------------------------------------------------------------------ |
1870 |
|
double ToFdEdx::f_desatBB( TArrayF &p, float x ) |
1871 |
|
{ |
1872 |
|
return |
1873 |
|
p[0] + |
1874 |
|
p[1]*x + |
1875 |
|
p[2]*x*x; |
1876 |
|
} |
1877 |
|
|
1878 |
return(0); |
//------------------------------------------------------------------------ |
1879 |
|
double ToFdEdx::f_desatBB5B( float x ) |
1880 |
|
{ |
1881 |
|
return |
1882 |
|
-2.4 + |
1883 |
|
0.75*x + |
1884 |
|
0.009*x*x; |
1885 |
} |
} |
1886 |
|
|
1887 |
|
|
1888 |
|
|
1889 |
|
|
1890 |
|
|
1891 |
|
|
1892 |
|
|
1893 |
|
|
1894 |
|
|
1895 |
|
|
1896 |
|
|
1897 |
|
|
1898 |
|
|
1899 |
|
|
1900 |
|
|
1901 |
|
|