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

Annotation of /PamelaDigitizer/DigitizeAC.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations) (download)
Wed Oct 15 14:03:15 2008 UTC (16 years, 1 month ago) by pamelats
Branch: MAIN
CVS Tags: v3r04, v3r05, v3r03
Changes since 1.2: +53 -101 lines
Cambiamenti principali: TOF, AC; cambiamenti di struttura (tutti *h esterni si trovano in Digitizer.h)

1 pamelats 1.1 #include "Digitizer.h"
2    
3 pamelats 1.3 void Digitizer::DigitizeAC() {
4 pamelats 1.1 // created: J. Conrad, KTH
5     // modified: S. Orsi, INFN Roma2
6     // fDataAC[0-63]: main AC board
7     // fDataAC[64-127]: extra AC board (identical to main board, for now)
8     // We activate all branches. Once the digitization algorithm is determined
9     // only the branches that involve needed information will be activated
10 pamelats 1.3
11     // Threshold: thr=0.8 MeV.
12     Float_t thr = 8e-4;
13     Int_t nReg=6,i;
14 pamelats 1.1 fDataAC[0] = 0xACAC;
15     fDataAC[64]= 0xACAC;
16     fDataAC[1] = 0xAC11;
17     fDataAC[65] = 0xAC22;
18 pamelats 1.3
19 pamelats 1.1 // the third word is a status word (dummy: "no errors are present in the AC boards")
20     fDataAC[2] = 0xFFFF; //FFEF?
21     fDataAC[66] = 0xFFFF;
22     // FPGA Registers (dummy)
23 pamelats 1.3 for (i=0; i<=nReg; i++){
24 pamelats 1.1 fDataAC[i+4] = 0xFFFF;
25     fDataAC[i+68] = 0xFFFF;
26     }
27     // the last word is a CRC
28     // Dummy for the time being, but it might need to be calculated in the end
29     fDataAC[63] = 0xABCD;
30     fDataAC[127] = 0xABCD;
31    
32     // shift registers (moved to the end of the routine)
33    
34     Int_t evntLSB=(UShort_t)Ievnt;
35     Int_t evntMSB=Ievnt >> 16;
36    
37     // singles counters are dummy
38 pamelats 1.3 for(i=0; i<=15; i++){ //SO Oct '07:
39 pamelats 1.1 fDataAC[i+26] = evntLSB;
40     fDataAC[i+90] = evntLSB;
41 pamelats 1.3 }
42     for(i=0; i<=7; i++){
43 pamelats 1.1 fDataAC[i+42] = evntLSB;
44     fDataAC[i+106] = evntLSB;
45 pamelats 1.3 }
46 pamelats 1.1 // increments for every trigger might be needed at some point.
47     // dummy for now
48     fDataAC[50] = 0x0000;
49     fDataAC[114] = 0x0000;
50    
51     // dummy FPGA clock (increment by 1 at each event)
52 pamelats 1.3 if(Ievnt<=0xFFFF){
53 pamelats 1.1 fDataAC[51] = 0x0000;
54     fDataAC[52] = Ievnt;
55     fDataAC[115] = 0x0000;
56     fDataAC[116] = Ievnt;
57 pamelats 1.3 }
58     else{
59 pamelats 1.1 fDataAC[51] = evntMSB;
60     fDataAC[52] = evntLSB;
61     fDataAC[115] = fDataAC[51];
62     fDataAC[116] = fDataAC[52];
63     }
64     // dummy temperatures
65     fDataAC[53] = 0x0000;
66     fDataAC[54] = 0x0000;
67     fDataAC[117] = 0x0000;
68     fDataAC[118] = 0x0000;
69     // dummy DAC thresholds
70 pamelats 1.3 for(i=0; i<=7; i++){
71 pamelats 1.1 fDataAC[i+55] = 0x1A13;
72     fDataAC[i+119] = 0x1A13;
73     }
74 pamelats 1.3 // In this simpliefied approach we will assume that once a particle releases > 0.5 mip in one of the 12 AC detectors it will fire. We will furthermore assume that both cards read out identical data.
75 pamelats 1.1
76 pamelats 1.3 // If you develop your digitization algorithm, you should start by identifying the information present in level2 (post-darth-vader) data.
77 pamelats 1.1
78 pamelats 1.3 Float_t SumEcat[4],SumEcas[4],SumEcard[4];
79     for(i=0;i<4;i++){
80     SumEcat[i]=0.;
81     SumEcas[i]=0.;
82     SumEcard[i]=0.;
83     }
84 pamelats 1.1 // energy dependence on position (see file AcFitOutputDistancePmt.C by S.Orsi)
85     // based on J.Lundquist's calculations (PhD thesis, page 94)
86     // function: [0]+[1]*atan([2]/(x+1)), where the 3 parameters are:
87     // 8.25470e-01 +- 1.79489e-02
88     // 6.41609e-01 +- 2.65846e-02
89     // 9.81177e+00 +- 1.21284e+00
90     // hp: 1 minimum ionising particle at 35cm from the PMT releases 1mip
91    
92     // PMT positions: x,y,z: (average position of the 2 PMTs)
93     Float_t posCasPmt[4][3]={{28.308, -17.168, 63.644}, // 1 - CAS CPU: x,y,z
94     {18.893, 24.913, 63.644}, // 2 - CAS DCDC
95     {-24.307, 17.162, 63.644}, // 3 - CAS VME
96     {-17.765, -28.300, 63.644}}; // 4 - CAS IPM
97     Float_t dAC=0.; // distance from PMT
98 pamelats 1.3
99     if(Nthcat>*ncat){
100     cout<<"*** ERROR AC! Nthcat= "<<Nthcat<<" out of range! "<<endl;
101     for(i=0;i<4;i++)SumEcat[i]=2*thr;
102     }
103     else{
104     for(i=0;i<Nthcat;i++){
105     if(Icat[i]>0 && Icat[i]<5)SumEcat[Icat[i]-1]+=Erelcat[i];
106     }
107     }
108     if(Nthcas>*ncas){
109     cout<<"*** ERROR AC! Nthcas= "<<Nthcas<<" out of range!"<<endl;
110     for(i=0;i<4;i++)SumEcas[i]=2*thr;
111     }
112     else{
113     for (i=0;i<Nthcas;i++){
114     if(Icas[i]>0 && Icas[i]<5){
115     dAC=sqrt(pow((Xincas[i]+Xoutcas[i])/2 - posCasPmt[Icas[i]-1][0],2) + pow((Yincas[i]+Youtcas[i])/2 - posCasPmt[Icas[i]-1][1],2) + pow((Zincas[i]+Zoutcas[i])/2 - posCasPmt[Icas[i]-1][2],2));
116     SumEcas[Icas[i]-1] += Erelcas[i]*attenAC->Eval(dAC);
117     }
118     }
119     }
120     if(Nthcard>*ncar){
121     cout<<"*** ERROR AC! Nthcard= "<<Nthcard<<" out of range!"<<endl;
122     for(i=0;i<4;i++)SumEcard[i]=2*thr;
123     }
124     else{
125     for(Int_t k= 0;k<Nthcard;k++){
126     if(Icard[i]>0 && Icard[i]<5)SumEcard[Icard[k]-1] += Erelcard[k];
127 pamelats 1.1 }
128 pamelats 1.3 }
129 pamelats 1.1
130     // channel mapping Hit Map
131     // 1 CARD4 0 LSB
132     // 2 CAT2 0
133     // 3 CAS1 0
134     // 4 NC 0
135     // 5 CARD2 0
136     // 6 CAT4 1
137     // 7 CAS4 0
138     // 8 NC 0
139     // 9 CARD3 0
140     // 10 CAT3 0
141     // 11 CAS3 0
142     // 12 NC 0
143     // 13 CARD1 0
144     // 14 CAT1 0
145     // 15 CAS2 0
146     // 16 NC 0 MSB
147    
148     // In the first version only the hit-map is filled, not the SR.
149    
150     fDataAC[3] = 0x0000;
151    
152     if (SumEcas[0] > thr) fDataAC[3] = 0x0004;
153     if (SumEcas[1] > thr) fDataAC[3] += 0x4000;
154     if (SumEcas[2] > thr) fDataAC[3] += 0x0400;
155     if (SumEcas[3] > thr) fDataAC[3] += 0x0040;
156    
157     if (SumEcat[0] > thr) fDataAC[3] += 0x2000;
158     if (SumEcat[1] > thr) fDataAC[3] += 0x0002;
159     if (SumEcat[2] > thr) fDataAC[3] += 0x0200;
160     if (SumEcat[3] > thr) fDataAC[3] += 0x0020;
161    
162     if (SumEcard[0] > thr) fDataAC[3] += 0x1000;
163     if (SumEcard[1] > thr) fDataAC[3] += 0x0010;
164     if (SumEcard[2] > thr) fDataAC[3] += 0x0100;
165     if (SumEcard[3] > thr) fDataAC[3] += 0x0001;
166    
167     fDataAC[67] = fDataAC[3];
168    
169     // shift registers
170     // the central bin is equal to the hitmap, all other bins in the shift register are 0
171     for (UInt_t i=0; i<=15; i++){
172     fDataAC[i+11] = 0x0000;
173     fDataAC[i+75] = 0x0000;
174     }
175     fDataAC[18] = fDataAC[3];
176     fDataAC[82] = fDataAC[3];
177    
178     // for (Int_t i=0; i<fACbuffer; i++){
179     // printf("%0x ",fDataAC[i]);
180     // if ((i+1)%8 ==0) cout << endl;
181     // }
182     };

  ViewVC Help
Powered by ViewVC 1.1.23