18 |
#include "TLeafI.h" |
#include "TLeafI.h" |
19 |
#include "TH1.h" |
#include "TH1.h" |
20 |
#include "TH2.h" |
#include "TH2.h" |
21 |
|
#include "TF1.h" |
22 |
#include "TMath.h" |
#include "TMath.h" |
23 |
#include "TRandom.h" |
#include "TRandom.h" |
24 |
#include "TSQLServer.h" |
#include "TSQLServer.h" |
41 |
fhBookTree = tree; |
fhBookTree = tree; |
42 |
fFilename = file_raw; |
fFilename = file_raw; |
43 |
fCounter = 0; |
fCounter = 0; |
44 |
|
fCounterPhys = 0; // SO 5/12/'07 |
45 |
fOBT = 0; |
fOBT = 0; |
46 |
|
|
47 |
// |
// |
231 |
|
|
232 |
DigitizeTrackCalib(1); |
DigitizeTrackCalib(1); |
233 |
UInt_t length=fTracklength*2; |
UInt_t length=fTracklength*2; |
234 |
DigitizePSCU(length,0x12); |
DigitizePSCU(length,0x12,fDataPSCU); |
235 |
AddPadding(); |
AddPadding(); |
236 |
WriteTrackCalib(); |
WriteTrackCalib(); |
237 |
|
|
238 |
DigitizeTrackCalib(2); |
DigitizeTrackCalib(2); |
239 |
length=fTracklength*2; |
length=fTracklength*2; |
240 |
DigitizePSCU(length,0x13); |
DigitizePSCU(length,0x13,fDataPSCU); |
241 |
AddPadding(); |
AddPadding(); |
242 |
WriteTrackCalib(); |
WriteTrackCalib(); |
243 |
|
|
244 |
|
DigitizeRunHeader(); |
245 |
|
WriteRunHeader(); |
246 |
|
|
247 |
LoadMipCor(); // some initialization of parameters -not used now- |
LoadMipCor(); // some initialization of parameters -not used now- |
248 |
// end loading, digitizing and writing tracker calibration |
// end loading, digitizing and writing tracker calibration |
249 |
|
|
258 |
nbytes += fhBookTree->GetEntry(i); |
nbytes += fhBookTree->GetEntry(i); |
259 |
// read detectors sequentially: |
// read detectors sequentially: |
260 |
// http://www.ts.infn.it/fileadmin/documents/physics/experiments/wizard/cpu/gen_arch/RM_Acquisition.pdf |
// http://www.ts.infn.it/fileadmin/documents/physics/experiments/wizard/cpu/gen_arch/RM_Acquisition.pdf |
261 |
// on pamelatov: |
// on pamelatov: /cvs/yoda/techmodel/physics/NeutronDetectorReader.cpp |
262 |
// /cvs/yoda/techmodel/physics/NeutronDetectorReader.cpp |
//DigitizeTRIGGER(); |
|
DigitizeTRIGGER(); |
|
263 |
DigitizeTOF(); |
DigitizeTOF(); |
264 |
DigitizeAC(); |
DigitizeAC(); |
265 |
DigitizeCALO(); |
DigitizeCALO(); |
266 |
DigitizeTrack(); |
DigitizeTrack(); |
267 |
DigitizeS4(); |
DigitizeS4(); |
268 |
DigitizeND(); |
DigitizeND(); |
269 |
// |
// |
270 |
// Add padding to 64 bits |
// Add padding to 64 bits |
271 |
// |
// |
272 |
AddPadding(); |
AddPadding(); |
273 |
// |
// |
274 |
// Create CPU header, we need packet type (0x10 = physics data) and packet length. |
// Create CPU header, we need packet type (0x10 = physics data) and packet length. |
275 |
// |
// |
276 |
UInt_t length=2*(fCALOlength+fACbuffer+fTracklength+fNDbuffer+fS4buffer)+fPadding+fTOFbuffer+fTRIGGERbuffer; |
UInt_t length=2*(fCALOlength+fACbuffer+fTracklength+fNDbuffer+fS4buffer)+fPadding+fTOFbuffer+fTRIGGERbuffer; |
277 |
//UInt_t length=2*(fCALOlength+fACbuffer+fTracklength+fNDbuffer)+fPadding+fTOFbuffer+fTRIGGERbuffer; |
//UInt_t length=2*(fCALOlength+fACbuffer+fTracklength+fNDbuffer)+fPadding+fTOFbuffer+fTRIGGERbuffer; |
278 |
DigitizePSCU(length,0x10); |
DigitizePSCU(length,0x10,fDataPSCU); |
279 |
if ( !i%100 ) std::cout << "writing event " << i << endl; |
if ( !i%100 ) std::cout << "writing event " << i << endl; |
280 |
WriteData(); |
WriteData(); |
281 |
}; |
}; |
282 |
|
|
283 |
|
DigitizeRunTrailer(); |
284 |
|
WriteRunTrailer(); |
285 |
|
|
286 |
fOutputfile.close(); |
fOutputfile.close(); |
287 |
std::cout << "files closed" << endl << flush; |
std::cout << "files closed" << endl << flush; |
288 |
|
|
289 |
}; |
}; |
290 |
|
|
291 |
|
void Digitizer::DigitizeRunHeader(){ |
292 |
|
const Int_t lenRH = fRunHeaderbuffer*2; |
293 |
|
UChar_t buffRH[lenRH]; |
294 |
|
UShort_t buffPSCU[8]; |
295 |
|
UChar_t *p; |
296 |
|
p=buffRH; |
297 |
|
|
298 |
|
// header: 16 bytes |
299 |
|
DigitizePSCU(fRunHeaderbuffer*2,0x20,buffPSCU); |
300 |
|
memcpy(p,buffPSCU,16*sizeof(UChar_t)); |
301 |
|
p+=16; |
302 |
|
|
303 |
|
// time stamp (uint32): 0x82569c97 |
304 |
|
*(p++) = 0x82; |
305 |
|
*(p++) = 0x56; |
306 |
|
*(p++) = 0x9C; |
307 |
|
*(p++) = 0x97; |
308 |
|
|
309 |
|
// acq_setting_mode (uint8) |
310 |
|
*(p++) = 2; |
311 |
|
|
312 |
|
// obt (uint32) |
313 |
|
ULong64_t obt = fOBT + 30LL; |
314 |
|
while ( obt > 4294967295LL ) |
315 |
|
obt -= 4294967295LL; |
316 |
|
fOBT = (UInt_t)obt; |
317 |
|
// |
318 |
|
*(p++) = (UChar_t)(fOBT >> 24); |
319 |
|
*(p++) = (UChar_t)(fOBT >> 16); |
320 |
|
*(p++) = (UChar_t)(fOBT >> 8); |
321 |
|
*(p++) = (UChar_t)fOBT; |
322 |
|
|
323 |
|
// last time_sync_info (uint32) (from file 000_001_00110) |
324 |
|
*(p++) = 0x00; |
325 |
|
*(p++) = 0x08; |
326 |
|
*(p++) = 0x68; |
327 |
|
*(p++) = 0xEF; |
328 |
|
|
329 |
|
// fav. working schedule (uint8) |
330 |
|
*(p++) = 0; |
331 |
|
|
332 |
|
// eff. working schedule (uint8) |
333 |
|
*(p++) = 0; |
334 |
|
|
335 |
|
// trigger_mode_A (uint32) |
336 |
|
*(p++) = 0; |
337 |
|
*(p++) = 0; |
338 |
|
*(p++) = 0; |
339 |
|
*(p++) = 0x01; |
340 |
|
|
341 |
|
// trigger_mode_B (uint32) |
342 |
|
*(p++) = 0; |
343 |
|
*(p++) = 0; |
344 |
|
*(p++) = 0; |
345 |
|
*(p++) = 0x03; |
346 |
|
|
347 |
|
// acq_after_calib (0,1) (uint8) |
348 |
|
*(p++) = 0; |
349 |
|
|
350 |
|
// trk_calib_used (uint32) |
351 |
|
*(p++) = 0; |
352 |
|
*(p++) = 0; |
353 |
|
*(p++) = 0; |
354 |
|
*(p++) = 0x68; |
355 |
|
|
356 |
|
// acq_build_info (4 zero bits + 28 1's) (uint32) |
357 |
|
*(p++) = 0x3F; |
358 |
|
*(p++) = 0xFF; |
359 |
|
*(p++) = 0xFF; |
360 |
|
*(p++) = 0xFF; |
361 |
|
|
362 |
|
// acq_var_info (11 bits) (uint16) |
363 |
|
*(p++) = 0x23; |
364 |
|
*(p++) = 0x7F; |
365 |
|
|
366 |
|
// cal_dsp_mask (uint8) |
367 |
|
*(p++) = 0; |
368 |
|
|
369 |
|
// crc (uint16) |
370 |
|
UShort_t crcRH = (UShort_t)CM_Compute_CRC16((UINT16)0, (BYTE*)&buffRH, (UINT32)(fRunHeaderbuffer*2-2)); |
371 |
|
*(p++) = (UChar_t)(crcRH << 8); |
372 |
|
*p = (UChar_t)crcRH; |
373 |
|
|
374 |
|
memcpy(fDataRunHeader,buffRH,fRunHeaderbuffer*sizeof(UShort_t)); |
375 |
|
}; |
376 |
|
|
377 |
|
void Digitizer::DigitizeRunTrailer(){ |
378 |
|
UChar_t buffRT[fRunTrailerbuffer*2]; |
379 |
|
UShort_t buffPSCU[8]; |
380 |
|
UChar_t *p; |
381 |
|
p=buffRT; |
382 |
|
|
383 |
|
// header: 16 bytes |
384 |
|
DigitizePSCU(fRunHeaderbuffer*2,0x21,buffPSCU); |
385 |
|
memcpy(p,buffPSCU,16*sizeof(UChar_t)); |
386 |
|
p+=16; |
387 |
|
|
388 |
|
// pkt_counter (uint32) |
389 |
|
fCounterPhys++; |
390 |
|
fCounter++; |
391 |
|
while ( fCounterPhys > 16777215 ) |
392 |
|
fCounterPhys -= 16777215; |
393 |
|
// |
394 |
|
*(p++) = (UChar_t)(fCounterPhys >> 24); |
395 |
|
*(p++) = (UChar_t)(fCounterPhys >> 16); |
396 |
|
*(p++) = (UChar_t)(fCounterPhys >> 8); |
397 |
|
*(p++) = (UChar_t)fCounterPhys; |
398 |
|
|
399 |
|
// pkt_readyCounter: valid packets in the run (uint32) |
400 |
|
*(p++) = 0; |
401 |
|
*(p++) = 0; |
402 |
|
*(p++) = 0; |
403 |
|
*(p++) = 0; |
404 |
|
|
405 |
|
// obt (uint32) |
406 |
|
ULong64_t obt = fOBT + 30LL; |
407 |
|
while ( obt > 4294967295LL ) |
408 |
|
obt -= 4294967295LL; |
409 |
|
fOBT = (UInt_t)obt; |
410 |
|
// |
411 |
|
*(p++) = (UChar_t)(fOBT >> 24); |
412 |
|
*(p++) = (UChar_t)(fOBT >> 16); |
413 |
|
*(p++) = (UChar_t)(fOBT >> 8); |
414 |
|
*(p++) = (UChar_t)fOBT; |
415 |
|
|
416 |
|
// last time_sync_info (uint32) |
417 |
|
*(p++) = 0; |
418 |
|
*(p++) = 0; |
419 |
|
*(p++) = 0; |
420 |
|
*(p++) = 0; |
421 |
|
|
422 |
|
// crc (uint16) |
423 |
|
UShort_t crcRT = (UShort_t)CM_Compute_CRC16((UINT16)0, (BYTE*)(buffRT), (UINT32)(fRunTrailerbuffer*2-2)); |
424 |
|
*(p++) = (UChar_t)(crcRT << 8); |
425 |
|
*p = (UChar_t)crcRT; |
426 |
|
|
427 |
|
memcpy(fDataRunTrailer,buffRT,fRunTrailerbuffer*sizeof(UShort_t)); |
428 |
|
}; |
429 |
|
|
430 |
void Digitizer::AddPadding(){ |
void Digitizer::AddPadding(){ |
431 |
// |
// |
432 |
Float_t pd0 = (fLen+16)/64.; |
Float_t pd0 = (fLen+16)/64.; |
449 |
}; |
}; |
450 |
|
|
451 |
|
|
452 |
void Digitizer::DigitizePSCU(UInt_t length, UChar_t type) { |
void Digitizer::DigitizePSCU(UInt_t length, UChar_t type, UShort_t *pPSCU) { |
453 |
// |
// |
454 |
UChar_t buff[16]; |
UChar_t buff[16]; |
455 |
// |
// |
501 |
// |
// |
502 |
buff[15] = (BYTE)CM_Compute_CRC16((UINT16)0, (BYTE*)&buff, (UINT32)15); |
buff[15] = (BYTE)CM_Compute_CRC16((UINT16)0, (BYTE*)&buff, (UINT32)15); |
503 |
// |
// |
504 |
memcpy(fDataPSCU,buff,16*sizeof(UChar_t)); |
//memcpy(fDataPSCU,buff,16*sizeof(UChar_t)); |
505 |
|
memcpy(pPSCU,buff,16*sizeof(UChar_t)); |
506 |
// |
// |
507 |
}; |
}; |
508 |
|
|
752 |
fCALOlength++; |
fCALOlength++; |
753 |
// |
// |
754 |
UInt_t length=fCALOlength*2; |
UInt_t length=fCALOlength*2; |
755 |
DigitizePSCU(length,0x18); |
DigitizePSCU(length,0x18,fDataPSCU); |
756 |
// |
// |
757 |
// Add padding to 64 bits |
// Add padding to 64 bits |
758 |
// |
// |
1175 |
// |
// |
1176 |
}; |
}; |
1177 |
|
|
1178 |
void Digitizer::DigitizeTRIGGER() { |
//void Digitizer::DigitizeTRIGGER() { |
1179 |
//fDataTrigger: 153 bytes |
//fDataTrigger: 152 bytes |
1180 |
for (Int_t j=0; j < 153; j++) |
// corrected 30/11/'07 SO (was 153) |
1181 |
fDataTrigger[j]=0x00; |
//for (Int_t j=0; j < 152; j++) |
1182 |
}; |
// fDataTrigger[j]=0x00; |
1183 |
|
//}; |
1184 |
|
|
1185 |
Int_t Digitizer::DigitizeTOF() { |
Int_t Digitizer::DigitizeTOF() { |
1186 |
//fDataTof: 12 x 23 bytes (=276 bytes) |
//fDataTof: 12 x 23 bytes (=276 bytes) |
1222 |
Float_t pmGain = 3.5e6; /* PMT Gain: the same for all PMTs */ |
Float_t pmGain = 3.5e6; /* PMT Gain: the same for all PMTs */ |
1223 |
Float_t effi=0.21; /* Efficienza di fotocatodo */ |
Float_t effi=0.21; /* Efficienza di fotocatodo */ |
1224 |
|
|
1225 |
Float_t ADC_pC0=-58.1; // ADC/pC conversion coefficient 0 |
// Float_t ADC_pC0=-58.1; // ADC/pC conversion coefficient 0 |
1226 |
Float_t ADC_pC1=1.728; // ADC/pC conversion coefficient 1 |
// Float_t ADC_pC1=1.728; // ADC/pC conversion coefficient 1 |
1227 |
Float_t ADC_pC2=-4.063e-05; // ADC/pC conversion coefficient 2 |
// Float_t ADC_pC2=-4.063e-05; // ADC/pC conversion coefficient 2 |
1228 |
Float_t ADC_pC3=-5.763e-08; // ADC/pC conversion coefficient 3 |
// Float_t ADC_pC3=-5.763e-08; // ADC/pC conversion coefficient 3 |
1229 |
|
|
1230 |
|
// pC < 800 |
1231 |
|
Float_t ADC_pC0A = -4.437616e+01 ; |
1232 |
|
Float_t ADC_pC1A = 1.573329e+00 ; |
1233 |
|
Float_t ADC_pC2A = 2.780518e-04 ; |
1234 |
|
Float_t ADC_pC3A = -2.302160e-07 ; |
1235 |
|
|
1236 |
|
// pC > 800: |
1237 |
|
Float_t ADC_pC0B = -2.245756e+02 ; |
1238 |
|
Float_t ADC_pC1B = 2.184156e+00 ; |
1239 |
|
Float_t ADC_pC2B = -4.171825e-04 ; |
1240 |
|
Float_t ADC_pC3B = 3.789715e-08 ; |
1241 |
|
|
1242 |
Float_t pCthres=40.; // threshold in charge |
Float_t pCthres=40.; // threshold in charge |
1243 |
Int_t ADClast=4095; // no signal --> ADC ch=4095 |
Int_t ADClast=4095; // no signal --> ADC ch=4095 |
1245 |
Int_t ADCtof[48]; |
Int_t ADCtof[48]; |
1246 |
|
|
1247 |
|
|
1248 |
// ---- introduce scale factors to tune simul ADC to real data 24-oct DC |
// ---- introduce scale factors to tune simul ADC to real data 24-oct DC |
1249 |
Float_t ScaleFact[48]={0.18,0.22,0.35,0.26,0.47,0.35,0.31,0.37, |
// Float_t ScaleFact[48]={0.18,0.22,0.35,0.26,0.47,0.35,0.31,0.37, |
1250 |
0.44,0.23,0.38,0.60,0.39,0.29,0.40,0.23, |
// 0.44,0.23,0.38,0.60,0.39,0.29,0.40,0.23, |
1251 |
0.30,0.66,0.22,1.53,0.17,0.55, |
// 0.30,0.66,0.22,1.53,0.17,0.55, |
1252 |
0.84,0.19,0.21,1.64,0.62,0.13, |
// 0.84,0.19,0.21,1.64,0.62,0.13, |
1253 |
0.18,0.15,0.10,0.14,0.14,0.14,0.14,0.12, |
// 0.18,0.15,0.10,0.14,0.14,0.14,0.14,0.12, |
1254 |
0.26,0.18,0.25,0.23,0.20,0.40, |
// 0.26,0.18,0.25,0.23,0.20,0.40,0.19,0.23,0.25,0.23,0.25,0.20}; |
1255 |
0.19,0.23,0.25,0.23,0.25,0.20}; |
|
1256 |
|
// new scale factors: WM 30-Oct-07 |
1257 |
|
// Float_t ScaleFact[48]={0.35,0.41,0.32,0.34,0.58,0.47,0.42,0.44, |
1258 |
|
// 0.50,0.34,0.50,0.50,0.51,0.42,0.46,0.25, |
1259 |
|
// 0.20,0.38,0.29,0.49,0.24,0.68, |
1260 |
|
// 0.30,0.26,0.28,0.79,0.31,0.12, |
1261 |
|
// 0.25,0.21,0.14,0.20, |
1262 |
|
// 0.16,0.17,0.19,0.18, |
1263 |
|
// 0.34,0.27,0.34,0.31,0.25,0.57, |
1264 |
|
// 0.24,0.34,0.34,0.32,0.31,0.30}; |
1265 |
|
|
1266 |
|
Float_t ScaleFact[48]={0.39, 0.49, 0.38, 0.40, 0.65, 0.51, 0.43, |
1267 |
|
0.49, 0.58, 0.38, 0.53, 0.57, 0.53, 0.45, 0.49, 0.16, |
1268 |
|
0.15, 0.44, 0.28, 0.57, 0.26, 0.72, 0.37, 0.29, 0.30, 0.89, |
1269 |
|
0.37, 0.08, 0.27, 0.23, 0.12, 0.22, 0.15, 0.16, 0.21, |
1270 |
|
0.19, 0.41, 0.32, 0.39, 0.38, 0.28, 0.66, 0.28, 0.40, 0.39, 0.40, 0.37, 0.35 }; |
1271 |
|
|
1272 |
for(Int_t i=0; i<48; i++){ |
for(Int_t i=0; i<48; i++){ |
1273 |
QevePmt_pC[i] = 0; |
QevePmt_pC[i] = 0; |
1274 |
ADCtof[i]=0; |
ADCtof[i]=0; |
1315 |
Float_t thresh=10.; // to be defined better... (Wolfgang) |
Float_t thresh=10.; // to be defined better... (Wolfgang) |
1316 |
|
|
1317 |
// === TDC: simulate timing for each paddle |
// === TDC: simulate timing for each paddle |
1318 |
Float_t dt1 = 285.e-12 ; // single PMT resolution |
//Float_t dt1 = 285.e-12 ; // single PMT resolution |
1319 |
// Float_t dt1 = 10.e-12 ; // TEST |
Float_t dt1 = 425.e-12 ; // single PMT resolution (WM, Nov'07) |
1320 |
Float_t tdcres[50],c1_S[50],c2_S[50],c3_S[50]; |
Float_t tdcres[50],c1_S[50],c2_S[50],c3_S[50]; |
1321 |
for(Int_t j=0;j<48;j++) tdcres[j] = 50.E-12; // TDC resolution 50 picosec |
for(Int_t j=0;j<48;j++) tdcres[j] = 50.E-12; // TDC resolution 50 picosec |
1322 |
for(Int_t j=0;j<48;j++) c1_S[j] = 500.; // cable length in channels |
for(Int_t j=0;j<48;j++) c1_S[j] = 500.; // cable length in channels |
1344 |
ipad = Ipaddle[nh]-1; |
ipad = Ipaddle[nh]-1; |
1345 |
pmtleft=0; |
pmtleft=0; |
1346 |
pmtright=0; |
pmtright=0; |
1347 |
|
|
1348 |
|
// WM: S12 paddles are "reversed" (Nov'07) |
1349 |
|
if (ip==2) |
1350 |
|
if (ipad==0) |
1351 |
|
ipad=1; |
1352 |
|
else |
1353 |
|
ipad=0; |
1354 |
|
|
1355 |
if (ip<6) { |
if (ip<6) { |
1356 |
Paddle2Pmt(ip, ipad, &pmtleft, &pmtright); |
Paddle2Pmt(ip, ipad, &pmtleft, &pmtright); |
1357 |
|
|
1363 |
if(ip==0 || ip==3 || ip==4) |
if(ip==0 || ip==3 || ip==4) |
1364 |
tpos = (Yintof[nh]+Youttof[nh])/2.; |
tpos = (Yintof[nh]+Youttof[nh])/2.; |
1365 |
else |
else |
1366 |
if(ip==1 || ip==2 || ip==5) //--- Strip in X per S12,S21,S32 |
if(ip==1 || ip==2 || ip==5) //--- Strip in X for S12,S21,S32 |
1367 |
tpos = (Xintof[nh]+Xouttof[nh])/2.; |
tpos = (Xintof[nh]+Xouttof[nh])/2.; |
1368 |
else //if (ip!=6) |
else //if (ip!=6) |
1369 |
printf("*** WARNING TOF: this option should never occur! (ip=%2i, nh=%2i)\n",ip,nh); |
printf("*** WARNING TOF: this option should never occur! (ip=%2i, nh=%2i)\n",ip,nh); |
1378 |
cout <<"pmtleft, pmtright "<<pmtleft<<" "<<pmtright<<endl; |
cout <<"pmtleft, pmtright "<<pmtleft<<" "<<pmtright<<endl; |
1379 |
} |
} |
1380 |
|
|
1381 |
// constant geometric factor, for the moment |
// constant geometric factor, the rest is handled by the scaling factor |
1382 |
FGeo[0] =0.5; |
FGeo[0] =0.5; |
1383 |
FGeo[1] =0.5; |
FGeo[1] =0.5; |
1384 |
// FGeo[1] = atan(path[1]/dimes[ip])/6.28318; // fraction of photons toward SX |
// FGeo[1] = atan(path[1]/dimes[ip])/6.28318; // fraction of photons toward left |
1385 |
// FGeo[2] = atan(path[2]/dimes[ip])/6.28318; // toward DX |
// FGeo[2] = atan(path[2]/dimes[ip])/6.28318; // toward right |
1386 |
|
|
1387 |
|
|
1388 |
// Npho = Poisson(ERELTOF[nh])*Pho_keV*1e6 Poissonian fluctuations to be inserted-DC |
// Npho = Poisson(ERELTOF[nh])*Pho_keV*1e6 Poissonian fluctuations to be inserted-DC |
1391 |
Float_t knorm[2]={0., 0.}; // Donatella |
Float_t knorm[2]={0., 0.}; // Donatella |
1392 |
Float_t Atten[2]={0., 0.}; // Donatella |
Float_t Atten[2]={0., 0.}; // Donatella |
1393 |
for(Int_t j=0; j<2; j++){ |
for(Int_t j=0; j<2; j++){ |
1394 |
QhitPad_pC[j]= Npho*FGeo[j]*effi*pmGain*echarge*1.E12; // corrected WM |
QhitPad_pC[j]= Npho*FGeo[j]*effi*pmGain*echarge*1.E12*ScaleFact[pmtleft+j]; |
1395 |
// WM |
// WM |
1396 |
knorm[j]=atte1[pmtleft+j]*exp(lambda1[pmtleft+j]*dimel[ip]/2.*pow(-1,j+1)) + |
knorm[j]=atte1[pmtleft+j]*exp(lambda1[pmtleft+j]*dimel[ip]/2.*pow(-1,j+1)) + |
1397 |
atte2[pmtleft+j]*exp(lambda2[pmtleft+j]*dimel[ip]/2.*pow(-1,j+1)); |
atte2[pmtleft+j]*exp(lambda2[pmtleft+j]*dimel[ip]/2.*pow(-1,j+1)); |
1415 |
QevePmt_pC[pmtright] += QhitPmt_pC[1]; |
QevePmt_pC[pmtright] += QhitPmt_pC[1]; |
1416 |
|
|
1417 |
// TDC |
// TDC |
1418 |
// WM right and left <-> |
// WM right and left <-> |
1419 |
// t2 = t2 + fabs(path[0]/veff) + s_l_g[ip]/veff1 ; // Signal reaches PMT |
// t2 = t2 + fabs(path[0]/veff) + s_l_g[ip]/veff1 ; // Signal reaches PMT |
1420 |
// t1 = t1 + fabs(path[1]/veff) + s_l_g[ip]/veff1; |
// t1 = t1 + fabs(path[1]/veff) + s_l_g[ip]/veff1; |
1421 |
|
|
1422 |
t1 = t1 + fabs(path[0]/veff) + s_l_g[ip]/veff1; |
t1 = t1 + fabs(path[0]/veff) + s_l_g[ip]/veff1; |
1423 |
t2 = t2 + fabs(path[1]/veff) + s_l_g[ip]/veff1 ; // Signal reaches PMT |
t2 = t2 + fabs(path[1]/veff) + s_l_g[ip]/veff1 ; // Signal reaches PMT |
1424 |
|
|
1425 |
Float_t t1save = t1; |
t1 = gRandom->Gaus(t1,dt1); //apply gaussian error dt |
1426 |
Float_t t2save = t2; |
t2 = gRandom->Gaus(t2,dt1); //apply gaussian error dt |
|
|
|
|
/* |
|
|
TRandom r; |
|
|
// This does not work... WM - but works in my simulation code ?? |
|
|
// t1 = r.Gaus(t1,dt1); //apply gaussian error dt |
|
|
// t2 = r.Gaus(t2,dt1); //apply gaussian error dt |
|
|
*/ |
|
|
t1 = gRandom->Gaus(t1,dt1); //apply gaussian error dt |
|
|
t2 = gRandom->Gaus(t2,dt1); //apply gaussian error dt |
|
|
|
|
|
// cout<<1E12*(t1save-t1)<<" "<<1E12*(t2save-t2)<<endl; |
|
1427 |
|
|
1428 |
t1 = t1 + c1_S[pmtleft] ; // Signal reaches Discriminator ,TDC starts to run |
t1 = t1 + c1_S[pmtleft] ; // Signal reaches Discriminator ,TDC starts to run |
1429 |
t2 = t2 + c1_S[pmtright] ; |
t2 = t2 + c1_S[pmtright] ; |
1466 |
|
|
1467 |
// ====== ADC ====== |
// ====== ADC ====== |
1468 |
|
|
|
|
|
1469 |
for(Int_t i=0; i<48; i++){ |
for(Int_t i=0; i<48; i++){ |
1470 |
if(QevePmt_pC[i] >= pCthres){ |
if (QevePmt_pC[i] < 800.) ADCtof[i]= (Int_t)(ADC_pC0A + ADC_pC1A*QevePmt_pC[i] + ADC_pC2A*pow(QevePmt_pC[i],2) + ADC_pC3A*pow(QevePmt_pC[i],3)); |
1471 |
ADCtof[i]= (Int_t)(ADC_pC0 + ADC_pC1*QevePmt_pC[i] + ADC_pC2*pow(QevePmt_pC[i],2) + ADC_pC3*pow(QevePmt_pC[i],3)); |
if (QevePmt_pC[i] > 800.) ADCtof[i]= (Int_t)(ADC_pC0B + ADC_pC1B*QevePmt_pC[i] + ADC_pC2B*pow(QevePmt_pC[i],2) + ADC_pC3B*pow(QevePmt_pC[i],3)); |
1472 |
} else |
if (QevePmt_pC[i] > 2485.) ADCtof[i]= (Int_t)(1758. + 0.54*QevePmt_pC[i]); //assuming a fictional 0.54 ch/pC above ADCsat |
1473 |
ADCtof[i]= ADClast; |
if (ADCtof[i]>ADCsat) ADCtof[i]=ADCsat; |
1474 |
} |
if (QevePmt_pC[i] < pCthres) ADCtof[i]= ADClast; |
1475 |
|
if (ADCtof[i] < 0) ADCtof[i]=ADClast; |
1476 |
// ---- introduce scale factors to tune simul ADC to real data 24-oct DC |
if (ADCtof[i] > ADClast) ADCtof[i]=ADClast; |
|
|
|
|
for(Int_t i=0; i<48; i++){ |
|
|
if(ADCtof[i] != ADClast){ |
|
|
// printf("%3d, %4d, %4.2f\n",i, ADCtof[i],ScaleFact[i]); |
|
|
ADCtof[i]= Int_t (ADCtof[i]*ScaleFact[i]); |
|
|
// printf("%3d, %4d,\n",i, ADCtof[i]); |
|
|
} |
|
1477 |
} |
} |
1478 |
|
|
1479 |
for(Int_t i=0; i<48; i++){ |
// for(Int_t i=0; i<48; i++){ |
1480 |
if(ADCtof[i] != ADClast){ |
// if(QevePmt_pC[i] >= pCthres){ |
1481 |
if(ADCtof[i]> ADCsat) ADCtof[i]=ADCsat; |
// ADCtof[i]= (Int_t)(ADC_pC0 + ADC_pC1*QevePmt_pC[i] + ADC_pC2*pow(QevePmt_pC[i],2) + ADC_pC3*pow(QevePmt_pC[i],3)); |
1482 |
else if(ADCtof[i]< 0) ADCtof[i]=ADClast; |
// } else |
1483 |
} |
// ADCtof[i]= ADClast; |
1484 |
} |
// } |
1485 |
// ====== build TDC coincidence ====== |
|
1486 |
|
// // ---- introduce scale factors to tune simul ADC to real data 24-oct DC |
1487 |
|
|
1488 |
|
// for(Int_t i=0; i<48; i++){ |
1489 |
|
// if(ADCtof[i] != ADClast){ |
1490 |
|
// // printf("%3d, %4d, %4.2f\n",i, ADCtof[i],ScaleFact[i]); |
1491 |
|
// ADCtof[i]= Int_t (ADCtof[i]*ScaleFact[i]); |
1492 |
|
// // printf("%3d, %4d,\n",i, ADCtof[i]); |
1493 |
|
// } |
1494 |
|
// } |
1495 |
|
|
1496 |
|
// for(Int_t i=0; i<48; i++){ |
1497 |
|
// if(ADCtof[i] != ADClast){ |
1498 |
|
// if(ADCtof[i]> ADCsat) ADCtof[i]=ADCsat; |
1499 |
|
// else if(ADCtof[i]< 0) ADCtof[i]=ADClast; |
1500 |
|
// } |
1501 |
|
// } |
1502 |
|
|
1503 |
|
|
1504 |
|
// ====== build TDC coincidence ====== |
1505 |
|
|
1506 |
Float_t t_coinc = 0; |
Float_t t_coinc = 0; |
1507 |
Int_t ilast = 100; |
Int_t ilast = 100; |
1519 |
if (tdc[ii] != 0) tdc1[ii] = t_coinc - tdcpmt[ii]; // test 2 |
if (tdc[ii] != 0) tdc1[ii] = t_coinc - tdcpmt[ii]; // test 2 |
1520 |
tdc1[ii] = tdc1[ii]/tdcres[ii]; // divide by TDC resolution |
tdc1[ii] = tdc1[ii]/tdcres[ii]; // divide by TDC resolution |
1521 |
if (tdc[ii] != 0) tdc1[ii] = tdc1[ii] + c3_S[ii]; // add cable length c3 |
if (tdc[ii] != 0) tdc1[ii] = tdc1[ii] + c3_S[ii]; // add cable length c3 |
|
|
|
1522 |
} // missing parenthesis inserted! (Silvio) |
} // missing parenthesis inserted! (Silvio) |
1523 |
|
|
1524 |
for(Int_t i=0; i<48; i++){ |
for(Int_t i=0; i<48; i++){ |
1537 |
cout<<"-----------"<<endl; |
cout<<"-----------"<<endl; |
1538 |
|
|
1539 |
|
|
1540 |
//------ use channelmap 18-oct WM |
//------ use channelmap for ToF: 18-oct WM |
1541 |
|
|
1542 |
Int_t channelmap[] = {3,21,11,29,19,45,27,37,36,28,44,20,5,12,13,4, |
Int_t channelmap[] = {3,21,11,29,19,45,27,37,36,28,44,20,5,12,13,4, |
1543 |
6,47,14,39,22,31,30,23,38,15,46,7,0,33,16,24, |
6,47,14,39,22,31,30,23,38,15,46,7,0,33,16,24, |
1544 |
8,41,32,40,25,17,34,9,42,1,2,10,18,26,35,43}; |
8,41,32,40,25,17,34,9,42,1,2,10,18,26,35,43}; |
1545 |
|
|
1546 |
Int_t ADChelp[48]; |
Int_t ADChelp[48]; |
1547 |
Int_t TDChelp[48]; |
Int_t TDChelp[48]; |
1548 |
|
|
1549 |
for(Int_t i=0; i<48; i++){ |
for(Int_t i=0; i<48; i++){ |
1550 |
Int_t ii=channelmap[i]; |
Int_t ii=channelmap[i]; |
1551 |
ADChelp[ii]= ADCtof[i]; |
ADChelp[ii]= ADCtof[i]; |
1552 |
TDChelp[ii]= TDCint[i]; |
TDChelp[ii]= TDCint[i]; |
1553 |
} |
} |
|
|
|
|
for(Int_t i=0; i<48; i++){ |
|
|
ADCtof[i]= ADChelp[i]; |
|
|
TDCint[i]= TDChelp[i]; |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
|
//--- fake data ------------------------ |
|
|
for(Int_t i=0; i<48; i++){ |
|
|
ADCtof[i]= 100 + 10*i; |
|
|
TDCint[i]= 800 + 10*i; |
|
|
// cout<<i<<" "<<ADCtof[i]<<" "<<TDCint[i]<<endl; |
|
|
} |
|
|
*/ |
|
1554 |
|
|
|
/* |
|
1555 |
for(Int_t i=0; i<48; i++){ |
for(Int_t i=0; i<48; i++){ |
1556 |
if (((ADCtof[i]>0)&&(ADCtof[i]<4095)) || ((TDCint[i]>0)&&(TDCint[i]<4095))) cout<<i<<" "<<ADCtof[i]<<" "<<TDCint[i]<<endl; |
ADCtof[i]= ADChelp[i]; |
1557 |
} |
TDCint[i]= TDChelp[i]; |
1558 |
*/ |
} |
1559 |
|
|
1560 |
|
|
1561 |
// ====== write fDataTof ======= |
// ====== write fDataTof ======= |
1562 |
|
|
1563 |
|
|
1564 |
// UChar_t tdcadd[8]={1,0,3,2,5,4,7,6}; (coded in 3 bit) |
// UChar_t tdcadd[8]={1,0,3,2,5,4,7,6}; (coded in 3 bit) |
1565 |
UChar_t Ctrl3bit[8]={32,0,96,64,160,128,224,192}; // DC (msb in 8 bit word ) |
UChar_t Ctrl3bit[8]={32,0,96,64,160,128,224,192}; // DC (msb in 8 bit word ) |
1566 |
|
|
1567 |
UChar_t tofBin; |
UChar_t tofBin; |
1593 |
fDataTof[j12+22]= EvaluateCrcTof(pTof); // CRC |
fDataTof[j12+22]= EvaluateCrcTof(pTof); // CRC |
1594 |
pTof+=23; |
pTof+=23; |
1595 |
}; |
}; |
1596 |
|
|
1597 |
|
// ====== evaluate trigger variables ======= |
1598 |
|
|
1599 |
|
//fDataTrigger: 152 bytes (corrected 30/11/'07 SO - it was 153) |
1600 |
|
|
1601 |
|
// initialization: |
1602 |
|
for (Int_t j=0; j < 152; j++) |
1603 |
|
fDataTrigger[j]=0x00; |
1604 |
|
UChar_t *pTrg=fDataTrigger; |
1605 |
|
|
1606 |
|
// Only the variables with a (*) are modified; the others are set to 0 |
1607 |
|
// info given in #bites data + #bites crc |
1608 |
|
// TB_READ_PMT_PLANE : 6 + 1 |
1609 |
|
// TB_READ_EVENT_COUNT : 3 + 1 (*) |
1610 |
|
// TB_READ_TRIGGER_RATE : 12 + 1 |
1611 |
|
// TB_READ_D_L_TIME : 4 + 1 |
1612 |
|
// TB_READ_S4_CAL_COUNT : 4 + 1 |
1613 |
|
// TB_READ_PMT_COUNT1 : 48 + 1 |
1614 |
|
// TB_READ_PMT_COUNT2 : 48 + 1 |
1615 |
|
// TB_READ_PATTERN_BUSY : 8 + 1 |
1616 |
|
// TB_READ_PATTERN_TRIGGER: 7 + 1 (*) |
1617 |
|
// TB_READ_TRIGGER_CONF : 2 + 1 (*) |
1618 |
|
|
1619 |
|
// TB_READ_EVENT_COUNT |
1620 |
|
fhBookTree->SetBranchStatus("Ievnt",&Ievnt); |
1621 |
|
UInt_t cTrg = (UInt_t)Ievnt; //counter |
1622 |
|
UInt_t cTrg2 = 0; //counter with bits inverted, according to document |
1623 |
|
//"formato dati provenienti dalla trigger board" |
1624 |
|
for (Int_t i=0; i < 24; i++){ // Use the first 24 bits |
1625 |
|
if (cTrg & (0x1 << i) ) |
1626 |
|
cTrg2 = cTrg2 | (0x1 << (24-i)); |
1627 |
|
}; |
1628 |
|
fDataTrigger[7] = (UChar_t)(cTrg2 >> 16); // 8 MSbits (out of 24) |
1629 |
|
fDataTrigger[8] = (UChar_t)(cTrg2 >> 8); // 8 "middle" bits |
1630 |
|
fDataTrigger[9] = (UChar_t)(cTrg2); // 8 LSbits |
1631 |
|
pTrg=fDataTrigger+7; |
1632 |
|
fDataTrigger[10]=EvaluateCrcTrigger(pTrg, 3); |
1633 |
|
|
1634 |
|
// TB_READ_PATTERN_TRIGGER: bytes 141-148: |
1635 |
|
// PatternTrigMap[i] corresponds to bit i in TB_READ_PATTERN_TRIGGER: |
1636 |
|
// mapping according to documents: |
1637 |
|
// 1. "formato dati provenienti dalla trigger board" |
1638 |
|
// 2. "The ToF quicklook software", Appendix A (Campana, Nagni) |
1639 |
|
Int_t PatternTrigMap[]={29,42,43,1,16,7,17,28,33,41,46,2,15,8,18,27, |
1640 |
|
30,40,44,3,14,9,19,26,32,37,47,4,13,10,20,25, |
1641 |
|
34,31,38,45,5,12,21,24,36,35,39,48,6,11,22,23}; |
1642 |
|
|
1643 |
|
for (Int_t i=0; i < 48; i++) |
1644 |
|
//if (ADCtof[i]>thrTrg) |
1645 |
|
if (tdc1[channelmap[i]]!=0) |
1646 |
|
fDataTrigger[147-(Int_t)((PatternTrigMap[i]+1)/8)]=fDataTrigger[147-(Int_t)((PatternTrigMap[i]+1)/8)] | (0x1 << (PatternTrigMap[i]%8)); |
1647 |
|
pTrg=fDataTrigger+141; |
1648 |
|
fDataTrigger[148]=EvaluateCrcTrigger(pTrg, 7); |
1649 |
|
|
1650 |
|
// TB_READ_TRIGGER_CONF : set always acq.mode TOF4 |
1651 |
|
// |
1652 |
|
// TOF1: S1-S2-S3 (&,|) |
1653 |
|
// TOF4: S2-S3 (&,&) |
1654 |
|
fDataTrigger[149]=0x02; |
1655 |
|
fDataTrigger[150]=0x0; |
1656 |
|
pTrg=fDataTrigger+149; |
1657 |
|
fDataTrigger[151]=EvaluateCrcTrigger(pTrg, 2); |
1658 |
|
|
1659 |
return(0); |
return(0); |
1660 |
}; |
}; |
1661 |
|
|
1709 |
return(crcTof); |
return(crcTof); |
1710 |
} |
} |
1711 |
|
|
1712 |
|
UChar_t Digitizer::EvaluateCrcTrigger(UChar_t *pTrg, Int_t nb) { |
1713 |
|
Bool_t DEBUG=false; |
1714 |
|
if (DEBUG) |
1715 |
|
return(0x00); |
1716 |
|
|
1717 |
|
UChar_t crcTrg=0x00; |
1718 |
|
UChar_t *pc=&crcTrg, *pc2; |
1719 |
|
pc2=pTrg; |
1720 |
|
for (Int_t jp=0; jp < nb; jp++) |
1721 |
|
Crc8Tof(pc2++,pc); |
1722 |
|
return(crcTrg); |
1723 |
|
} |
1724 |
|
|
1725 |
void Digitizer::Crc8Tof(UChar_t *oldCRC, UChar_t *crcTof){ |
void Digitizer::Crc8Tof(UChar_t *oldCRC, UChar_t *crcTof){ |
1726 |
union crctof_data { |
union crctof_data { |
1727 |
UChar_t word; |
UChar_t word; |
1793 |
// created: J. Conrad, KTH |
// created: J. Conrad, KTH |
1794 |
// modified: S. Orsi, INFN Roma2 |
// modified: S. Orsi, INFN Roma2 |
1795 |
// fDataAC[0-63]: main AC board |
// fDataAC[0-63]: main AC board |
1796 |
// fDataAC[64-127]: extra AC board |
// fDataAC[64-127]: extra AC board (identical to main board, for now) |
1797 |
|
|
1798 |
|
// We activate all branches. Once the digitization algorithm is determined |
1799 |
|
// only the branches that involve needed information will be activated |
1800 |
|
|
1801 |
|
fhBookTree->SetBranchStatus("Ievnt",&Ievnt); |
1802 |
|
fhBookTree->SetBranchStatus("Nthcat",1); |
1803 |
|
fhBookTree->SetBranchStatus("Iparcat",1); |
1804 |
|
fhBookTree->SetBranchStatus("Icat",1); |
1805 |
|
fhBookTree->SetBranchStatus("Xincat",1); |
1806 |
|
fhBookTree->SetBranchStatus("Yincat",1); |
1807 |
|
fhBookTree->SetBranchStatus("Zincat",1); |
1808 |
|
fhBookTree->SetBranchStatus("Xoutcat",1); |
1809 |
|
fhBookTree->SetBranchStatus("Youtcat",1); |
1810 |
|
fhBookTree->SetBranchStatus("Zoutcat",1); |
1811 |
|
fhBookTree->SetBranchStatus("Erelcat",1); |
1812 |
|
fhBookTree->SetBranchStatus("Timecat",1); |
1813 |
|
fhBookTree->SetBranchStatus("Pathcat",1); |
1814 |
|
fhBookTree->SetBranchStatus("P0cat",1); |
1815 |
|
fhBookTree->SetBranchStatus("Nthcas",1); |
1816 |
|
fhBookTree->SetBranchStatus("Iparcas",1); |
1817 |
|
fhBookTree->SetBranchStatus("Icas",1); |
1818 |
|
fhBookTree->SetBranchStatus("Xincas",1); |
1819 |
|
fhBookTree->SetBranchStatus("Yincas",1); |
1820 |
|
fhBookTree->SetBranchStatus("Zincas",1); |
1821 |
|
fhBookTree->SetBranchStatus("Xoutcas",1); |
1822 |
|
fhBookTree->SetBranchStatus("Youtcas",1); |
1823 |
|
fhBookTree->SetBranchStatus("Zoutcas",1); |
1824 |
|
fhBookTree->SetBranchStatus("Erelcas",1); |
1825 |
|
fhBookTree->SetBranchStatus("Timecas",1); |
1826 |
|
fhBookTree->SetBranchStatus("Pathcas",1); |
1827 |
|
fhBookTree->SetBranchStatus("P0cas",1); |
1828 |
|
fhBookTree->SetBranchStatus("Nthcard",1); |
1829 |
|
fhBookTree->SetBranchStatus("Iparcard",1); |
1830 |
|
fhBookTree->SetBranchStatus("Icard",1); |
1831 |
|
fhBookTree->SetBranchStatus("Xincard",1); |
1832 |
|
fhBookTree->SetBranchStatus("Yincard",1); |
1833 |
|
fhBookTree->SetBranchStatus("Zincard",1); |
1834 |
|
fhBookTree->SetBranchStatus("Xoutcard",1); |
1835 |
|
fhBookTree->SetBranchStatus("Youtcard",1); |
1836 |
|
fhBookTree->SetBranchStatus("Zoutcard",1); |
1837 |
|
fhBookTree->SetBranchStatus("Erelcard",1); |
1838 |
|
fhBookTree->SetBranchStatus("Timecard",1); |
1839 |
|
fhBookTree->SetBranchStatus("Pathcard",1); |
1840 |
|
fhBookTree->SetBranchStatus("P0card",1); |
1841 |
|
|
1842 |
fDataAC[0] = 0xACAC; |
fDataAC[0] = 0xACAC; |
1843 |
fDataAC[64]= 0xACAC; |
fDataAC[64]= 0xACAC; |
1863 |
|
|
1864 |
// shift registers (moved to the end of the routine) |
// shift registers (moved to the end of the routine) |
1865 |
|
|
1866 |
Int_t evntLSB=Ievnt%65536; |
//Int_t evntLSB=Ievnt%65536; |
1867 |
Int_t evntMSB=(Int_t)(Ievnt/65536); |
//Int_t evntMSB=(Int_t)(Ievnt/65536); |
1868 |
|
Int_t evntLSB=(UShort_t)Ievnt; |
1869 |
|
Int_t evntMSB=Ievnt >> 16; |
1870 |
|
|
1871 |
// singles counters are dummy |
// singles counters are dummy |
1872 |
for (UInt_t i=0; i<=15; i++){ //SO Oct '07: // for (UInt_t i=0; i<=16; i++){ |
for (UInt_t i=0; i<=15; i++){ //SO Oct '07: // for (UInt_t i=0; i<=16; i++){ |
1923 |
fDataAC[i+119] = 0x1A13; |
fDataAC[i+119] = 0x1A13; |
1924 |
} |
} |
1925 |
|
|
|
// We activate all branches. Once the digitization algorithm is determined |
|
|
// only the branches that involve needed information will be activated |
|
|
|
|
|
fhBookTree->SetBranchAddress("Ievnt",&Ievnt); |
|
|
fhBookTree->SetBranchStatus("Nthcat",1); |
|
|
fhBookTree->SetBranchStatus("Iparcat",1); |
|
|
fhBookTree->SetBranchStatus("Icat",1); |
|
|
fhBookTree->SetBranchStatus("Xincat",1); |
|
|
fhBookTree->SetBranchStatus("Yincat",1); |
|
|
fhBookTree->SetBranchStatus("Zincat",1); |
|
|
fhBookTree->SetBranchStatus("Xoutcat",1); |
|
|
fhBookTree->SetBranchStatus("Youtcat",1); |
|
|
fhBookTree->SetBranchStatus("Zoutcat",1); |
|
|
fhBookTree->SetBranchStatus("Erelcat",1); |
|
|
fhBookTree->SetBranchStatus("Timecat",1); |
|
|
fhBookTree->SetBranchStatus("Pathcat",1); |
|
|
fhBookTree->SetBranchStatus("P0cat",1); |
|
|
fhBookTree->SetBranchStatus("Nthcas",1); |
|
|
fhBookTree->SetBranchStatus("Iparcas",1); |
|
|
fhBookTree->SetBranchStatus("Icas",1); |
|
|
fhBookTree->SetBranchStatus("Xincas",1); |
|
|
fhBookTree->SetBranchStatus("Yincas",1); |
|
|
fhBookTree->SetBranchStatus("Zincas",1); |
|
|
fhBookTree->SetBranchStatus("Xoutcas",1); |
|
|
fhBookTree->SetBranchStatus("Youtcas",1); |
|
|
fhBookTree->SetBranchStatus("Zoutcas",1); |
|
|
fhBookTree->SetBranchStatus("Erelcas",1); |
|
|
fhBookTree->SetBranchStatus("Timecas",1); |
|
|
fhBookTree->SetBranchStatus("Pathcas",1); |
|
|
fhBookTree->SetBranchStatus("P0cas",1); |
|
|
fhBookTree->SetBranchStatus("Nthcard",1); |
|
|
fhBookTree->SetBranchStatus("Iparcard",1); |
|
|
fhBookTree->SetBranchStatus("Icard",1); |
|
|
fhBookTree->SetBranchStatus("Xincard",1); |
|
|
fhBookTree->SetBranchStatus("Yincard",1); |
|
|
fhBookTree->SetBranchStatus("Zincard",1); |
|
|
fhBookTree->SetBranchStatus("Xoutcard",1); |
|
|
fhBookTree->SetBranchStatus("Youtcard",1); |
|
|
fhBookTree->SetBranchStatus("Zoutcard",1); |
|
|
fhBookTree->SetBranchStatus("Erelcard",1); |
|
|
fhBookTree->SetBranchStatus("Timecard",1); |
|
|
fhBookTree->SetBranchStatus("Pathcard",1); |
|
|
fhBookTree->SetBranchStatus("P0card",1); |
|
|
|
|
1926 |
// In this simpliefied approach we will assume that once |
// In this simpliefied approach we will assume that once |
1927 |
// a particle releases > 0.5 mip in one of the 12 AC detectors it |
// a particle releases > 0.5 mip in one of the 12 AC detectors it |
1928 |
// will fire. We will furthermore assume that both cards read out |
// will fire. We will furthermore assume that both cards read out |
1951 |
// 6.41609e-01 +- 2.65846e-02 |
// 6.41609e-01 +- 2.65846e-02 |
1952 |
// 9.81177e+00 +- 1.21284e+00 |
// 9.81177e+00 +- 1.21284e+00 |
1953 |
// hp: 1 minimum ionising particle at 35cm from the PMT releases 1mip |
// hp: 1 minimum ionising particle at 35cm from the PMT releases 1mip |
|
// |
|
|
// NB: the PMT positions are needed! |
|
1954 |
|
|
1955 |
|
TF1 *attenAC = new TF1("fAttAC",".825+.64*atan(9.8/x)",0.,45.); |
1956 |
|
|
1957 |
|
// PMT positions: x,y,z: (average position of the 2 PMTs) |
1958 |
|
Float_t posCasPmt[4][3]={{28.308, -17.168, 63.644}, // 1 - CAS CPU: x,y,z |
1959 |
|
{18.893, 24.913, 63.644}, // 2 - CAS DCDC |
1960 |
|
{-24.307, 17.162, 63.644}, // 3 - CAS VME |
1961 |
|
{-17.765, -28.300, 63.644}}; // 4 - CAS IPM |
1962 |
|
|
1963 |
|
Float_t dAC=0.; // distance from PMT |
1964 |
|
|
1965 |
// look in CAT |
// look in CAT |
1966 |
// for (UInt_t k= 0;k<50;k++){ |
// for (UInt_t k= 0;k<50;k++){ |
1967 |
for (Int_t k= 0;k<Nthcat;k++){ |
for (Int_t k= 0;k<Nthcat;k++){ |
1971 |
|
|
1972 |
// look in CAS |
// look in CAS |
1973 |
for (Int_t k= 0;k<Nthcas;k++){ |
for (Int_t k= 0;k<Nthcas;k++){ |
1974 |
if (Erelcas[k] >0) |
if (Erelcas[k] >0) { |
1975 |
SumEcas[Icas[k]] += Erelcas[k]; |
dAC=sqrt(pow((Xincas[k]+Xoutcas[k])/2 - posCasPmt[Icas[k]-1][0],2) + pow((Yincas[k]+Youtcas[k])/2 - posCasPmt[Icas[k]-1][1],2) + pow((Zincas[k]+Zoutcas[k])/2 - posCasPmt[Icas[k]-1][2],2)); |
1976 |
|
SumEcas[Icas[k]] += Erelcas[k]*attenAC->Eval(dAC); |
1977 |
|
} |
1978 |
}; |
}; |
1979 |
|
|
1980 |
// look in CARD |
// look in CARD |
1981 |
for (Int_t k= 0;k<Nthcard;k++){ |
for (Int_t k= 0;k<Nthcard;k++){ |
1982 |
if (Erelcard[k] >0) |
if (Erelcard[k] >0) |
1983 |
SumEcard[Icard[k]] += Erelcard[k]; |
SumEcard[Icard[k]] += Erelcard[k]; |
1984 |
}; |
}; |
1985 |
|
|
2211 |
} |
} |
2212 |
}; |
}; |
2213 |
|
|
2214 |
|
void Digitizer::WriteRunHeader(){ |
2215 |
|
fOutputfile.write(reinterpret_cast<char*>(fDataRunHeader),sizeof(UShort_t)*fRunHeaderbuffer); |
2216 |
|
}; |
2217 |
|
|
2218 |
|
void Digitizer::WriteRunTrailer(){ |
2219 |
|
fOutputfile.write(reinterpret_cast<char*>(fDataRunTrailer),sizeof(UShort_t)*fRunTrailerbuffer); |
2220 |
|
}; |
2221 |
|
|
2222 |
void Digitizer::WriteData(){ |
void Digitizer::WriteData(){ |
2223 |
|
|
2225 |
// PSCU data are already swapped |
// PSCU data are already swapped |
2226 |
fOutputfile.write(reinterpret_cast<char*>(fDataPSCU),sizeof(UShort_t)*fPSCUbuffer); |
fOutputfile.write(reinterpret_cast<char*>(fDataPSCU),sizeof(UShort_t)*fPSCUbuffer); |
2227 |
// TRG |
// TRG |
2228 |
fOutputfile.write(reinterpret_cast<char*>(fDataTrigger),sizeof(UChar_t)*153); |
fOutputfile.write(reinterpret_cast<char*>(fDataTrigger),sizeof(UChar_t)*fTRIGGERbuffer); //30/11/07 SO; it was 153 |
2229 |
// TOF |
// TOF |
2230 |
fOutputfile.write(reinterpret_cast<char*>(fDataTof),sizeof(UChar_t)*276); |
fOutputfile.write(reinterpret_cast<char*>(fDataTof),sizeof(UChar_t)*fTOFbuffer); |
2231 |
// AC |
// AC |
2232 |
UShort_t temp[1000000]; |
UShort_t temp[1000000]; |
2233 |
memset(temp,0,sizeof(UShort_t)*1000000); |
memset(temp,0,sizeof(UShort_t)*1000000); |