]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PMD/AliPMDCalibGain.cxx
skip if the MCM number is wrong
[u/mrichter/AliRoot.git] / PMD / AliPMDCalibGain.cxx
CommitLineData
4fc06b3a 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
19#include "TF1.h"
20#include "TFile.h"
21#include "TObjString.h"
22#include "TROOT.h"
23#include "TClonesArray.h"
24#include "TH1F.h"
25#include "TObjArray.h"
26#include "TTree.h"
27
28// --- Standard library ---
29
30// --- AliRoot header files ---
31#include "AliDAQ.h"
32#include "AliLog.h"
33#include "AliRawReader.h"
34#include "AliPMDRawStream.h"
35#include "AliPMDddldata.h"
36#include "AliPMDCalibGain.h"
37
38ClassImp(AliPMDCalibGain)
39
40AliPMDCalibGain::AliPMDCalibGain(): TObject()
41{
42 // Standard Constructor
43 for(Int_t idet = 0; idet < kDet; idet++)
44 {
45 for(Int_t ismn = 0; ismn < kMaxSMN; ismn++)
46 {
0ab3a530 47 fSMIso[idet][ismn] = 0.;
48 fSMCount[idet][ismn] = 0.;
4fc06b3a 49 for(Int_t jrow = 0; jrow < kMaxRow; jrow++)
50 {
51 for(Int_t kcol = 0; kcol < kMaxCol; kcol++)
52 {
0ab3a530 53 fCellIso[idet][ismn][jrow][kcol] = 0.;
54 fCellCount[idet][ismn][jrow][kcol] = 0.;
4fc06b3a 55 }
56 }
57 }
58 }
0ab3a530 59
4fc06b3a 60}
61// ------------------------------------------------------------------------ //
62AliPMDCalibGain::AliPMDCalibGain(const AliPMDCalibGain &pmdcalibgain):
63 TObject(pmdcalibgain)
64{
65 for(Int_t idet = 0; idet < kDet; idet++)
66 {
67 for(Int_t ismn = 0; ismn < kMaxSMN; ismn++)
68 {
0ab3a530 69 fSMIso[idet][ismn] = pmdcalibgain.fSMIso[idet][ismn] ;
70 fSMCount[idet][ismn] = pmdcalibgain.fSMCount[idet][ismn] ;
4fc06b3a 71 for(Int_t jrow = 0; jrow < kMaxRow; jrow++)
72 {
73 for(Int_t kcol = 0; kcol < kMaxCol; kcol++)
74 {
0ab3a530 75 fCellIso[idet][ismn][jrow][kcol] = pmdcalibgain.fCellIso[idet][ismn][jrow][kcol];
76 fCellCount[idet][ismn][jrow][kcol] = pmdcalibgain.fCellCount[idet][ismn][jrow][kcol];
4fc06b3a 77 }
78 }
79 }
80 }
81
82}
83// ------------------------------------------------------------------------ //
84AliPMDCalibGain &AliPMDCalibGain::operator=(const AliPMDCalibGain &pmdcalibgain)
85{
86 if(this != &pmdcalibgain)
87 {
88 for(Int_t idet = 0; idet < kDet; idet++)
89 {
90 for(Int_t ismn = 0; ismn < kMaxSMN; ismn++)
91 {
0ab3a530 92 fSMIso[idet][ismn] = pmdcalibgain.fSMIso[idet][ismn];
93 fSMCount[idet][ismn] = pmdcalibgain.fSMCount[idet][ismn];
4fc06b3a 94 for(Int_t jrow = 0; jrow < kMaxRow;jrow++)
95 {
96 for(Int_t kcol = 0; kcol < kMaxCol; kcol++)
97 {
0ab3a530 98 fCellIso[idet][ismn][jrow][kcol] =
99 pmdcalibgain.fCellIso[idet][ismn][jrow][kcol];
100 fCellCount[idet][ismn][jrow][kcol] =
101 pmdcalibgain.fCellCount[idet][ismn][jrow][kcol];
4fc06b3a 102 }
103 }
104 }
105 }
106 }
107 return *this;
108}
109// ------------------------------------------------------------------------ //
110AliPMDCalibGain::~AliPMDCalibGain()
111{
112 // dtor
0ab3a530 113
4fc06b3a 114}
115// ------------------------------------------------------------------------ //
338c285a 116Bool_t AliPMDCalibGain::ProcessEvent(AliRawReader *rawReader, TObjArray *pmdddlcont)
4fc06b3a 117{
118 // Calculates the ADC of isolated cell
119
338c285a 120 //TObjArray pmdddlcont;
4fc06b3a 121
122 const Int_t kDDL = AliDAQ::NumberOfDdls("PMD");
123 const Int_t kCellNeighbour = 6;
124
125 Int_t neibx[6] = {1,0,-1,-1,0,1};
126 Int_t neiby[6] = {0,1,1,0,-1,-1};
127
128 Int_t id1,jd1; //neighbour row/col
129 Int_t isocount; //number of neighbours with 0 signal
130
0ab3a530 131 Float_t d1[kDet][kMaxSMN][kMaxRow][kMaxCol];
4fc06b3a 132
133 for(Int_t idet = 0; idet < kDet; idet++)
134 {
135 for(Int_t ismn = 0; ismn < kMaxSMN; ismn++)
136 {
137 for(Int_t irow = 0; irow < kMaxRow; irow++)
138 {
139 for(Int_t icol = 0; icol < kMaxCol; icol++)
140 {
0ab3a530 141 d1[idet][ismn][irow][icol] = 0.;
4fc06b3a 142 }
143 }
144 }
145 }
146
147 AliPMDRawStream rawStream(rawReader);
148
722ccc67 149 Int_t iddl;
150
151 Int_t numberofDDLs = 0;
152
338c285a 153 while ((iddl = rawStream.DdlData(pmdddlcont)) >=0) {
722ccc67 154 numberofDDLs++;
155
338c285a 156 Int_t ientries = pmdddlcont->GetEntries();
4fc06b3a 157 for (Int_t ient = 0; ient < ientries; ient++)
158 {
338c285a 159 AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont->UncheckedAt(ient);
4fc06b3a 160
161 Int_t idet = pmdddl->GetDetector();
162 Int_t ismn = pmdddl->GetSMN();
163 //Int_t mcm = pmdddl->GetMCM();
164 //Int_t ichno = pmdddl->GetChannel();
165 Int_t irow = pmdddl->GetRow();
166 Int_t icol = pmdddl->GetColumn();
167 Int_t isig = pmdddl->GetSignal();
168
169 if (isig>0)
170 {
0ab3a530 171 d1[idet][ismn][irow][icol] = (Float_t) isig;
4fc06b3a 172 }
173 }
338c285a 174 pmdddlcont->Delete();
4fc06b3a 175 }
176
177 for(Int_t idet=0; idet < kDet; idet++)
178 {
179 for(Int_t ismn = 0; ismn < kMaxSMN; ismn++)
180 {
181 for(Int_t irow = 0; irow < kMaxRow; irow++)
182 {
183 for(Int_t icol = 0; icol < kMaxCol; icol++)
184 {
185 if(d1[idet][ismn][irow][icol] > 0)
186 {
187 isocount = 0;
188 for(Int_t ii = 0; ii < kCellNeighbour; ii++)
189 {
190 id1 = irow + neibx[ii];
191 jd1 = icol + neiby[ii];
192 if(d1[idet][ismn][id1][jd1] == 0)
193 {
194 isocount++;
195 if(isocount == kCellNeighbour)
196 {
0ab3a530 197
198 fSMIso[idet][ismn] += d1[idet][ismn][irow][icol];
199 fCellIso[idet][ismn][irow][icol] += d1[idet][ismn][irow][icol];
200
201 fSMCount[idet][ismn]++;
202 fCellCount[idet][ismn][irow][icol]++;
203
4fc06b3a 204 }
205 }
206 } // neigh cell cond.
207 } // d>0 cond.
208 }
209 }
210 }
211
212 }
722ccc67 213
214 if (numberofDDLs < kDDL)
215 return kFALSE;
216 return kTRUE;
217
4fc06b3a 218}
219// ------------------------------------------------------------------------ //
220void AliPMDCalibGain::Analyse(TTree *gaintree)
221{
222 // Calculates the mean
0ab3a530 223 Int_t det, sm, row, col;
224 Float_t gain;
225 Float_t modmean = 0.;
226 Float_t cellmean = 0.;
4fc06b3a 227
0ab3a530 228 gaintree->Branch("det",&det,"det/I");
229 gaintree->Branch("sm",&sm,"sm/I");
230 gaintree->Branch("row",&row,"row/I");
231 gaintree->Branch("col",&col,"col/I");
232 gaintree->Branch("gain",&gain,"gain/F");
4fc06b3a 233
234 for(Int_t idet = 0; idet < kDet; idet++)
235 {
236 for(Int_t ism = 0; ism < kMaxSMN; ism++)
237 {
0ab3a530 238 if (fSMCount[idet][ism] > 0)
239 modmean = fSMIso[idet][ism]/fSMCount[idet][ism];
4fc06b3a 240 for(Int_t irow = 0; irow < kMaxRow; irow++)
241 {
242 for(Int_t icol = 0; icol < kMaxCol; icol++)
243 {
0ab3a530 244 if (fCellCount[idet][ism][irow][icol] > 0)
245 cellmean = fCellIso[idet][ism][irow][icol]/fCellCount[idet][ism][irow][icol];
246
247
248 det = idet;
249 sm = ism;
250 row = irow;
251 col = icol;
252 gain = 1.;
4fc06b3a 253
254 if(modmean > 0.0)
255 {
0ab3a530 256 gain = cellmean/modmean;
4fc06b3a 257 }
258 gaintree->Fill();
259 }
260 }
261 }
262 }
263
264}
265// ------------------------------------------------------------------------ //