//
// Typical use case:
// AliRawReader* rf = new AliRawReaderDate("2006run2211.raw");
+// AliPHOSRawDecoder dc(rf);
// while (rf->NextEvent()) {
-// AliPHOSRawDecoder dc(rf);
-// dc.SetOldRCUFormat(kTRUE);
// dc.SubtractPedestals(kTRUE);
// while ( dc.NextDigit() ) {
// Int_t module = dc.GetModule();
// Author: Boris Polichtchouk
// --- ROOT system ---
-#include "TH1.h"
+#include "TArrayI.h"
// --- AliRoot header files ---
#include "AliPHOSRawDecoder.h"
-#include "AliPHOSPulseGenerator.h"
+#include "AliRawReader.h"
ClassImp(AliPHOSRawDecoder)
//-----------------------------------------------------------------------------
AliPHOSRawDecoder::AliPHOSRawDecoder():
- fRawReader(0),fCaloStream(0),fPedSubtract(kFALSE),fEnergy(-111),fTime(-111),fModule(-1),fColumn(-1),fRow(-1)
+ fRawReader(0),fCaloStream(0),fPedSubtract(kFALSE),fEnergy(-111),fTime(-111),fQuality(0.),
+ fModule(-1),fColumn(-1),fRow(-1),fNewModule(-1),fNewColumn(-1),fNewRow(-1),fNewAmp(0),fNewTime(0),
+ fLowGainFlag(kFALSE),fNewLowGainFlag(kFALSE),fOverflow(kFALSE),fSamples(0),fTimes(0)
{
//Default constructor.
}
//-----------------------------------------------------------------------------
-AliPHOSRawDecoder::AliPHOSRawDecoder(AliRawReader* rawReader):
- fRawReader(0),fCaloStream(0),fPedSubtract(kFALSE),fEnergy(-111),fTime(-111),fModule(-1),fColumn(-1),fRow(-1)
+AliPHOSRawDecoder::AliPHOSRawDecoder(AliRawReader* rawReader, AliAltroMapping **mapping):
+ fRawReader(0),fCaloStream(0),fPedSubtract(kFALSE),fEnergy(-111),fTime(-111),fQuality(0.),
+ fModule(-1),fColumn(-1),fRow(-1),fNewModule(-1),fNewColumn(-1),fNewRow(-1),fNewAmp(0),fNewTime(0),
+ fLowGainFlag(kFALSE),fNewLowGainFlag(kFALSE),fOverflow(kFALSE),fSamples(0),fTimes(0)
{
//Construct a decoder object.
//Is is user responsibility to provide next raw event
//using AliRawReader::NextEvent().
fRawReader = rawReader;
- fCaloStream = new AliCaloRawStream(rawReader,"PHOS");
- fCaloStream->SetOldRCUFormat(kFALSE);
+ fCaloStream = new AliCaloRawStream(rawReader,"PHOS",mapping);
+ fSamples = new TArrayI(100);
+ fTimes = new TArrayI(100);
}
//-----------------------------------------------------------------------------
{
//Destructor.
- if(fCaloStream) delete fCaloStream;
+ if(fCaloStream){ delete fCaloStream; fCaloStream=0;}
+ if(fSamples){ delete fSamples; fSamples=0 ;}
+ if(fTimes){ delete fTimes; fTimes=0 ;}
}
//-----------------------------------------------------------------------------
AliPHOSRawDecoder::AliPHOSRawDecoder(const AliPHOSRawDecoder &phosDecoder ):
fRawReader(phosDecoder.fRawReader),fCaloStream(phosDecoder.fCaloStream),
fPedSubtract(phosDecoder.fPedSubtract),
- fEnergy(phosDecoder.fEnergy),fTime(phosDecoder.fTime),
+ fEnergy(phosDecoder.fEnergy),fTime(phosDecoder.fTime),fQuality(phosDecoder.fQuality),
fModule(phosDecoder.fModule),fColumn(phosDecoder.fColumn),
- fRow(phosDecoder.fRow)
+ fRow(phosDecoder.fRow),fNewModule(phosDecoder.fNewModule),fNewColumn(phosDecoder.fNewColumn),
+ fNewRow(phosDecoder.fNewRow),fNewAmp(phosDecoder.fNewAmp),fNewTime(phosDecoder.fNewTime),
+ fLowGainFlag(phosDecoder.fLowGainFlag),fNewLowGainFlag(phosDecoder.fNewLowGainFlag),
+ fOverflow(phosDecoder.fOverflow),fSamples(phosDecoder.fSamples),
+ fTimes(phosDecoder.fTimes)
{
//Copy constructor.
}
fEnergy = phosDecode.fEnergy;
fTime = phosDecode.fTime;
+ fQuality = phosDecode.fQuality ;
fModule = phosDecode.fModule;
fColumn = phosDecode.fColumn;
fRow = phosDecode.fRow;
+ fNewModule = phosDecode.fNewModule;
+ fNewColumn = phosDecode.fNewColumn;
+ fNewRow = phosDecode.fNewRow;
+ fNewAmp = phosDecode.fNewAmp ;
+ fNewTime= phosDecode.fNewTime ;
+ fLowGainFlag = phosDecode.fLowGainFlag;
+ fNewLowGainFlag = phosDecode.fNewLowGainFlag;
+ fOverflow = phosDecode.fOverflow ;
+
+ if(fSamples) delete fSamples;
+ fSamples = phosDecode.fSamples;
+
+ if(fTimes) delete fTimes;
+ fTimes = phosDecode.fTimes;
}
return *this;
//Extract an energy deposited in the crystal,
//crystal' position (module,column,row),
//time and gain (high or low).
-
+
AliCaloRawStream* in = fCaloStream;
-
- // Create a shaper pulse object
- AliPHOSPulseGenerator pulse;
-
- Bool_t lowGainFlag = kFALSE ;
+
Int_t iBin = 0;
-
- // Create histogram to store samples
- TH1F hSamples("hSamples","ALTRO samples",in->GetTimeLength(),0,in->GetTimeLength());
+ Int_t mxSmps = fSamples->GetSize();
+ Int_t tLength = 0;
+ fEnergy = -111;
+ Float_t pedMean = 0;
+ Int_t nPed = 0;
+ Float_t baseLine = 1.0;
+ const Int_t kPreSamples = 10;
+ fSamples->Reset();
while ( in->Next() ) {
- lowGainFlag = in->IsLowGain();
- // Fill histograms with samples
- hSamples.SetBinContent(in->GetTimeLength()-iBin-1,in->GetSignal());
- iBin++;
-
- // Fit the full sample
- if(iBin==in->GetTimeLength()) {
- iBin=0;
-
- // Temporarily we do not fit the sample graph, but
- // take the energy from the graph maximum, and the pedestal
- // from the 0th point (30 Aug 2006).
- // Time is not evaluated for the moment (12.01.2007).
- // Take is as a first time bin multiplied by the sample tick time
-
- fTime = pulse.GetRawFormatTimeTrigger() * in->GetTime();
-
- fModule = in->GetModule()+1;
- fRow = in->GetRow() +1;
- fColumn = in->GetColumn()+1;
-
- fEnergy = hSamples.GetMaximum(); // "digit amplitude"
- if(fPedSubtract)
- fEnergy-= hSamples.GetBinContent(0); // "pedestal subtraction"
-
- if(lowGainFlag)
- fEnergy *= pulse.GetRawFormatHighLowGainFactor(); // *16
-
- return kTRUE;
- }
-
- } // in.Next()
-
-
- return kFALSE;
+ if(!tLength) {
+ tLength = in->GetTimeLength();
+ if(tLength>mxSmps) {
+ fSamples->Set(tLength);
+ }
+ }
+
+ // Fit the full sample
+ if(in->IsNewHWAddress() && iBin>0) {
+
+ iBin=0;
+ //First remember new sample
+ fNewLowGainFlag = in->IsLowGain();
+ fNewModule = in->GetModule()+1;
+ fNewRow = in->GetRow() +1;
+ fNewColumn = in->GetColumn()+1;
+ fNewAmp = in->GetSignal() ;
+ fNewTime=in->GetTime() ;
+
+ // Temporarily we take the energy as a maximum amplitude
+ // and the pedestal from the 0th point (30 Aug 2006).
+ // Time is not evaluated for the moment (12.01.2007).
+ // Take is as a first time bin multiplied by the sample tick time
+
+ if(fPedSubtract)
+ if (nPed > 0)
+ fEnergy -= (Double_t)(pedMean/nPed); // pedestal subtraction
+ else
+ return kFALSE;
+ if (fEnergy < baseLine) fEnergy = 0;
+
+ pedMean = 0;
+ return kTRUE;
+ }
+
+ fLowGainFlag = in->IsLowGain();
+// fTime = in->GetTime();
+ fModule = in->GetModule()+1;
+ fRow = in->GetRow() +1;
+ fColumn = in->GetColumn()+1;
+
+ if(fLowGainFlag==fNewLowGainFlag && fModule==fNewModule &&
+ fRow==fNewRow && fColumn==fNewColumn ){
+ if(fNewAmp>fEnergy) fEnergy = (Double_t)fNewAmp ;
+ fNewModule=-1 ;
+ }
+
+ //Calculate pedestal if necessary
+ if(fPedSubtract && in->GetTime() < kPreSamples) {
+ pedMean += in->GetSignal();
+ nPed++;
+ }
+ if((Double_t)in->GetSignal() > fEnergy) fEnergy = (Double_t)in->GetSignal();
+ iBin++ ;
+
+ } // in.Next()
+
+ return kFALSE;
}