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