]>
Commit | Line | Data |
---|---|---|
33a4976d | 1 | // $Id$ |
2 | /************************************************************************** | |
3 | * This file is property of and copyright by the ALICE HLT Project * | |
4 | * ALICE Experiment at CERN, All rights reserved. * | |
5 | * * | |
6 | * Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> * | |
7 | * for The ALICE HLT Project. * | |
8 | * * | |
9 | * Permission to use, copy, modify and distribute this software and its * | |
10 | * documentation strictly for non-commercial purposes is hereby granted * | |
11 | * without fee, provided that the above copyright notice appears in all * | |
12 | * copies and that both the copyright notice and this permission notice * | |
13 | * appear in the supporting documentation. The authors make no claims * | |
14 | * about the suitability of this software for any purpose. It is * | |
15 | * provided "as is" without express or implied warranty. * | |
16 | **************************************************************************/ | |
17 | ||
18 | /** @file AliHLTTPCCalibTimeComponent.cxx | |
19 | @author Kalliopi Kanaki | |
20 | @date 2009-07-08 | |
21 | @brief A calibration component for interfacing the offline calculation of TPC drift velocity correction | |
22 | */ | |
23 | ||
24 | // see header file for class documentation | |
25 | // or | |
26 | // refer to README to build package | |
27 | // or | |
28 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
29 | ||
30 | #if __GNUC__>= 3 | |
31 | using namespace std; | |
32 | #endif | |
33 | ||
84bdcebe | 34 | |
33a4976d | 35 | #include "AliHLTTPCCalibTimeComponent.h" |
33a4976d | 36 | #include "AliHLTTPCDefinitions.h" |
1151db47 | 37 | |
8677d183 | 38 | #include "AliESDEvent.h" |
1151db47 | 39 | #include "AliESDtrack.h" |
421dce74 | 40 | #include "AliESDfriend.h" |
1151db47 | 41 | |
42 | #include "AliTPCcalibTime.h" | |
74ad39fa | 43 | #include "AliTPCcalibCalib.h"; |
1151db47 | 44 | #include "AliTPCseed.h" |
84bdcebe | 45 | #include "AliTPCcalibCalib.h" |
8677d183 | 46 | |
47 | #include "TObjArray.h" | |
48 | #include "TString.h" | |
33a4976d | 49 | |
84bdcebe | 50 | #include "THnSparse.h" |
51 | #include "TGraphErrors.h" | |
52 | ||
33a4976d | 53 | #include <cstdlib> |
54 | #include <cerrno> | |
33a4976d | 55 | |
84bdcebe | 56 | #include "AliHLTReadoutList.h" |
33a4976d | 57 | |
58 | ClassImp(AliHLTTPCCalibTimeComponent) // ROOT macro for the implementation of ROOT specific class methods | |
59 | ||
60 | AliHLTTPCCalibTimeComponent::AliHLTTPCCalibTimeComponent() | |
61 | : | |
62 | fCalibTime(NULL), | |
74ad39fa | 63 | fCal(NULL), |
84bdcebe | 64 | fESDevent(NULL), |
65 | fESDtrack(NULL), | |
66 | fESDfriendTrack(NULL), | |
74ad39fa | 67 | fESDfriend(NULL), |
68 | fSeedArray(NULL) | |
33a4976d | 69 | { |
70 | // see header file for class documentation | |
71 | // or | |
72 | // refer to README to build package | |
73 | // or | |
74 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
75 | } | |
76 | ||
77 | AliHLTTPCCalibTimeComponent::~AliHLTTPCCalibTimeComponent() { | |
78 | // see header file for class documentation | |
79 | } | |
80 | ||
81 | ||
82 | const char* AliHLTTPCCalibTimeComponent::GetComponentID() { | |
83 | // see header file for class documentation | |
84 | ||
85 | return "TPCCalibTime"; | |
86 | } | |
87 | ||
88 | void AliHLTTPCCalibTimeComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) { | |
89 | // see header file for class documentation | |
90 | ||
91 | list.clear(); | |
1151db47 | 92 | list.push_back( kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC ); // output of TPCCalibSeedMaker |
93 | list.push_back( kAliHLTDataTypeESDObject|kAliHLTDataOriginOut ); // output of global esd converter | |
33a4976d | 94 | } |
95 | ||
96 | AliHLTComponentDataType AliHLTTPCCalibTimeComponent::GetOutputDataType() { | |
97 | // see header file for class documentation | |
98 | ||
1151db47 | 99 | return AliHLTTPCDefinitions::fgkCalibCEDataType|kAliHLTDataOriginOut; |
33a4976d | 100 | } |
101 | ||
102 | void AliHLTTPCCalibTimeComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) { | |
103 | // see header file for class documentation | |
104 | ||
84bdcebe | 105 | constBase = 20000; |
33a4976d | 106 | inputMultiplier = (2.0); // to be estimated |
107 | } | |
108 | ||
109 | AliHLTComponent* AliHLTTPCCalibTimeComponent::Spawn() { | |
110 | // see header file for class documentation | |
111 | ||
112 | return new AliHLTTPCCalibTimeComponent(); | |
113 | } | |
114 | ||
115 | ||
74ad39fa | 116 | Int_t AliHLTTPCCalibTimeComponent::ScanArgument( Int_t /*argc*/, const char** /*argv*/ ) { |
33a4976d | 117 | // see header file for class documentation |
74ad39fa | 118 | |
119 | return 0; | |
33a4976d | 120 | } |
121 | ||
122 | Int_t AliHLTTPCCalibTimeComponent::InitCalibration() { | |
123 | // see header file for class documentation | |
124 | ||
125 | if(fCalibTime) return EINPROGRESS; | |
126 | //fCalibTime = new AliTPCcalibTime(); | |
84bdcebe | 127 | //fCalibTime = new AliTPCcalibTime("calibTime","time dependent Vdrift calibration",-2, 2, 1); |
74ad39fa | 128 | fCal = new AliTPCcalibCalib(); |
129 | ||
33a4976d | 130 | return 0; |
131 | } | |
132 | ||
133 | Int_t AliHLTTPCCalibTimeComponent::DeinitCalibration() { | |
134 | // see header file for class documentation | |
135 | ||
74ad39fa | 136 | if(fCalibTime) delete fCalibTime; fCalibTime = NULL; |
137 | if(fCal) delete fCal; fCal = NULL; | |
138 | if(fESDtrack) delete fESDtrack; fESDtrack = NULL; | |
139 | if(fESDfriendTrack) delete fESDfriendTrack; fESDfriendTrack = NULL; | |
140 | if(fESDfriend) delete fESDfriend; fESDfriend = NULL; | |
141 | if(fSeedArray) delete fSeedArray; fSeedArray = NULL; | |
33a4976d | 142 | |
143 | return 0; | |
144 | } | |
145 | ||
146 | Int_t AliHLTTPCCalibTimeComponent::ProcessCalibration( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ){ | |
147 | // see header file for class documentation | |
84bdcebe | 148 | |
33a4976d | 149 | if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )) return 0; |
150 | ||
1151db47 | 151 | TObject *iter = NULL; |
33a4976d | 152 | |
1151db47 | 153 | //--------------- output over TObjArray of AliTPCseed objects (output of TPCSeedMaker) -------------------// |
154 | ||
155 | for(iter = (TObject*)GetFirstInputObject(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC); iter != NULL; iter = (TObject*)GetNextInputObject()){ | |
156 | ||
157 | if(GetDataType(iter) != (kAliHLTDataTypeTObjArray | kAliHLTDataOriginTPC)) continue; | |
158 | fSeedArray = dynamic_cast<TObjArray*>(iter); | |
159 | } | |
8677d183 | 160 | |
1151db47 | 161 | |
162 | //----------- loop over output of global esd converter ----------------// | |
163 | ||
164 | for(iter = (TObject*)GetFirstInputObject(kAliHLTDataTypeESDObject | kAliHLTDataOriginOut); iter != NULL; iter = (TObject*)GetNextInputObject()){ | |
165 | ||
84bdcebe | 166 | if(GetDataType(iter) != (kAliHLTDataTypeESDObject | kAliHLTDataOriginOut)) continue; |
84bdcebe | 167 | |
168 | fESDevent = dynamic_cast<AliESDEvent*>(iter); | |
ac517e4d | 169 | fESDevent->GetStdContent(); |
84bdcebe | 170 | |
171 | //fESDevent->SetTimeStamp(1256910155); | |
74ad39fa | 172 | //fESDevent->SetRunNumber(0); |
84bdcebe | 173 | //fESDevent->SetRunNumber(84714); |
ac517e4d | 174 | |
84bdcebe | 175 | HLTDebug("# Seeds: %i\n", fSeedArray->GetEntriesFast()); |
74ad39fa | 176 | |
84bdcebe | 177 | for(Int_t i=0; i<fSeedArray->GetEntriesFast(); i++){ |
178 | ||
179 | AliTPCseed *seed = (AliTPCseed*)fSeedArray->UncheckedAt(i); | |
180 | if(!seed) continue; | |
181 | ||
182 | fESDtrack = fESDevent->GetTrack(i); | |
421dce74 | 183 | if(!fESDtrack) continue; |
ac517e4d | 184 | |
74ad39fa | 185 | fCal->RefitTrack(fESDtrack, seed, GetBz()); |
186 | ||
84bdcebe | 187 | AliTPCseed *seedCopy = new AliTPCseed(*seed, kTRUE); |
ac517e4d | 188 | fESDtrack->AddCalibObject(seedCopy); |
189 | ||
74ad39fa | 190 | //fESDfriendTrack = const_cast<AliESDfriendTrack*>(fESDtrack->GetFriendTrack()); |
ac517e4d | 191 | } |
84bdcebe | 192 | } |
ac517e4d | 193 | |
194 | ||
84bdcebe | 195 | if(!fCalibTime) { |
ac517e4d | 196 | Int_t startTime = fESDevent->GetTimeStamp()-60*60*1; //Start time one hour before first event, will make precise cuts later. |
197 | Int_t endTime = fESDevent->GetTimeStamp()+60*60*23; //End time 23 hours after first event. | |
84bdcebe | 198 | fCalibTime = new AliTPCcalibTime("calibTime","time dependent Vdrift calibration", startTime, endTime, 20*60); |
199 | printf("fCalibTime=%i, startTime=%i, endTime=%i\n", fCalibTime!=0, startTime, endTime); | |
200 | } | |
74ad39fa | 201 | |
202 | fESDfriend = new AliESDfriend(); | |
203 | fESDevent->GetESDfriend(fESDfriend); | |
204 | fESDevent->SetESDfriend(fESDfriend); | |
205 | fESDevent->AddObject(fESDfriend); | |
84bdcebe | 206 | |
207 | fCalibTime->UpdateEventInfo(fESDevent); | |
208 | fCalibTime->Process(fESDevent); | |
209 | ||
74ad39fa | 210 | //PushBack( (TObject*)fCalibTime, AliHLTTPCDefinitions::fgkCalibCEDataType | kAliHLTDataOriginOut, 0x0); |
33a4976d | 211 | |
212 | return 0; | |
213 | } | |
214 | ||
215 | Int_t AliHLTTPCCalibTimeComponent::ShipDataToFXS( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ){ | |
216 | // see header file for class documentation | |
84bdcebe | 217 | |
218 | HLTInfo("Shipping data to FXS...\n"); | |
74ad39fa | 219 | |
220 | fCalibTime->Analyze(); | |
84bdcebe | 221 | |
222 | THnSparse* addHist=fCalibTime->GetHistoDrift("all"); | |
223 | if(!addHist) return -1; | |
224 | ||
225 | //Identifying used range of histogram | |
226 | Int_t startTimeBin=0; | |
227 | Int_t endTimeBin=0; | |
228 | TH1D* histoTime=addHist->Projection(0); | |
229 | if(histoTime) { | |
230 | startTimeBin=histoTime->FindFirstBinAbove(0); | |
231 | endTimeBin =histoTime->FindLastBinAbove(0); | |
232 | printf("startTimeBin=%i endTimeBin=%i\n", startTimeBin, endTimeBin); | |
233 | printf("startTimeBinCentre=%f endTimeBinCentre=%f\n", histoTime->GetBinCenter(startTimeBin), histoTime->GetBinCenter(endTimeBin)); | |
234 | printf("startTimeBinWidth=%f endTimeBinWidth=%f\n", histoTime->GetBinWidth(startTimeBin), histoTime->GetBinWidth(endTimeBin)); | |
235 | delete histoTime; | |
236 | histoTime=0; | |
237 | } | |
238 | ||
239 | Int_t startPtBin=0; | |
240 | Int_t endPtBin=0; | |
241 | TH1D* histoPt=addHist->Projection(1); | |
242 | if(histoPt) { | |
243 | startPtBin=histoPt->FindFirstBinAbove(0); | |
244 | endPtBin =histoPt->FindLastBinAbove(0); | |
245 | printf("startPtBin=%i endPtBin=%i\n", startPtBin, endPtBin); | |
246 | printf("startPtBinCentre=%f endPtBinCentre=%f\n", histoPt->GetBinCenter(startPtBin), histoPt->GetBinCenter(endPtBin)); | |
247 | printf("startPtinWidth=%f endPtBinWidth=%f\n", histoPt->GetBinWidth(startPtBin), histoPt->GetBinWidth(endPtBin)); | |
248 | delete histoPt; | |
249 | histoPt=0; | |
250 | } | |
251 | ||
252 | Int_t startVdBin=0; | |
253 | Int_t endVdBin=0; | |
254 | TH1D* histoVd=addHist->Projection(2); | |
255 | if(histoVd) { | |
256 | startVdBin=histoVd->FindFirstBinAbove(0); | |
257 | endVdBin =histoVd->FindLastBinAbove(0); | |
258 | printf("startVdBin=%i endVdBin=%i\n", startVdBin, endVdBin); | |
259 | printf("startVdBinCentre=%f endVdBinCentre=%f\n", histoVd->GetBinCenter(startVdBin), histoVd->GetBinCenter(endVdBin)); | |
260 | printf("startVdBinWidth=%f endVdBinWidth=%f\n", histoVd->GetBinWidth(startVdBin), histoVd->GetBinWidth(endVdBin)); | |
261 | delete histoVd; | |
262 | histoVd=0; | |
263 | } | |
264 | ||
265 | TH1D* histoRun=addHist->Projection(3); | |
266 | Int_t startRunBin=0; | |
267 | Int_t endRunBin=0; | |
268 | if(histoRun) { | |
269 | startRunBin=histoRun->FindFirstBinAbove(0); | |
270 | endRunBin =histoRun->FindLastBinAbove(0); | |
271 | printf("startRunBin=%i endRunBin=%i\n", startRunBin, endRunBin); | |
272 | printf("startRunBinCentre=%f endRunBinCentre=%f\n", histoRun->GetBinCenter(startRunBin), histoRun->GetBinCenter(endRunBin)); | |
273 | printf("startRunBinWidth=%f endRunBinWidth=%f\n", histoRun->GetBinWidth(startRunBin), histoRun->GetBinWidth(endRunBin)); | |
274 | delete histoRun; | |
275 | histoRun=0; | |
276 | } | |
277 | ||
278 | TObjArray* vdriftArray = new TObjArray(); | |
279 | if(!vdriftArray) return -2; | |
280 | ||
281 | TObjArray* array=fCalibTime->GetHistoDrift(); | |
282 | if(!array) return -3; | |
283 | ||
284 | TIterator* iterator = array->MakeIterator(); | |
285 | if(!iterator) return -4; | |
286 | ||
287 | iterator->Reset(); | |
288 | THnSparse* hist=NULL; | |
289 | while((hist=(THnSparseF*)iterator->Next())){ | |
290 | if(!hist) continue; | |
291 | hist->Print(); | |
292 | hist->GetAxis(0)->SetRange(startTimeBin, endTimeBin); | |
293 | hist->GetAxis(1)->SetRange(startPtBin, endPtBin); | |
294 | hist->GetAxis(0)->SetRange(startVdBin, endVdBin); | |
295 | hist->GetAxis(3)->SetRange(startRunBin, endRunBin); | |
296 | TString name=hist->GetName(); | |
297 | Int_t dim[4]={0,1,2,3}; | |
298 | THnSparse* newHist=hist->Projection(4,dim); | |
299 | newHist->SetName(name); | |
300 | vdriftArray->Add(newHist); | |
301 | TGraphErrors* graph=AliTPCcalibBase::FitSlices(newHist,2,0,400,100,0.05,0.95, kTRUE); | |
302 | printf("name=%s graph=%i\n", name.Data(), graph==0); | |
303 | if(!graph || !graph->GetN()) continue; | |
304 | printf("name=%s graph=%i, N=%i\n", name.Data(), graph==0, graph->GetN()); | |
305 | Int_t pos=name.Index("_"); | |
306 | name=name(pos,name.Capacity()-pos); | |
307 | TString graphName=graph->ClassName(); | |
308 | graphName+=name; | |
309 | graphName.ToUpper(); | |
310 | graph->SetName(graphName); | |
311 | printf("name=%s\n", graphName.Data()); | |
312 | vdriftArray->Add(graph); | |
313 | ||
314 | //Currently, AliSplineFits can not be given names... | |
315 | //AliSplineFit* fit=new AliSplineFit(); | |
316 | //fit->SetGraph(graph); | |
317 | //fit->SetMinPoints(graph->GetN()+1); | |
318 | //fit->InitKnots(graph,2,0,0.001); | |
319 | //fit->SplineFit(0); | |
320 | //TString fiName=fit->ClassName(); | |
321 | //fiName+=type; | |
322 | //fiName+=trigger; | |
323 | //fiName.ToUpper(); | |
324 | //fit->SetName(fiName.Data()); | |
325 | //printf("name=%s\n", fiName.Data()); | |
326 | //vdriftArray->Add(fit); | |
327 | } | |
328 | THnSparse* laserHist=NULL; | |
329 | TGraphErrors* laserGraph=NULL; | |
330 | TString laserName=""; | |
331 | ||
332 | //Histograms and graphs for A side lasers | |
333 | laserHist=fCalibTime->GetHistVdriftLaserA(1); | |
334 | if(laserHist){ | |
335 | laserName=laserHist->ClassName(); | |
336 | laserName+="_MEAN_DRIFT_LASER_ALL_A"; | |
337 | laserName.ToUpper(); | |
338 | laserHist->SetName(laserName); | |
339 | vdriftArray->Add(laserHist); | |
340 | laserGraph=AliTPCcalibBase::FitSlices(laserHist,2,0,400,100,0.05,0.95, kTRUE); | |
341 | if(laserGraph && laserGraph->GetN()){ | |
342 | laserName=laserGraph->GetName(); | |
343 | laserName+="_MEAN_DRIFT_LASER_ALL_A"; | |
344 | laserName.ToUpper(); | |
345 | laserGraph->SetName(laserName); | |
346 | vdriftArray->Add(laserGraph); | |
347 | } | |
348 | } | |
349 | ||
350 | //Histograms and graphs for C side lasers | |
351 | laserHist=fCalibTime->GetHistVdriftLaserC(1); | |
352 | if(laserHist){ | |
353 | laserName=laserHist->ClassName(); | |
354 | laserName+="_MEAN_DRIFT_LASER_ALL_C"; | |
355 | laserName.ToUpper(); | |
356 | laserHist->SetName(laserName); | |
357 | vdriftArray->Add(laserHist); | |
358 | laserGraph=AliTPCcalibBase::FitSlices(laserHist,2,0,400,100,0.05,0.95, kTRUE); | |
359 | if(laserGraph && laserGraph->GetN()){ | |
360 | laserName=laserGraph->GetName(); | |
361 | laserName+="_MEAN_DRIFT_LASER_ALL_C"; | |
362 | laserName.ToUpper(); | |
363 | laserGraph->SetName(laserName); | |
364 | vdriftArray->Add(laserGraph); | |
365 | } | |
366 | } | |
367 | ||
368 | //Meatdata set in off-line... | |
369 | //AliCDBMetaData *metaData= new AliCDBMetaData(); | |
370 | //metaData->SetObjectClassName("TObjArray"); | |
371 | //metaData->SetResponsible("Dag Toppe Larsen"); | |
372 | //metaData->SetBeamPeriod(1); | |
373 | //metaData->SetAliRootVersion("05-25-01"); //root version | |
374 | //metaData->SetComment("Calibration of the time dependence of the drift velocity due to pressure and temperature changes"); | |
375 | //AliCDBId* id1=NULL; | |
376 | //if(end) id1=new AliCDBId("TPC/Calib/TimeDrift", runNumber, end); | |
377 | //else id1=new AliCDBId("TPC/Calib/TimeDrift", runNumber, runNumber); | |
378 | //AliCDBStorage* gStorage = AliCDBManager::Instance()->GetStorage("local://$ALICE_ROOT/OCDB"); | |
379 | //gStorage->Put(vdriftArray, (*id1), metaData); | |
380 | //printf("done runNumber=%i, end=%i\n", runNumber, end); | |
381 | ||
8d53dca2 | 382 | static AliHLTReadoutList rdList(AliHLTReadoutList::kTPC); |
84bdcebe | 383 | PushToFXS( (TObject*)vdriftArray, "TPC", "Time", rdList.Buffer() ); |
74ad39fa | 384 | |
84bdcebe | 385 | //PushToFXS( (TObject*)vdriftArray, "TPC", "Time"); |
386 | ||
387 | //Should array be deleted now? | |
388 | // if(vdriftArray){ | |
389 | // vdriftArray.Clear(); | |
390 | // delete vdriftArray; | |
391 | // vdriftArray=0; | |
392 | // } | |
33a4976d | 393 | |
394 | return 0; | |
395 | } | |
396 |