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