1 |
nikolas |
1.1 |
#include "PamVMCTofDig.h" |
2 |
|
|
#include "TDatabasePDG.h" |
3 |
|
|
|
4 |
|
|
#include <TMath.h> |
5 |
|
|
#include <TRandom.h> |
6 |
|
|
|
7 |
|
|
using TMath::Power; |
8 |
|
|
using TMath::Exp; |
9 |
|
|
using TMath::Abs; |
10 |
|
|
|
11 |
|
|
ClassImp(PamVMCTofDig) |
12 |
|
|
|
13 |
|
|
|
14 |
|
|
void PamVMCTofDig::LoadCalib(){ |
15 |
|
|
|
16 |
|
|
cout<<"Loading Tof Calibrations..."<<endl; |
17 |
|
|
|
18 |
|
|
Int_t time=3; |
19 |
|
|
Int_t type=202; |
20 |
|
|
|
21 |
|
|
fdberr = fsql->Query_GL_PARAM(time,type); |
22 |
|
|
|
23 |
|
|
fquery.str(""); |
24 |
|
|
fquery << fsql->GetPAR()->PATH.Data() << "/"; |
25 |
|
|
fquery << fsql->GetPAR()->NAME.Data(); |
26 |
|
|
|
27 |
|
|
ThrowCalFileUsage("TOF",fquery.str().c_str()); |
28 |
|
|
|
29 |
|
|
fcfile.open(fquery.str().c_str()); |
30 |
|
|
// fcfile.open("/opt/pamela-5.21/calib/tof-param/ToFCalibParam.txt"); |
31 |
|
|
|
32 |
|
|
if(!fcfile) ThrowCalFileWarning("TOF"); else { |
33 |
|
|
|
34 |
|
|
Int_t temp; |
35 |
|
|
|
36 |
|
|
for(Int_t i=0; i<NP; i++){ |
37 |
|
|
fcfile >> temp; |
38 |
|
|
fcfile >> fatte1[i]; |
39 |
|
|
fcfile >> flambda1[i]; |
40 |
|
|
fcfile >> fatte2[i]; |
41 |
|
|
fcfile >> flambda2[i]; |
42 |
|
|
fcfile >> temp; |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
} |
46 |
|
|
|
47 |
|
|
fcfile.close(); |
48 |
|
|
} |
49 |
|
|
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
void PamVMCTofDig::DigitizeTOF(Int_t EventNo, Int_t PrimaryPDG){ |
54 |
|
|
|
55 |
|
|
fDEBUG = kFALSE; |
56 |
|
|
|
57 |
|
|
// pC < 800 |
58 |
|
|
const Float_t ADC_pC0A = -4.437616e+01; |
59 |
|
|
const Float_t ADC_pC1A = 1.573329e+00; |
60 |
|
|
const Float_t ADC_pC2A = 2.780518e-04; |
61 |
|
|
const Float_t ADC_pC3A = -2.302160e-07; |
62 |
|
|
// pC > 800: |
63 |
|
|
const Float_t ADC_pC0B = -2.245756e+02; |
64 |
|
|
const Float_t ADC_pC1B = 2.184156e+00; |
65 |
|
|
const Float_t ADC_pC2B = -4.171825e-04; |
66 |
|
|
const Float_t ADC_pC3B = 3.789715e-08; |
67 |
|
|
|
68 |
|
|
const Float_t pCthres=40.; // threshold in charge |
69 |
|
|
const Int_t ADClast=4095; // no signal --> ADC ch=4095 |
70 |
|
|
const Int_t ADCsat=3100; // saturation value for the ADCs |
71 |
|
|
const Int_t TDClast=4095; |
72 |
|
|
|
73 |
|
|
for(Int_t i =0; i<NP; i++){ |
74 |
|
|
fQevePmt_pC[i]=ftdc[i]=ftdc1[i]=0.; |
75 |
|
|
ftdcpmt[i]=1000.; |
76 |
|
|
} |
77 |
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
TClonesArray* hc = 0; |
81 |
|
|
const char* keyplane [6] = {"S11Y","S12X","S21X","S22Y","S31Y","S32X"}; |
82 |
|
|
for(Int_t i=0; i<6; i++){ |
83 |
|
|
hc = (TClonesArray*)fhitscolmap.GetValue(keyplane[i]); |
84 |
|
|
if (hc) DigitizeTofPlane(i,hc, PrimaryPDG); |
85 |
|
|
hc = 0; |
86 |
|
|
} |
87 |
|
|
|
88 |
|
|
//+++++ ADC +++++ |
89 |
|
|
|
90 |
|
|
for(Int_t i=0; i<NP; i++){ |
91 |
|
|
if (fQevePmt_pC[i] < 800.) |
92 |
|
|
fADCtof[i]= (Int_t)(ADC_pC0A + ADC_pC1A*fQevePmt_pC[i] |
93 |
|
|
+ ADC_pC2A*Power(fQevePmt_pC[i],2) |
94 |
|
|
+ ADC_pC3A*Power(fQevePmt_pC[i],3)); |
95 |
|
|
if ((fQevePmt_pC[i] > 800.) && (fQevePmt_pC[i] <= 2485.)) |
96 |
|
|
fADCtof[i]= (Int_t)(ADC_pC0B + ADC_pC1B*fQevePmt_pC[i] |
97 |
|
|
+ ADC_pC2B*Power(fQevePmt_pC[i],2) |
98 |
|
|
+ ADC_pC3B*Power(fQevePmt_pC[i],3)); |
99 |
|
|
if (fQevePmt_pC[i] > 2485.) fADCtof[i]= (Int_t)(1758. + 0.54*fQevePmt_pC[i]); |
100 |
|
|
//assuming a fictional 0.54 ch/pC above ADCsat |
101 |
|
|
if (fADCtof[i]>ADCsat) fADCtof[i]=ADCsat; |
102 |
|
|
if (fQevePmt_pC[i] < pCthres) fADCtof[i]= ADClast; |
103 |
|
|
if (fADCtof[i] < 0) fADCtof[i]=ADClast; |
104 |
|
|
if (fADCtof[i] > ADClast) fADCtof[i]=ADClast; |
105 |
|
|
} |
106 |
|
|
|
107 |
|
|
// ====== TDC coincidence ====== |
108 |
|
|
|
109 |
|
|
Float_t t_coinc = 0; |
110 |
|
|
Int_t ilast = 100; |
111 |
|
|
for (Int_t ii=0; ii<NP;ii++) |
112 |
|
|
if (ftdc[ii] > t_coinc) { |
113 |
|
|
t_coinc = ftdc[ii]; |
114 |
|
|
ilast = ii; |
115 |
|
|
} |
116 |
|
|
|
117 |
|
|
for (Int_t ii=0; ii<NP;ii++){ |
118 |
|
|
if (ftdc[ii] != 0) ftdc1[ii] = t_coinc - ftdcpmt[ii]; // test 2 |
119 |
|
|
ftdc1[ii] = ftdc1[ii]/ftdcres[ii]; // divide by TDC resolution |
120 |
|
|
if (ftdc[ii] != 0) ftdc1[ii] = ftdc1[ii] + fc3_S[ii]; // add cable length c3 |
121 |
|
|
} |
122 |
|
|
|
123 |
|
|
if (fDEBUG)cout<<"====== TOF coincidence ======"<<endl; |
124 |
|
|
for(Int_t i=0; i<NP; i++){ |
125 |
|
|
if(ftdc1[i] != 0.){ |
126 |
|
|
fTDCint[i]=(Int_t)ftdc1[i]; |
127 |
|
|
if (fTDCint[i]>4093) fTDCint[i]=TDClast; // 18-oct WM |
128 |
|
|
if (fDEBUG)cout<<"PMT: "<<i<<" ADC: "<<fADCtof[i]<<" TDC: " |
129 |
|
|
<<fTDCint[i]<<endl; |
130 |
|
|
} else |
131 |
|
|
fTDCint[i]= TDClast; |
132 |
|
|
} |
133 |
|
|
if (fDEBUG)cout<<"============================="<<endl; |
134 |
|
|
|
135 |
|
|
//------ use channelmap for ToF: 18-oct WM |
136 |
|
|
Int_t channelmap[] = {3,21,11,29,19,45,27,37,36,28,44,20,5,12,13,4, |
137 |
|
|
6,47,14,39,22,31,30,23,38,15,46,7,0,33,16,24, |
138 |
|
|
8,41,32,40,25,17,34,9,42,1,2,10,18,26,35,43}; |
139 |
|
|
Int_t ADChelp[NP],TDChelp[NP]; |
140 |
|
|
for(Int_t i=0; i<NP; i++){ |
141 |
|
|
Int_t ii=channelmap[i]; |
142 |
|
|
ADChelp[ii]= fADCtof[i]; |
143 |
|
|
TDChelp[ii]= fTDCint[i]; |
144 |
|
|
} |
145 |
|
|
for(Int_t i=0; i<NP; i++){ |
146 |
|
|
fADCtof[i]= ADChelp[i]; |
147 |
|
|
fTDCint[i]= TDChelp[i]; |
148 |
|
|
} |
149 |
|
|
|
150 |
|
|
|
151 |
|
|
// ====== write DataTof ======= |
152 |
|
|
|
153 |
|
|
UChar_t Ctrl3bit[8]={32,0,96,64,160,128,224,192}; // DC (msb in 8 bit word ) |
154 |
|
|
UChar_t tofBin; |
155 |
|
|
UChar_t DataTof[276]; |
156 |
|
|
for (Int_t j=0; j < 276; j++)DataTof[j]=0x00; |
157 |
|
|
UChar_t *pTof=DataTof; |
158 |
|
|
for (Int_t j=0; j < 12; j++){ // loop on TDC #12 |
159 |
|
|
Int_t j12=j*23; // for each TDC 23 bytes (8 bits) |
160 |
|
|
DataTof[j12+0]=0x00; // TDC_ID |
161 |
|
|
DataTof[j12+1]=0x00; // EV_COUNT |
162 |
|
|
DataTof[j12+2]=0x00; // TDC_MASK (1) |
163 |
|
|
DataTof[j12+3]=0x00; // TDC_MASK (2) |
164 |
|
|
for (Int_t k=0; k < 4; k++){ // for each TDC 4 channels (ADC+TDC) |
165 |
|
|
Int_t jk12=j12+4*k; // ADC,TDC channel (0-47) |
166 |
|
|
tofBin =(UChar_t)(fADCtof[k+4*j]/256); // ADC# (msb) |
167 |
|
|
DataTof[jk12+4] = Bin2GrayTof(tofBin,DataTof[jk12+4]); |
168 |
|
|
/* control bits inserted here, after the bin to gray conv - DC*/ |
169 |
|
|
DataTof[jk12+4] = Ctrl3bit[2*k] | DataTof[jk12+4]; |
170 |
|
|
tofBin=(UChar_t)(fADCtof[k+4*j]%256); // ADC# (lsb) |
171 |
|
|
DataTof[jk12+5] = Bin2GrayTof(tofBin,DataTof[jk12+5]); |
172 |
|
|
tofBin=(UChar_t)(fTDCint[k+4*j]/256); // TDC# (msb) |
173 |
|
|
DataTof[jk12+6]=Bin2GrayTof(tofBin,DataTof[jk12+6]); |
174 |
|
|
/* control bits inserted here, after the bin to gray conv - DC*/ |
175 |
|
|
DataTof[jk12+6] = Ctrl3bit[2*k+1] | DataTof[jk12+6]; |
176 |
|
|
tofBin=(UChar_t)(fTDCint[k+4*j]%256); // TDC# (lsb) |
177 |
|
|
DataTof[jk12+7]=Bin2GrayTof(tofBin,DataTof[jk12+7]); |
178 |
|
|
} |
179 |
|
|
DataTof[j12+20]=0x00; // TEMP1 |
180 |
|
|
DataTof[j12+21]=0x00; // TEMP2 |
181 |
|
|
DataTof[j12+22]= EvaluateCrc(pTof,22); // CRC |
182 |
|
|
pTof+=23; |
183 |
|
|
} |
184 |
|
|
|
185 |
|
|
//===== write DataTrigger ======= |
186 |
|
|
|
187 |
|
|
UChar_t DataTrigger[152]; |
188 |
|
|
for (Int_t j=0; j < 152; j++)DataTrigger[j]=0x00; |
189 |
|
|
UChar_t *pTrg=DataTrigger; |
190 |
|
|
// Only the variables with a (*) are modified; the others are set to 0 |
191 |
|
|
// info given in #bites data + #bites crc |
192 |
|
|
// TB_READ_PMT_PLANE : 6 + 1 |
193 |
|
|
// TB_READ_EVENT_COUNT : 3 + 1 (*) |
194 |
|
|
// TB_READ_TRIGGER_RATE : 12 + 1 |
195 |
|
|
// TB_READ_D_L_TIME : 4 + 1 |
196 |
|
|
// TB_READ_S4_CAL_COUNT : 4 + 1 |
197 |
|
|
// TB_READ_PMT_COUNT1 : 48 + 1 |
198 |
|
|
// TB_READ_PMT_COUNT2 : 48 + 1 |
199 |
|
|
// TB_READ_PATTERN_BUSY : 8 + 1 |
200 |
|
|
// TB_READ_PATTERN_TRIGGER: 7 + 1 (*) |
201 |
|
|
// TB_READ_TRIGGER_CONF : 2 + 1 (*) |
202 |
|
|
// TB_READ_EVENT_COUNT |
203 |
|
|
UInt_t cTrg = EventNo; //counter |
204 |
|
|
UInt_t cTrg2 = 0; //counter with bits inverted, according to document |
205 |
|
|
//"formato dati provenienti dalla trigger board" |
206 |
|
|
for (Int_t i=0; i < 24; i++){ // Use the first 24 bits |
207 |
|
|
if (cTrg & (0x1 << i) ) |
208 |
|
|
cTrg2 = cTrg2 | (0x1 << (24-i)); |
209 |
|
|
} |
210 |
|
|
DataTrigger[7] = (UChar_t)(cTrg2 >> 16); // 8 MSbits (out of 24) |
211 |
|
|
DataTrigger[8] = (UChar_t)(cTrg2 >> 8); // 8 "middle" bits |
212 |
|
|
DataTrigger[9] = (UChar_t)(cTrg2); // 8 LSbits |
213 |
|
|
pTrg=DataTrigger+7; |
214 |
|
|
DataTrigger[10]=EvaluateCrc(pTrg, 3); |
215 |
|
|
|
216 |
|
|
// TB_READ_PATTERN_TRIGGER: bytes 141-148: |
217 |
|
|
// PatternTrigMap[i] corresponds to bit i in TB_READ_PATTERN_TRIGGER: |
218 |
|
|
// mapping according to documents: |
219 |
|
|
// 1. "formato dati provenienti dalla trigger board" |
220 |
|
|
// 2. "The ToF quicklook software", Appendix A (Campana, Nagni) |
221 |
|
|
Int_t PatternTrigMap[]={29,42,43,1,16,7,17,28,33,41,46,2,15,8,18,27, |
222 |
|
|
30,40,44,3,14,9,19,26,32,37,47,4,13,10,20,25, |
223 |
|
|
34,31,38,45,5,12,21,24,36,35,39,48,6,11,22,23}; |
224 |
|
|
for (Int_t i=0; i<NP; i++){ |
225 |
|
|
if (ftdc1[channelmap[i]]!=0) |
226 |
|
|
DataTrigger[147-(Int_t)((PatternTrigMap[i]+1)/8)]=DataTrigger[147-(Int_t)((PatternTrigMap[i]+1)/8)] | (0x1 << (PatternTrigMap[i]%8)); |
227 |
|
|
} |
228 |
|
|
pTrg=DataTrigger+141; |
229 |
|
|
DataTrigger[148]=EvaluateCrc(pTrg, 7); |
230 |
|
|
|
231 |
|
|
// TB_READ_TRIGGER_CONF : set always acq.mode TOF4 |
232 |
|
|
// |
233 |
|
|
// TOF1: S1-S2-S3 (&,|) |
234 |
|
|
// TOF4: S2-S3 (&,&) |
235 |
|
|
DataTrigger[149]=0x02; |
236 |
|
|
DataTrigger[150]=0x0; |
237 |
|
|
pTrg=DataTrigger+149; |
238 |
|
|
DataTrigger[151]=EvaluateCrc(pTrg, 2); |
239 |
|
|
|
240 |
|
|
|
241 |
|
|
//++++++ WRITE EVERYTHING TO DIGITIZER'S BUFFER +++// |
242 |
|
|
cout<<"TOF Digitizing"<<endl; |
243 |
|
|
|
244 |
|
|
fDataC.clear(); //clearing Tof & Trig data buffer |
245 |
|
|
|
246 |
|
|
for(Int_t i= 0; i<152; i++) fDataC.push_back(DataTrigger[i]); |
247 |
|
|
|
248 |
|
|
for(Int_t i= 0; i<276; i++) fDataC.push_back(DataTof[i]); |
249 |
|
|
|
250 |
|
|
} |
251 |
|
|
|
252 |
|
|
Float_t PamVMCTofDig::TimeRes(Int_t PrimaryPDG){ |
253 |
|
|
|
254 |
|
|
Float_t time_res[8] = {425.,210.,170.,130.,120.,120.,120.,120.}; |
255 |
|
|
Int_t Z = Int_t((TDatabasePDG::Instance()->GetParticle(PrimaryPDG))->Charge()/3.); |
256 |
|
|
|
257 |
|
|
Float_t dt1 = 1.e-12*time_res[0]; // single PMT resolution for Z=1 (WM, Nov'07) |
258 |
|
|
if ((Z > 1) && (Z < 9)) dt1=1.e-12*time_res[(Z-1)]; |
259 |
|
|
if (Z > 8) dt1=120.e-12; |
260 |
|
|
|
261 |
|
|
return dt1; |
262 |
|
|
} |
263 |
|
|
|
264 |
|
|
void PamVMCTofDig::DigitizeTofPlane(Int_t planeNo, TClonesArray* HitColl, Int_t PrimaryPDG){ |
265 |
|
|
|
266 |
|
|
PamVMCDetectorHit * hit = 0; |
267 |
|
|
const Float_t veff0 = 100.*1.0e8;//(m/s) light velocity in scintillator |
268 |
|
|
const Float_t veff1 = 100.*1.5e8;//(m/s) light velocity in lightguide |
269 |
|
|
const Float_t FGeo[2] = {0.5, 0.5}; //geometrical factor |
270 |
|
|
const Float_t Pho_keV = 10.;// photons per keV in scintillator |
271 |
|
|
const Float_t effi = 0.21; //photocathofe efficiency |
272 |
|
|
const Float_t pmGain = 3.5e6; //PMT Gain: the same for all PMTs |
273 |
|
|
const Float_t echarge = 1.6e-19; // electron charge |
274 |
|
|
const Float_t thresh=20.; // to be defined better... (Wolfgang) |
275 |
|
|
|
276 |
|
|
const Float_t dimel[6] = {33.0, 40.8 ,18.0, 15.0, 15.0, 18.0}; //(cm) TOF paddles dimensions |
277 |
|
|
// S11 8 paddles 33.0 x 5.1 cm |
278 |
|
|
// S12 6 paddles 40.8 x 5.5 cm |
279 |
|
|
// S21 2 paddles 18.0 x 7.5 cm |
280 |
|
|
// S22 2 paddles 15.0 x 9.0 cm |
281 |
|
|
// S31 3 paddles 15.0 x 6.0 cm |
282 |
|
|
// S32 3 paddles 18.0 x 5.0 cm |
283 |
|
|
|
284 |
|
|
const Float_t s_l_g[6] = {8.0, 8.0, 20.9, 22.0, 9.8, 8.3 }; //(cm) length of the lightguide |
285 |
|
|
|
286 |
|
|
const Float_t ScaleFact[48]={0.39, 0.49, 0.38, 0.40, 0.65, 0.51, 0.43, |
287 |
|
|
0.49, 0.58, 0.38, 0.53, 0.57, 0.53, 0.45, 0.49, 0.16, |
288 |
|
|
0.15, 0.44, 0.28, 0.57, 0.26, 0.72, 0.37, 0.29, 0.30, 0.89, |
289 |
|
|
0.37, 0.08, 0.27, 0.23, 0.12, 0.22, 0.15, 0.16, 0.21, |
290 |
|
|
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 }; |
291 |
|
|
|
292 |
|
|
Float_t t1, t2, tpos, Npho; |
293 |
|
|
Float_t path[2], knorm[2], Atten[2], QhitPad_pC[2], QhitPmt_pC[2]; |
294 |
|
|
Int_t padNo, pmtleft, pmtright; |
295 |
|
|
//LOOP |
296 |
|
|
for(Int_t i =0; i<HitColl->GetEntriesFast(); i++){ |
297 |
|
|
|
298 |
|
|
hit = (PamVMCDetectorHit*)HitColl->At(i); |
299 |
|
|
|
300 |
|
|
t1=t2 = hit->GetTOF(); |
301 |
|
|
padNo = hit->GetPOS()-1; |
302 |
|
|
pmtleft=pmtright=0; |
303 |
|
|
if(planeNo==2) |
304 |
|
|
if(padNo==0) |
305 |
|
|
padNo=1; |
306 |
|
|
else |
307 |
|
|
padNo=0; |
308 |
|
|
|
309 |
|
|
Paddle2Pmt(planeNo,padNo, &pmtleft, &pmtright); |
310 |
|
|
|
311 |
|
|
switch(planeNo){ |
312 |
|
|
case 0: |
313 |
|
|
case 3: |
314 |
|
|
case 4: |
315 |
|
|
tpos = (hit->GetYIN()+hit->GetYOUT())/2.; //Y-planes |
316 |
|
|
break; |
317 |
|
|
case 1: |
318 |
|
|
case 2: |
319 |
|
|
case 5: |
320 |
|
|
tpos = (hit->GetXIN()+hit->GetXOUT())/2.; //X-planes |
321 |
|
|
break; |
322 |
|
|
default: |
323 |
|
|
cout<<"PamVMCTofDig::DigitizeTOFPlane wrong plane no "<<planeNo<<endl; |
324 |
|
|
tpos = -100.; |
325 |
|
|
break; |
326 |
|
|
} |
327 |
|
|
|
328 |
|
|
path[0]= tpos + dimel[planeNo]/2.; // path to left PMT |
329 |
|
|
path[1]= dimel[planeNo]/2.- tpos; // path to right PMT |
330 |
|
|
|
331 |
|
|
if (fDEBUG) { |
332 |
|
|
cout <<"+++++ TOF HIT VERBOSE INFORMATION: +++++"<<endl; |
333 |
|
|
cout <<"planeNo "<<planeNo<<" padNo "<< padNo <<" tpos "<< tpos <<"\n"; |
334 |
|
|
cout <<"pmtleft, pmtright "<<pmtleft<<","<<pmtright<<endl; |
335 |
|
|
} |
336 |
|
|
|
337 |
|
|
Npho = hit->GetEREL()*Pho_keV*1.0e6; //calculation of photons number |
338 |
|
|
|
339 |
|
|
for(Int_t j=0; j<2; j++){ |
340 |
|
|
QhitPad_pC[j]= Npho*FGeo[j]*effi*pmGain*echarge*1.E12*ScaleFact[pmtleft+j]; |
341 |
|
|
knorm[j]=fatte1[pmtleft+j]*Exp(flambda1[pmtleft+j]*dimel[planeNo]/2.*Power(-1,j+1)) + |
342 |
|
|
fatte2[pmtleft+j]*Exp(flambda2[pmtleft+j]*dimel[planeNo]/2.*Power(-1,j+1)); |
343 |
|
|
Atten[j]=fatte1[pmtleft+j]*Exp(tpos*flambda1[pmtleft+j]) + |
344 |
|
|
fatte2[pmtleft+j]*Exp(tpos*flambda2[pmtleft+j]) ; |
345 |
|
|
QhitPmt_pC[j]= QhitPad_pC[j]*Atten[j]/knorm[j]; |
346 |
|
|
if (fDEBUG) { |
347 |
|
|
cout<<"pmtleft:"<<pmtleft<<" j:"<<j<<endl; |
348 |
|
|
cout<<"atte1:"<<fatte1[pmtleft+j]<<" lambda1:"<<flambda1[pmtleft+j] |
349 |
|
|
<<" atte2:"<<fatte2[pmtleft+j]<<" lambda2:"<<flambda2[pmtleft+j] |
350 |
|
|
<<endl; |
351 |
|
|
cout<<j<<" tpos:"<<tpos<<" knorm:"<<knorm[j]<<" "<<Atten[j]<<" " |
352 |
|
|
<<"QhitPmt_pC "<<QhitPmt_pC[j]<<endl; |
353 |
|
|
} |
354 |
|
|
} |
355 |
|
|
|
356 |
|
|
if(fDEBUG)cout<<"Energy release (keV):"<<hit->GetEREL()*1.e6<<" Npho:"<<Npho<< |
357 |
|
|
" QhitPmt_pC(left,right):"<<QhitPmt_pC[0]<<" "<<QhitPmt_pC[1]<<endl; |
358 |
|
|
|
359 |
|
|
fQevePmt_pC[pmtleft] += QhitPmt_pC[0]; //cdding charge from separate hits |
360 |
|
|
fQevePmt_pC[pmtright] += QhitPmt_pC[1]; |
361 |
|
|
|
362 |
|
|
// TDC |
363 |
|
|
// WM right and left <-> |
364 |
|
|
t1 += Abs(path[0]/veff0) + s_l_g[planeNo]/veff1; |
365 |
|
|
t2 += Abs(path[1]/veff0) + s_l_g[planeNo]/veff1; // Signal reaches PMT |
366 |
|
|
t1 = gRandom->Gaus(t1,TimeRes(PrimaryPDG)); //apply gaussian error dt |
367 |
|
|
t2 = gRandom->Gaus(t2,TimeRes(PrimaryPDG)); //apply gaussian error dt |
368 |
|
|
t1 += fc1_S[pmtleft] ; // Signal reaches Discriminator ,TDC starts to run |
369 |
|
|
t2 += fc1_S[pmtright] ; |
370 |
|
|
|
371 |
|
|
// check if signal is above threshold |
372 |
|
|
// then check if tdcpmt is already filled by another hit... |
373 |
|
|
// only re-fill if time is smaller |
374 |
|
|
if (QhitPmt_pC[0] > thresh) { |
375 |
|
|
if (ftdcpmt[pmtleft] == 1000.) { // fill for the first time |
376 |
|
|
ftdcpmt[pmtleft] = t1; |
377 |
|
|
ftdc[pmtleft] = t1 + fc2_S[pmtleft] ; // Signal reaches Coincidence |
378 |
|
|
} |
379 |
|
|
if (ftdcpmt[pmtleft] < 1000.) // is already filled! |
380 |
|
|
if (t1 < ftdcpmt[pmtleft]) { |
381 |
|
|
ftdcpmt[pmtleft] = t1; |
382 |
|
|
t1 += fc2_S[pmtleft] ; // Signal reaches Coincidence |
383 |
|
|
ftdc[pmtleft] = t1; |
384 |
|
|
} |
385 |
|
|
} |
386 |
|
|
if (QhitPmt_pC[1] > thresh) { |
387 |
|
|
if (ftdcpmt[pmtright] == 1000.) { // fill for the first time |
388 |
|
|
ftdcpmt[pmtright] = t2; |
389 |
|
|
ftdc[pmtright] = t2 + fc2_S[pmtright] ; // Signal reaches Coincidence |
390 |
|
|
} |
391 |
|
|
if (ftdcpmt[pmtright] < 1000.) // is already filled! |
392 |
|
|
if (t2 < ftdcpmt[pmtright]) { |
393 |
|
|
ftdcpmt[pmtright] = t2; |
394 |
|
|
t2+= fc2_S[pmtright] ; |
395 |
|
|
ftdc[pmtright] = t2; |
396 |
|
|
} |
397 |
|
|
} |
398 |
|
|
if(fDEBUG)cout<<"Time(s):"<<hit->GetTOF()<<" t1:"<<t1<<" t2:"<<t2<<endl |
399 |
|
|
<<"+++++ END OF TOF HIT +++++"<<endl; |
400 |
|
|
|
401 |
|
|
}; |
402 |
|
|
//END OF HIT COLLECTION LOOP |
403 |
|
|
|
404 |
|
|
} |
405 |
|
|
|
406 |
|
|
void PamVMCTofDig::Paddle2Pmt(Int_t planeNo, Int_t padNo, Int_t *pl, Int_t *pr){ |
407 |
|
|
//* @param plane (0 - 5) |
408 |
|
|
//* @param paddle (plane=0, paddle = 0,...5) |
409 |
|
|
//* @param padid (0 - 23) |
410 |
|
|
// |
411 |
|
|
Int_t padid=-1; |
412 |
|
|
Int_t pads[6]={8,6,2,2,3,3}; |
413 |
|
|
// |
414 |
|
|
Int_t somma=0; |
415 |
|
|
for(Int_t j=0; j<planeNo; j++) somma+=pads[j]; |
416 |
|
|
padid=padNo+somma; |
417 |
|
|
*pl = padid*2; |
418 |
|
|
*pr = *pl + 1; // WM |
419 |
|
|
|
420 |
|
|
} |
421 |
|
|
|
422 |
|
|
|
423 |
|
|
UChar_t PamVMCTofDig::Bin2GrayTof(UChar_t binaTOF,UChar_t grayTOF){ |
424 |
|
|
union graytof_data { |
425 |
|
|
UChar_t word; |
426 |
|
|
struct bit_field { |
427 |
|
|
unsigned b0:1; |
428 |
|
|
unsigned b1:1; |
429 |
|
|
unsigned b2:1; |
430 |
|
|
unsigned b3:1; |
431 |
|
|
unsigned b4:1; |
432 |
|
|
unsigned b5:1; |
433 |
|
|
unsigned b6:1; |
434 |
|
|
unsigned b7:1; |
435 |
|
|
} bit; |
436 |
|
|
} bi,gr; |
437 |
|
|
// |
438 |
|
|
bi.word = binaTOF; |
439 |
|
|
gr.word = grayTOF; |
440 |
|
|
// |
441 |
|
|
gr.bit.b0 = bi.bit.b1 ^ bi.bit.b0; |
442 |
|
|
gr.bit.b1 = bi.bit.b2 ^ bi.bit.b1; |
443 |
|
|
gr.bit.b2 = bi.bit.b3 ^ bi.bit.b2; |
444 |
|
|
gr.bit.b3 = bi.bit.b3; |
445 |
|
|
// |
446 |
|
|
/* bin to gray conversion 4 bit per time*/ |
447 |
|
|
// |
448 |
|
|
gr.bit.b4 = bi.bit.b5 ^ bi.bit.b4; |
449 |
|
|
gr.bit.b5 = bi.bit.b6 ^ bi.bit.b5; |
450 |
|
|
gr.bit.b6 = bi.bit.b7 ^ bi.bit.b6; |
451 |
|
|
gr.bit.b7 = bi.bit.b7; |
452 |
|
|
// |
453 |
|
|
return(gr.word); |
454 |
|
|
} |
455 |
|
|
|
456 |
|
|
void PamVMCTofDig::Crc8Tof(UChar_t *oldCRC, UChar_t *crcTof){ |
457 |
|
|
union crctof_data { |
458 |
|
|
UChar_t word; |
459 |
|
|
struct bit_field { |
460 |
|
|
unsigned b0:1; |
461 |
|
|
unsigned b1:1; |
462 |
|
|
unsigned b2:1; |
463 |
|
|
unsigned b3:1; |
464 |
|
|
unsigned b4:1; |
465 |
|
|
unsigned b5:1; |
466 |
|
|
unsigned b6:1; |
467 |
|
|
unsigned b7:1; |
468 |
|
|
} bit; |
469 |
|
|
} c,d,r; |
470 |
|
|
|
471 |
|
|
c.word = *oldCRC; |
472 |
|
|
//d.word = *newCRC; |
473 |
|
|
d.word = *crcTof; |
474 |
|
|
r.word = 0; |
475 |
|
|
|
476 |
|
|
r.bit.b0 = c.bit.b7 ^ c.bit.b6 ^ c.bit.b0 ^ |
477 |
|
|
d.bit.b0 ^ d.bit.b6 ^ d.bit.b7; |
478 |
|
|
|
479 |
|
|
r.bit.b1 = c.bit.b6 ^ c.bit.b1 ^ c.bit.b0 ^ |
480 |
|
|
d.bit.b0 ^ d.bit.b1 ^ d.bit.b6; |
481 |
|
|
|
482 |
|
|
r.bit.b2 = c.bit.b6 ^ c.bit.b2 ^ c.bit.b1 ^ c.bit.b0 ^ |
483 |
|
|
d.bit.b0 ^ d.bit.b1 ^ d.bit.b2 ^ d.bit.b6; |
484 |
|
|
|
485 |
|
|
r.bit.b3 = c.bit.b7 ^ c.bit.b3 ^ c.bit.b2 ^ c.bit.b1 ^ |
486 |
|
|
d.bit.b1 ^ d.bit.b2 ^ d.bit.b3 ^ d.bit.b7; |
487 |
|
|
|
488 |
|
|
r.bit.b4 = c.bit.b4 ^ c.bit.b3 ^ c.bit.b2 ^ |
489 |
|
|
d.bit.b2 ^ d.bit.b3 ^ d.bit.b4; |
490 |
|
|
|
491 |
|
|
r.bit.b5 = c.bit.b5 ^ c.bit.b4 ^ c.bit.b3 ^ |
492 |
|
|
d.bit.b3 ^ d.bit.b4 ^ d.bit.b5; |
493 |
|
|
|
494 |
|
|
r.bit.b6 = c.bit.b6 ^ c.bit.b5 ^ c.bit.b4 ^ |
495 |
|
|
d.bit.b4 ^ d.bit.b5 ^ d.bit.b6; |
496 |
|
|
|
497 |
|
|
r.bit.b7 = c.bit.b7 ^ c.bit.b6 ^ c.bit.b5 ^ |
498 |
|
|
d.bit.b5 ^ d.bit.b6 ^ d.bit.b7 ; |
499 |
|
|
|
500 |
|
|
*crcTof=r.word; |
501 |
|
|
//return r.word; |
502 |
|
|
}; |
503 |
|
|
|
504 |
|
|
|
505 |
|
|
|
506 |
|
|
|
507 |
|
|
UChar_t PamVMCTofDig::EvaluateCrc(UChar_t *pTrg, Int_t nb) { |
508 |
|
|
Bool_t DEBUG=false; |
509 |
|
|
if (DEBUG) |
510 |
|
|
return(0x00); |
511 |
|
|
|
512 |
|
|
UChar_t crcTrg=0x00; |
513 |
|
|
UChar_t *pc=&crcTrg, *pc2; |
514 |
|
|
pc2=pTrg; |
515 |
|
|
for (Int_t jp=0; jp < nb; jp++) |
516 |
|
|
Crc8Tof(pc2++,pc); |
517 |
|
|
return(crcTrg); |
518 |
|
|
} |