]>
Commit | Line | Data |
---|---|---|
1 | ////////////////////////////////////////////////////////////////////////////// | |
2 | // | |
3 | // * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
4 | // * * | |
5 | // * Author: The ALICE Off-line Project. * | |
6 | // * Contributors are mentioned in the code where appropriate. * | |
7 | // * * | |
8 | // * Permission to use, copy, modify and distribute this software and its * | |
9 | // * documentation strictly for non-commercial purposes is hereby granted * | |
10 | // * without fee, provided that the above copyright notice appears in all * | |
11 | // * copies and that both the copyright notice and this permission notice * | |
12 | // * appear in the supporting documentation. The authors make no claims * | |
13 | // * about the suitability of this software for any purpose. It is * | |
14 | // * provided "as is" without express or implied warranty. * | |
15 | // **************************************************************************/ | |
16 | // | |
17 | ////////////////////////////////////////////////////////////////////////////// | |
18 | // Author : Z. Ahamed | |
19 | ||
20 | #include "TF1.h" | |
21 | #include "TFile.h" | |
22 | #include "TObjString.h" | |
23 | #include "TROOT.h" | |
24 | #include "TClonesArray.h" | |
25 | #include "TH1F.h" | |
26 | #include "TObjArray.h" | |
27 | ||
28 | // --- Standard library --- | |
29 | ||
30 | // --- AliRoot header files --- | |
31 | #include "AliLog.h" | |
32 | #include "AliRawReaderFile.h" | |
33 | #include "AliPMDCalibrator.h" | |
34 | #include "AliRawReaderDate.h" | |
35 | #include "AliPMDRawStream.h" | |
36 | #include "AliPMDCalibData.h" | |
37 | #include "AliPMDddldata.h" | |
38 | #include "AliCDBManager.h" | |
39 | #include "AliCDBId.h" | |
40 | #include "AliCDBMetaData.h" | |
41 | #include "AliDAQ.h" | |
42 | ||
43 | ClassImp(AliPMDCalibrator) | |
44 | ||
45 | const Int_t kDet =2; | |
46 | const Int_t kMaxSMN = 24; | |
47 | const Int_t kMaxRow =96; | |
48 | const Int_t kMaxCol =96; | |
49 | ||
50 | AliPMDCalibrator::AliPMDCalibrator() | |
51 | { | |
52 | // Standard Constructor | |
53 | ||
54 | fCalibData = new AliPMDCalibData(); | |
55 | ||
56 | for(Int_t d=0;d<2;d++) | |
57 | { | |
58 | for(Int_t i=0;i<24;i++) | |
59 | { | |
60 | fHsmIso[d][i] = NULL ; | |
61 | for(Int_t j=0;j<96;j++) | |
62 | { | |
63 | for(Int_t k=0;k<96;k++) | |
64 | { | |
65 | fGainFact[d][i][j][k] = 0.0; | |
66 | fHadcIso[d][i][j][k] = NULL; | |
67 | } | |
68 | } | |
69 | } | |
70 | } | |
71 | } | |
72 | // ------------------------------------------------------------------------ // | |
73 | ||
74 | AliPMDCalibrator::~AliPMDCalibrator() | |
75 | { | |
76 | // dtor | |
77 | if(fHsmIso) delete fHsmIso ; | |
78 | if(fHadcIso) delete fHadcIso ; | |
79 | delete fCalibData; | |
80 | } | |
81 | // ------------------------------------------------------------------------ // | |
82 | ||
83 | void AliPMDCalibrator::Exec() | |
84 | { | |
85 | // reads parameters and does the calibration | |
86 | CalculateIsoCell() ; | |
87 | ||
88 | } | |
89 | // ------------------------------------------------------------------------ // | |
90 | ||
91 | void AliPMDCalibrator::Init() | |
92 | { | |
93 | // intializes everything | |
94 | char hname[kMaxSMN]; | |
95 | char hname24[kMaxSMN]; | |
96 | char hnameiso[120]; | |
97 | char htitle1[120]; | |
98 | ||
99 | for(Int_t d=0;d<2;d++) { | |
100 | for(Int_t i1=0; i1<kMaxSMN;i1++) { | |
101 | sprintf(hname,"det_%d_iso_sm_%2d",d,i1); | |
102 | sprintf(hname24,"det_%d_iso_sm_%2d",d,i1); | |
103 | fHsmIso[d][i1]= new TH1F(hname,hname24,100,0,1000); | |
104 | for(Int_t j1 = 0; j1 < kMaxRow; j1++) { | |
105 | for(Int_t k1 = 0; k1 < kMaxCol; k1++) { | |
106 | sprintf(hnameiso,"Isolated Cell ADC for det_%d_cell_sm%d_row%d_col%d" | |
107 | ,d,i1,j1,k1); | |
108 | sprintf(htitle1,"Isolated Cell ADC for det_%d_cell_sm%d_row%d_col%d" | |
109 | ,d,i1,j1,k1); | |
110 | ||
111 | TObject *old=gDirectory->GetList()->FindObject(hnameiso); | |
112 | if (old) gDirectory->GetList()->Remove(old); | |
113 | fHadcIso[d][i1][j1][k1] = new TH1F(hnameiso,htitle1,100,0.,4000.); | |
114 | } | |
115 | } | |
116 | } | |
117 | } | |
118 | ||
119 | } | |
120 | ||
121 | // ------------------------------------------------------------------------ // | |
122 | ||
123 | void AliPMDCalibrator::CalculateIsoCell() | |
124 | { | |
125 | // Calculates the ADC of isolated cell | |
126 | ||
127 | TObjArray pmdddlcont; | |
128 | const Int_t kDDL = AliDAQ::NumberOfDdls("PMD"); | |
129 | const Int_t kMaxHit = 60000; | |
130 | const Int_t kCellNeighbour = 6; | |
131 | ||
132 | Int_t neibx[6] = {1,0,-1,-1,0,1}; | |
133 | Int_t neiby[6] = {0,1,1,0,-1,-1}; | |
134 | ||
135 | Int_t id1,jd1; //neighbour row/col | |
136 | Int_t countisocell = 0 ;//number of isilated cell | |
137 | Int_t isocount; //number of neighbours with 0 signal | |
138 | Int_t d1[kDet][kMaxSMN][kMaxRow][kMaxCol]; | |
139 | Int_t ch[kDet][kMaxSMN][kMaxRow][kMaxCol]; | |
140 | Int_t maxhit; | |
141 | ||
142 | ||
143 | Int_t det[kMaxHit],smn[kMaxHit]; | |
144 | Int_t row[kMaxHit],col[kMaxHit],sig[kMaxHit],chno[kMaxHit]; | |
145 | ||
146 | for(Int_t idet = 0; idet < kDet; idet++) | |
147 | { | |
148 | for(Int_t ismn = 0; ismn < kMaxSMN; ismn++) | |
149 | { | |
150 | for(Int_t irow = 0; irow < kMaxRow; irow++) | |
151 | { | |
152 | for(Int_t icol = 0; icol < kMaxCol; icol++) | |
153 | { | |
154 | d1[idet][ismn][irow][icol] = 0; | |
155 | ch[idet][ismn][irow][icol] = 0; | |
156 | } | |
157 | } | |
158 | } | |
159 | } | |
160 | //accessing raw data | |
161 | AliRawReaderFile reader("."); | |
162 | AliPMDRawStream stream(&reader); | |
163 | while(reader.NextEvent()) | |
164 | { | |
165 | // printf("In CalculateIsoCell before while(stream.Next()), ...\n"); | |
166 | ||
167 | /* | |
168 | while(stream.Next()) | |
169 | { | |
170 | Int_t idet = stream.GetDetector(); | |
171 | Int_t ismn = stream.GetSMN(); | |
172 | Int_t ichno = stream.GetChannel(); | |
173 | Int_t irow = stream.GetRow(); | |
174 | Int_t icol = stream.GetColumn(); | |
175 | Int_t isig = stream.GetSignal(); | |
176 | ||
177 | if (isig>0) | |
178 | { | |
179 | d1[idet][ismn][irow][icol] = isig; | |
180 | ch[idet][ismn][irow][icol] = ichno; | |
181 | } | |
182 | } | |
183 | */ | |
184 | // New PMD Reader is plugged in | |
185 | ||
186 | for (Int_t iddl = 0; iddl < kDDL; iddl++) | |
187 | { | |
188 | reader.Select("PMD", iddl, iddl); | |
189 | stream.DdlData(&pmdddlcont); | |
190 | ||
191 | Int_t ientries = pmdddlcont.GetEntries(); | |
192 | for (Int_t ient = 0; ient < ientries; ient++) | |
193 | { | |
194 | AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient); | |
195 | ||
196 | Int_t idet = pmdddl->GetDetector(); | |
197 | Int_t ismn = pmdddl->GetSMN(); | |
198 | //Int_t mcm = pmdddl->GetMCM(); | |
199 | Int_t ichno = pmdddl->GetChannel(); | |
200 | Int_t irow = pmdddl->GetRow(); | |
201 | Int_t icol = pmdddl->GetColumn(); | |
202 | Int_t isig = pmdddl->GetSignal(); | |
203 | ||
204 | if (isig>0) | |
205 | { | |
206 | d1[idet][ismn][irow][icol] = isig; | |
207 | ch[idet][ismn][irow][icol] = ichno; | |
208 | } | |
209 | } | |
210 | pmdddlcont.Clear(); | |
211 | } | |
212 | ||
213 | ||
214 | maxhit = 0; | |
215 | ||
216 | for(Int_t idet=0; idet < kDet; idet++) | |
217 | { | |
218 | for(Int_t ismn = 0; ismn < kMaxSMN; ismn++) | |
219 | { | |
220 | for(Int_t irow = 0; irow < kMaxRow; irow++) | |
221 | { | |
222 | for(Int_t icol = 0; icol < kMaxCol; icol++) | |
223 | { | |
224 | ||
225 | //printf("d1[%d][%d][%d][%d]=%d\n", | |
226 | //det,ksmn,irow,jcol, d1[det][ksmn][irow][jcol] ); | |
227 | //printf("ch[%d][%d][%d][%d]=%d\n", | |
228 | //det,ksmn,irow,jcol, ch[det][ksmn][irow][jcol] ); | |
229 | ||
230 | if(d1[idet][ismn][irow][icol] > 0) | |
231 | { | |
232 | isocount = 0; | |
233 | for(Int_t ii = 0; ii < kCellNeighbour; ii++) | |
234 | { | |
235 | id1 = irow + neibx[ii]; | |
236 | jd1 = icol + neiby[ii]; | |
237 | if(d1[idet][ismn][id1][jd1] == 0) | |
238 | { | |
239 | isocount++; | |
240 | if(isocount == kCellNeighbour) | |
241 | { | |
242 | countisocell++; | |
243 | det[maxhit] = idet; | |
244 | smn[maxhit] = ismn; | |
245 | row[maxhit] = irow; | |
246 | col[maxhit] = icol; | |
247 | sig[maxhit] = d1[idet][ismn][irow][icol]; | |
248 | chno[maxhit] = ch[idet][ismn][irow][icol]; | |
249 | maxhit++; | |
250 | fHsmIso[idet][ismn]->Fill(d1[idet][ismn][irow][icol]); | |
251 | fHadcIso[idet][ismn][irow][icol]->Fill(d1[idet][ismn][irow][icol]); | |
252 | } | |
253 | } | |
254 | } // neigh cell cond. | |
255 | } // d>0 cond. | |
256 | } | |
257 | } | |
258 | } | |
259 | } //event loop | |
260 | } | |
261 | Double_t histMean[2][24]; | |
262 | Double_t isoMean[2][24][96][96]; | |
263 | for(Int_t d1=0;d1<2;d1++) | |
264 | { | |
265 | for(Int_t i1=0;i1<24;i1++) | |
266 | { | |
267 | histMean[d1][i1]= fHsmIso[d1][i1]->GetMean(); | |
268 | for(Int_t j1=0;j1<96;j1++) | |
269 | { | |
270 | for(Int_t k1=0;k1<96;k1++) | |
271 | { | |
272 | isoMean[d1][i1][j1][k1]=fHadcIso[d1][i1][j1][k1]->GetMean(); | |
273 | if(isoMean[d1][i1][j1][k1]>0.0 && histMean[d1][i1]>0.0) | |
274 | { | |
275 | fGainFact[d1][i1][j1][k1]=isoMean[d1][i1][k1][j1]/histMean[d1][i1]; | |
276 | Float_t gain=fGainFact[d1][i1][j1][k1]; | |
277 | fCalibData->SetGainFact(d1,i1,j1,k1,gain); | |
278 | } | |
279 | } | |
280 | } | |
281 | } | |
282 | } | |
283 | ||
284 | } | |
285 | // ------------------------------------------------------------------------ // | |
286 | Bool_t AliPMDCalibrator::Store() | |
287 | { | |
288 | AliCDBManager *man = AliCDBManager::Instance(); | |
289 | man->SetDefaultStorage("local://$ALICE_ROOT"); | |
290 | AliCDBId id("PMD/Calib/Data",0,0); | |
291 | AliCDBMetaData md; | |
292 | md.SetResponsible("Zubayer"); | |
293 | md.SetBeamPeriod(0); | |
294 | md.SetAliRootVersion("28.02.2006"); | |
295 | md.SetComment("Test"); | |
296 | ||
297 | printf("\n\n\n fCalibData\n"); | |
298 | //fCalibData->Print(0); | |
299 | //printf("\n\n\n fCalibData\n"); | |
300 | ||
301 | Bool_t result = man->Put(fCalibData,id,&md); | |
302 | ||
303 | return result; | |
304 | } | |
305 |