]>
Commit | Line | Data |
---|---|---|
d5d0cab2 | 1 | #if !defined(__CINT__) || defined(__MAKECINT__) |
2 | #include "AliCDBManager.h" | |
3 | #include "AliITSCalibrationSDD.h" | |
4 | #include "AliITSresponseSDD.h" | |
5 | #include "AliCDBMetaData.h" | |
6 | #include "AliCDBStorage.h" | |
7 | #include "AliCDBId.h" | |
8 | #include "AliCDBPath.h" | |
9 | #include "AliCDBEntry.h" | |
10 | #include <TObjArray.h> | |
11 | #include <TRandom3.h> | |
12 | #endif | |
13 | ||
14 | void StoreCalibSDD(Int_t firstRun=0,Int_t lastRun=9999999 ){ | |
15 | /////////////////////////////////////////////////////////////////////// | |
16 | // Macro to generate and store the calibration files for SDD // | |
17 | // Generates: // | |
18 | // 1 file with 260 AliITSCalibrationSDD objects with // | |
19 | // baselines, noise, gain, drift speed for each module (CalibSDD) // | |
20 | // 1 file with the AliITSrespionseSDD object (RespSDD) // | |
21 | /////////////////////////////////////////////////////////////////////// | |
22 | ||
23 | if(!AliCDBManager::Instance()->IsDefaultStorageSet()) { | |
24 | AliCDBManager::Instance()->SetDefaultStorage("local://OCDB"); | |
25 | } | |
26 | ||
27 | ||
28 | AliCDBMetaData *md1= new AliCDBMetaData(); // metaData describing the object | |
29 | md1->SetObjectClassName("AliITSCalibration"); | |
30 | md1->SetResponsible("Elisabetta Crescio, Francesco Prino"); | |
31 | md1->SetBeamPeriod(0); | |
32 | md1->SetAliRootVersion("Head 20 nov. 2007"); //root version | |
33 | md1->SetComment("This is a test"); | |
34 | // TObject* str; | |
35 | // md1->SetProperty("key1",str); | |
36 | ||
37 | AliCDBMetaData *md2 = new AliCDBMetaData(); | |
38 | md2->SetObjectClassName("AliITSresponse"); | |
39 | md2->SetResponsible("Elisabetta Crescio, Francesco Prino"); | |
40 | md2->SetBeamPeriod(0); | |
41 | md2->SetAliRootVersion("Head 20 nov. 2007"); //root version | |
42 | md2->SetComment("This is a test"); | |
43 | ||
44 | ||
45 | AliCDBId idCalSDD("ITS/Calib/CalibSDD",firstRun, lastRun); | |
46 | TObjArray respSDD(260); | |
47 | respSDD.SetOwner(kFALSE); | |
48 | ||
49 | ||
50 | ||
51 | AliCDBId idRespSDD("ITS/Calib/RespSDD",firstRun, lastRun); | |
52 | AliITSresponseSDD* rd = new AliITSresponseSDD(); | |
53 | const Int_t nData = 209; | |
54 | Int_t anodeUp[209] = {0,36,0,12,20,32,0,0,12,76,28,8,16,0,0,0,8,0,0,0,20,4,0,0,0,0,0,0 | |
55 | ,0,0,8,0,0,0,0,0,0,0,0,0,0,0,12,0,8,0,4,4,0,160,0,0,0,252,16,0,8,8 | |
56 | ,0,0,12,0,0,0,12,0,15,20,0,0,0,0,0,0,0,12,12,0,0,0,0,0,8,8,3,240,212 | |
57 | ,12,0,8,0,12,0,0,12,0,8,24,0,0,12,0,0,0,0,40,0,0,40,12,28,0,0,12,12 | |
58 | ,0,0,0,0,20,0,0,0,12,0,24,0,0,0,0,0,0,0,8,16,0,0,0,0,0,256,0,0,0,0,0,20 | |
59 | ,0,12,0,0,0,0,24,0,0,0,0,0,0,0,20,0,0,16,0,0,0,0,24,0,0,0,8,0,16,40,0 | |
60 | ,0,0,0,0,0,0,0,0,4,0,32,12,8,28,0,76,0,0,0,12,60,144,0,0,0,0,16,0,16,0,3 }; | |
61 | ||
62 | Int_t anodeDown[209] = {0,8,0,48,0,12,0,8,0,80,12,0,4,4,0,0,24,0,0,20,0,0,0,0,20,0,0,0,0,0,0,0 | |
63 | ,0,0,0,0,4,0,24,4,0,0,8,0,0,36,20,0,12,236,0,0,12,256,16,8,32,4,0,0,24 | |
64 | ,24,10,0,16,8,0,2,40,0,0,0,24,0,0,0,8,0,0,0,0,0,32,240,0,92,60,28,8,0,0 | |
65 | ,2,0,0,0,0,12,48,0,0,0,0,0,36,11,12,0,0,0,12,12,11,0,20,0,0,12,20,0,0,4 | |
66 | ,0,8,12,0,0,0,16,16,0,32,72,12,0,88,20,16,112,8,0,244,28,256,28,0,24,236 | |
67 | ,56,0,68,0,4,20,208,20,12,4,28,12,0,0,20,12,0,100,0,16,8,8,0,24,16,0,12,12 | |
68 | ,16,0,16,20,0,28,0,8,24,0,12,8,4,40,0,104,96,32,140,20,12,8,20,24,16,16,20 | |
69 | ,8,140,96,0,32,20,44}; | |
70 | ||
71 | ||
72 | Float_t drVelParam[4]={7.75,0.002344,-0.000009,0}; | |
73 | Float_t edrVelParam[4]={0,0,0,0}; | |
74 | Float_t drVel[4]; | |
75 | TRandom3 *gran = new TRandom3(); | |
76 | ||
77 | for(Int_t mod=0;mod<260;mod++){ | |
78 | AliITSCalibrationSDD* resd = new AliITSCalibrationSDD("simulated"); | |
79 | ||
d5d0cab2 | 80 | Int_t nBadUp = 0; |
81 | Int_t nBadDown = 0; | |
82 | ||
83 | ||
84 | // gain | |
85 | for(Int_t iWing=0; iWing<2;iWing++){ | |
86 | for(Int_t iChip=0; iChip<4;iChip++){ | |
87 | Float_t chipgain=gran->Gaus(1.,0.1); | |
88 | if(chipgain<0.1) chipgain=0.1; | |
89 | for(Int_t iChan=0; iChan<64;iChan++){ | |
90 | Float_t gain=gran->Gaus(chipgain,0.01); | |
91 | if(gain<0.1) gain=0.1; | |
92 | resd->SetGain(gain,iWing,iChip,iChan); | |
93 | } | |
94 | } | |
95 | } | |
96 | ||
97 | // bad channels | |
98 | Int_t count=0; | |
99 | do { | |
100 | Int_t ranMod = Int_t(nData*gran->Uniform()); | |
101 | nBadUp = anodeUp[ranMod]; | |
102 | nBadDown = anodeDown[ranMod]; | |
103 | }while (nBadUp+nBadDown>25); | |
104 | ||
105 | resd->SetDeadChannels(nBadDown+nBadUp); | |
106 | Int_t remainingBad = nBadDown; | |
107 | while (remainingBad>0) { | |
108 | Int_t nBadChannel; | |
109 | if (remainingBad<5) { | |
110 | nBadChannel = remainingBad; | |
111 | } else { | |
112 | Int_t width = remainingBad-(5-1); | |
113 | if (width>4) width = 4; | |
114 | nBadChannel = 5 + Int_t(width*gran->Uniform()); | |
115 | } | |
116 | ||
117 | ||
118 | Int_t iChannelPos = Int_t( (4*64-nBadChannel)*gran->Uniform() ); | |
119 | // Int_t iChip = iChannelPos/64; | |
120 | // Int_t iChan = iChannelPos - iChip*64; | |
121 | if(resd->IsBadChannel(iChannelPos)) continue; | |
122 | Int_t *clus = new Int_t[nBadChannel]; | |
123 | Int_t ich = iChannelPos; | |
124 | for(Int_t i=0;i<nBadChannel;i++){ | |
125 | clus[i]=ich; | |
126 | ich++; | |
127 | } | |
128 | ||
129 | for(Int_t i=0;i<nBadChannel;i++){ | |
130 | if(resd->IsBadChannel(clus[i])) break; | |
131 | resd->SetBadChannel(count,clus[i]); | |
132 | count++; | |
133 | } | |
134 | remainingBad -= nBadChannel; | |
135 | delete [] clus; | |
136 | } | |
137 | ||
138 | // May happen that, due to overlapping clusters, we | |
139 | // have less bad channels than requested | |
140 | // Let's put the remaining one per one ... | |
141 | Int_t nSeToBad = 0; | |
142 | for (Int_t i=0; i<4; i++){ | |
143 | for(Int_t j=0;j<64;j++){ | |
144 | if (resd->Gain(0,i,j)<0.0001) nSeToBad++; | |
145 | } | |
146 | } | |
147 | while (nSeToBad<nBadDown) { | |
148 | Int_t i = Int_t(4*64*gran->Uniform()); | |
149 | if(resd->IsBadChannel(i)==kFALSE){ | |
150 | resd->SetBadChannel(count,i); | |
151 | count++; | |
152 | nSeToBad++; | |
153 | } | |
154 | } | |
155 | ||
156 | remainingBad = nBadUp; | |
157 | while (remainingBad>0) { | |
158 | Int_t nBadChannel; | |
159 | if (remainingBad<5) { | |
160 | nBadChannel = remainingBad; | |
161 | } else { | |
162 | Int_t width = remainingBad-(5-1); | |
163 | if (width>4) width = 4; | |
164 | nBadChannel = 5 + Int_t(width*gran->Uniform()); | |
165 | } | |
166 | ||
167 | Int_t iChannelPos = Int_t( (4*64-nBadChannel)*gran->Uniform() ); | |
168 | // Int_t iChip = iChannelPos/64; | |
169 | // Int_t iChan = iChannelPos - iChip*64; | |
170 | if(resd->IsBadChannel(iChannelPos)) continue; | |
171 | ||
172 | Int_t *clus = new Int_t[nBadChannel]; | |
173 | Int_t ich = iChannelPos; | |
174 | for(Int_t i=0;i<nBadChannel;i++){ | |
175 | clus[i]=ich+256; | |
176 | ich++; | |
177 | } | |
178 | for(Int_t i=0;i<nBadChannel;i++){ | |
179 | ||
180 | if(resd->IsBadChannel(clus[i])) break; | |
181 | resd->SetBadChannel(count,clus[i]); | |
182 | count++; | |
183 | ||
184 | } | |
185 | remainingBad -= nBadChannel; | |
186 | delete [] clus; | |
187 | } | |
188 | ||
189 | nSeToBad = 0; | |
190 | for (Int_t i=0; i<4; i++){ | |
191 | for(Int_t j=0;j<64;j++){ | |
192 | if (resd->Gain(1,i,j)<0.0001) nSeToBad++; | |
193 | } | |
194 | } | |
195 | ||
196 | while (nSeToBad<nBadUp) { | |
197 | Int_t i = Int_t(4*64*gran->Uniform()); | |
198 | if(resd->IsBadChannel(i+256)==kFALSE){ | |
199 | resd->SetBadChannel(count,i+256); | |
200 | count++; | |
201 | nSeToBad++; | |
202 | } | |
203 | } | |
204 | ||
205 | //baselines | |
206 | /* | |
207 | for(Int_t nan=0;nan<512;nan++){ | |
208 | ||
209 | Int_t baseline = resd->GetBaseline(0); | |
210 | Double_t noise = resd->GetNoiseAfterElectronics(0); | |
211 | resd->SetBaseline(nan,baseline+(Int_t)gran->Gaus(0,4)); //baseline di def. e' 20, ho messo variazione di 4 | |
212 | resd->SetNoiseAfterElectronics(nan,noise+(Double_t)gran->Gaus(0,0.6)); | |
213 | ||
214 | } | |
215 | */ | |
216 | ||
217 | ||
218 | if(mod==88) resd->SetDead(); | |
219 | respSDD.Add(resd); | |
220 | printf("Added module %d\n",mod); | |
221 | } | |
222 | ||
223 | FILE* out = fopen("deadchannels.dat","w"); | |
224 | for(Int_t i=0;i<260;i++){ | |
225 | fprintf(out,"MODULE=%d\n",i); | |
226 | AliITSCalibrationSDD* cl = (AliITSCalibrationSDD*)respSDD.At(i); | |
227 | Int_t ndead=cl->GetDeadChannels(); | |
228 | fprintf(out,"n %d\n",ndead); | |
229 | for(Int_t n=0;n<ndead;n++){ | |
230 | fprintf(out,"%d\n",cl->GetBadChannel(n)); | |
231 | } | |
232 | } | |
233 | fclose(out); | |
234 | AliCDBManager::Instance()->GetDefaultStorage()->Put(&respSDD, idCalSDD, md1); | |
235 | AliCDBManager::Instance()->GetDefaultStorage()->Put(rd, idRespSDD, md2); | |
236 | } |