]>
Commit | Line | Data |
---|---|---|
06810de6 | 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 | ||
27 | // --- Standard library --- | |
28 | ||
29 | // --- AliRoot header files --- | |
30 | #include "AliLog.h" | |
31 | #include "AliPMDCalibrator.h" | |
32 | #include "AliRawReaderDate.h" | |
33 | #include "AliPMDRawStream.h" | |
34 | #include "AliRawReaderFile.h" | |
35 | #include "AliPMDCalibData.h" | |
36 | #include "AliCDBManager.h" | |
37 | #include "AliCDBId.h" | |
38 | #include "AliCDBMetaData.h" | |
39 | ||
40 | ClassImp(AliPMDCalibrator) | |
41 | ||
42 | const Int_t kDet =2; | |
43 | const Int_t kMaxSMN = 24; | |
44 | const Int_t kMaxRow =96; | |
45 | const Int_t kMaxCol =96; | |
46 | ||
47 | AliPMDCalibrator::AliPMDCalibrator() | |
48 | { | |
49 | // Standard Constructor | |
50 | ||
51 | fCalibData = new AliPMDCalibData(); | |
52 | ||
53 | for(Int_t d=0;d<2;d++) | |
54 | { | |
55 | for(Int_t i=0;i<24;i++) | |
56 | { | |
57 | fHsmIso[d][i] = NULL ; | |
58 | for(Int_t j=0;j<96;j++) | |
59 | { | |
60 | for(Int_t k=0;k<96;k++) | |
61 | { | |
62 | fGainFact[d][i][j][k] = 0.0; | |
63 | fHadcIso[d][i][j][k] = NULL; | |
64 | } | |
65 | } | |
66 | } | |
67 | } | |
68 | } | |
69 | // ------------------------------------------------------------------------ // | |
70 | ||
71 | AliPMDCalibrator::~AliPMDCalibrator() | |
72 | { | |
73 | // dtor | |
74 | if(fHsmIso) delete fHsmIso ; | |
75 | if(fHadcIso) delete fHadcIso ; | |
76 | delete fCalibData; | |
77 | } | |
78 | // ------------------------------------------------------------------------ // | |
79 | ||
80 | void AliPMDCalibrator::Exec() | |
81 | { | |
82 | // reads parameters and does the calibration | |
83 | CalculateIsoCell() ; | |
84 | ||
85 | } | |
86 | // ------------------------------------------------------------------------ // | |
87 | ||
88 | void AliPMDCalibrator::Init() | |
89 | { | |
90 | // intializes everything | |
91 | char hname[kMaxSMN]; | |
92 | char hname24[kMaxSMN]; | |
93 | char hnameiso[120]; | |
94 | char htitle1[120]; | |
95 | ||
96 | for(Int_t d=0;d<2;d++) { | |
97 | for(Int_t i1=0; i1<kMaxSMN;i1++) { | |
98 | sprintf(hname,"det_%d_iso_sm_%2d",d,i1); | |
99 | sprintf(hname24,"det_%d_iso_sm_%2d",d,i1); | |
100 | fHsmIso[d][i1]= new TH1F(hname,hname24,100,0,1000); | |
101 | for(Int_t j1 = 0; j1 < kMaxRow; j1++) { | |
102 | for(Int_t k1 = 0; k1 < kMaxCol; k1++) { | |
103 | sprintf(hnameiso,"Isolated Cell ADC for det_%d_cell_sm%d_row%d_col%d" | |
104 | ,d,i1,j1,k1); | |
105 | sprintf(htitle1,"Isolated Cell ADC for det_%d_cell_sm%d_row%d_col%d" | |
106 | ,d,i1,j1,k1); | |
107 | ||
108 | TObject *old=gDirectory->GetList()->FindObject(hnameiso); | |
109 | if (old) gDirectory->GetList()->Remove(old); | |
110 | fHadcIso[d][i1][j1][k1] = new TH1F(hnameiso,htitle1,100,0.,4000.); | |
111 | } | |
112 | } | |
113 | } | |
114 | } | |
115 | ||
116 | } | |
117 | ||
118 | // ------------------------------------------------------------------------ // | |
119 | ||
120 | void AliPMDCalibrator::CalculateIsoCell() | |
121 | { | |
122 | // Calculates the ADC of isolated cell | |
123 | ||
124 | const Int_t kMaxHit = 60000; | |
125 | const Int_t kCellNeighbour = 6; | |
126 | ||
127 | Int_t neibx[6] = {1,0,-1,-1,0,1}; | |
128 | Int_t neiby[6] = {0,1,1,0,-1,-1}; | |
129 | ||
130 | Int_t id1,jd1; //neighbour row/col | |
131 | Int_t countisocell = 0 ;//number of isilated cell | |
132 | Int_t isocount; //number of neighbours with 0 signal | |
133 | Int_t d1[kDet][kMaxSMN][kMaxRow][kMaxCol]; | |
134 | Int_t ch[kDet][kMaxSMN][kMaxRow][kMaxCol]; | |
135 | Int_t maxhit; | |
136 | ||
137 | ||
138 | Int_t det[kMaxHit],smn[kMaxHit]; | |
139 | Int_t row[kMaxHit],col[kMaxHit],sig[kMaxHit],chno[kMaxHit]; | |
140 | ||
141 | for(Int_t idet = 0; idet < kDet; idet++) | |
142 | { | |
143 | for(Int_t ismn = 0; ismn < kMaxSMN; ismn++) | |
144 | { | |
145 | for(Int_t irow = 0; irow < kMaxRow; irow++) | |
146 | { | |
147 | for(Int_t icol = 0; icol < kMaxCol; icol++) | |
148 | { | |
149 | d1[idet][ismn][irow][icol] = 0; | |
150 | ch[idet][ismn][irow][icol] = 0; | |
151 | } | |
152 | } | |
153 | } | |
154 | } | |
155 | //accessing raw data | |
156 | AliRawReaderFile reader("."); | |
157 | AliPMDRawStream stream(&reader); | |
158 | while(reader.NextEvent()) | |
159 | { | |
160 | // printf("In CalculateIsoCell before while(stream.Next()), ...\n"); | |
161 | ||
162 | while(stream.Next()) | |
163 | { | |
164 | Int_t idet = stream.GetDetector(); | |
165 | Int_t ismn = stream.GetSMN(); | |
166 | Int_t ichno = stream.GetChannel(); | |
167 | Int_t irow = stream.GetRow(); | |
168 | Int_t icol = stream.GetColumn(); | |
169 | Int_t isig = stream.GetSignal(); | |
170 | ||
171 | if (isig>0) | |
172 | { | |
173 | d1[idet][ismn][irow][icol] = isig; | |
174 | ch[idet][ismn][irow][icol] = ichno; | |
175 | } | |
176 | } | |
177 | ||
178 | maxhit = 0; | |
179 | ||
180 | for(Int_t idet=0; idet < kDet; idet++) | |
181 | { | |
182 | for(Int_t ismn = 0; ismn < kMaxSMN; ismn++) | |
183 | { | |
184 | for(Int_t irow = 0; irow < kMaxRow; irow++) | |
185 | { | |
186 | for(Int_t icol = 0; icol < kMaxCol; icol++) | |
187 | { | |
188 | ||
189 | //printf("d1[%d][%d][%d][%d]=%d\n", | |
190 | //det,ksmn,irow,jcol, d1[det][ksmn][irow][jcol] ); | |
191 | //printf("ch[%d][%d][%d][%d]=%d\n", | |
192 | //det,ksmn,irow,jcol, ch[det][ksmn][irow][jcol] ); | |
193 | ||
194 | if(d1[idet][ismn][irow][icol] > 0) | |
195 | { | |
196 | isocount = 0; | |
197 | for(Int_t ii = 0; ii < kCellNeighbour; ii++) | |
198 | { | |
199 | id1 = irow + neibx[ii]; | |
200 | jd1 = icol + neiby[ii]; | |
201 | if(d1[idet][ismn][id1][jd1] == 0) | |
202 | { | |
203 | isocount++; | |
204 | if(isocount == kCellNeighbour) | |
205 | { | |
206 | countisocell++; | |
207 | det[maxhit] = idet; | |
208 | smn[maxhit] = ismn; | |
209 | row[maxhit] = irow; | |
210 | col[maxhit] = icol; | |
211 | sig[maxhit] = d1[idet][ismn][irow][icol]; | |
212 | chno[maxhit] = ch[idet][ismn][irow][icol]; | |
213 | maxhit++; | |
214 | fHsmIso[idet][ismn]->Fill(d1[idet][ismn][irow][icol]); | |
215 | fHadcIso[idet][ismn][irow][icol]->Fill(d1[idet][ismn][irow][icol]); | |
216 | } | |
217 | } | |
218 | } // neigh cell cond. | |
219 | } // d>0 cond. | |
220 | } | |
221 | } | |
222 | } | |
223 | } //event loop | |
224 | } | |
225 | Double_t histMean[2][24]; | |
226 | Double_t isoMean[2][24][96][96]; | |
227 | for(Int_t d1=0;d1<2;d1++) | |
228 | { | |
229 | for(Int_t i1=0;i1<24;i1++) | |
230 | { | |
231 | histMean[d1][i1]= fHsmIso[d1][i1]->GetMean(); | |
232 | for(Int_t j1=0;j1<96;j1++) | |
233 | { | |
234 | for(Int_t k1=0;k1<96;k1++) | |
235 | { | |
236 | isoMean[d1][i1][j1][k1]=fHadcIso[d1][i1][j1][k1]->GetMean(); | |
237 | if(isoMean[d1][i1][j1][k1]>0.0 && histMean[d1][i1]>0.0) | |
238 | { | |
239 | fGainFact[d1][i1][j1][k1]=isoMean[d1][i1][k1][j1]/histMean[d1][i1]; | |
c7cf04a8 | 240 | Float_t gain=fGainFact[d1][i1][j1][k1]; |
06810de6 | 241 | fCalibData->SetGainFact(d1,i1,j1,k1,gain); |
242 | } | |
243 | } | |
244 | } | |
245 | } | |
246 | } | |
247 | ||
248 | } | |
249 | // ------------------------------------------------------------------------ // | |
250 | Bool_t AliPMDCalibrator::Store() | |
251 | { | |
252 | AliCDBManager *man = AliCDBManager::Instance(); | |
253 | man->SetDefaultStorage("local://$ALICE_ROOT"); | |
254 | AliCDBId id("PMD/Calib/Data",0,0); | |
255 | AliCDBMetaData md; | |
256 | md.SetResponsible("Zubayer"); | |
257 | md.SetBeamPeriod(0); | |
258 | md.SetAliRootVersion("28.02.2006"); | |
259 | md.SetComment("Test"); | |
260 | ||
261 | printf("\n\n\n fCalibData\n"); | |
262 | //fCalibData->Print(0); | |
263 | //printf("\n\n\n fCalibData\n"); | |
264 | ||
265 | Bool_t result = man->Put(fCalibData,id,&md); | |
266 | ||
267 | return result; | |
268 | } | |
269 |