1 /**************************************************************************
2 * Copyright(c) 2007, 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 // This class decodes the stream of ALTRO samples to extract
19 // the PHOS "digits" of current event.
22 // AliRawReader* rf = new AliRawReaderDate("2006run2211.raw");
23 // AliPHOSRawDecoder dc(rf);
24 // while (rf->NextEvent()) {
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();
37 // Author: Boris Polichtchouk
39 // --- ROOT system ---
43 // --- AliRoot header files ---
44 #include "AliPHOSRawDecoder.h"
45 #include "AliRawReader.h"
47 ClassImp(AliPHOSRawDecoder)
49 //-----------------------------------------------------------------------------
50 AliPHOSRawDecoder::AliPHOSRawDecoder():
51 fRawReader(0),fCaloStream(0),fPedSubtract(kFALSE),fEnergy(-111),fTime(-111),fQuality(0.),fPedestalRMS(0.),
52 fModule(-1),fColumn(-1),fRow(-1),fNewModule(-1),fNewColumn(-1),fNewRow(-1),fNewAmp(0),fNewTime(0),
53 fLowGainFlag(kFALSE),fNewLowGainFlag(kFALSE),fOverflow(kFALSE),fSamples(0),fTimes(0)
55 //Default constructor.
58 //-----------------------------------------------------------------------------
59 AliPHOSRawDecoder::AliPHOSRawDecoder(AliRawReader* rawReader, AliAltroMapping **mapping):
60 fRawReader(0),fCaloStream(0),fPedSubtract(kFALSE),fEnergy(-111),fTime(-111),fQuality(0.),fPedestalRMS(0.),
61 fModule(-1),fColumn(-1),fRow(-1),fNewModule(-1),fNewColumn(-1),fNewRow(-1),fNewAmp(0),fNewTime(0),
62 fLowGainFlag(kFALSE),fNewLowGainFlag(kFALSE),fOverflow(kFALSE),fSamples(0),fTimes(0)
64 //Construct a decoder object.
65 //Is is user responsibility to provide next raw event
66 //using AliRawReader::NextEvent().
68 fRawReader = rawReader;
69 fCaloStream = new AliCaloRawStream(rawReader,"PHOS",mapping);
70 fSamples = new TArrayI(100);
71 fTimes = new TArrayI(100);
74 //-----------------------------------------------------------------------------
75 AliPHOSRawDecoder::~AliPHOSRawDecoder()
79 if(fCaloStream){ delete fCaloStream; fCaloStream=0;}
80 if(fSamples){ delete fSamples; fSamples=0 ;}
81 if(fTimes){ delete fTimes; fTimes=0 ;}
84 //-----------------------------------------------------------------------------
85 AliPHOSRawDecoder::AliPHOSRawDecoder(const AliPHOSRawDecoder &phosDecoder ):
86 fRawReader(phosDecoder.fRawReader),fCaloStream(phosDecoder.fCaloStream),
87 fPedSubtract(phosDecoder.fPedSubtract),
88 fEnergy(phosDecoder.fEnergy),fTime(phosDecoder.fTime),fQuality(phosDecoder.fQuality),fPedestalRMS(phosDecoder.fPedestalRMS),
89 fModule(phosDecoder.fModule),fColumn(phosDecoder.fColumn),
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),
93 fOverflow(phosDecoder.fOverflow),fSamples(phosDecoder.fSamples),
94 fTimes(phosDecoder.fTimes)
99 //-----------------------------------------------------------------------------
100 AliPHOSRawDecoder& AliPHOSRawDecoder::operator = (const AliPHOSRawDecoder &phosDecode)
102 //Assignment operator.
104 if(this != &phosDecode) {
105 fRawReader = phosDecode.fRawReader;
107 if(fCaloStream) delete fCaloStream;
108 fCaloStream = phosDecode.fCaloStream;
110 fEnergy = phosDecode.fEnergy;
111 fTime = phosDecode.fTime;
112 fQuality = phosDecode.fQuality ;
113 fModule = phosDecode.fModule;
114 fColumn = phosDecode.fColumn;
115 fRow = phosDecode.fRow;
116 fNewModule = phosDecode.fNewModule;
117 fNewColumn = phosDecode.fNewColumn;
118 fNewRow = phosDecode.fNewRow;
119 fNewAmp = phosDecode.fNewAmp ;
120 fNewTime= phosDecode.fNewTime ;
121 fLowGainFlag = phosDecode.fLowGainFlag;
122 fNewLowGainFlag = phosDecode.fNewLowGainFlag;
123 fOverflow = phosDecode.fOverflow ;
125 if(fSamples) delete fSamples;
126 fSamples = phosDecode.fSamples;
128 if(fTimes) delete fTimes;
129 fTimes = phosDecode.fTimes;
135 //-----------------------------------------------------------------------------
137 Bool_t AliPHOSRawDecoder::NextDigit()
139 //Extract an energy deposited in the crystal,
140 //crystal' position (module,column,row),
141 //time and gain (high or low).
143 AliCaloRawStream* in = fCaloStream;
146 Int_t mxSmps = fSamples->GetSize();
152 Float_t baseLine = 1.0;
153 const Int_t kPreSamples = 10;
156 while ( in->Next() ) {
159 tLength = in->GetTimeLength();
161 fSamples->Set(tLength);
165 // Fit the full sample
166 if(in->IsNewHWAddress() && iBin>0) {
169 //First remember new sample
170 fNewLowGainFlag = in->IsLowGain();
171 fNewModule = in->GetModule()+1;
172 fNewRow = in->GetRow() +1;
173 fNewColumn = in->GetColumn()+1;
174 fNewAmp = in->GetSignal() ;
175 fNewTime=in->GetTime() ;
177 // Temporarily we take the energy as a maximum amplitude
178 // and the pedestal from the 0th point (30 Aug 2006).
179 // Time is not evaluated for the moment (12.01.2007).
180 // Take is as a first time bin multiplied by the sample tick time
184 fPedestalRMS=(pedRMS-pedMean*pedMean/nPed)/nPed ;
185 if(fPedestalRMS > 0.)
186 fPedestalRMS = TMath::Sqrt(fPedestalRMS) ;
187 fEnergy -= (Double_t)(pedMean/nPed); // pedestal subtraction
191 if (fEnergy < baseLine) fEnergy = 0;
196 fLowGainFlag = in->IsLowGain();
197 // fTime = in->GetTime();
199 fModule = in->GetModule()+1;
200 fRow = in->GetRow() +1;
201 fColumn = in->GetColumn()+1;
203 if(fLowGainFlag==fNewLowGainFlag && fModule==fNewModule &&
204 fRow==fNewRow && fColumn==fNewColumn ){
205 if(fNewAmp>fEnergy) fEnergy = (Double_t)fNewAmp ;
209 //Calculate pedestal if necessary
210 if(fPedSubtract && in->GetTime() < kPreSamples) {
211 pedMean += in->GetSignal();
212 pedRMS+=in->GetSignal()*in->GetSignal() ;
215 if((Double_t)in->GetSignal() > fEnergy) fEnergy = (Double_t)in->GetSignal();