/[PAMELA software]/PamelaDigitizer/DigitizeTOF.cxx
ViewVC logotype

Annotation of /PamelaDigitizer/DigitizeTOF.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations) (download)
Thu Dec 18 17:11:47 2008 UTC (15 years, 11 months ago) by mocchiut
Branch: MAIN
CVS Tags: v3r04
Changes since 1.3: +1 -1 lines
Small changes for a better compilation

1 pamelats 1.1 #include "Digitizer.h"
2    
3     void Digitizer::DigitizeTOF(int np,float *atte1,float *atte2,float *lambda1,float *lambda2){
4     //fDataTof: 12 x 23 bytes (=276 bytes)
5     UChar_t *pTof=fDataTof;
6     Bool_t DEBUG=false;
7    
8     Int_t cdp[75] = {0,1,1,0,1,1,0,1,1,0,1,1,0,1,1, //0-14
9     0,0,0,1,0,1,0,1,1,0,0,1,0,1,0, //15-29
10     1,1,1,1,2,2,2,3,3,3,3,4,4,4,1, //30-44
11     1,2,0,2,0,0,5,5,5,5,6,6,6,6,7, //45-59
12     3,3,4,4,5,5,6,7,8,9,10,11,12,13,14 }; //60-74
13 pamelats 1.3
14 pamelats 1.1 int Z = cdp[Ipa-1];
15    
16     float time_res[8] = {425.,210.,170.,130.,120.,120.,120.,120.};
17 pamelats 1.3 for(Int_t i=0;i<8;i++)time_res[i]/=1.4;//1.17;1.5;1.3*/
18 mocchiut 1.4 Float_t dt1 = 0.;// = 1.e-12*time_res[0]; // single PMT resolution for Z=1 (WM, Nov'07)
19 pamelats 1.3
20 pamelats 1.1 if ((Z > 1) && (Z < 9)) dt1=1.e-12*time_res[(Z-1)];
21     if (Z > 8) dt1=120.e-12;
22 pamelats 1.3
23 pamelats 1.1
24     // ------ evaluate energy in each pmt: ------
25     // strip geometry (lenght/width)
26     Float_t dimel[6] = {33.0, 40.8 ,18.0, 15.0, 15.0, 18.0};
27     // S11 8 paddles 33.0 x 5.1 cm
28     // S12 6 paddles 40.8 x 5.5 cm
29     // S21 2 paddles 18.0 x 7.5 cm
30     // S22 2 paddles 15.0 x 9.0 cm
31     // S31 3 paddles 15.0 x 6.0 cm
32     // S32 3 paddles 18.0 x 5.0 cm
33     Float_t FGeo[2]={0., 0.}; /* geometrical factor */
34     const Float_t Pho_keV = 10.; // photons per keV in scintillator
35     const Float_t echarge = 1.6e-19; // electron charge
36     Float_t Npho=0.;
37     Float_t QevePmt_pC[48];
38 pamelats 1.3 Float_t QhitPad_pC[2]={0.,0.};
39     Float_t QhitPmt_pC[2]={0.,0.};
40 pamelats 1.1 Float_t pmGain = 3.5e6; /* PMT Gain: the same for all PMTs */
41     Float_t effi=0.21; /* Efficienza di fotocatodo */
42     // pC < 800
43 pamelats 1.3 Float_t ADC_pC0A =-4.437616e+01;
44     Float_t ADC_pC1A = 1.573329e+00;
45     Float_t ADC_pC2A = 2.780518e-04;
46     Float_t ADC_pC3A =-2.302160e-07;
47 pamelats 1.1 // pC > 800:
48 pamelats 1.3 Float_t ADC_pC0B =-2.245756e+02;
49     Float_t ADC_pC1B = 2.184156e+00;
50     Float_t ADC_pC2B =-4.171825e-04;
51     Float_t ADC_pC3B = 3.789715e-08;
52 pamelats 1.1
53     Float_t pCthres=40.; // threshold in charge
54     Int_t ADClast=4095; // no signal --> ADC ch=4095
55     Int_t ADCsat=3100; // saturation value for the ADCs
56     Int_t ADCtof[48];
57 pamelats 1.3 Float_t ScaleFact[48]={0.39, 0.49, 0.38, 0.40, 0.65, 0.51, 0.43, 0.49,
58     0.58, 0.38, 0.53, 0.57, 0.53, 0.45, 0.49, 0.22,
59     0.21, 0.44, 0.28, 0.57, 0.26, 0.72, 0.37, 0.29,
60     0.30, 0.89, 0.37, 0.12, 0.27, 0.23, 0.15, 0.22,
61     0.19, 0.20, 0.21, 0.19, 0.41, 0.32, 0.39, 0.38,
62     0.28, 0.66, 0.28, 0.40, 0.39, 0.40, 0.37, 0.35};//15:0.7--0.95, 16:0.9--1.25, 27:0.9--1.3, 30:0.9--1.15, 32:0.85--1.05, 33:0.85--1.05
63 pamelats 1.1 for(Int_t i=0; i<48; i++){
64     QevePmt_pC[i] = 0;
65     ADCtof[i]=0;
66     }
67 pamelats 1.3 Int_t ip,ipad,pmtleft=0,pmtright=0;
68 pamelats 1.1 // TDC variables:
69     Int_t TDClast=4095,TDCint[48];
70     Float_t tdc[48],tdc1[48],tdcpmt[48];
71     for(Int_t i=0; i<48; i++) {
72     tdcpmt[i] = 1000.;
73     tdc[i] = 0.; // 18-oct WM
74     tdc1[i] = 0.; // 18-oct WM
75     }
76     Float_t thresh=20.; // to be defined better... (Wolfgang)
77     // === TDC: simulate timing for each paddle
78     Float_t tdcres[50],c1_S[50],c2_S[50],c3_S[50];
79     for(Int_t j=0;j<48;j++){
80     tdcres[j] = 50.E-12; // TDC resolution 50 picosec
81     c1_S[j] = 500.; // cable length in channels
82     c2_S[j] = 0.;
83     c3_S[j] = 1000.;
84     c1_S[j] = c1_S[j]*tdcres[j]; // cable length in sec
85     c2_S[j] = c2_S[j]*tdcres[j];
86     }
87     /* ********************************** start loop over hits */
88 pamelats 1.3 if(Nthtof>*ntof)cout<<"NTHTOF > "<<*ntof<<" , event rejected ! "<<Nthtof<<endl;
89 pamelats 1.1 else{
90     for(Int_t nh=0; nh<Nthtof; nh++){
91     Float_t s_l_g[6] = {8.0, 8.0, 20.9, 22.0, 9.8, 8.3 }; // length of the lightguide
92     Float_t t1,t2,veff,veff1,veff0 ;
93     veff0 = 100.*1.0e8 ; // light velocity in the scintillator in m/sec
94     veff1 = 100.*1.5e8; // light velocity in the lightguide in m/sec
95     veff=veff0; // signal velocity in the paddle
96     t1 = Timetof[nh] ; // Start
97     t2 = Timetof[nh] ;
98     // Donatella: redefinition plane and pad for vectors in C
99     ip = Ipltof[nh]-1;
100     ipad = Ipaddle[nh]-1;
101     pmtleft=0;
102     pmtright=0;
103     // WM: S12 paddles are "reversed" (Nov'07)
104     if (ip==2)
105     if (ipad==0)
106     ipad=1;
107     else
108     ipad=0;
109     if ((ip>-1)&&(ip<6)) { //ToF paddles only, not S4
110     Paddle2Pmt(ip, ipad, &pmtleft, &pmtright);
111     // DC: evaluates mean position and path inside the paddle
112     Float_t tpos=0.;
113     Float_t path[2] = {0., 0.};
114     //--- Strip in Y = S11,S22,S31 ------
115     if(ip==0 || ip==3 || ip==4)
116     tpos = (Yintof[nh]+Youttof[nh])/2.;
117     else
118     if(ip==1 || ip==2 || ip==5) //--- Strip in X for S12,S21,S32
119     tpos = (Xintof[nh]+Xouttof[nh])/2.;
120     else //if (ip!=6)
121     printf("*** WARNING TOF: this option should never occur! (ip=%2i, nh=%2i)\n",ip,nh);
122     path[0]= tpos + dimel[ip]/2.; // path to left PMT
123     path[1]= dimel[ip]/2.- tpos; // path to right PMT
124     if (DEBUG) {
125     cout <<" plane "<<ip<<" strip # ="<< ipad <<" tpos "<< tpos <<"\n";
126     cout <<"pmtleft, pmtright "<<pmtleft<<" "<<pmtright<<endl;
127     }
128     // constant geometric factor, the rest is handled by the scaling factor
129     FGeo[0] =0.5;
130     FGeo[1] =0.5;
131     Npho = Ereltof[nh]*Pho_keV*1.0e6; // Eloss in GeV
132    
133     Float_t knorm[2]={0., 0.}; // Donatella
134     Float_t Atten[2]={0., 0.}; // Donatella
135     for(Int_t j=0; j<2; j++){
136     QhitPad_pC[j]= Npho*FGeo[j]*effi*pmGain*echarge*1.E12*ScaleFact[pmtleft+j];
137     // WM
138 pamelats 1.3 knorm[j]=atte1[pmtleft+j]*exp(lambda1[pmtleft+j]*dimel[ip]/2.*pow(-1,j+1)) + atte2[pmtleft+j]*exp(lambda2[pmtleft+j]*dimel[ip]/2.*pow(-1,j+1));
139     Atten[j]=atte1[pmtleft+j]*exp(tpos*lambda1[pmtleft+j]) + atte2[pmtleft+j]*exp(tpos*lambda2[pmtleft+j]) ;
140 pamelats 1.1 QhitPmt_pC[j]= QhitPad_pC[j]*Atten[j]/knorm[j];
141     if (DEBUG) {
142     cout<<"pmtleft "<<pmtleft<<" j "<<j<<endl;
143     cout<<" atte1 "<<atte1[pmtleft+j]<<"lambda1 "<<lambda1[pmtleft+j]<<" atte2 "<<atte2[pmtleft+j]<<"lambda2 "<<lambda2[pmtleft+j] <<endl;
144     cout<<j<<" tpos "<<tpos<<" knorm "<<knorm[j]<<" "<<Atten[j]<<" "<<"QhitPmt_pC "<<QhitPmt_pC[j]<<endl;
145     }
146     }
147     if(DEBUG)cout<<"Npho "<<Npho<<" QhitPmt_pC "<<QhitPmt_pC[0]<<" "<<QhitPmt_pC[1]<<endl;
148     QevePmt_pC[pmtleft] += QhitPmt_pC[0];
149     QevePmt_pC[pmtright] += QhitPmt_pC[1];
150 pamelats 1.3 //TDC
151     // WM right and left <->
152 pamelats 1.1 t1 = t1 + fabs(path[0]/veff) + s_l_g[ip]/veff1;
153     t2 = t2 + fabs(path[1]/veff) + s_l_g[ip]/veff1 ; // Signal reaches PMT
154     t1 = gRandom->Gaus(t1,dt1); //apply gaussian error dt
155     t2 = gRandom->Gaus(t2,dt1); //apply gaussian error dt
156     t1 = t1 + c1_S[pmtleft] ; // Signal reaches Discriminator ,TDC starts to run
157     t2 = t2 + c1_S[pmtright] ;
158     // check if signal is above threshold
159     // then check if tdcpmt is already filled by another hit...
160     // only re-fill if time is smaller
161     if (QhitPmt_pC[0] > thresh) {
162     if (tdcpmt[pmtleft] == 1000.) { // fill for the first time
163     tdcpmt[pmtleft] = t1;
164     tdc[pmtleft] = t1 + c2_S[pmtleft] ; // Signal reaches Coincidence
165     }
166     if (tdcpmt[pmtleft] < 1000.) // is already filled!
167     if (t1 < tdcpmt[pmtleft]) {
168     tdcpmt[pmtleft] = t1;
169     t1 = t1 + c2_S[pmtleft] ; // Signal reaches Coincidence
170     tdc[pmtleft] = t1;
171     }
172     }
173     if (QhitPmt_pC[1] > thresh) {
174     if (tdcpmt[pmtright] == 1000.) { // fill for the first time
175     tdcpmt[pmtright] = t2;
176     tdc[pmtright] = t2 + c2_S[pmtright] ; // Signal reaches Coincidence
177     }
178     if (tdcpmt[pmtright] < 1000.) // is already filled!
179     if (t2 < tdcpmt[pmtright]) {
180     tdcpmt[pmtright] = t2;
181     t2 = t2 + c2_S[pmtright] ;
182     tdc[pmtright] = t2;
183     }
184     }
185     if(DEBUG)cout<<nh<<" "<<Timetof[nh]<<" "<<t1<<" "<<t2<<endl;
186     } // ip > -1 && ip < 6
187     } // **************************************** end loop over hits
188     } // NTHTOF < 200
189     // ====== ADC ======
190     for(Int_t i=0; i<48; i++){
191     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));
192     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));
193     if (QevePmt_pC[i] > 2485.) ADCtof[i]= (Int_t)(1758. + 0.54*QevePmt_pC[i]); //assuming a fictional 0.54 ch/pC above ADCsat
194     if (ADCtof[i]>ADCsat) ADCtof[i]=ADCsat;
195     if (QevePmt_pC[i] < pCthres) ADCtof[i]= ADClast;
196     if (ADCtof[i] < 0) ADCtof[i]=ADClast;
197     if (ADCtof[i] > ADClast) ADCtof[i]=ADClast;
198     //if(ADCtof[i]!=4095)cout<<ADCtof[i]<<" ";
199     //if((i+1)%4==0)cout<<endl;
200     }
201     // cin>>ciao;
202    
203     // ====== build TDC coincidence ======
204    
205     Float_t t_coinc = 0;
206     Int_t ilast = 100;
207     for (Int_t ii=0; ii<48;ii++)
208     if (tdc[ii] > t_coinc) {
209     t_coinc = tdc[ii];
210     ilast = ii;
211     }
212    
213     // cout<<ilast<<" "<<t_coinc<<endl;
214     // At t_coinc trigger condition is fulfilled
215    
216     for (Int_t ii=0; ii<48;ii++){
217     // if (tdc[ii] != 0) tdc1[ii] = t_coinc - tdc[ii]; // test 1
218     if (tdc[ii] != 0) tdc1[ii] = t_coinc - tdcpmt[ii]; // test 2
219     tdc1[ii] = tdc1[ii]/tdcres[ii]; // divide by TDC resolution
220     if (tdc[ii] != 0) tdc1[ii] = tdc1[ii] + c3_S[ii]; // add cable length c3
221     } // missing parenthesis inserted! (Silvio)
222    
223     for(Int_t i=0; i<48; i++){
224     if(tdc1[i] != 0.){
225     TDCint[i]=(Int_t)tdc1[i];
226     if (TDCint[i]>4093) TDCint[i]=TDClast; // 18-oct WM
227     if (DEBUG)cout<<i<<" "<<TDCint[i]<<endl;
228     } else
229     TDCint[i]= TDClast;
230     }
231     if (DEBUG)cout<<"-----------"<<endl;
232     //------ use channelmap for ToF: 18-oct WM
233     Int_t channelmap[] = {3,21,11,29,19,45,27,37,36,28,44,20,5,12,13,4,
234     6,47,14,39,22,31,30,23,38,15,46,7,0,33,16,24,
235     8,41,32,40,25,17,34,9,42,1,2,10,18,26,35,43};
236     Int_t ADChelp[48],TDChelp[48];
237     for(Int_t i=0; i<48; i++){
238     Int_t ii=channelmap[i];
239     ADChelp[ii]= ADCtof[i];
240     TDChelp[ii]= TDCint[i];
241     }
242     for(Int_t i=0; i<48; i++){
243     ADCtof[i]= ADChelp[i];
244     TDCint[i]= TDChelp[i];
245     }
246     // ====== write fDataTof =======
247     UChar_t Ctrl3bit[8]={32,0,96,64,160,128,224,192}; // DC (msb in 8 bit word )
248     UChar_t tofBin;
249     for (Int_t j=0; j < 12; j++){ // loop on TDC #12
250     Int_t j12=j*23; // for each TDC 23 bytes (8 bits)
251     fDataTof[j12+0]=0x00; // TDC_ID
252     fDataTof[j12+1]=0x00; // EV_COUNT
253     fDataTof[j12+2]=0x00; // TDC_MASK (1)
254     fDataTof[j12+3]=0x00; // TDC_MASK (2)
255     for (Int_t k=0; k < 4; k++){ // for each TDC 4 channels (ADC+TDC)
256     Int_t jk12=j12+4*k; // ADC,TDC channel (0-47)
257     tofBin =(UChar_t)(ADCtof[k+4*j]/256); // ADC# (msb)
258     fDataTof[jk12+4] = Bin2GrayTof(tofBin,fDataTof[jk12+4]);
259     /* control bits inserted here, after the bin to gray conv - DC*/
260     fDataTof[jk12+4] = Ctrl3bit[2*k] | fDataTof[jk12+4];
261     tofBin=(UChar_t)(ADCtof[k+4*j]%256); // ADC# (lsb)
262     fDataTof[jk12+5] = Bin2GrayTof(tofBin,fDataTof[jk12+5]);
263     tofBin=(UChar_t)(TDCint[k+4*j]/256); // TDC# (msb)
264     fDataTof[jk12+6]=Bin2GrayTof(tofBin,fDataTof[jk12+6]);
265     /* control bits inserted here, after the bin to gray conv - DC*/
266     fDataTof[jk12+6] = Ctrl3bit[2*k+1] | fDataTof[jk12+6];
267     tofBin=(UChar_t)(TDCint[k+4*j]%256); // TDC# (lsb)
268     fDataTof[jk12+7]=Bin2GrayTof(tofBin,fDataTof[jk12+7]);
269     }
270     fDataTof[j12+20]=0x00; // TEMP1
271     fDataTof[j12+21]=0x00; // TEMP2
272     fDataTof[j12+22]= EvaluateCrcTof(pTof); // CRC
273     pTof+=23;
274     }
275     // ====== evaluate trigger variables =======
276     //fDataTrigger: 152 bytes (corrected 30/11/'07 SO - it was 153)
277     // initialization:
278     for (Int_t j=0; j < 152; j++)fDataTrigger[j]=0x00;
279     UChar_t *pTrg=fDataTrigger;
280     // Only the variables with a (*) are modified; the others are set to 0
281     // info given in #bites data + #bites crc
282     // TB_READ_PMT_PLANE : 6 + 1
283     // TB_READ_EVENT_COUNT : 3 + 1 (*)
284     // TB_READ_TRIGGER_RATE : 12 + 1
285     // TB_READ_D_L_TIME : 4 + 1
286     // TB_READ_S4_CAL_COUNT : 4 + 1
287     // TB_READ_PMT_COUNT1 : 48 + 1
288     // TB_READ_PMT_COUNT2 : 48 + 1
289     // TB_READ_PATTERN_BUSY : 8 + 1
290     // TB_READ_PATTERN_TRIGGER: 7 + 1 (*)
291     // TB_READ_TRIGGER_CONF : 2 + 1 (*)
292    
293     // TB_READ_EVENT_COUNT
294     fhBookTree->SetBranchStatus("Ievnt",&Ievnt);
295     UInt_t cTrg = (UInt_t)Ievnt; //counter
296     UInt_t cTrg2 = 0; //counter with bits inverted, according to document
297     //"formato dati provenienti dalla trigger board"
298     for (Int_t i=0; i < 24; i++){ // Use the first 24 bits
299     if (cTrg & (0x1 << i) )
300     cTrg2 = cTrg2 | (0x1 << (24-i));
301     }
302     fDataTrigger[7] = (UChar_t)(cTrg2 >> 16); // 8 MSbits (out of 24)
303     fDataTrigger[8] = (UChar_t)(cTrg2 >> 8); // 8 "middle" bits
304     fDataTrigger[9] = (UChar_t)(cTrg2); // 8 LSbits
305     pTrg=fDataTrigger+7;
306     fDataTrigger[10]=EvaluateCrcTrigger(pTrg, 3);
307    
308     // TB_READ_PATTERN_TRIGGER: bytes 141-148:
309     // PatternTrigMap[i] corresponds to bit i in TB_READ_PATTERN_TRIGGER:
310     // mapping according to documents:
311     // 1. "formato dati provenienti dalla trigger board"
312     // 2. "The ToF quicklook software", Appendix A (Campana, Nagni)
313     Int_t PatternTrigMap[]={29,42,43,1,16,7,17,28,33,41,46,2,15,8,18,27,
314     30,40,44,3,14,9,19,26,32,37,47,4,13,10,20,25,
315     34,31,38,45,5,12,21,24,36,35,39,48,6,11,22,23};
316     for (Int_t i=0; i < 48; i++)
317     //if (ADCtof[i]>thrTrg)
318     if (tdc1[channelmap[i]]!=0)
319     fDataTrigger[147-(Int_t)((PatternTrigMap[i]+1)/8)]=fDataTrigger[147-(Int_t)((PatternTrigMap[i]+1)/8)] | (0x1 << (PatternTrigMap[i]%8));
320     pTrg=fDataTrigger+141;
321     fDataTrigger[148]=EvaluateCrcTrigger(pTrg, 7);
322    
323     // TB_READ_TRIGGER_CONF : set always acq.mode TOF4
324     //
325     // TOF1: S1-S2-S3 (&,|)
326     // TOF4: S2-S3 (&,&)
327     fDataTrigger[149]=0x02;
328     fDataTrigger[150]=0x0;
329     pTrg=fDataTrigger+149;
330     fDataTrigger[151]=EvaluateCrcTrigger(pTrg, 2);
331     }
332    
333    
334     UChar_t Digitizer::Bin2GrayTof(UChar_t binaTOF,UChar_t grayTOF){
335     union graytof_data {
336     UChar_t word;
337     struct bit_field {
338     unsigned b0:1;
339     unsigned b1:1;
340     unsigned b2:1;
341     unsigned b3:1;
342     unsigned b4:1;
343     unsigned b5:1;
344     unsigned b6:1;
345     unsigned b7:1;
346     } bit;
347     } bi,gr;
348     //
349     bi.word = binaTOF;
350     gr.word = grayTOF;
351     //
352     gr.bit.b0 = bi.bit.b1 ^ bi.bit.b0;
353     gr.bit.b1 = bi.bit.b2 ^ bi.bit.b1;
354     gr.bit.b2 = bi.bit.b3 ^ bi.bit.b2;
355     gr.bit.b3 = bi.bit.b3;
356     //
357     /* bin to gray conversion 4 bit per time*/
358     //
359     gr.bit.b4 = bi.bit.b5 ^ bi.bit.b4;
360     gr.bit.b5 = bi.bit.b6 ^ bi.bit.b5;
361     gr.bit.b6 = bi.bit.b7 ^ bi.bit.b6;
362     gr.bit.b7 = bi.bit.b7;
363     //
364     return(gr.word);
365     }
366    
367     UChar_t Digitizer::EvaluateCrcTof(UChar_t *pTof) {
368     Bool_t DEBUG=false;
369     if (DEBUG)
370     return(0x00);
371    
372     UChar_t crcTof=0x00;
373     UChar_t *pc=&crcTof, *pc2;
374     pc2=pTof;
375     for (Int_t jp=0; jp < 23; jp++){
376     //crcTof = crc8(...)
377     Crc8Tof(pc2++,pc);
378     // printf("%2i --- %x\n",jp,crcTof);
379     }
380     return(crcTof);
381     }
382    
383     UChar_t Digitizer::EvaluateCrcTrigger(UChar_t *pTrg, Int_t nb) {
384     Bool_t DEBUG=false;
385     if (DEBUG)
386     return(0x00);
387    
388     UChar_t crcTrg=0x00;
389     UChar_t *pc=&crcTrg, *pc2;
390     pc2=pTrg;
391     for (Int_t jp=0; jp < nb; jp++)
392     Crc8Tof(pc2++,pc);
393     return(crcTrg);
394     }
395    
396     void Digitizer::Crc8Tof(UChar_t *oldCRC, UChar_t *crcTof){
397     union crctof_data {
398     UChar_t word;
399     struct bit_field {
400     unsigned b0:1;
401     unsigned b1:1;
402     unsigned b2:1;
403     unsigned b3:1;
404     unsigned b4:1;
405     unsigned b5:1;
406     unsigned b6:1;
407     unsigned b7:1;
408     } bit;
409     } c,d,r;
410    
411     c.word = *oldCRC;
412     //d.word = *newCRC;
413     d.word = *crcTof;
414     r.word = 0;
415    
416     r.bit.b0 = c.bit.b7 ^ c.bit.b6 ^ c.bit.b0 ^
417     d.bit.b0 ^ d.bit.b6 ^ d.bit.b7;
418    
419     r.bit.b1 = c.bit.b6 ^ c.bit.b1 ^ c.bit.b0 ^
420     d.bit.b0 ^ d.bit.b1 ^ d.bit.b6;
421    
422     r.bit.b2 = c.bit.b6 ^ c.bit.b2 ^ c.bit.b1 ^ c.bit.b0 ^
423     d.bit.b0 ^ d.bit.b1 ^ d.bit.b2 ^ d.bit.b6;
424    
425     r.bit.b3 = c.bit.b7 ^ c.bit.b3 ^ c.bit.b2 ^ c.bit.b1 ^
426     d.bit.b1 ^ d.bit.b2 ^ d.bit.b3 ^ d.bit.b7;
427    
428     r.bit.b4 = c.bit.b4 ^ c.bit.b3 ^ c.bit.b2 ^
429     d.bit.b2 ^ d.bit.b3 ^ d.bit.b4;
430    
431     r.bit.b5 = c.bit.b5 ^ c.bit.b4 ^ c.bit.b3 ^
432     d.bit.b3 ^ d.bit.b4 ^ d.bit.b5;
433    
434     r.bit.b6 = c.bit.b6 ^ c.bit.b5 ^ c.bit.b4 ^
435     d.bit.b4 ^ d.bit.b5 ^ d.bit.b6;
436    
437     r.bit.b7 = c.bit.b7 ^ c.bit.b6 ^ c.bit.b5 ^
438     d.bit.b5 ^ d.bit.b6 ^ d.bit.b7 ;
439    
440     *crcTof=r.word;
441     //return r.word;
442     };
443    
444     void Digitizer::Paddle2Pmt(Int_t plane, Int_t paddle, Int_t *pl, Int_t *pr){
445     //* @param plane (0 - 5)
446     //* @param paddle (plane=0, paddle = 0,...5)
447     //* @param padid (0 - 23)
448     //
449     Int_t padid=-1;
450     Int_t pads[6]={8,6,2,2,3,3};
451     //
452     Int_t somma=0;
453     Int_t np=plane;
454 pamelats 1.3 for(Int_t j=0; j<np; j++)somma+=pads[j];
455 pamelats 1.1 padid=paddle+somma;
456     *pl = padid*2;
457     // *pr = *pr + 1;
458     *pr = *pl + 1; // WM
459     };
460    
461     void Digitizer::LoadTOFCalib(int np,float *atte1,float *atte2,float *lambda1,float *lambda2){
462     stringstream calfile;
463     Int_t error = 0,temp=0;
464     GL_PARAM *glparam = new GL_PARAM();
465     error = glparam->Query_GL_PARAM(3,202,fDbc);
466     calfile.str("");
467     calfile << glparam->PATH.Data() << "/";
468     calfile << glparam->NAME.Data();
469     printf("\n Using TOF calibration file: \n %s\n",calfile.str().c_str());
470     ifstream fileTriggerCalib;
471     fileTriggerCalib.open(calfile.str().c_str());
472     if(!fileTriggerCalib)printf("debug: no trigger calib file!\n");
473     // correct readout WM Oct '07
474     for(Int_t i=0; i<np; i++){
475     fileTriggerCalib >> temp;
476     fileTriggerCalib >> atte1[i];
477     fileTriggerCalib >> lambda1[i];
478     fileTriggerCalib >> atte2[i];
479     fileTriggerCalib >> lambda2[i];
480     fileTriggerCalib >> temp;
481     }
482     fileTriggerCalib.close();
483     //end tof calib
484     }

  ViewVC Help
Powered by ViewVC 1.1.23