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 // while (rf->NextEvent()) {
24 // AliPHOSRawDecoder dc(rf);
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();
38 // Author: Boris Polichtchouk
40 // --- ROOT system ---
43 // --- AliRoot header files ---
44 #include "AliPHOSRawDecoder.h"
45 #include "AliPHOSPulseGenerator.h"
47 ClassImp(AliPHOSRawDecoder)
49 //-----------------------------------------------------------------------------
50 AliPHOSRawDecoder::AliPHOSRawDecoder():
51 fRawReader(0),fCaloStream(0),fPedSubtract(kFALSE),fEnergy(-111),fTime(-111),fModule(-1),fColumn(-1),fRow(-1)
53 //Default constructor.
56 //-----------------------------------------------------------------------------
57 AliPHOSRawDecoder::AliPHOSRawDecoder(AliRawReader* rawReader):
58 fRawReader(0),fCaloStream(0),fPedSubtract(kFALSE),fEnergy(-111),fTime(-111),fModule(-1),fColumn(-1),fRow(-1)
60 //Construct a decoder object.
61 //Is is user responsibility to provide next raw event
62 //using AliRawReader::NextEvent().
64 fRawReader = rawReader;
65 fCaloStream = new AliCaloRawStream(rawReader,"PHOS");
66 fCaloStream->SetOldRCUFormat(kFALSE);
69 //-----------------------------------------------------------------------------
70 AliPHOSRawDecoder::~AliPHOSRawDecoder()
74 if(fCaloStream) delete fCaloStream;
77 //-----------------------------------------------------------------------------
78 AliPHOSRawDecoder::AliPHOSRawDecoder(const AliPHOSRawDecoder &phosDecoder ):
79 fRawReader(phosDecoder.fRawReader),fCaloStream(phosDecoder.fCaloStream),
80 fPedSubtract(phosDecoder.fPedSubtract),
81 fEnergy(phosDecoder.fEnergy),fTime(phosDecoder.fTime),
82 fModule(phosDecoder.fModule),fColumn(phosDecoder.fColumn),
83 fRow(phosDecoder.fRow)
88 //-----------------------------------------------------------------------------
89 AliPHOSRawDecoder& AliPHOSRawDecoder::operator = (const AliPHOSRawDecoder &phosDecode)
91 //Assignment operator.
93 if(this != &phosDecode) {
94 fRawReader = phosDecode.fRawReader;
96 if(fCaloStream) delete fCaloStream;
97 fCaloStream = phosDecode.fCaloStream;
99 fEnergy = phosDecode.fEnergy;
100 fTime = phosDecode.fTime;
101 fModule = phosDecode.fModule;
102 fColumn = phosDecode.fColumn;
103 fRow = phosDecode.fRow;
109 //-----------------------------------------------------------------------------
111 Bool_t AliPHOSRawDecoder::NextDigit()
113 //Extract an energy deposited in the crystal,
114 //crystal' position (module,column,row),
115 //time and gain (high or low).
117 AliCaloRawStream* in = fCaloStream;
119 // Create a shaper pulse object
120 AliPHOSPulseGenerator pulse;
122 Bool_t lowGainFlag = kFALSE ;
125 // Create histogram to store samples
126 TH1F hSamples("hSamples","ALTRO samples",in->GetTimeLength(),0,in->GetTimeLength());
128 while ( in->Next() ) {
130 lowGainFlag = in->IsLowGain();
131 // Fill histograms with samples
132 hSamples.SetBinContent(in->GetTimeLength()-iBin-1,in->GetSignal());
135 // Fit the full sample
136 if(iBin==in->GetTimeLength()) {
139 // Temporarily we do not fit the sample graph, but
140 // take the energy from the graph maximum, and the pedestal
141 // from the 0th point (30 Aug 2006).
142 // Time is not evaluated for the moment (12.01.2007).
143 // Take is as a first time bin multiplied by the sample tick time
145 fTime = pulse.GetRawFormatTimeTrigger() * in->GetTime();
147 fModule = in->GetModule()+1;
148 fRow = in->GetRow() +1;
149 fColumn = in->GetColumn()+1;
151 fEnergy = hSamples.GetMaximum(); // "digit amplitude"
153 fEnergy-= hSamples.GetBinContent(0); // "pedestal subtraction"
156 fEnergy *= pulse.GetRawFormatHighLowGainFactor(); // *16