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