]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSRawDecoder.cxx
Fixed creation of arrays in the copy constructors
[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"
45#include "AliPHOSPulseGenerator.h"
46
47ClassImp(AliPHOSRawDecoder)
48
49//-----------------------------------------------------------------------------
50AliPHOSRawDecoder::AliPHOSRawDecoder():
14100b90 51 fRawReader(0),fCaloStream(0),fPedSubtract(kFALSE),fEnergy(-111),fTime(-111),fModule(-1),fColumn(-1),fRow(-1),
52 fLowGainFlag(kFALSE),fOverflow(kFALSE),fSamples(0),fTimes(0),fPulseGenerator(0)
a29c28b6 53{
54 //Default constructor.
55}
56
57//-----------------------------------------------------------------------------
467957dc 58AliPHOSRawDecoder::AliPHOSRawDecoder(AliRawReader* rawReader, AliAltroMapping **mapping):
14100b90 59 fRawReader(0),fCaloStream(0),fPedSubtract(kFALSE),fEnergy(-111),fTime(-111),fModule(-1),fColumn(-1),fRow(-1),
60 fLowGainFlag(kFALSE),fOverflow(kFALSE),fSamples(0),fTimes(0),fPulseGenerator(0)
a29c28b6 61{
62 //Construct a decoder object.
63 //Is is user responsibility to provide next raw event
64 //using AliRawReader::NextEvent().
65
66 fRawReader = rawReader;
467957dc 67 fCaloStream = new AliCaloRawStream(rawReader,"PHOS",mapping);
a29c28b6 68 fCaloStream->SetOldRCUFormat(kFALSE);
b1a8a9cb 69 fSamples = new TArrayI(100);
14100b90 70 fTimes = new TArrayI(100);
b1a8a9cb 71 fPulseGenerator = new AliPHOSPulseGenerator();
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 ;}
82 if(fPulseGenerator){ delete fPulseGenerator; fPulseGenerator=0 ;}
a29c28b6 83}
84
85//-----------------------------------------------------------------------------
86AliPHOSRawDecoder::AliPHOSRawDecoder(const AliPHOSRawDecoder &phosDecoder ):
87 fRawReader(phosDecoder.fRawReader),fCaloStream(phosDecoder.fCaloStream),
88 fPedSubtract(phosDecoder.fPedSubtract),
89 fEnergy(phosDecoder.fEnergy),fTime(phosDecoder.fTime),
90 fModule(phosDecoder.fModule),fColumn(phosDecoder.fColumn),
56c9f64a 91 fRow(phosDecoder.fRow),fLowGainFlag(phosDecoder.fLowGainFlag),
14100b90 92 fOverflow(phosDecoder.fOverflow),fSamples(phosDecoder.fSamples),
93 fTimes(phosDecoder.fTimes),fPulseGenerator(phosDecoder.fPulseGenerator)
a29c28b6 94{
95 //Copy constructor.
96}
97
98//-----------------------------------------------------------------------------
99AliPHOSRawDecoder& AliPHOSRawDecoder::operator = (const AliPHOSRawDecoder &phosDecode)
100{
7bc140a5 101 //Assignment operator.
102
a29c28b6 103 if(this != &phosDecode) {
104 fRawReader = phosDecode.fRawReader;
105
106 if(fCaloStream) delete fCaloStream;
107 fCaloStream = phosDecode.fCaloStream;
108
109 fEnergy = phosDecode.fEnergy;
110 fTime = phosDecode.fTime;
111 fModule = phosDecode.fModule;
112 fColumn = phosDecode.fColumn;
113 fRow = phosDecode.fRow;
56c9f64a 114 fLowGainFlag = phosDecode.fLowGainFlag;
14100b90 115 fOverflow = phosDecode.fOverflow ;
56c9f64a 116
b1a8a9cb 117 if(fSamples) delete fSamples;
118 fSamples = phosDecode.fSamples;
119
14100b90 120 if(fTimes) delete fTimes;
121 fTimes = phosDecode.fTimes;
122
b1a8a9cb 123 if(fPulseGenerator) delete fPulseGenerator;
124 fPulseGenerator = phosDecode.fPulseGenerator;
a29c28b6 125 }
126
127 return *this;
128}
129
130//-----------------------------------------------------------------------------
131
132Bool_t AliPHOSRawDecoder::NextDigit()
133{
134 //Extract an energy deposited in the crystal,
135 //crystal' position (module,column,row),
136 //time and gain (high or low).
b1a8a9cb 137
a29c28b6 138 AliCaloRawStream* in = fCaloStream;
b1a8a9cb 139
a29c28b6 140 Int_t iBin = 0;
b1a8a9cb 141 Int_t mxSmps = fSamples->GetSize();
56c9f64a 142 Int_t tLength = 0;
b1a8a9cb 143 fEnergy = -111;
1267d56d 144 Float_t pedMean = 0;
145 Int_t nPed = 0;
146 Float_t baseLine = 1.0;
14100b90 147 const Int_t nPreSamples = 10;
b1a8a9cb 148
149 fSamples->Reset();
14100b90 150 while ( in->Next() ) {
56c9f64a 151
152 if(!tLength) {
153 tLength = in->GetTimeLength();
154 if(tLength>mxSmps) {
155 fSamples->Set(tLength);
156 }
157 }
158
159 // Fit the full sample
160 if(in->IsNewHWAddress() && iBin>0) {
161
162 iBin=0;
163
164 // Temporarily we take the energy as a maximum amplitude
165 // and the pedestal from the 0th point (30 Aug 2006).
166 // Time is not evaluated for the moment (12.01.2007).
167 // Take is as a first time bin multiplied by the sample tick time
168
169 if(fPedSubtract)
7b02b945 170 if (nPed > 0)
171 fEnergy -= (Double_t)(pedMean/nPed); // pedestal subtraction
172 else
173 return kFALSE;
56c9f64a 174
175 if(fLowGainFlag)
176 fEnergy *= fPulseGenerator->GetRawFormatHighLowGainFactor(); // *16
1267d56d 177
178 if (fEnergy < baseLine) fEnergy = 0;
179
180 pedMean = 0;
56c9f64a 181 return kTRUE;
182 }
183
184 fLowGainFlag = in->IsLowGain();
185 fTime = fPulseGenerator->GetRawFormatTimeTrigger() * in->GetTime();
186 fModule = in->GetModule()+1;
1267d56d 187 fRow = in->GetRow() +1;
56c9f64a 188 fColumn = in->GetColumn()+1;
189
14100b90 190 //Calculate pedestal if necessary
191 if(fPedSubtract && in->GetTime() < nPreSamples) {
1267d56d 192 pedMean += in->GetSignal();
193 nPed++;
194 }
56c9f64a 195 if((Double_t)in->GetSignal() > fEnergy) fEnergy = (Double_t)in->GetSignal();
14100b90 196 iBin++ ;
56c9f64a 197
198 } // in.Next()
199
200 return kFALSE;
a29c28b6 201}