1 //////////////////////////////////////////////////////////////////////////////
3 // * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 // * Author: The ALICE Off-line Project. *
6 // * Contributors are mentioned in the code where appropriate. *
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 // **************************************************************************/
17 //////////////////////////////////////////////////////////////////////////////
22 #include "TObjString.h"
24 #include "TClonesArray.h"
27 // --- Standard library ---
29 // --- AliRoot header files ---
31 #include "AliPMDCalibrator.h"
32 #include "AliRawReaderDate.h"
33 #include "AliPMDRawStream.h"
34 #include "AliRawReaderFile.h"
35 #include "AliPMDCalibData.h"
36 #include "AliCDBManager.h"
38 #include "AliCDBMetaData.h"
40 ClassImp(AliPMDCalibrator)
43 const Int_t kMaxSMN = 24;
44 const Int_t kMaxRow =96;
45 const Int_t kMaxCol =96;
47 AliPMDCalibrator::AliPMDCalibrator()
49 // Standard Constructor
51 fCalibData = new AliPMDCalibData();
53 for(Int_t d=0;d<2;d++)
55 for(Int_t i=0;i<24;i++)
57 fHsmIso[d][i] = NULL ;
58 for(Int_t j=0;j<96;j++)
60 for(Int_t k=0;k<96;k++)
62 fGainFact[d][i][j][k] = 0.0;
63 fHadcIso[d][i][j][k] = NULL;
69 // ------------------------------------------------------------------------ //
71 AliPMDCalibrator::~AliPMDCalibrator()
74 if(fHsmIso) delete fHsmIso ;
75 if(fHadcIso) delete fHadcIso ;
78 // ------------------------------------------------------------------------ //
80 void AliPMDCalibrator::Exec()
82 // reads parameters and does the calibration
86 // ------------------------------------------------------------------------ //
88 void AliPMDCalibrator::Init()
90 // intializes everything
92 char hname24[kMaxSMN];
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"
105 sprintf(htitle1,"Isolated Cell ADC for det_%d_cell_sm%d_row%d_col%d"
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.);
118 // ------------------------------------------------------------------------ //
120 void AliPMDCalibrator::CalculateIsoCell()
122 // Calculates the ADC of isolated cell
124 const Int_t kMaxHit = 60000;
125 const Int_t kCellNeighbour = 6;
127 Int_t neibx[6] = {1,0,-1,-1,0,1};
128 Int_t neiby[6] = {0,1,1,0,-1,-1};
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];
138 Int_t det[kMaxHit],smn[kMaxHit];
139 Int_t row[kMaxHit],col[kMaxHit],sig[kMaxHit],chno[kMaxHit];
141 for(Int_t idet = 0; idet < kDet; idet++)
143 for(Int_t ismn = 0; ismn < kMaxSMN; ismn++)
145 for(Int_t irow = 0; irow < kMaxRow; irow++)
147 for(Int_t icol = 0; icol < kMaxCol; icol++)
149 d1[idet][ismn][irow][icol] = 0;
150 ch[idet][ismn][irow][icol] = 0;
156 AliRawReaderFile reader(".");
157 AliPMDRawStream stream(&reader);
158 while(reader.NextEvent())
160 // printf("In CalculateIsoCell before while(stream.Next()), ...\n");
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();
173 d1[idet][ismn][irow][icol] = isig;
174 ch[idet][ismn][irow][icol] = ichno;
180 for(Int_t idet=0; idet < kDet; idet++)
182 for(Int_t ismn = 0; ismn < kMaxSMN; ismn++)
184 for(Int_t irow = 0; irow < kMaxRow; irow++)
186 for(Int_t icol = 0; icol < kMaxCol; icol++)
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] );
194 if(d1[idet][ismn][irow][icol] > 0)
197 for(Int_t ii = 0; ii < kCellNeighbour; ii++)
199 id1 = irow + neibx[ii];
200 jd1 = icol + neiby[ii];
201 if(d1[idet][ismn][id1][jd1] == 0)
204 if(isocount == kCellNeighbour)
211 sig[maxhit] = d1[idet][ismn][irow][icol];
212 chno[maxhit] = ch[idet][ismn][irow][icol];
214 fHsmIso[idet][ismn]->Fill(d1[idet][ismn][irow][icol]);
215 fHadcIso[idet][ismn][irow][icol]->Fill(d1[idet][ismn][irow][icol]);
218 } // neigh cell cond.
225 Double_t histMean[2][24];
226 Double_t isoMean[2][24][96][96];
227 for(Int_t d1=0;d1<2;d1++)
229 for(Int_t i1=0;i1<24;i1++)
231 histMean[d1][i1]= fHsmIso[d1][i1]->GetMean();
232 for(Int_t j1=0;j1<96;j1++)
234 for(Int_t k1=0;k1<96;k1++)
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)
239 fGainFact[d1][i1][j1][k1]=isoMean[d1][i1][k1][j1]/histMean[d1][i1];
240 Float_t gain=fGainFact[d1][i1][j1][k1];
241 fCalibData->SetGainFact(d1,i1,j1,k1,gain);
249 // ------------------------------------------------------------------------ //
250 Bool_t AliPMDCalibrator::Store()
252 AliCDBManager *man = AliCDBManager::Instance();
253 man->SetDefaultStorage("local://$ALICE_ROOT");
254 AliCDBId id("PMD/Calib/Data",0,0);
256 md.SetResponsible("Zubayer");
258 md.SetAliRootVersion("28.02.2006");
259 md.SetComment("Test");
261 printf("\n\n\n fCalibData\n");
262 //fCalibData->Print(0);
263 //printf("\n\n\n fCalibData\n");
265 Bool_t result = man->Put(fCalibData,id,&md);