1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include <TObjArray.h>
24 #include <TDirectory.h>
26 #include "TTreeStream.h"
31 #include "AliRawReader.h"
32 #include "AliPMDRawStream.h"
33 #include "AliPMDddldata.h"
36 #include "AliPMDCalibPedestal.h"
39 ClassImp(AliPMDCalibPedestal)
42 AliPMDCalibPedestal::AliPMDCalibPedestal() :
46 // default constructor
49 for (int i = 0; i < kDet; i++)
51 for (int j = 0; j < kMaxSMN; j++)
53 for (int k = 0; k < kMaxRow; k++)
55 for (int l = 0; l < kMaxCol; l++)
57 fPedVal[i][j][k][l] = 0.;
58 fPedValSq[i][j][k][l] = 0.;
59 fPedCount[i][j][k][l] = 0.;
67 //_____________________________________________________________________
68 AliPMDCalibPedestal::AliPMDCalibPedestal(const AliPMDCalibPedestal &ped) :
74 for (int i = 0; i < kDet; i++)
76 for (int j = 0; j < kMaxSMN; j++)
78 for (int k = 0; k < kMaxRow; k++)
80 for (int l = 0; l < kMaxCol; l++)
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];
91 //_____________________________________________________________________
92 AliPMDCalibPedestal& AliPMDCalibPedestal::operator = (const AliPMDCalibPedestal &source)
95 // assignment operator
97 if (&source == this) return *this;
98 new (this) AliPMDCalibPedestal(source);
102 //_____________________________________________________________________
103 AliPMDCalibPedestal::~AliPMDCalibPedestal()
109 //_____________________________________________________________________
110 Bool_t AliPMDCalibPedestal::ProcessEvent(AliRawReader *rawReader)
113 // Event processing loop - AliRawReader
116 const Int_t kDDL = AliDAQ::NumberOfDdls("PMD");
118 AliPMDRawStream rawStream(rawReader);
120 TObjArray pmdddlcont;
121 Bool_t streamout = kTRUE;
123 for (Int_t iddl = 0; iddl < kDDL; iddl++)
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++)
131 AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient);
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();
139 Float_t sig = (Float_t) pmdddl->GetSignal();
141 fPedVal[det][smn][row][col] += sig;
142 fPedValSq[det][smn][row][col] += sig*sig;
143 fPedCount[det][smn][row][col]++;
149 //_____________________________________________________________________
151 void AliPMDCalibPedestal::Analyse(TTree *pedtree)
154 // Calculate pedestal Mean and RMS
156 Int_t det, sm, row, col;
158 Float_t meansq, diff;
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");
168 for (int idet = 0; idet < kDet; idet++)
170 for (int ism = 0; ism < kMaxSMN; ism++)
172 for (int irow = 0; irow < kMaxRow; irow++)
174 for (int icol = 0; icol < kMaxCol; icol++)
180 if (fPedCount[idet][ism][irow][icol] > 0)
182 mean = fPedVal[idet][ism][irow][icol]/fPedCount[idet][ism][irow][icol];
184 meansq = fPedValSq[idet][ism][irow][icol]/fPedCount[idet][ism][irow][icol];
186 diff = meansq - mean*mean;
203 //_____________________________________________________________________