/[PAMELA software]/PamVMC/tof/src/PamVMCTofDig.cxx
ViewVC logotype

Annotation of /PamVMC/tof/src/PamVMCTofDig.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (hide annotations) (download)
Fri Jun 12 18:39:47 2009 UTC (15 years, 5 months ago) by pam-rm2
Branch: MAIN
CVS Tags: v1r0
Changes since 1.1: +32 -11 lines
- Introduced user-defined names of output files and random seeds number.
Users can do it use options of PamVMCApplication constructor:
PamVMCApplication(const char* name,  const char *title, const char*
filename="pamtest", Int_t seed=0).
The Random object that I use is TRandom3 object which has astronomical
large period (in case of default initialization 0). All random generators
in the code use this object by calling of gRandom singleton which keeps
it.

- Corrected TOF digitization routine. No problems with TDC hits due to
hadronic interactions anymore.

- Some small changes was done to compile code under Root 5.23. +
geant4_vmc v. 2.6 without any warnings

- Some classes of PamG4RunConfiguartion was changed for geant4_vmc v.
2.6.Some obsolete classes was deleted as soon as developers implemented
regions.

- Navigation was changed from "geomRootToGeant4" to "geomRoot", because on
VMC web page written that as soon as Geant4 has no option ONLY/MANY
translation of overlapped geometry to Geant4 through VGM could be wrong.
I'd like to stay with Root navigation:
http://root.cern.ch/root/vmc/Geant4VMC.html. This should be default
option.

- New Tracker digitization routine written by Sergio was implemented

- PamVMC again became compatible with geant4_vmc v.2.5 and ROOT 5.20.
 The problem was that ROOT developers introduced in TVirtualMC class a new
method SetMagField and new base class:TVirtualMagField from which
user-defined classes shoukd be derived

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

  ViewVC Help
Powered by ViewVC 1.1.23