]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCCalibRawBase.cxx
Adding histograms for absolute z residuals
[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//_____________________________________________________________________
123Bool_t AliTPCCalibRawBase::ProcessEventFast(AliTPCRawStreamFast *rawStreamFast)
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//_____________________________________________________________________
153Bool_t AliTPCCalibRawBase::ProcessEventFast(AliRawReader *rawReader)
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//_____________________________________________________________________
c3066940 170Bool_t AliTPCCalibRawBase::ProcessEvent(AliTPCRawStreamV3 *rawStreamV3)
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() ){
197 Int_t startTbin = (Int_t)rawStreamV3->GetStartTimeBin();
198// Int_t endTbin = (Int_t)rawStreamV3->GetEndTimeBin();
199 Int_t bunchlength = (Int_t)rawStreamV3->GetBunchLength();
200 const UShort_t *sig = rawStreamV3->GetSignals();
201 for (Int_t iTimeBin = 0; iTimeBin<bunchlength; iTimeBin++){
202 Float_t signal=(Float_t)sig[iTimeBin];
203// printf("%02d - %03d - %03d - %04d: %.1f\n",isector,iRow,iPad,startTbin,signal);
204 Update(isector,iRow,iPad,startTbin--,signal);
205 fPrevRCUId=fCurrRCUId;
206 fPrevDDLNum=fCurrDDLNum;
207 withInput = kTRUE;
208 }
209 }
210 }
211 }
212 if (withInput){
213 EndEvent();
214 }
215 return withInput;
216}
217//_____________________________________________________________________
218Bool_t AliTPCCalibRawBase::ProcessEvent(AliRawReader *rawReader)
219{
220 //
221 // Event processing loop - AliRawReader
222 //
223 AliRawEventHeaderBase* eventHeader = (AliRawEventHeaderBase*)rawReader->GetEventHeader();
224 if (eventHeader){
225 fTimeStamp = eventHeader->Get("Timestamp");
226 fRunNumber = eventHeader->Get("RunNb");
227 fEventType = eventHeader->Get("Type");
228 }
229 AliTPCRawStreamV3 *rawStreamV3 = new AliTPCRawStreamV3(rawReader, (AliAltroMapping**)fMapping);
230 Bool_t res=ProcessEvent(rawStreamV3);
231 delete rawStreamV3;
232 return res;
233}
234//_____________________________________________________________________
880c3382 235Bool_t AliTPCCalibRawBase::ProcessEvent(AliTPCRawStream *rawStream)
236{
237 //
238 // Event Processing loop - AliTPCRawStream
239 //
240
241 ResetEvent();
242
243 Bool_t withInput = kFALSE;
244 fAltroL1Phase=0;
245 fAltroL1PhaseTB=0;
246 fAltroRawStream = static_cast<AliAltroRawStream*>(rawStream);
247 while (rawStream->Next()) {
248 if (fUseL1Phase){
249 fAltroL1Phase = fAltroRawStream->GetL1Phase();
250 fAltroL1PhaseTB = (fAltroL1Phase*1e09/100.);
251 }
c3066940 252 fPrevRCUId=fCurrRCUId;
253 fCurrRCUId=rawStream->GetRCUId();
254 fPrevDDLNum=fCurrDDLNum;
255 fCurrDDLNum=rawStream->GetDDLNumber();
880c3382 256 Int_t isector = rawStream->GetSector(); // current sector
257 Int_t iRow = rawStream->GetRow(); // current row
258 Int_t iPad = rawStream->GetPad(); // current pad
259 Int_t iTimeBin = rawStream->GetTime(); // current time bin
260 Float_t signal = rawStream->GetSignal(); // current ADC signal
261
262 Update(isector,iRow,iPad,iTimeBin,signal);
263 withInput = kTRUE;
264 }
265 fAltroRawStream=0x0;
266 if (withInput){
267 EndEvent();
268 }
269 return withInput;
270}
271//_____________________________________________________________________
c3066940 272Bool_t AliTPCCalibRawBase::ProcessEventOld(AliRawReader *rawReader)
880c3382 273{
274 //
275 // Event processing loop - AliRawReader
276 //
277 AliRawEventHeaderBase* eventHeader = (AliRawEventHeaderBase*)rawReader->GetEventHeader();
278 if (eventHeader){
279 fTimeStamp = eventHeader->Get("Timestamp");
280 fRunNumber = eventHeader->Get("RunNb");
281 fEventType = eventHeader->Get("Type");
282 }
283
284 AliTPCRawStream rawStream(rawReader, (AliAltroMapping**)fMapping);
285 rawReader->Select("TPC");
286 return ProcessEvent(&rawStream);
287}
288//_____________________________________________________________________
289Bool_t AliTPCCalibRawBase::ProcessEvent(eventHeaderStruct *event)
290{
291 //
292 // Event processing loop - date event
293 //
5312f439 294
295 fRunNumber=event->eventRunNb;
296 fTimeStamp=event->eventTimestamp;
297 fEventType=event->eventType;
298 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
299 AliTPCRawStreamV3 *rawStreamV3 = new AliTPCRawStreamV3(rawReader, (AliAltroMapping**)fMapping);
300 Bool_t result=ProcessEvent(rawStreamV3);
301 delete rawStreamV3;
302 delete rawReader;
303 return result;
880c3382 304
305}
306//_____________________________________________________________________
307void AliTPCCalibRawBase::DumpToFile(const Char_t *filename, const Char_t *dir, Bool_t append)
308{
309 //
310 // Write class to file
311 //
312
313 TString sDir(dir);
314 TString option;
315
316 if ( append )
317 option = "update";
318 else
319 option = "recreate";
320
321 TDirectory *backup = gDirectory;
322 TFile f(filename,option.Data());
323 f.cd();
324 if ( !sDir.IsNull() ){
325 f.mkdir(sDir.Data());
326 f.cd(sDir);
327 }
328 this->Write();
329 f.Close();
330
331 if ( backup ) backup->cd();
332}
333//_____________________________________________________________________
334TTreeSRedirector *AliTPCCalibRawBase::GetDebugStreamer(){
335 //
336 // Get Debug streamer
337 // In case debug streamer not yet initialized and StreamLevel>0 create new one
338 //
339 if (fStreamLevel==0) return 0;
340 if (fDebugStreamer) return fDebugStreamer;
341 TString dsName;
342 dsName=GetName();
343 dsName+="Debug.root";
344 dsName.ReplaceAll(" ","");
345 fDebugStreamer = new TTreeSRedirector(dsName.Data());
346 return fDebugStreamer;
347}