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

Annotation of /PamelaDigitizer/DigitizeAC.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Sun Jun 8 06:33:44 2008 UTC (16 years, 5 months ago) by pamelats
Branch: MAIN
CVS Tags: v3r02
Changes since 1.1: +4 -56 lines
*** empty log message ***

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

  ViewVC Help
Powered by ViewVC 1.1.23