]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCCalibRawBase.cxx
1- Storing in the output of the cuts object
[u/mrichter/AliRoot.git] / TPC / AliTPCCalibRawBase.cxx
CommitLineData
880c3382 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"
c3066940 38#include "AliTPCRawStreamV3.h"
880c3382 39#include "AliTPCRawStream.h"
c3066940 40#include "AliLog.h"
880c3382 41#include "TTreeStream.h"
42#include "event.h"
43
44#include "AliTPCCalibRawBase.h"
45
46ClassImp(AliTPCCalibRawBase)
47
48AliTPCCalibRawBase::AliTPCCalibRawBase() :
49 TNamed(),
50 fFirstTimeBin(0),
51 fLastTimeBin(1000),
52 fNevents(0),
53 fDebugLevel(0),
54 fStreamLevel(0),
880c3382 55 fRunNumber(0),
c3066940 56 fTimeStamp(0),
880c3382 57 fEventType(0),
58 fAltroL1Phase(0),
59 fAltroL1PhaseTB(0),
c3066940 60 fCurrRCUId(-1),
61 fPrevRCUId(-1),
62 fCurrDDLNum(-1),
63 fPrevDDLNum(-1),
880c3382 64 fUseL1Phase(kTRUE),
65 fDebugStreamer(0x0),
66 fAltroRawStream(0x0),
67 fMapping(0x0),
68 fROC(AliTPCROC::Instance())
69{
70 //
71 // default ctor
72 //
73
74}
75//_____________________________________________________________________
76AliTPCCalibRawBase::AliTPCCalibRawBase(const AliTPCCalibRawBase &calib) :
77 TNamed(calib),
78 fFirstTimeBin(calib.fFirstTimeBin),
79 fLastTimeBin(calib.fLastTimeBin),
80 fNevents(calib.fNevents),
81 fDebugLevel(calib.fDebugLevel),
82 fStreamLevel(calib.fStreamLevel),
880c3382 83 fRunNumber(0),
c3066940 84 fTimeStamp(0),
880c3382 85 fEventType(0),
86 fAltroL1Phase(0),
87 fAltroL1PhaseTB(0),
c3066940 88 fCurrRCUId(-1),
89 fPrevRCUId(-1),
90 fCurrDDLNum(-1),
91 fPrevDDLNum(-1),
880c3382 92 fUseL1Phase(kTRUE),
93 fDebugStreamer(0x0),
94 fAltroRawStream(0x0),
95 fMapping(0x0),
96 fROC(AliTPCROC::Instance())
97{
98 //
99 // copy ctor
100 //
101
102}
103//_____________________________________________________________________
104AliTPCCalibRawBase::~AliTPCCalibRawBase()
105{
106 //
107 // dtor
108 //
109 if (fDebugStreamer) delete fDebugStreamer;
110}
111//_____________________________________________________________________
112 AliTPCCalibRawBase& AliTPCCalibRawBase::operator = (const AliTPCCalibRawBase &source)
113 {
114 //
115 // assignment operator
116 //
117 if (&source == this) return *this;
118 new (this) AliTPCCalibRawBase(source);
119
120 return *this;
121 }
122//_____________________________________________________________________
7442bceb 123Bool_t AliTPCCalibRawBase::ProcessEventFast(AliTPCRawStreamFast * const rawStreamFast)
880c3382 124{
125 //
126 // Event Processing loop - AliTPCRawStreamFast
127 //
128 ResetEvent();
129 Bool_t withInput = kFALSE;
130 while ( rawStreamFast->NextDDL() ){
131 while ( rawStreamFast->NextChannel() ){
132 Int_t isector = rawStreamFast->GetSector(); // current sector
133 Int_t iRow = rawStreamFast->GetRow(); // current row
134 Int_t iPad = rawStreamFast->GetPad(); // current pad
135
136 while ( rawStreamFast->NextBunch() ){
137 Int_t startTbin = (Int_t)rawStreamFast->GetStartTimeBin();
138 Int_t endTbin = (Int_t)rawStreamFast->GetEndTimeBin();
139 for (Int_t iTimeBin = startTbin; iTimeBin < endTbin; iTimeBin++){
140 Float_t signal=(Float_t)rawStreamFast->GetSignals()[iTimeBin-startTbin];
c3066940 141 Update(isector,iRow,iPad,iTimeBin+1,signal);
880c3382 142 withInput = kTRUE;
143 }
144 }
145 }
146 }
147 if (withInput){
148 EndEvent();
149 }
150 return withInput;
151}
152//_____________________________________________________________________
7442bceb 153Bool_t AliTPCCalibRawBase::ProcessEventFast(AliRawReader * const rawReader)
880c3382 154{
155 //
156 // Event processing loop - AliRawReader
157 //
158 AliRawEventHeaderBase* eventHeader = (AliRawEventHeaderBase*)rawReader->GetEventHeader();
159 if (eventHeader){
160 fTimeStamp = eventHeader->Get("Timestamp");
161 fRunNumber = eventHeader->Get("RunNb");
162 fEventType = eventHeader->Get("Type");
163 }
164 AliTPCRawStreamFast *rawStreamFast = new AliTPCRawStreamFast(rawReader, (AliAltroMapping**)fMapping);
165 Bool_t res=ProcessEventFast(rawStreamFast);
166 delete rawStreamFast;
167 return res;
168}
169//_____________________________________________________________________
7442bceb 170Bool_t AliTPCCalibRawBase::ProcessEvent(AliTPCRawStreamV3 * const rawStreamV3)
c3066940 171{
172 //
173 // Event Processing loop - AliTPCRawStreamV3
174 //
175 ResetEvent();
176 Bool_t withInput = kFALSE;
177 fAltroL1Phase=0;
178 fAltroL1PhaseTB=0;
179// fAltroRawStream = static_cast<AliAltroRawStream*>(rawStreamV3);
180 while ( rawStreamV3->NextDDL() ){
181 if (AliLog::GetGlobalDebugLevel()>2) rawStreamV3->PrintRCUTrailer();
5312f439 182 fPrevDDLNum=-1;
183 fCurrRCUId=rawStreamV3->GetRCUId();
184 fCurrDDLNum=rawStreamV3->GetDDLNumber();
c3066940 185 if (fUseL1Phase){
186// fAltroL1Phase = fAltroRawStream->GetL1Phase();
187 fAltroL1Phase = rawStreamV3->GetL1Phase();
188 fAltroL1PhaseTB = (fAltroL1Phase*1e09/100.);
5312f439 189 AliDebug(1, Form("L1Phase: %.2e (%03d)\n",fAltroL1PhaseTB,fCurrDDLNum));
c3066940 190 }
5312f439 191 UpdateDDL();
c3066940 192 while ( rawStreamV3->NextChannel() ){
193 Int_t isector = rawStreamV3->GetSector(); // current sector
194 Int_t iRow = rawStreamV3->GetRow(); // current row
195 Int_t iPad = rawStreamV3->GetPad(); // current pad
196 while ( rawStreamV3->NextBunch() ){
96bf9029 197 UInt_t startTbin = rawStreamV3->GetStartTimeBin();
c3066940 198// Int_t endTbin = (Int_t)rawStreamV3->GetEndTimeBin();
96bf9029 199 Int_t bunchlength = rawStreamV3->GetBunchLength();
c3066940 200 const UShort_t *sig = rawStreamV3->GetSignals();
96bf9029 201 ProcessBunch(isector,iRow,iPad,bunchlength,startTbin,sig);
c3066940 202 for (Int_t iTimeBin = 0; iTimeBin<bunchlength; iTimeBin++){
203 Float_t signal=(Float_t)sig[iTimeBin];
204// printf("%02d - %03d - %03d - %04d: %.1f\n",isector,iRow,iPad,startTbin,signal);
205 Update(isector,iRow,iPad,startTbin--,signal);
206 fPrevRCUId=fCurrRCUId;
207 fPrevDDLNum=fCurrDDLNum;
208 withInput = kTRUE;
209 }
210 }
211 }
212 }
213 if (withInput){
214 EndEvent();
215 }
216 return withInput;
217}
218//_____________________________________________________________________
7442bceb 219Bool_t AliTPCCalibRawBase::ProcessEvent(AliRawReader * const rawReader)
c3066940 220{
221 //
222 // Event processing loop - AliRawReader
223 //
224 AliRawEventHeaderBase* eventHeader = (AliRawEventHeaderBase*)rawReader->GetEventHeader();
225 if (eventHeader){
226 fTimeStamp = eventHeader->Get("Timestamp");
227 fRunNumber = eventHeader->Get("RunNb");
228 fEventType = eventHeader->Get("Type");
229 }
230 AliTPCRawStreamV3 *rawStreamV3 = new AliTPCRawStreamV3(rawReader, (AliAltroMapping**)fMapping);
231 Bool_t res=ProcessEvent(rawStreamV3);
232 delete rawStreamV3;
233 return res;
234}
235//_____________________________________________________________________
7442bceb 236Bool_t AliTPCCalibRawBase::ProcessEvent(AliTPCRawStream * const rawStream)
880c3382 237{
238 //
239 // Event Processing loop - AliTPCRawStream
240 //
241
242 ResetEvent();
243
244 Bool_t withInput = kFALSE;
245 fAltroL1Phase=0;
246 fAltroL1PhaseTB=0;
247 fAltroRawStream = static_cast<AliAltroRawStream*>(rawStream);
248 while (rawStream->Next()) {
249 if (fUseL1Phase){
250 fAltroL1Phase = fAltroRawStream->GetL1Phase();
251 fAltroL1PhaseTB = (fAltroL1Phase*1e09/100.);
252 }
c3066940 253 fPrevRCUId=fCurrRCUId;
254 fCurrRCUId=rawStream->GetRCUId();
255 fPrevDDLNum=fCurrDDLNum;
256 fCurrDDLNum=rawStream->GetDDLNumber();
880c3382 257 Int_t isector = rawStream->GetSector(); // current sector
258 Int_t iRow = rawStream->GetRow(); // current row
259 Int_t iPad = rawStream->GetPad(); // current pad
260 Int_t iTimeBin = rawStream->GetTime(); // current time bin
261 Float_t signal = rawStream->GetSignal(); // current ADC signal
262
263 Update(isector,iRow,iPad,iTimeBin,signal);
264 withInput = kTRUE;
265 }
266 fAltroRawStream=0x0;
267 if (withInput){
268 EndEvent();
269 }
270 return withInput;
271}
272//_____________________________________________________________________
7442bceb 273Bool_t AliTPCCalibRawBase::ProcessEventOld(AliRawReader * const rawReader)
880c3382 274{
275 //
276 // Event processing loop - AliRawReader
277 //
278 AliRawEventHeaderBase* eventHeader = (AliRawEventHeaderBase*)rawReader->GetEventHeader();
279 if (eventHeader){
280 fTimeStamp = eventHeader->Get("Timestamp");
281 fRunNumber = eventHeader->Get("RunNb");
282 fEventType = eventHeader->Get("Type");
283 }
284
285 AliTPCRawStream rawStream(rawReader, (AliAltroMapping**)fMapping);
286 rawReader->Select("TPC");
287 return ProcessEvent(&rawStream);
288}
289//_____________________________________________________________________
7442bceb 290Bool_t AliTPCCalibRawBase::ProcessEvent(eventHeaderStruct * const event)
880c3382 291{
292 //
293 // Event processing loop - date event
294 //
5312f439 295
296 fRunNumber=event->eventRunNb;
297 fTimeStamp=event->eventTimestamp;
298 fEventType=event->eventType;
299 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
300 AliTPCRawStreamV3 *rawStreamV3 = new AliTPCRawStreamV3(rawReader, (AliAltroMapping**)fMapping);
301 Bool_t result=ProcessEvent(rawStreamV3);
302 delete rawStreamV3;
303 delete rawReader;
304 return result;
880c3382 305
306}
307//_____________________________________________________________________
308void AliTPCCalibRawBase::DumpToFile(const Char_t *filename, const Char_t *dir, Bool_t append)
309{
310 //
311 // Write class to file
312 //
313
314 TString sDir(dir);
315 TString option;
316
317 if ( append )
318 option = "update";
319 else
320 option = "recreate";
321
322 TDirectory *backup = gDirectory;
323 TFile f(filename,option.Data());
324 f.cd();
325 if ( !sDir.IsNull() ){
326 f.mkdir(sDir.Data());
327 f.cd(sDir);
328 }
329 this->Write();
330 f.Close();
331
332 if ( backup ) backup->cd();
333}
334//_____________________________________________________________________
335TTreeSRedirector *AliTPCCalibRawBase::GetDebugStreamer(){
336 //
337 // Get Debug streamer
338 // In case debug streamer not yet initialized and StreamLevel>0 create new one
339 //
340 if (fStreamLevel==0) return 0;
341 if (fDebugStreamer) return fDebugStreamer;
342 TString dsName;
343 dsName=GetName();
344 dsName+="Debug.root";
345 dsName.ReplaceAll(" ","");
346 fDebugStreamer = new TTreeSRedirector(dsName.Data());
347 return fDebugStreamer;
348}