]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSRawDecoder.cxx
Propagating the tracks to the primary vertex reconstructed with the tracks
[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
16// This class decodes the stream of ALTRO samples to extract
17// the PHOS "digits" of current event.
18//
19// Typical use case:
20// AliRawReader* rf = new AliRawReaderDate("2006run2211.raw");
21// while (rf->NextEvent()) {
22// AliPHOSRawDecoder dc(rf);
23// dc.SetOldRCUFormat(kTRUE);
24// dc.SubtractPedestals(kTRUE);
25// while ( dc.NextDigit() ) {
26// Int_t module = dc.GetModule();
27// Int_t column = dc.GetColumn();
28// Int_t row = dc.GetRow();
29// Double_t amplitude = dc.GetEnergy();
30// Double_t time = dc.GetTime();
31// Bool_t IsLowGain = dc.IsLowGain();
32// ..........
33// }
34// }
35
36// Author: Boris Polichtchouk
37
38// --- ROOT system ---
39#include "TH1.h"
40
41// --- AliRoot header files ---
42#include "AliPHOSRawDecoder.h"
43#include "AliPHOSPulseGenerator.h"
44
45ClassImp(AliPHOSRawDecoder)
46
47//-----------------------------------------------------------------------------
48AliPHOSRawDecoder::AliPHOSRawDecoder():
49 fRawReader(0),fCaloStream(0),fPedSubtract(kFALSE),fEnergy(-111),fTime(-111),fModule(-1),fColumn(-1),fRow(-1)
50{
51 //Default constructor.
52}
53
54//-----------------------------------------------------------------------------
55AliPHOSRawDecoder::AliPHOSRawDecoder(AliRawReader* rawReader):
56 fRawReader(0),fCaloStream(0),fPedSubtract(kFALSE),fEnergy(-111),fTime(-111),fModule(-1),fColumn(-1),fRow(-1)
57{
58 //Construct a decoder object.
59 //Is is user responsibility to provide next raw event
60 //using AliRawReader::NextEvent().
61
62 fRawReader = rawReader;
63 fCaloStream = new AliCaloRawStream(rawReader,"PHOS");
64 fCaloStream->SetOldRCUFormat(kFALSE);
65}
66
67//-----------------------------------------------------------------------------
68AliPHOSRawDecoder::~AliPHOSRawDecoder()
69{
70 //Destructor.
71
72 if(fCaloStream) delete fCaloStream;
73}
74
75//-----------------------------------------------------------------------------
76AliPHOSRawDecoder::AliPHOSRawDecoder(const AliPHOSRawDecoder &phosDecoder ):
77 fRawReader(phosDecoder.fRawReader),fCaloStream(phosDecoder.fCaloStream),
78 fPedSubtract(phosDecoder.fPedSubtract),
79 fEnergy(phosDecoder.fEnergy),fTime(phosDecoder.fTime),
80 fModule(phosDecoder.fModule),fColumn(phosDecoder.fColumn),
81 fRow(phosDecoder.fRow)
82{
83 //Copy constructor.
84}
85
86//-----------------------------------------------------------------------------
87AliPHOSRawDecoder& AliPHOSRawDecoder::operator = (const AliPHOSRawDecoder &phosDecode)
88{
89 if(this != &phosDecode) {
90 fRawReader = phosDecode.fRawReader;
91
92 if(fCaloStream) delete fCaloStream;
93 fCaloStream = phosDecode.fCaloStream;
94
95 fEnergy = phosDecode.fEnergy;
96 fTime = phosDecode.fTime;
97 fModule = phosDecode.fModule;
98 fColumn = phosDecode.fColumn;
99 fRow = phosDecode.fRow;
100 }
101
102 return *this;
103}
104
105//-----------------------------------------------------------------------------
106
107Bool_t AliPHOSRawDecoder::NextDigit()
108{
109 //Extract an energy deposited in the crystal,
110 //crystal' position (module,column,row),
111 //time and gain (high or low).
112
113 AliCaloRawStream* in = fCaloStream;
114
115 // Create a shaper pulse object
116 AliPHOSPulseGenerator pulse;
117
118 Bool_t lowGainFlag = kFALSE ;
119 Int_t iBin = 0;
120
121 // Create histogram to store samples
122 TH1F hSamples("hSamples","ALTRO samples",in->GetTimeLength(),0,in->GetTimeLength());
123
124 while ( in->Next() ) {
125
126 lowGainFlag = in->IsLowGain();
127 // Fill histograms with samples
128 hSamples.SetBinContent(in->GetTimeLength()-iBin-1,in->GetSignal());
129 iBin++;
130
131 // Fit the full sample
132 if(iBin==in->GetTimeLength()) {
133 iBin=0;
134
135 // Temporarily we do not fit the sample graph, but
136 // take the energy from the graph maximum, and the pedestal
137 // from the 0th point (30 Aug 2006).
138 // Time is not evaluated for the moment (12.01.2007).
139 // Take is as a first time bin multiplied by the sample tick time
140
141 fTime = pulse.GetRawFormatTimeTrigger() * in->GetTime();
142
143 fModule = in->GetModule()+1;
144 fRow = in->GetRow() +1;
145 fColumn = in->GetColumn()+1;
146
147 fEnergy = hSamples.GetMaximum(); // "digit amplitude"
148 if(fPedSubtract)
149 fEnergy-= hSamples.GetBinContent(0); // "pedestal subtraction"
150
151 if(lowGainFlag)
152 fEnergy *= pulse.GetRawFormatHighLowGainFactor(); // *16
153
154 return kTRUE;
155 }
156
157 } // in.Next()
158
159
160 return kFALSE;
161}