]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSRawDecoder.cxx
Runloader is updated when moving to next file (quick fix).
[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");
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();
34// ..........
35// }
36// }
37
38// Author: Boris Polichtchouk
39
40// --- ROOT system ---
41#include "TH1.h"
42
43// --- AliRoot header files ---
44#include "AliPHOSRawDecoder.h"
45#include "AliPHOSPulseGenerator.h"
46
47ClassImp(AliPHOSRawDecoder)
48
49//-----------------------------------------------------------------------------
50AliPHOSRawDecoder::AliPHOSRawDecoder():
51 fRawReader(0),fCaloStream(0),fPedSubtract(kFALSE),fEnergy(-111),fTime(-111),fModule(-1),fColumn(-1),fRow(-1)
52{
53 //Default constructor.
54}
55
56//-----------------------------------------------------------------------------
57AliPHOSRawDecoder::AliPHOSRawDecoder(AliRawReader* rawReader):
58 fRawReader(0),fCaloStream(0),fPedSubtract(kFALSE),fEnergy(-111),fTime(-111),fModule(-1),fColumn(-1),fRow(-1)
59{
60 //Construct a decoder object.
61 //Is is user responsibility to provide next raw event
62 //using AliRawReader::NextEvent().
63
64 fRawReader = rawReader;
65 fCaloStream = new AliCaloRawStream(rawReader,"PHOS");
66 fCaloStream->SetOldRCUFormat(kFALSE);
67}
68
69//-----------------------------------------------------------------------------
70AliPHOSRawDecoder::~AliPHOSRawDecoder()
71{
72 //Destructor.
73
74 if(fCaloStream) delete fCaloStream;
75}
76
77//-----------------------------------------------------------------------------
78AliPHOSRawDecoder::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)
84{
85 //Copy constructor.
86}
87
88//-----------------------------------------------------------------------------
89AliPHOSRawDecoder& AliPHOSRawDecoder::operator = (const AliPHOSRawDecoder &phosDecode)
90{
7bc140a5 91 //Assignment operator.
92
a29c28b6 93 if(this != &phosDecode) {
94 fRawReader = phosDecode.fRawReader;
95
96 if(fCaloStream) delete fCaloStream;
97 fCaloStream = phosDecode.fCaloStream;
98
99 fEnergy = phosDecode.fEnergy;
100 fTime = phosDecode.fTime;
101 fModule = phosDecode.fModule;
102 fColumn = phosDecode.fColumn;
103 fRow = phosDecode.fRow;
104 }
105
106 return *this;
107}
108
109//-----------------------------------------------------------------------------
110
111Bool_t AliPHOSRawDecoder::NextDigit()
112{
113 //Extract an energy deposited in the crystal,
114 //crystal' position (module,column,row),
115 //time and gain (high or low).
116
117 AliCaloRawStream* in = fCaloStream;
118
119 // Create a shaper pulse object
120 AliPHOSPulseGenerator pulse;
121
122 Bool_t lowGainFlag = kFALSE ;
123 Int_t iBin = 0;
124
125 // Create histogram to store samples
126 TH1F hSamples("hSamples","ALTRO samples",in->GetTimeLength(),0,in->GetTimeLength());
127
128 while ( in->Next() ) {
129
130 lowGainFlag = in->IsLowGain();
131 // Fill histograms with samples
132 hSamples.SetBinContent(in->GetTimeLength()-iBin-1,in->GetSignal());
133 iBin++;
134
135 // Fit the full sample
136 if(iBin==in->GetTimeLength()) {
137 iBin=0;
138
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
144
145 fTime = pulse.GetRawFormatTimeTrigger() * in->GetTime();
146
147 fModule = in->GetModule()+1;
148 fRow = in->GetRow() +1;
149 fColumn = in->GetColumn()+1;
150
151 fEnergy = hSamples.GetMaximum(); // "digit amplitude"
152 if(fPedSubtract)
153 fEnergy-= hSamples.GetBinContent(0); // "pedestal subtraction"
154
155 if(lowGainFlag)
156 fEnergy *= pulse.GetRawFormatHighLowGainFactor(); // *16
157
158 return kTRUE;
159 }
160
161 } // in.Next()
162
163
164 return kFALSE;
165}