]>
Commit | Line | Data |
---|---|---|
1 | /************************************************************************** | |
2 | * Copyright(c) 1998-1999, 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 | /* $Id: AliTPCCalibRawBase.cxx */ | |
17 | ||
18 | ///////////////////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // Base class for the calibration algorithms using raw data as input // | |
21 | // // | |
22 | // Origin: Jens Wiechula J.Wiechula@gsi.de // | |
23 | // // | |
24 | ///////////////////////////////////////////////////////////////////////////////////////// | |
25 | ||
26 | //Root includes | |
27 | #include <TDirectory.h> | |
28 | #include <TFile.h> | |
29 | ||
30 | //Aliroot includes | |
31 | #include "AliRawReaderDate.h" | |
32 | #include "AliRawReader.h" | |
33 | #include "AliRawEventHeaderBase.h" | |
34 | #include "AliAltroMapping.h" | |
35 | #include "AliAltroRawStream.h" | |
36 | #include "AliTPCROC.h" | |
37 | #include "AliTPCRawStreamFast.h" | |
38 | #include "AliTPCRawStream.h" | |
39 | #include "TTreeStream.h" | |
40 | #include "event.h" | |
41 | ||
42 | #include "AliTPCCalibRawBase.h" | |
43 | ||
44 | ClassImp(AliTPCCalibRawBase) | |
45 | ||
46 | AliTPCCalibRawBase::AliTPCCalibRawBase() : | |
47 | TNamed(), | |
48 | fFirstTimeBin(0), | |
49 | fLastTimeBin(1000), | |
50 | fNevents(0), | |
51 | fDebugLevel(0), | |
52 | fStreamLevel(0), | |
53 | fTimeStamp(0), | |
54 | fRunNumber(0), | |
55 | fEventType(0), | |
56 | fAltroL1Phase(0), | |
57 | fAltroL1PhaseTB(0), | |
58 | fUseL1Phase(kTRUE), | |
59 | fDebugStreamer(0x0), | |
60 | fAltroRawStream(0x0), | |
61 | fMapping(0x0), | |
62 | fROC(AliTPCROC::Instance()) | |
63 | { | |
64 | // | |
65 | // default ctor | |
66 | // | |
67 | ||
68 | } | |
69 | //_____________________________________________________________________ | |
70 | AliTPCCalibRawBase::AliTPCCalibRawBase(const AliTPCCalibRawBase &calib) : | |
71 | TNamed(calib), | |
72 | fFirstTimeBin(calib.fFirstTimeBin), | |
73 | fLastTimeBin(calib.fLastTimeBin), | |
74 | fNevents(calib.fNevents), | |
75 | fDebugLevel(calib.fDebugLevel), | |
76 | fStreamLevel(calib.fStreamLevel), | |
77 | fTimeStamp(0), | |
78 | fRunNumber(0), | |
79 | fEventType(0), | |
80 | fAltroL1Phase(0), | |
81 | fAltroL1PhaseTB(0), | |
82 | fUseL1Phase(kTRUE), | |
83 | fDebugStreamer(0x0), | |
84 | fAltroRawStream(0x0), | |
85 | fMapping(0x0), | |
86 | fROC(AliTPCROC::Instance()) | |
87 | { | |
88 | // | |
89 | // copy ctor | |
90 | // | |
91 | ||
92 | } | |
93 | //_____________________________________________________________________ | |
94 | AliTPCCalibRawBase::~AliTPCCalibRawBase() | |
95 | { | |
96 | // | |
97 | // dtor | |
98 | // | |
99 | if (fDebugStreamer) delete fDebugStreamer; | |
100 | } | |
101 | //_____________________________________________________________________ | |
102 | AliTPCCalibRawBase& AliTPCCalibRawBase::operator = (const AliTPCCalibRawBase &source) | |
103 | { | |
104 | // | |
105 | // assignment operator | |
106 | // | |
107 | if (&source == this) return *this; | |
108 | new (this) AliTPCCalibRawBase(source); | |
109 | ||
110 | return *this; | |
111 | } | |
112 | //_____________________________________________________________________ | |
113 | Bool_t AliTPCCalibRawBase::ProcessEventFast(AliTPCRawStreamFast *rawStreamFast) | |
114 | { | |
115 | // | |
116 | // Event Processing loop - AliTPCRawStreamFast | |
117 | // | |
118 | ResetEvent(); | |
119 | Bool_t withInput = kFALSE; | |
120 | while ( rawStreamFast->NextDDL() ){ | |
121 | while ( rawStreamFast->NextChannel() ){ | |
122 | Int_t isector = rawStreamFast->GetSector(); // current sector | |
123 | Int_t iRow = rawStreamFast->GetRow(); // current row | |
124 | Int_t iPad = rawStreamFast->GetPad(); // current pad | |
125 | ||
126 | while ( rawStreamFast->NextBunch() ){ | |
127 | Int_t startTbin = (Int_t)rawStreamFast->GetStartTimeBin(); | |
128 | Int_t endTbin = (Int_t)rawStreamFast->GetEndTimeBin(); | |
129 | for (Int_t iTimeBin = startTbin; iTimeBin < endTbin; iTimeBin++){ | |
130 | Float_t signal=(Float_t)rawStreamFast->GetSignals()[iTimeBin-startTbin]; | |
131 | Update(isector,iRow,iPad,iTimeBin+1,signal); | |
132 | withInput = kTRUE; | |
133 | } | |
134 | } | |
135 | } | |
136 | } | |
137 | if (withInput){ | |
138 | EndEvent(); | |
139 | } | |
140 | return withInput; | |
141 | } | |
142 | //_____________________________________________________________________ | |
143 | Bool_t AliTPCCalibRawBase::ProcessEventFast(AliRawReader *rawReader) | |
144 | { | |
145 | // | |
146 | // Event processing loop - AliRawReader | |
147 | // | |
148 | AliRawEventHeaderBase* eventHeader = (AliRawEventHeaderBase*)rawReader->GetEventHeader(); | |
149 | if (eventHeader){ | |
150 | fTimeStamp = eventHeader->Get("Timestamp"); | |
151 | fRunNumber = eventHeader->Get("RunNb"); | |
152 | fEventType = eventHeader->Get("Type"); | |
153 | } | |
154 | AliTPCRawStreamFast *rawStreamFast = new AliTPCRawStreamFast(rawReader, (AliAltroMapping**)fMapping); | |
155 | Bool_t res=ProcessEventFast(rawStreamFast); | |
156 | delete rawStreamFast; | |
157 | return res; | |
158 | } | |
159 | //_____________________________________________________________________ | |
160 | Bool_t AliTPCCalibRawBase::ProcessEvent(AliTPCRawStream *rawStream) | |
161 | { | |
162 | // | |
163 | // Event Processing loop - AliTPCRawStream | |
164 | // | |
165 | ||
166 | ResetEvent(); | |
167 | ||
168 | Bool_t withInput = kFALSE; | |
169 | fAltroL1Phase=0; | |
170 | fAltroL1PhaseTB=0; | |
171 | fAltroRawStream = static_cast<AliAltroRawStream*>(rawStream); | |
172 | while (rawStream->Next()) { | |
173 | if (fUseL1Phase){ | |
174 | fAltroL1Phase = fAltroRawStream->GetL1Phase(); | |
175 | fAltroL1PhaseTB = (fAltroL1Phase*1e09/100.); | |
176 | } | |
177 | Int_t isector = rawStream->GetSector(); // current sector | |
178 | Int_t iRow = rawStream->GetRow(); // current row | |
179 | Int_t iPad = rawStream->GetPad(); // current pad | |
180 | Int_t iTimeBin = rawStream->GetTime(); // current time bin | |
181 | Float_t signal = rawStream->GetSignal(); // current ADC signal | |
182 | ||
183 | Update(isector,iRow,iPad,iTimeBin,signal); | |
184 | withInput = kTRUE; | |
185 | } | |
186 | fAltroRawStream=0x0; | |
187 | if (withInput){ | |
188 | EndEvent(); | |
189 | } | |
190 | return withInput; | |
191 | } | |
192 | //_____________________________________________________________________ | |
193 | Bool_t AliTPCCalibRawBase::ProcessEvent(AliRawReader *rawReader) | |
194 | { | |
195 | // | |
196 | // Event processing loop - AliRawReader | |
197 | // | |
198 | AliRawEventHeaderBase* eventHeader = (AliRawEventHeaderBase*)rawReader->GetEventHeader(); | |
199 | if (eventHeader){ | |
200 | fTimeStamp = eventHeader->Get("Timestamp"); | |
201 | fRunNumber = eventHeader->Get("RunNb"); | |
202 | fEventType = eventHeader->Get("Type"); | |
203 | } | |
204 | ||
205 | AliTPCRawStream rawStream(rawReader, (AliAltroMapping**)fMapping); | |
206 | rawReader->Select("TPC"); | |
207 | return ProcessEvent(&rawStream); | |
208 | } | |
209 | //_____________________________________________________________________ | |
210 | Bool_t AliTPCCalibRawBase::ProcessEvent(eventHeaderStruct *event) | |
211 | { | |
212 | // | |
213 | // Event processing loop - date event | |
214 | // | |
215 | AliRawReader *rawReader = new AliRawReaderDate((void*)event); | |
216 | Bool_t result=ProcessEvent(rawReader); | |
217 | delete rawReader; | |
218 | return result; | |
219 | ||
220 | } | |
221 | //_____________________________________________________________________ | |
222 | void AliTPCCalibRawBase::DumpToFile(const Char_t *filename, const Char_t *dir, Bool_t append) | |
223 | { | |
224 | // | |
225 | // Write class to file | |
226 | // | |
227 | ||
228 | TString sDir(dir); | |
229 | TString option; | |
230 | ||
231 | if ( append ) | |
232 | option = "update"; | |
233 | else | |
234 | option = "recreate"; | |
235 | ||
236 | TDirectory *backup = gDirectory; | |
237 | TFile f(filename,option.Data()); | |
238 | f.cd(); | |
239 | if ( !sDir.IsNull() ){ | |
240 | f.mkdir(sDir.Data()); | |
241 | f.cd(sDir); | |
242 | } | |
243 | this->Write(); | |
244 | f.Close(); | |
245 | ||
246 | if ( backup ) backup->cd(); | |
247 | } | |
248 | //_____________________________________________________________________ | |
249 | TTreeSRedirector *AliTPCCalibRawBase::GetDebugStreamer(){ | |
250 | // | |
251 | // Get Debug streamer | |
252 | // In case debug streamer not yet initialized and StreamLevel>0 create new one | |
253 | // | |
254 | if (fStreamLevel==0) return 0; | |
255 | if (fDebugStreamer) return fDebugStreamer; | |
256 | TString dsName; | |
257 | dsName=GetName(); | |
258 | dsName+="Debug.root"; | |
259 | dsName.ReplaceAll(" ",""); | |
260 | fDebugStreamer = new TTreeSRedirector(dsName.Data()); | |
261 | return fDebugStreamer; | |
262 | } |