]>
Commit | Line | Data |
---|---|---|
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.SubtractPedestals(kTRUE); |
26 | // while ( dc.NextDigit() ) { | |
27 | // Int_t module = dc.GetModule(); | |
28 | // Int_t column = dc.GetColumn(); | |
29 | // Int_t row = dc.GetRow(); | |
30 | // Double_t amplitude = dc.GetEnergy(); | |
31 | // Double_t time = dc.GetTime(); | |
32 | // Bool_t IsLowGain = dc.IsLowGain(); | |
33 | // .......... | |
34 | // } | |
35 | // } | |
36 | ||
37 | // Author: Boris Polichtchouk | |
38 | ||
39 | // --- ROOT system --- | |
b1a8a9cb | 40 | #include "TArrayI.h" |
a29c28b6 | 41 | |
42 | // --- AliRoot header files --- | |
43 | #include "AliPHOSRawDecoder.h" | |
c5d477f8 | 44 | #include "AliRawReader.h" |
45 | ||
a29c28b6 | 46 | ClassImp(AliPHOSRawDecoder) |
47 | ||
48 | //----------------------------------------------------------------------------- | |
49 | AliPHOSRawDecoder::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 | 58 | AliPHOSRawDecoder::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); |
b1a8a9cb | 69 | fSamples = new TArrayI(100); |
14100b90 | 70 | fTimes = new TArrayI(100); |
a29c28b6 | 71 | } |
72 | ||
73 | //----------------------------------------------------------------------------- | |
74 | AliPHOSRawDecoder::~AliPHOSRawDecoder() | |
75 | { | |
76 | //Destructor. | |
77 | ||
14100b90 | 78 | if(fCaloStream){ delete fCaloStream; fCaloStream=0;} |
79 | if(fSamples){ delete fSamples; fSamples=0 ;} | |
80 | if(fTimes){ delete fTimes; fTimes=0 ;} | |
a29c28b6 | 81 | } |
82 | ||
83 | //----------------------------------------------------------------------------- | |
84 | AliPHOSRawDecoder::AliPHOSRawDecoder(const AliPHOSRawDecoder &phosDecoder ): | |
85 | fRawReader(phosDecoder.fRawReader),fCaloStream(phosDecoder.fCaloStream), | |
86 | fPedSubtract(phosDecoder.fPedSubtract), | |
70d93620 | 87 | fEnergy(phosDecoder.fEnergy),fTime(phosDecoder.fTime),fQuality(phosDecoder.fQuality), |
a29c28b6 | 88 | fModule(phosDecoder.fModule),fColumn(phosDecoder.fColumn), |
39569d36 | 89 | fRow(phosDecoder.fRow),fNewModule(phosDecoder.fNewModule),fNewColumn(phosDecoder.fNewColumn), |
90 | fNewRow(phosDecoder.fNewRow),fNewAmp(phosDecoder.fNewAmp),fNewTime(phosDecoder.fNewTime), | |
91 | fLowGainFlag(phosDecoder.fLowGainFlag),fNewLowGainFlag(phosDecoder.fNewLowGainFlag), | |
14100b90 | 92 | fOverflow(phosDecoder.fOverflow),fSamples(phosDecoder.fSamples), |
39569d36 | 93 | fTimes(phosDecoder.fTimes) |
a29c28b6 | 94 | { |
95 | //Copy constructor. | |
96 | } | |
97 | ||
98 | //----------------------------------------------------------------------------- | |
99 | AliPHOSRawDecoder& 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; | |
70d93620 | 111 | fQuality = phosDecode.fQuality ; |
a29c28b6 | 112 | fModule = phosDecode.fModule; |
113 | fColumn = phosDecode.fColumn; | |
114 | fRow = phosDecode.fRow; | |
39569d36 | 115 | fNewModule = phosDecode.fNewModule; |
116 | fNewColumn = phosDecode.fNewColumn; | |
117 | fNewRow = phosDecode.fNewRow; | |
118 | fNewAmp = phosDecode.fNewAmp ; | |
119 | fNewTime= phosDecode.fNewTime ; | |
56c9f64a | 120 | fLowGainFlag = phosDecode.fLowGainFlag; |
39569d36 | 121 | fNewLowGainFlag = phosDecode.fNewLowGainFlag; |
14100b90 | 122 | fOverflow = phosDecode.fOverflow ; |
56c9f64a | 123 | |
b1a8a9cb | 124 | if(fSamples) delete fSamples; |
125 | fSamples = phosDecode.fSamples; | |
126 | ||
14100b90 | 127 | if(fTimes) delete fTimes; |
128 | fTimes = phosDecode.fTimes; | |
a29c28b6 | 129 | } |
130 | ||
131 | return *this; | |
132 | } | |
133 | ||
134 | //----------------------------------------------------------------------------- | |
135 | ||
136 | Bool_t AliPHOSRawDecoder::NextDigit() | |
137 | { | |
138 | //Extract an energy deposited in the crystal, | |
139 | //crystal' position (module,column,row), | |
140 | //time and gain (high or low). | |
b1a8a9cb | 141 | |
a29c28b6 | 142 | AliCaloRawStream* in = fCaloStream; |
b1a8a9cb | 143 | |
a29c28b6 | 144 | Int_t iBin = 0; |
b1a8a9cb | 145 | Int_t mxSmps = fSamples->GetSize(); |
56c9f64a | 146 | Int_t tLength = 0; |
b1a8a9cb | 147 | fEnergy = -111; |
1267d56d | 148 | Float_t pedMean = 0; |
149 | Int_t nPed = 0; | |
150 | Float_t baseLine = 1.0; | |
c5d477f8 | 151 | const Int_t kPreSamples = 10; |
b1a8a9cb | 152 | |
153 | fSamples->Reset(); | |
14100b90 | 154 | while ( in->Next() ) { |
56c9f64a | 155 | |
156 | if(!tLength) { | |
157 | tLength = in->GetTimeLength(); | |
158 | if(tLength>mxSmps) { | |
159 | fSamples->Set(tLength); | |
160 | } | |
161 | } | |
162 | ||
163 | // Fit the full sample | |
164 | if(in->IsNewHWAddress() && iBin>0) { | |
165 | ||
166 | iBin=0; | |
39569d36 | 167 | //First remember new sample |
168 | fNewLowGainFlag = in->IsLowGain(); | |
169 | fNewModule = in->GetModule()+1; | |
170 | fNewRow = in->GetRow() +1; | |
171 | fNewColumn = in->GetColumn()+1; | |
172 | fNewAmp = in->GetSignal() ; | |
173 | fNewTime=in->GetTime() ; | |
56c9f64a | 174 | |
175 | // Temporarily we take the energy as a maximum amplitude | |
176 | // and the pedestal from the 0th point (30 Aug 2006). | |
177 | // Time is not evaluated for the moment (12.01.2007). | |
178 | // Take is as a first time bin multiplied by the sample tick time | |
179 | ||
180 | if(fPedSubtract) | |
7b02b945 | 181 | if (nPed > 0) |
182 | fEnergy -= (Double_t)(pedMean/nPed); // pedestal subtraction | |
183 | else | |
184 | return kFALSE; | |
1267d56d | 185 | if (fEnergy < baseLine) fEnergy = 0; |
186 | ||
187 | pedMean = 0; | |
56c9f64a | 188 | return kTRUE; |
189 | } | |
190 | ||
191 | fLowGainFlag = in->IsLowGain(); | |
39569d36 | 192 | // fTime = in->GetTime(); |
56c9f64a | 193 | fModule = in->GetModule()+1; |
1267d56d | 194 | fRow = in->GetRow() +1; |
56c9f64a | 195 | fColumn = in->GetColumn()+1; |
196 | ||
39569d36 | 197 | if(fLowGainFlag==fNewLowGainFlag && fModule==fNewModule && |
198 | fRow==fNewRow && fColumn==fNewColumn ){ | |
199 | if(fNewAmp>fEnergy) fEnergy = (Double_t)fNewAmp ; | |
200 | fNewModule=-1 ; | |
201 | } | |
202 | ||
14100b90 | 203 | //Calculate pedestal if necessary |
c5d477f8 | 204 | if(fPedSubtract && in->GetTime() < kPreSamples) { |
1267d56d | 205 | pedMean += in->GetSignal(); |
206 | nPed++; | |
207 | } | |
56c9f64a | 208 | if((Double_t)in->GetSignal() > fEnergy) fEnergy = (Double_t)in->GetSignal(); |
14100b90 | 209 | iBin++ ; |
56c9f64a | 210 | |
211 | } // in.Next() | |
212 | ||
213 | return kFALSE; | |
a29c28b6 | 214 | } |