]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSRawDecoder.cxx
SDD cone implemented and activated in geometry v11Hybrid. Volume IS02 removed (M...
[u/mrichter/AliRoot.git] / PHOS / AliPHOSRawDecoder.cxx
CommitLineData
a29c28b6 1/**************************************************************************
2 * Copyright(c) 2007, 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
7bc140a5 16/* $Id$ */
17
a29c28b6 18// This class decodes the stream of ALTRO samples to extract
19// the PHOS "digits" of current event.
20//
21// Typical use case:
22// AliRawReader* rf = new AliRawReaderDate("2006run2211.raw");
b1a8a9cb 23// AliPHOSRawDecoder dc(rf);
a29c28b6 24// while (rf->NextEvent()) {
a29c28b6 25// dc.SetOldRCUFormat(kTRUE);
26// dc.SubtractPedestals(kTRUE);
27// while ( dc.NextDigit() ) {
28// Int_t module = dc.GetModule();
29// Int_t column = dc.GetColumn();
30// Int_t row = dc.GetRow();
31// Double_t amplitude = dc.GetEnergy();
32// Double_t time = dc.GetTime();
33// Bool_t IsLowGain = dc.IsLowGain();
34// ..........
35// }
36// }
37
38// Author: Boris Polichtchouk
39
40// --- ROOT system ---
b1a8a9cb 41#include "TArrayI.h"
a29c28b6 42
43// --- AliRoot header files ---
44#include "AliPHOSRawDecoder.h"
39569d36 45#include <iostream.h>
a29c28b6 46ClassImp(AliPHOSRawDecoder)
47
48//-----------------------------------------------------------------------------
49AliPHOSRawDecoder::AliPHOSRawDecoder():
70d93620 50 fRawReader(0),fCaloStream(0),fPedSubtract(kFALSE),fEnergy(-111),fTime(-111),fQuality(0.),
39569d36 51 fModule(-1),fColumn(-1),fRow(-1),fNewModule(-1),fNewColumn(-1),fNewRow(-1),fNewAmp(0),fNewTime(0),
52 fLowGainFlag(kFALSE),fNewLowGainFlag(kFALSE),fOverflow(kFALSE),fSamples(0),fTimes(0)
a29c28b6 53{
54 //Default constructor.
55}
56
57//-----------------------------------------------------------------------------
467957dc 58AliPHOSRawDecoder::AliPHOSRawDecoder(AliRawReader* rawReader, AliAltroMapping **mapping):
70d93620 59 fRawReader(0),fCaloStream(0),fPedSubtract(kFALSE),fEnergy(-111),fTime(-111),fQuality(0.),
39569d36 60 fModule(-1),fColumn(-1),fRow(-1),fNewModule(-1),fNewColumn(-1),fNewRow(-1),fNewAmp(0),fNewTime(0),
61 fLowGainFlag(kFALSE),fNewLowGainFlag(kFALSE),fOverflow(kFALSE),fSamples(0),fTimes(0)
a29c28b6 62{
63 //Construct a decoder object.
64 //Is is user responsibility to provide next raw event
65 //using AliRawReader::NextEvent().
66
67 fRawReader = rawReader;
467957dc 68 fCaloStream = new AliCaloRawStream(rawReader,"PHOS",mapping);
a29c28b6 69 fCaloStream->SetOldRCUFormat(kFALSE);
b1a8a9cb 70 fSamples = new TArrayI(100);
14100b90 71 fTimes = new TArrayI(100);
a29c28b6 72}
73
74//-----------------------------------------------------------------------------
75AliPHOSRawDecoder::~AliPHOSRawDecoder()
76{
77 //Destructor.
78
14100b90 79 if(fCaloStream){ delete fCaloStream; fCaloStream=0;}
80 if(fSamples){ delete fSamples; fSamples=0 ;}
81 if(fTimes){ delete fTimes; fTimes=0 ;}
a29c28b6 82}
83
84//-----------------------------------------------------------------------------
85AliPHOSRawDecoder::AliPHOSRawDecoder(const AliPHOSRawDecoder &phosDecoder ):
86 fRawReader(phosDecoder.fRawReader),fCaloStream(phosDecoder.fCaloStream),
87 fPedSubtract(phosDecoder.fPedSubtract),
70d93620 88 fEnergy(phosDecoder.fEnergy),fTime(phosDecoder.fTime),fQuality(phosDecoder.fQuality),
a29c28b6 89 fModule(phosDecoder.fModule),fColumn(phosDecoder.fColumn),
39569d36 90 fRow(phosDecoder.fRow),fNewModule(phosDecoder.fNewModule),fNewColumn(phosDecoder.fNewColumn),
91 fNewRow(phosDecoder.fNewRow),fNewAmp(phosDecoder.fNewAmp),fNewTime(phosDecoder.fNewTime),
92 fLowGainFlag(phosDecoder.fLowGainFlag),fNewLowGainFlag(phosDecoder.fNewLowGainFlag),
14100b90 93 fOverflow(phosDecoder.fOverflow),fSamples(phosDecoder.fSamples),
39569d36 94 fTimes(phosDecoder.fTimes)
a29c28b6 95{
96 //Copy constructor.
97}
98
99//-----------------------------------------------------------------------------
100AliPHOSRawDecoder& AliPHOSRawDecoder::operator = (const AliPHOSRawDecoder &phosDecode)
101{
7bc140a5 102 //Assignment operator.
103
a29c28b6 104 if(this != &phosDecode) {
105 fRawReader = phosDecode.fRawReader;
106
107 if(fCaloStream) delete fCaloStream;
108 fCaloStream = phosDecode.fCaloStream;
109
110 fEnergy = phosDecode.fEnergy;
111 fTime = phosDecode.fTime;
70d93620 112 fQuality = phosDecode.fQuality ;
a29c28b6 113 fModule = phosDecode.fModule;
114 fColumn = phosDecode.fColumn;
115 fRow = phosDecode.fRow;
39569d36 116 fNewModule = phosDecode.fNewModule;
117 fNewColumn = phosDecode.fNewColumn;
118 fNewRow = phosDecode.fNewRow;
119 fNewAmp = phosDecode.fNewAmp ;
120 fNewTime= phosDecode.fNewTime ;
56c9f64a 121 fLowGainFlag = phosDecode.fLowGainFlag;
39569d36 122 fNewLowGainFlag = phosDecode.fNewLowGainFlag;
14100b90 123 fOverflow = phosDecode.fOverflow ;
56c9f64a 124
b1a8a9cb 125 if(fSamples) delete fSamples;
126 fSamples = phosDecode.fSamples;
127
14100b90 128 if(fTimes) delete fTimes;
129 fTimes = phosDecode.fTimes;
a29c28b6 130 }
131
132 return *this;
133}
134
135//-----------------------------------------------------------------------------
136
137Bool_t AliPHOSRawDecoder::NextDigit()
138{
139 //Extract an energy deposited in the crystal,
140 //crystal' position (module,column,row),
141 //time and gain (high or low).
b1a8a9cb 142
a29c28b6 143 AliCaloRawStream* in = fCaloStream;
b1a8a9cb 144
a29c28b6 145 Int_t iBin = 0;
b1a8a9cb 146 Int_t mxSmps = fSamples->GetSize();
56c9f64a 147 Int_t tLength = 0;
b1a8a9cb 148 fEnergy = -111;
1267d56d 149 Float_t pedMean = 0;
150 Int_t nPed = 0;
151 Float_t baseLine = 1.0;
14100b90 152 const Int_t nPreSamples = 10;
b1a8a9cb 153
154 fSamples->Reset();
14100b90 155 while ( in->Next() ) {
56c9f64a 156
157 if(!tLength) {
158 tLength = in->GetTimeLength();
159 if(tLength>mxSmps) {
160 fSamples->Set(tLength);
161 }
162 }
163
164 // Fit the full sample
165 if(in->IsNewHWAddress() && iBin>0) {
166
167 iBin=0;
39569d36 168 //First remember new sample
169 fNewLowGainFlag = in->IsLowGain();
170 fNewModule = in->GetModule()+1;
171 fNewRow = in->GetRow() +1;
172 fNewColumn = in->GetColumn()+1;
173 fNewAmp = in->GetSignal() ;
174 fNewTime=in->GetTime() ;
56c9f64a 175
176 // Temporarily we take the energy as a maximum amplitude
177 // and the pedestal from the 0th point (30 Aug 2006).
178 // Time is not evaluated for the moment (12.01.2007).
179 // Take is as a first time bin multiplied by the sample tick time
180
181 if(fPedSubtract)
7b02b945 182 if (nPed > 0)
183 fEnergy -= (Double_t)(pedMean/nPed); // pedestal subtraction
184 else
185 return kFALSE;
1267d56d 186 if (fEnergy < baseLine) fEnergy = 0;
187
188 pedMean = 0;
56c9f64a 189 return kTRUE;
190 }
191
192 fLowGainFlag = in->IsLowGain();
39569d36 193// fTime = in->GetTime();
56c9f64a 194 fModule = in->GetModule()+1;
1267d56d 195 fRow = in->GetRow() +1;
56c9f64a 196 fColumn = in->GetColumn()+1;
197
39569d36 198 if(fLowGainFlag==fNewLowGainFlag && fModule==fNewModule &&
199 fRow==fNewRow && fColumn==fNewColumn ){
200 if(fNewAmp>fEnergy) fEnergy = (Double_t)fNewAmp ;
201 fNewModule=-1 ;
202 }
203
14100b90 204 //Calculate pedestal if necessary
205 if(fPedSubtract && in->GetTime() < nPreSamples) {
1267d56d 206 pedMean += in->GetSignal();
207 nPed++;
208 }
56c9f64a 209 if((Double_t)in->GetSignal() > fEnergy) fEnergy = (Double_t)in->GetSignal();
14100b90 210 iBin++ ;
56c9f64a 211
212 } // in.Next()
213
214 return kFALSE;
a29c28b6 215}