]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PMD/AliPMDCalibPedestal.cxx
Added const members to contain the IDs of FMD files used by the preprocessor and...
[u/mrichter/AliRoot.git] / PMD / AliPMDCalibPedestal.cxx
CommitLineData
24e8f6b2 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16
17//Root includes
18#include <TObjArray.h>
19#include <TH1F.h>
20#include <TString.h>
21#include <TMath.h>
22#include <TF1.h>
23#include <TRandom.h>
24#include <TDirectory.h>
25#include <TFile.h>
26#include "TTreeStream.h"
27
28//AliRoot includes
9d7353e3 29#include "AliDAQ.h"
30#include "AliLog.h"
24e8f6b2 31#include "AliRawReader.h"
32#include "AliPMDRawStream.h"
33#include "AliPMDddldata.h"
34
35//header file
36#include "AliPMDCalibPedestal.h"
37
38
39ClassImp(AliPMDCalibPedestal)
40
41
42AliPMDCalibPedestal::AliPMDCalibPedestal() :
43 TObject()
44{
45 //
46 // default constructor
47 //
48
0ab3a530 49 for (int i = 0; i < kDet; i++)
24e8f6b2 50 {
0ab3a530 51 for (int j = 0; j < kMaxSMN; j++)
24e8f6b2 52 {
0ab3a530 53 for (int k = 0; k < kMaxRow; k++)
24e8f6b2 54 {
0ab3a530 55 for (int l = 0; l < kMaxCol; l++)
24e8f6b2 56 {
0ab3a530 57 fPedVal[i][j][k][l] = 0.;
58 fPedValSq[i][j][k][l] = 0.;
59 fPedCount[i][j][k][l] = 0.;
24e8f6b2 60 }
61 }
62 }
63 }
64
65
66}
67//_____________________________________________________________________
68AliPMDCalibPedestal::AliPMDCalibPedestal(const AliPMDCalibPedestal &ped) :
69 TObject(ped)
70{
71 //
72 // copy constructor
73 //
0ab3a530 74 for (int i = 0; i < kDet; i++)
24e8f6b2 75 {
0ab3a530 76 for (int j = 0; j < kMaxSMN; j++)
24e8f6b2 77 {
0ab3a530 78 for (int k = 0; k < kMaxRow; k++)
24e8f6b2 79 {
0ab3a530 80 for (int l = 0; l < kMaxCol; l++)
24e8f6b2 81 {
0ab3a530 82 fPedVal[i][j][k][l] = ped.fPedVal[i][j][k][l];
83 fPedValSq[i][j][k][l] = ped.fPedValSq[i][j][k][l];
84 fPedCount[i][j][k][l] = ped.fPedCount[i][j][k][l];
24e8f6b2 85 }
86 }
87 }
88 }
89
90}
91//_____________________________________________________________________
92AliPMDCalibPedestal& AliPMDCalibPedestal::operator = (const AliPMDCalibPedestal &source)
93{
94 //
95 // assignment operator
96 //
97 if (&source == this) return *this;
98 new (this) AliPMDCalibPedestal(source);
99
100 return *this;
101}
102//_____________________________________________________________________
103AliPMDCalibPedestal::~AliPMDCalibPedestal()
104{
105 //
106 // destructor
107 //
24e8f6b2 108}
109//_____________________________________________________________________
110Bool_t AliPMDCalibPedestal::ProcessEvent(AliRawReader *rawReader)
111{
112 //
113 // Event processing loop - AliRawReader
114 //
9d7353e3 115
116 const Int_t kDDL = AliDAQ::NumberOfDdls("PMD");
117
24e8f6b2 118 AliPMDRawStream rawStream(rawReader);
119
120 TObjArray pmdddlcont;
121 Bool_t streamout = kTRUE;
122
9d7353e3 123 for (Int_t iddl = 0; iddl < kDDL; iddl++)
24e8f6b2 124 {
24e8f6b2 125 rawReader->Select("PMD", iddl, iddl);
126 //cout << reader.GetDataSize() << endl;
127 streamout = rawStream.DdlData(iddl, &pmdddlcont);
128 Int_t ientries = pmdddlcont.GetEntries();
129 for (Int_t ient = 0; ient < ientries; ient++)
130 {
131 AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
132
133 Int_t det = pmdddl->GetDetector();
134 Int_t smn = pmdddl->GetSMN();
135 //Int_t mcm = pmdddl->GetMCM();
136 //Int_t chno = pmdddl->GetChannel();
137 Int_t row = pmdddl->GetRow();
138 Int_t col = pmdddl->GetColumn();
0ab3a530 139 Float_t sig = (Float_t) pmdddl->GetSignal();
24e8f6b2 140
0ab3a530 141 fPedVal[det][smn][row][col] += sig;
142 fPedValSq[det][smn][row][col] += sig*sig;
143 fPedCount[det][smn][row][col]++;
24e8f6b2 144 }
145 pmdddlcont.Clear();
146 }
147 return streamout;
148}
149//_____________________________________________________________________
150
9d7353e3 151void AliPMDCalibPedestal::Analyse(TTree *pedtree)
24e8f6b2 152{
153 //
154 // Calculate pedestal Mean and RMS
155 //
0ab3a530 156 Int_t det, sm, row, col;
157 Float_t mean, rms;
158 Float_t meansq, diff;
159
160
161 pedtree->Branch("det",&det,"det/I");
162 pedtree->Branch("sm",&sm,"sm/I");
163 pedtree->Branch("row",&row,"row/I");
164 pedtree->Branch("col",&col,"col/I");
165 pedtree->Branch("mean",&mean,"mean/F");
166 pedtree->Branch("rms",&rms,"rms/F");
167
168 for (int idet = 0; idet < kDet; idet++)
24e8f6b2 169 {
0ab3a530 170 for (int ism = 0; ism < kMaxSMN; ism++)
24e8f6b2 171 {
0ab3a530 172 for (int irow = 0; irow < kMaxRow; irow++)
24e8f6b2 173 {
0ab3a530 174 for (int icol = 0; icol < kMaxCol; icol++)
24e8f6b2 175 {
0ab3a530 176 det = idet;
177 sm = ism;
178 row = irow;
179 col = icol;
180 if (fPedCount[idet][ism][irow][icol] > 0)
181 {
182 mean = fPedVal[idet][ism][irow][icol]/fPedCount[idet][ism][irow][icol];
183
184 meansq = fPedValSq[idet][ism][irow][icol]/fPedCount[idet][ism][irow][icol];
185
186 diff = meansq - mean*mean;
187 if (diff > 0.)
188 {
189 rms = sqrt(diff);
190 }
191 else
192 {
193 rms = 0.;
194 }
195 }
196
9d7353e3 197 pedtree->Fill();
24e8f6b2 198 }
199 }
200 }
201 }
202}
203//_____________________________________________________________________