]>
Commit | Line | Data |
---|---|---|
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" | |
c3066940 | 37 | #include "AliTPCRawStreamV3.h" |
c3066940 | 38 | #include "AliLog.h" |
880c3382 | 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), | |
880c3382 | 53 | fRunNumber(0), |
78f17711 | 54 | fFirstTimeStamp(0), |
55 | fLastTimeStamp(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 | //_____________________________________________________________________ | |
76 | AliTPCCalibRawBase::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), | |
78f17711 | 83 | fRunNumber(calib.fRunNumber), |
84 | fFirstTimeStamp(calib.fFirstTimeStamp), | |
85 | fLastTimeStamp(calib.fLastTimeStamp), | |
c3066940 | 86 | fTimeStamp(0), |
880c3382 | 87 | fEventType(0), |
88 | fAltroL1Phase(0), | |
89 | fAltroL1PhaseTB(0), | |
c3066940 | 90 | fCurrRCUId(-1), |
91 | fPrevRCUId(-1), | |
92 | fCurrDDLNum(-1), | |
93 | fPrevDDLNum(-1), | |
880c3382 | 94 | fUseL1Phase(kTRUE), |
95 | fDebugStreamer(0x0), | |
96 | fAltroRawStream(0x0), | |
97 | fMapping(0x0), | |
98 | fROC(AliTPCROC::Instance()) | |
99 | { | |
100 | // | |
101 | // copy ctor | |
102 | // | |
103 | ||
104 | } | |
105 | //_____________________________________________________________________ | |
106 | AliTPCCalibRawBase::~AliTPCCalibRawBase() | |
107 | { | |
108 | // | |
109 | // dtor | |
110 | // | |
111 | if (fDebugStreamer) delete fDebugStreamer; | |
112 | } | |
113 | //_____________________________________________________________________ | |
114 | AliTPCCalibRawBase& AliTPCCalibRawBase::operator = (const AliTPCCalibRawBase &source) | |
115 | { | |
116 | // | |
117 | // assignment operator | |
118 | // | |
119 | if (&source == this) return *this; | |
120 | new (this) AliTPCCalibRawBase(source); | |
121 | ||
122 | return *this; | |
123 | } | |
124 | //_____________________________________________________________________ | |
7442bceb | 125 | Bool_t AliTPCCalibRawBase::ProcessEvent(AliTPCRawStreamV3 * const rawStreamV3) |
c3066940 | 126 | { |
127 | // | |
128 | // Event Processing loop - AliTPCRawStreamV3 | |
129 | // | |
130 | ResetEvent(); | |
131 | Bool_t withInput = kFALSE; | |
132 | fAltroL1Phase=0; | |
133 | fAltroL1PhaseTB=0; | |
134 | // fAltroRawStream = static_cast<AliAltroRawStream*>(rawStreamV3); | |
135 | while ( rawStreamV3->NextDDL() ){ | |
136 | if (AliLog::GetGlobalDebugLevel()>2) rawStreamV3->PrintRCUTrailer(); | |
5312f439 | 137 | fPrevDDLNum=-1; |
138 | fCurrRCUId=rawStreamV3->GetRCUId(); | |
139 | fCurrDDLNum=rawStreamV3->GetDDLNumber(); | |
c3066940 | 140 | if (fUseL1Phase){ |
141 | // fAltroL1Phase = fAltroRawStream->GetL1Phase(); | |
142 | fAltroL1Phase = rawStreamV3->GetL1Phase(); | |
143 | fAltroL1PhaseTB = (fAltroL1Phase*1e09/100.); | |
5312f439 | 144 | AliDebug(1, Form("L1Phase: %.2e (%03d)\n",fAltroL1PhaseTB,fCurrDDLNum)); |
c3066940 | 145 | } |
5312f439 | 146 | UpdateDDL(); |
c3066940 | 147 | while ( rawStreamV3->NextChannel() ){ |
148 | Int_t isector = rawStreamV3->GetSector(); // current sector | |
149 | Int_t iRow = rawStreamV3->GetRow(); // current row | |
150 | Int_t iPad = rawStreamV3->GetPad(); // current pad | |
151 | while ( rawStreamV3->NextBunch() ){ | |
96bf9029 | 152 | UInt_t startTbin = rawStreamV3->GetStartTimeBin(); |
c3066940 | 153 | // Int_t endTbin = (Int_t)rawStreamV3->GetEndTimeBin(); |
96bf9029 | 154 | Int_t bunchlength = rawStreamV3->GetBunchLength(); |
c3066940 | 155 | const UShort_t *sig = rawStreamV3->GetSignals(); |
96bf9029 | 156 | ProcessBunch(isector,iRow,iPad,bunchlength,startTbin,sig); |
c3066940 | 157 | for (Int_t iTimeBin = 0; iTimeBin<bunchlength; iTimeBin++){ |
158 | Float_t signal=(Float_t)sig[iTimeBin]; | |
159 | // printf("%02d - %03d - %03d - %04d: %.1f\n",isector,iRow,iPad,startTbin,signal); | |
160 | Update(isector,iRow,iPad,startTbin--,signal); | |
161 | fPrevRCUId=fCurrRCUId; | |
162 | fPrevDDLNum=fCurrDDLNum; | |
163 | withInput = kTRUE; | |
164 | } | |
165 | } | |
166 | } | |
167 | } | |
168 | if (withInput){ | |
169 | EndEvent(); | |
170 | } | |
171 | return withInput; | |
172 | } | |
173 | //_____________________________________________________________________ | |
7442bceb | 174 | Bool_t AliTPCCalibRawBase::ProcessEvent(AliRawReader * const rawReader) |
c3066940 | 175 | { |
176 | // | |
177 | // Event processing loop - AliRawReader | |
178 | // | |
179 | AliRawEventHeaderBase* eventHeader = (AliRawEventHeaderBase*)rawReader->GetEventHeader(); | |
180 | if (eventHeader){ | |
181 | fTimeStamp = eventHeader->Get("Timestamp"); | |
182 | fRunNumber = eventHeader->Get("RunNb"); | |
183 | fEventType = eventHeader->Get("Type"); | |
184 | } | |
78f17711 | 185 | if (!fFirstTimeStamp) fFirstTimeStamp=fTimeStamp; |
186 | ||
c3066940 | 187 | AliTPCRawStreamV3 *rawStreamV3 = new AliTPCRawStreamV3(rawReader, (AliAltroMapping**)fMapping); |
188 | Bool_t res=ProcessEvent(rawStreamV3); | |
78f17711 | 189 | |
190 | fLastTimeStamp=fTimeStamp; | |
191 | ||
c3066940 | 192 | delete rawStreamV3; |
193 | return res; | |
194 | } | |
195 | //_____________________________________________________________________ | |
7442bceb | 196 | Bool_t AliTPCCalibRawBase::ProcessEvent(eventHeaderStruct * const event) |
880c3382 | 197 | { |
198 | // | |
199 | // Event processing loop - date event | |
200 | // | |
5312f439 | 201 | |
202 | fRunNumber=event->eventRunNb; | |
203 | fTimeStamp=event->eventTimestamp; | |
78f17711 | 204 | if (!fFirstTimeStamp) fFirstTimeStamp=fTimeStamp; |
205 | fLastTimeStamp=fTimeStamp; | |
5312f439 | 206 | fEventType=event->eventType; |
207 | AliRawReader *rawReader = new AliRawReaderDate((void*)event); | |
208 | AliTPCRawStreamV3 *rawStreamV3 = new AliTPCRawStreamV3(rawReader, (AliAltroMapping**)fMapping); | |
209 | Bool_t result=ProcessEvent(rawStreamV3); | |
210 | delete rawStreamV3; | |
211 | delete rawReader; | |
212 | return result; | |
880c3382 | 213 | |
214 | } | |
215 | //_____________________________________________________________________ | |
216 | void AliTPCCalibRawBase::DumpToFile(const Char_t *filename, const Char_t *dir, Bool_t append) | |
217 | { | |
218 | // | |
219 | // Write class to file | |
220 | // | |
221 | ||
222 | TString sDir(dir); | |
223 | TString option; | |
224 | ||
225 | if ( append ) | |
226 | option = "update"; | |
227 | else | |
228 | option = "recreate"; | |
229 | ||
230 | TDirectory *backup = gDirectory; | |
231 | TFile f(filename,option.Data()); | |
232 | f.cd(); | |
233 | if ( !sDir.IsNull() ){ | |
234 | f.mkdir(sDir.Data()); | |
235 | f.cd(sDir); | |
236 | } | |
237 | this->Write(); | |
238 | f.Close(); | |
239 | ||
240 | if ( backup ) backup->cd(); | |
241 | } | |
242 | //_____________________________________________________________________ | |
243 | TTreeSRedirector *AliTPCCalibRawBase::GetDebugStreamer(){ | |
244 | // | |
245 | // Get Debug streamer | |
246 | // In case debug streamer not yet initialized and StreamLevel>0 create new one | |
247 | // | |
248 | if (fStreamLevel==0) return 0; | |
249 | if (fDebugStreamer) return fDebugStreamer; | |
250 | TString dsName; | |
251 | dsName=GetName(); | |
252 | dsName+="Debug.root"; | |
253 | dsName.ReplaceAll(" ",""); | |
254 | fDebugStreamer = new TTreeSRedirector(dsName.Data()); | |
255 | return fDebugStreamer; | |
256 | } | |
78f17711 | 257 | //_____________________________________________________________________ |
258 | void AliTPCCalibRawBase::MergeBase(const AliTPCCalibRawBase *calib) | |
259 | { | |
260 | // | |
261 | // merge this with base | |
262 | // | |
263 | if (calib->fFirstTimeStamp<fFirstTimeStamp) fFirstTimeStamp=calib->fFirstTimeStamp; | |
264 | if (calib->fLastTimeStamp>fLastTimeStamp) fLastTimeStamp =calib->fLastTimeStamp; | |
265 | } | |
266 |