95259bbb |
1 | // $Id$ |
2 | |
3 | /************************************************************************** |
4 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
5 | * * |
d70155ad |
6 | * Authors: * |
7 | * for The ALICE HLT Project. * |
95259bbb |
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 | |
d70155ad |
18 | // @file AliHLTTRDCalibrationComponent.cxx |
19 | // @author |
20 | // @date |
21 | // @brief A TRDCalibration processing component for the HLT. |
22 | // |
95259bbb |
23 | |
24 | #if __GNUC__ >= 3 |
775f67d7 |
25 | using namespace std; |
95259bbb |
26 | #endif |
27 | |
28 | #include "TTree.h" |
29 | #include "TFile.h" |
30 | #include "TBranch.h" |
d8731936 |
31 | #include "TH2I.h" |
32 | #include "TH2.h" |
33 | #include "TProfile2D.h" |
34 | |
35 | #include "AliHLTReadoutList.h" |
95259bbb |
36 | |
37 | #include "AliHLTTRDCalibrationComponent.h" |
38 | #include "AliHLTTRDDefinitions.h" |
dc2e6604 |
39 | #include "AliHLTTRDUtils.h" |
95259bbb |
40 | |
41 | #include "AliCDBManager.h" |
775f67d7 |
42 | #include "AliCDBStorage.h" |
95259bbb |
43 | #include "AliRawReaderMemory.h" |
d8731936 |
44 | |
45 | #include "AliTRDCalPad.h" |
46 | #include "AliTRDCalDet.h" |
47 | |
9aea5deb |
48 | #include "AliTRDCalibraFillHisto.h" |
dc2e6604 |
49 | #include "AliTRDtrackV1.h" |
95259bbb |
50 | |
d8731936 |
51 | #include "AliTRDCalibraFit.h" |
52 | #include "AliTRDCalibraMode.h" |
53 | #include "AliTRDCalibraVector.h" |
54 | #include "AliTRDCalibraVdriftLinearFit.h" |
521b7005 |
55 | #include "AliTRDReconstructor.h" |
56 | #include "AliTRDrecoParam.h" |
d8731936 |
57 | |
95259bbb |
58 | #include <cstdlib> |
59 | #include <cerrno> |
60 | #include <string> |
61 | |
95259bbb |
62 | ClassImp(AliHLTTRDCalibrationComponent); |
dc2e6604 |
63 | |
93ce7d1b |
64 | AliHLTTRDCalibrationComponent::AliHLTTRDCalibrationComponent() |
d8731936 |
65 | : AliHLTCalibrationProcessor(), |
66 | fTRDCalibraFillHisto(NULL), |
67 | fOutputSize(500000), |
68 | fTracksArray(NULL), |
69 | fOutArray(NULL), |
70 | fAfterRunArray(NULL), |
71 | fDisplayArray(NULL), |
521b7005 |
72 | fSavedTimeBins(kFALSE), |
d8731936 |
73 | fTrgStrings(NULL), |
ae24e8b7 |
74 | fAccRejTrg(0), |
75 | fMinClusters(0), |
102f11b6 |
76 | fMinTracklets(0), |
77 | fTakeAllEvents(kFALSE) |
95259bbb |
78 | { |
775f67d7 |
79 | // Default constructor |
95259bbb |
80 | } |
81 | |
82 | AliHLTTRDCalibrationComponent::~AliHLTTRDCalibrationComponent() |
83 | { |
775f67d7 |
84 | // Destructor |
95259bbb |
85 | } |
86 | |
87 | const char* AliHLTTRDCalibrationComponent::GetComponentID() |
88 | { |
775f67d7 |
89 | // Return the component ID const char * |
90 | return "TRDCalibration"; // The ID of this component |
95259bbb |
91 | } |
92 | |
93ce7d1b |
93 | void AliHLTTRDCalibrationComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) |
95259bbb |
94 | { |
775f67d7 |
95 | // Get the list of input data |
96 | list.clear(); // We do not have any requirements for our input data type(s). |
07f31c0e |
97 | list.push_back(AliHLTTRDDefinitions::fgkTracksDataType); |
95259bbb |
98 | } |
99 | |
93ce7d1b |
100 | AliHLTComponentDataType AliHLTTRDCalibrationComponent::GetOutputDataType() |
95259bbb |
101 | { |
775f67d7 |
102 | // Get the output data type |
d8731936 |
103 | return kAliHLTMultipleDataType; |
104 | // return AliHLTTRDDefinitions::fgkCalibrationDataType; |
105 | |
106 | } |
107 | |
108 | int AliHLTTRDCalibrationComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList) |
109 | { |
110 | // Get the output data type |
111 | tgtList.clear(); |
112 | tgtList.push_back(AliHLTTRDDefinitions::fgkCalibrationDataType); |
113 | tgtList.push_back(AliHLTTRDDefinitions::fgkEORCalibrationDataType); |
114 | return tgtList.size(); |
95259bbb |
115 | } |
116 | |
117 | void AliHLTTRDCalibrationComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) |
118 | { |
775f67d7 |
119 | // Get the output data size |
93ce7d1b |
120 | constBase = fOutputSize; |
121 | inputMultiplier = 0; |
95259bbb |
122 | } |
123 | |
124 | AliHLTComponent* AliHLTTRDCalibrationComponent::Spawn() |
125 | { |
775f67d7 |
126 | // Spawn function, return new instance of this class |
127 | return new AliHLTTRDCalibrationComponent; |
95259bbb |
128 | }; |
129 | |
130 | Int_t AliHLTTRDCalibrationComponent::ScanArgument( int argc, const char** argv ) |
131 | { |
775f67d7 |
132 | // perform initialization. We check whether our relative output size is specified in the arguments. |
133 | int i = 0; |
134 | char* cpErr; |
d8731936 |
135 | if(!fTrgStrings) |
136 | fTrgStrings = new TObjArray(); |
137 | |
775f67d7 |
138 | while ( i < argc ) |
139 | { |
140 | HLTDebug("argv[%d] == %s", i, argv[i] ); |
93ce7d1b |
141 | if ( !strcmp( argv[i], "output_size" ) ) |
dc2e6604 |
142 | { |
775f67d7 |
143 | if ( i+1>=argc ) |
144 | { |
93ce7d1b |
145 | HLTError("Missing output_size parameter"); |
775f67d7 |
146 | return ENOTSUP; |
dc2e6604 |
147 | } |
775f67d7 |
148 | HLTDebug("argv[%d+1] == %s", i, argv[i+1] ); |
93ce7d1b |
149 | fOutputSize = strtoul( argv[i+1], &cpErr, 0 ); |
775f67d7 |
150 | if ( *cpErr ) |
151 | { |
93ce7d1b |
152 | HLTError("Cannot convert output_size parameter '%s'", argv[i+1] ); |
775f67d7 |
153 | return EINVAL; |
154 | } |
93ce7d1b |
155 | HLTInfo("Output size set to %lu %%", fOutputSize ); |
775f67d7 |
156 | i += 2; |
157 | continue; |
dc2e6604 |
158 | } |
ae24e8b7 |
159 | if ( !strcmp( argv[i], "-minClusters" ) ) |
93ce7d1b |
160 | { |
161 | if ( i+1>=argc ) |
162 | { |
ae24e8b7 |
163 | HLTError("Missing minClusters parameter"); |
93ce7d1b |
164 | return ENOTSUP; |
165 | } |
166 | HLTDebug("argv[%d+1] == %s", i, argv[i+1] ); |
ae24e8b7 |
167 | fMinClusters = strtoul( argv[i+1], &cpErr, 0 ); |
168 | i += 2; |
169 | continue; |
170 | } |
171 | if ( !strcmp( argv[i], "-minTracklets" ) ) |
172 | { |
173 | if ( i+1>=argc ) |
174 | { |
175 | HLTError("Missing minTracklets parameter"); |
176 | return ENOTSUP; |
177 | } |
178 | HLTDebug("argv[%d+1] == %s", i, argv[i+1] ); |
179 | fMinTracklets = strtoul( argv[i+1], &cpErr, 0 ); |
93ce7d1b |
180 | i += 2; |
181 | continue; |
182 | } |
d8731936 |
183 | if ( !strcmp( argv[i], "-TrgStr" ) ) |
184 | { |
185 | if ( i+1>=argc ) |
186 | { |
187 | HLTError("Missing parameter for mbTriggerString"); |
188 | return ENOTSUP; |
189 | } |
190 | HLTDebug("argv[%d+1] == %s", i, argv[i+1] ); |
191 | fTrgStrings->Add(new TObjString(argv[i+1])); |
192 | i += 2; |
193 | continue; |
194 | } |
195 | |
196 | if ( !strcmp( argv[i], "-acceptTrgStr" ) ) |
197 | { |
198 | fAccRejTrg=1; |
199 | i += 1; |
200 | continue; |
201 | } |
202 | if ( !strcmp( argv[i], "-rejectTrgStr" ) ) |
203 | { |
204 | fAccRejTrg=-1; |
205 | i += 1; |
206 | continue; |
207 | } |
102f11b6 |
208 | if ( !strcmp( argv[i], "-takeAllEvents" ) ) |
209 | { |
210 | fTakeAllEvents = kTRUE; |
211 | fAccRejTrg = 0; |
212 | i += 1; |
213 | continue; |
214 | } |
93ce7d1b |
215 | |
775f67d7 |
216 | else { |
217 | HLTError("Unknown option '%s'", argv[i] ); |
218 | return EINVAL; |
219 | } |
220 | } |
d8731936 |
221 | return i; |
95259bbb |
222 | } |
223 | |
224 | Int_t AliHLTTRDCalibrationComponent::InitCalibration() |
225 | { |
d8731936 |
226 | |
bb2a05d3 |
227 | if(!fTrgStrings) |
d8731936 |
228 | fTrgStrings = new TObjArray(); |
229 | |
775f67d7 |
230 | if(!AliCDBManager::Instance()->IsDefaultStorageSet()){ |
93ce7d1b |
231 | HLTError("DefaultStorage is not set in CDBManager"); |
232 | return -EINVAL; |
775f67d7 |
233 | } |
234 | if(AliCDBManager::Instance()->GetRun()<0){ |
93ce7d1b |
235 | HLTError("Run Number is not set in CDBManager"); |
236 | return -EINVAL; |
775f67d7 |
237 | } |
238 | HLTInfo("CDB default storage: %s; RunNo: %i", (AliCDBManager::Instance()->GetDefaultStorage()->GetBaseFolder()).Data(), AliCDBManager::Instance()->GetRun()); |
775f67d7 |
239 | |
d8731936 |
240 | if(fTrgStrings->GetEntriesFast()>0 && !fAccRejTrg){ |
241 | HLTError("Trigger string(s) given, but acceptTrgStr or rejectTrgStr not selected"); |
242 | return -EINVAL; |
243 | } |
244 | |
775f67d7 |
245 | fTRDCalibraFillHisto = AliTRDCalibraFillHisto::Instance(); |
d8731936 |
246 | fTRDCalibraFillHisto->SetIsHLT(kTRUE); |
775f67d7 |
247 | fTRDCalibraFillHisto->SetHisto2d(); // choose to use histograms |
248 | fTRDCalibraFillHisto->SetCH2dOn(); // choose to calibrate the gain |
249 | fTRDCalibraFillHisto->SetPH2dOn(); // choose to calibrate the drift velocity |
250 | fTRDCalibraFillHisto->SetPRF2dOn(); // choose to look at the PRF |
93ce7d1b |
251 | fTRDCalibraFillHisto->SetIsHLT(); // per detector |
252 | //fTRDCalibraFillHisto->SetDebugLevel(1);// debug |
253 | fTRDCalibraFillHisto->SetFillWithZero(kTRUE); |
d8731936 |
254 | fTRDCalibraFillHisto->SetLinearFitterOn(kTRUE); |
255 | fTRDCalibraFillHisto->SetNumberBinCharge(100); |
256 | |
93ce7d1b |
257 | fTracksArray = new TClonesArray("AliTRDtrackV1"); |
d8731936 |
258 | fOutArray = new TObjArray(4); |
259 | fAfterRunArray=new TObjArray(5); |
260 | fDisplayArray=new TObjArray(4); |
261 | |
262 | HLTDebug("run SetupCTPData"); |
263 | SetupCTPData(); |
93ce7d1b |
264 | |
775f67d7 |
265 | return 0; |
95259bbb |
266 | } |
267 | |
268 | Int_t AliHLTTRDCalibrationComponent::DeinitCalibration() |
269 | { |
93ce7d1b |
270 | |
775f67d7 |
271 | // Deinitialization of the component |
93ce7d1b |
272 | |
273 | HLTDebug("DeinitCalibration"); |
d8731936 |
274 | delete fTracksArray; fTracksArray=0; |
3310c421 |
275 | fTRDCalibraFillHisto->DestroyDebugStreamer(); |
d8731936 |
276 | //fTRDCalibraFillHisto->Destroy(); |
93ce7d1b |
277 | //fOutArray->Delete(); |
d8731936 |
278 | delete fOutArray; fOutArray=0; |
279 | fAfterRunArray->Delete(); |
280 | delete fAfterRunArray; fAfterRunArray=0; |
281 | fDisplayArray->Delete(); |
282 | delete fDisplayArray; fDisplayArray=0; |
283 | fTrgStrings->Delete(); |
284 | delete fTrgStrings; fTrgStrings=0; |
775f67d7 |
285 | return 0; |
95259bbb |
286 | } |
287 | |
2edf582c |
288 | Int_t AliHLTTRDCalibrationComponent::ProcessCalibration(const AliHLTComponent_EventData& /*evtData*/, |
521b7005 |
289 | const AliHLTComponent_BlockData* /*blocks*/, |
6840d0ab |
290 | AliHLTComponent_TriggerData& /*trigData*/, |
dc2e6604 |
291 | AliHLTUInt8_t* /*outputPtr*/, |
292 | AliHLTUInt32_t& /*size*/, |
293 | vector<AliHLTComponent_BlockData>& /*outputBlocks*/) |
95259bbb |
294 | { |
775f67d7 |
295 | // Process an event |
d8731936 |
296 | |
521b7005 |
297 | TClonesArray* TCAarray[18] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; |
298 | Int_t usedEntries = 0; |
299 | Int_t blockOrObject = 0; |
300 | Int_t nTimeBins = -1; |
301 | |
302 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(AliHLTTRDDefinitions::fgkTracksDataType); pBlock; pBlock=GetNextInputBlock()) |
775f67d7 |
303 | { |
521b7005 |
304 | TCAarray[0] = fTracksArray; |
305 | AliHLTTRDUtils::ReadTracks(TCAarray[0], pBlock->fPtr, pBlock->fSize, &nTimeBins); |
306 | usedEntries = 1; |
307 | blockOrObject = -1; |
308 | } |
775f67d7 |
309 | |
521b7005 |
310 | for(const TObject *iter = GetFirstInputObject(AliHLTTRDDefinitions::fgkHiLvlTracksDataType); iter; iter = GetNextInputObject()) |
311 | { |
312 | if(blockOrObject<0){ |
313 | HLTError("You may not mix high level and low level!"); |
314 | return -1; |
775f67d7 |
315 | } |
521b7005 |
316 | |
317 | TCAarray[usedEntries] = dynamic_cast<TClonesArray*>(const_cast<TObject*>(iter)); |
318 | if(!TCAarray[usedEntries])continue; |
319 | TObjString* strg = dynamic_cast<TObjString*>(const_cast<TObject*>(GetNextInputObject())); |
320 | if(!strg)continue; |
321 | |
322 | nTimeBins = strg->String().Atoi(); |
323 | usedEntries++; |
324 | blockOrObject = 1; |
325 | } |
326 | |
327 | if(!blockOrObject) |
328 | return 0; |
329 | |
330 | if(!fSavedTimeBins){ |
331 | if(nTimeBins<0){ |
332 | HLTFatal("Number of timebins is negative!"); |
333 | return -1; |
334 | } |
335 | HLTDebug("Saving number of time bins which was read from input block. Value is: %d", nTimeBins); |
336 | fTRDCalibraFillHisto->Init2Dhistos(nTimeBins); // initialise the histos |
ae24e8b7 |
337 | fTRDCalibraFillHisto->SetNumberClusters(fMinClusters); // At least fMinClusters clusters |
521b7005 |
338 | fTRDCalibraFillHisto->SetNumberClustersf(nTimeBins); // Not more than %d clusters |
339 | fSavedTimeBins=kTRUE; |
340 | } |
341 | |
102f11b6 |
342 | Bool_t TriggerPassed = fTakeAllEvents; |
521b7005 |
343 | |
344 | if(fAccRejTrg){ |
345 | if(fAccRejTrg>0){ |
346 | TriggerPassed=kFALSE; |
347 | for(int i = 0; i < fTrgStrings->GetEntriesFast(); i++){ |
348 | const TObjString *const obString=(TObjString*)fTrgStrings->At(i); |
349 | const TString tString=obString->GetString(); |
d70155ad |
350 | if(CheckCTPTrigger(tString.Data())>0){TriggerPassed=kTRUE; break;} |
d8731936 |
351 | } |
521b7005 |
352 | } |
353 | else{ |
354 | TriggerPassed=kTRUE; |
355 | for(int i = 0; i < fTrgStrings->GetEntriesFast(); i++){ |
356 | const TObjString *const obString=(TObjString*)fTrgStrings->At(i); |
357 | const TString tString=obString->GetString(); |
d70155ad |
358 | if(CheckCTPTrigger(tString.Data())>0){TriggerPassed=kFALSE; break;} |
93ce7d1b |
359 | } |
775f67d7 |
360 | } |
521b7005 |
361 | } |
362 | |
363 | fTRDCalibraFillHisto->SetCH2dOn(TriggerPassed); |
579d2e0a |
364 | fTRDCalibraFillHisto->SetPH2dOn(TriggerPassed); |
521b7005 |
365 | for(int i=0; i<usedEntries; i++){ |
366 | const TClonesArray* inArr = TCAarray[i]; |
367 | Int_t nbEntries = inArr->GetEntries(); |
368 | HLTDebug(" %i TRDtracks in tracksArray", nbEntries); |
369 | AliTRDtrackV1* trdTrack = 0x0; |
ae24e8b7 |
370 | for (Int_t ii = 0; ii < nbEntries; ii++){ |
371 | HLTDebug("%i/%i: ", ii+1, nbEntries); |
372 | trdTrack = (AliTRDtrackV1*)inArr->At(ii); |
2edf582c |
373 | if(trdTrack->GetNumberOfTracklets()<fMinTracklets)continue; |
521b7005 |
374 | fTRDCalibraFillHisto->UpdateHistogramsV1(trdTrack); |
ae24e8b7 |
375 | // for(int i3=0; i3<7; i3++) |
376 | // if(trdTrack->GetTracklet(i3))trdTrack->GetTracklet(i3)->Bootstrap(fReconstructor); |
521b7005 |
377 | } |
378 | } |
379 | |
380 | if(!fOutArray->At(0))FormOutput(0); |
381 | if(!fDisplayArray->At(0))FormOutput(1); |
382 | PushBack(fDisplayArray, AliHLTTRDDefinitions::fgkCalibrationDataType); |
383 | |
384 | if(blockOrObject<0){ |
385 | TCAarray[0]->Delete(); |
386 | } |
387 | |
775f67d7 |
388 | return 0; |
dc2e6604 |
389 | |
95259bbb |
390 | } |
391 | |
d679dd6c |
392 | /** |
dc2e6604 |
393 | * Form output array of histrograms |
d679dd6c |
394 | */ |
395 | //============================================================================ |
d8731936 |
396 | void AliHLTTRDCalibrationComponent::FormOutput(Int_t param) |
d679dd6c |
397 | { |
775f67d7 |
398 | // gain histo |
399 | TH2I *hCH2d = fTRDCalibraFillHisto->GetCH2d(); |
d8731936 |
400 | if(!param)fOutArray->Add(hCH2d); |
401 | else fDisplayArray->Add(hCH2d); |
d679dd6c |
402 | |
775f67d7 |
403 | // drift velocity histo |
404 | TProfile2D *hPH2d = fTRDCalibraFillHisto->GetPH2d(); |
d8731936 |
405 | if(!param)fOutArray->Add(hPH2d); |
406 | else fDisplayArray->Add(hPH2d); |
d679dd6c |
407 | |
775f67d7 |
408 | // PRF histo |
409 | TProfile2D *hPRF2d = fTRDCalibraFillHisto->GetPRF2d(); |
d8731936 |
410 | if(!param)fOutArray->Add(hPRF2d); |
411 | else fDisplayArray->Add(hPRF2d); |
412 | |
413 | // Vdrift Linear Fit |
414 | if(!param){ |
415 | AliTRDCalibraVdriftLinearFit *hVdriftLinearFitOne=(AliTRDCalibraVdriftLinearFit *)fTRDCalibraFillHisto->GetVdriftLinearFit(); |
416 | fOutArray->Add(hVdriftLinearFitOne); |
417 | } |
418 | else{ |
419 | TH2S *hVdriftLinearFitOne = (TH2S *)(((AliTRDCalibraVdriftLinearFit *)fTRDCalibraFillHisto->GetVdriftLinearFit())->GetLinearFitterHisto(10,kTRUE)); |
bb2a05d3 |
420 | fDisplayArray->Add(hVdriftLinearFitOne); |
d8731936 |
421 | } |
dc2e6604 |
422 | |
bb2a05d3 |
423 | HLTDebug("GetCH2d = 0x%x; NEntries = %i; size = %i", hCH2d, hCH2d->GetEntries(), sizeof(*hCH2d)); |
775f67d7 |
424 | hCH2d->Print(); |
bb2a05d3 |
425 | HLTDebug("GetPH2d = 0x%x; NEntries = %i; size = %i", hPH2d, hPH2d->GetEntries(), sizeof(*hPH2d)); |
775f67d7 |
426 | hPH2d->Print(); |
bb2a05d3 |
427 | HLTDebug("GetPRF2d = 0x%x; NEntries = %i; size = %i", hPRF2d, hPRF2d->GetEntries(), sizeof(*hPRF2d)); |
775f67d7 |
428 | hPRF2d->Print(); |
bb2a05d3 |
429 | //HLTDebug("GetVdriftLinearFit = 0x%x; size = %i", hVdriftLinearFitOne, sizeof(hVdriftLinearFitOne)); |
d8731936 |
430 | |
93ce7d1b |
431 | HLTDebug("output Array: pointer = 0x%x; NEntries = %i; size = %i", fOutArray, fOutArray->GetEntries(), sizeof(fOutArray)); |
d8731936 |
432 | |
d679dd6c |
433 | } |
434 | |
93ce7d1b |
435 | Int_t AliHLTTRDCalibrationComponent::ShipDataToFXS(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/) |
436 | { |
d8731936 |
437 | AliHLTReadoutList rdList(AliHLTReadoutList::kTRD); |
438 | |
439 | EORCalibration(); |
440 | |
441 | fOutArray->Remove(fOutArray->FindObject("AliTRDCalibraVdriftLinearFit")); |
442 | //fOutArray->Remove(fOutArray->FindObject("PRF2d")); |
443 | //fOutArray->Remove(fOutArray->FindObject("PH2d")); |
444 | //fOutArray->Remove(fOutArray->FindObject("CH2d")); |
445 | |
44d3e6f5 |
446 | if(!(fOutArray->FindObject("CH2d"))) { |
447 | TH2I * ch2d = new TH2I("CH2d","Nz0Nrphi0",100,0.0,300.0,540,0,540); |
448 | fOutArray->Add(ch2d); |
449 | } |
450 | |
451 | if(!(fOutArray->FindObject("PH2d"))) { |
452 | TProfile2D * ph2d = new TProfile2D("PH2d","Nz0Nrphi0",30,-0.05,2.95,540,0,540); |
453 | fOutArray->Add(ph2d); |
454 | } |
455 | |
456 | if(!(fOutArray->FindObject("PRF2d"))) { |
457 | TProfile2D * prf2d = new TProfile2D("PRF2d","Nz0Nrphi0Ngp3",60,-9.0,9.0,540,0,540); |
458 | fOutArray->Add(prf2d); |
459 | } |
d8731936 |
460 | |
d8731936 |
461 | HLTDebug("Size of the fOutArray is %d\n",fOutArray->GetEntriesFast()); |
462 | |
89413559 |
463 | PushToFXS((TObject*)fOutArray, "TRD", "GAINDRIFTPRF", &rdList ); |
d8731936 |
464 | //PushToFXS((TObject*)fOutArray->FindObject("CH2d"), "TRD", "GAINDRIFTPRF", rdList.Buffer() ); |
465 | |
e03c1166 |
466 | return 0; |
93ce7d1b |
467 | } |
102f11b6 |
468 | |
d8731936 |
469 | Int_t AliHLTTRDCalibrationComponent::EORCalibration() |
470 | { |
471 | //Also Fill histograms for the online display |
472 | TH2I *hCH2d=(TH2I*)fOutArray->FindObject("CH2d"); |
473 | TProfile2D *hPH2d=(TProfile2D*)fOutArray->FindObject("PH2d"); |
474 | TProfile2D *hPRF2d= (TProfile2D*)fOutArray->FindObject("PRF2d"); |
475 | AliTRDCalibraVdriftLinearFit* hVdriftLinearFit = (AliTRDCalibraVdriftLinearFit*)fOutArray->FindObject("AliTRDCalibraVdriftLinearFit"); |
476 | |
477 | |
478 | if(!hCH2d || !hPH2d || !hPRF2d || !hVdriftLinearFit) return 0; |
479 | |
480 | //Fit |
481 | AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance(); |
482 | |
483 | //Gain |
484 | calibra->SetMinEntries(100); |
485 | calibra->AnalyseCH(hCH2d); |
f5ef4659 |
486 | //Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(0)) |
487 | // + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(0)); |
488 | //Int_t nbfit = calibra->GetNumberFit(); |
489 | //Int_t nbE = calibra->GetNumberEnt(); |
d8731936 |
490 | TH1F *coefgain = 0x0; |
491 | // enough statistics |
492 | //if ((nbtg > 0) && |
493 | // (nbfit >= 0.2*nbE)) { |
494 | // create the cal objects |
495 | //calibra->PutMeanValueOtherVectorFit(1,kTRUE); |
496 | TObjArray object = calibra->GetVectorFit(); |
497 | AliTRDCalDet *objgaindet = calibra->CreateDetObjectGain(&object,kFALSE); |
498 | coefgain = objgaindet->MakeHisto1DAsFunctionOfDet(); |
499 | //} |
500 | calibra->ResetVectorFit(); |
501 | |
502 | // vdrift second method |
bb2a05d3 |
503 | calibra->SetMinEntries(100); // If there is less than 100 |
d8731936 |
504 | hVdriftLinearFit->FillPEArray(); |
505 | calibra->AnalyseLinearFitters(hVdriftLinearFit); |
f5ef4659 |
506 | //nbtg = 540; |
507 | //nbfit = calibra->GetNumberFit(); |
508 | //nbE = calibra->GetNumberEnt(); |
d8731936 |
509 | TH1F *coefdriftsecond = 0x0; |
510 | // enough statistics |
511 | //if ((nbtg > 0) && |
512 | // (nbfit >= 0.1*nbE)) { |
513 | // create the cal objects |
514 | //calibra->PutMeanValueOtherVectorFit(1,kTRUE); |
515 | object = calibra->GetVectorFit(); |
516 | AliTRDCalDet *objdriftvelocitydetsecond = calibra->CreateDetObjectVdrift(&object,kTRUE); |
517 | objdriftvelocitydetsecond->SetTitle("secondmethodvdrift"); |
518 | coefdriftsecond = objdriftvelocitydetsecond->MakeHisto1DAsFunctionOfDet(); |
519 | //} |
520 | calibra->ResetVectorFit(); |
521 | |
522 | // vdrift first method |
523 | calibra->SetMinEntries(100*20); // If there is less than 20000 |
524 | calibra->AnalysePH(hPH2d); |
f5ef4659 |
525 | //nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1)) |
526 | // + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1)); |
527 | //nbfit = calibra->GetNumberFit(); |
528 | //nbE = calibra->GetNumberEnt(); |
d8731936 |
529 | TH1F *coefdrift = 0x0; |
530 | TH1F *coeft0 = 0x0; |
531 | // enough statistics |
532 | //if ((nbtg > 0) && |
533 | // (nbfit >= 0.2*nbE)) { |
534 | // create the cal objects |
535 | //calibra->PutMeanValueOtherVectorFit(1,kTRUE); |
536 | //calibra->PutMeanValueOtherVectorFit2(1,kTRUE); |
537 | object = calibra->GetVectorFit(); |
538 | AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE); |
539 | coefdrift = objdriftvelocitydet->MakeHisto1DAsFunctionOfDet(); |
540 | object = calibra->GetVectorFit2(); |
541 | AliTRDCalDet *objtime0det = calibra->CreateDetObjectT0(&object,kTRUE); |
542 | coeft0 = objtime0det->MakeHisto1DAsFunctionOfDet(); |
543 | //} |
544 | calibra->ResetVectorFit(); |
545 | |
546 | |
547 | //PRF |
548 | calibra->SetMinEntries(200); |
549 | calibra->AnalysePRFMarianFit(hPRF2d); |
f5ef4659 |
550 | //nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(2)) |
551 | // + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(2)); |
552 | //nbfit = calibra->GetNumberFit(); |
553 | //nbE = calibra->GetNumberEnt(); |
d8731936 |
554 | TH1F *coefprf = 0x0; |
555 | // enough statistics |
556 | //if ((nbtg > 0) && |
557 | // (nbfit >= 0.95*nbE)) { |
558 | // create cal pad objects |
559 | object = calibra->GetVectorFit(); |
560 | TObject *objPRFpad = calibra->CreatePadObjectPRF(&object); |
561 | coefprf = ((AliTRDCalPad *) objPRFpad)->MakeHisto1D(); |
562 | //} |
563 | calibra->ResetVectorFit(); |
564 | |
565 | |
566 | coefgain->SetName("coefgain"); |
567 | coefprf->SetName("coefprf"); |
568 | coefdrift->SetName("coefdrift"); |
569 | coefdriftsecond->SetName("coefdriftsecond"); |
570 | coeft0->SetName("coeft0"); |
5e0dedf7 |
571 | fAfterRunArray->Add(coefgain); |
572 | fAfterRunArray->Add(coefprf); |
573 | fAfterRunArray->Add(coefdrift); |
574 | fAfterRunArray->Add(coefdriftsecond); |
575 | fAfterRunArray->Add(coeft0); |
d8731936 |
576 | |
577 | if(coefgain||coefprf||coefdrift||coeft0||coefdriftsecond) { |
bb2a05d3 |
578 | PushBack(fAfterRunArray, AliHLTTRDDefinitions::fgkEORCalibrationDataType); |
579 | } |
d8731936 |
580 | |
ae24e8b7 |
581 | // TString fileName="/tmp/CalibHistoDump_run"; |
582 | // fileName+=AliCDBManager::Instance()->GetRun(); |
583 | // fileName+=".root"; |
584 | // HLTInfo("Dumping Histogram file to %s",fileName.Data()); |
585 | // TFile* file = TFile::Open(fileName, "RECREATE"); |
586 | // fAfterRunArray->Write(); |
587 | // fOutArray->Write(); |
588 | // file->Close(); |
589 | // HLTInfo("Histogram file dumped"); |
d8731936 |
590 | |
591 | return 0; |
592 | } |
593 | |