Fixes for coverity.
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibTask.cxx
CommitLineData
98937691 1
2/**************************************************************************
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
7 * *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
16
17/////////////////////////////////////////////////////////////////////////////////
18//
19// AliTRDCalibTask
20//
21// Offline TRD calibration task
22//
23// Author:
24// R. Bailhache (R.Bailhache@gsi.de)
25//
26//////////////////////////////////////////////////////////////////////////////////////
27
01239968 28#include <iostream>
29using namespace std;
98937691 30#include "Riostream.h"
31#include "TChain.h"
32#include "TTree.h"
33#include "TFile.h"
34#include "TProfile2D.h"
35#include "TH2I.h"
36#include "TH1F.h"
37#include "TH2F.h"
38#include "TList.h"
39#include "TMath.h"
40#include "TObject.h"
41#include "TObjArray.h"
42#include "TString.h"
43#include "TCanvas.h"
44#include "TLegend.h"
45#include "TStyle.h"
46#include "TLine.h"
57185ead 47#include "TIterator.h"
98937691 48
49#include "AliAnalysisTask.h"
50#include "AliAnalysisManager.h"
51
52#include "AliESDVertex.h"
53#include "AliESDEvent.h"
54#include "AliESDfriend.h"
55#include "AliESDInputHandler.h"
56#include "AliESDtrack.h"
57#include "AliESDfriendTrack.h"
58#include "AliTRDtrackV1.h"
59#include "AliTRDseedV1.h"
60#include "AliTRDcluster.h"
61#include "AliTRDgeometry.h"
62#include "AliESDtrackCuts.h"
63#include "AliESDVertex.h"
64#include "AliTRDCalDet.h"
65
57185ead 66#include "AliTRDCalibraVector.h"
98937691 67#include "AliTRDCalibraFillHisto.h"
68#include "AliTRDCalibraVdriftLinearFit.h"
69
70#include "AliTRDcalibDB.h"
71
72
73#include "AliTRDCalibTask.h"
74
75
76ClassImp(AliTRDCalibTask)
77
78//________________________________________________________________________
79 AliTRDCalibTask::AliTRDCalibTask(const char *name)
01239968 80 : AliAnalysisTaskSE(name), fESD(0),
98937691 81 fESDfriend(0),
82 fkEsdTrack(0),
83 fFriendTrack(0),
84 fCalibObject(0),
85 fTrdTrack(0),
86 fCl(0),
87 fListHist(0),
88 fTRDCalibraFillHisto(0),
89 fNEvents(0),
90 fNbTRDTrack(0),
91 fNbTRDTrackOffline(0),
92 fNbTRDTrackStandalone(0),
93 fNbTPCTRDtrack(0),
94 fNbTimeBin(0),
95 fNbTimeBinOffline(0),
96 fNbTimeBinStandalone(0),
97 fNbClusters(0),
98 fNbClustersOffline(0),
99 fNbClustersStandalone(0),
100 fNbTracklets(0),
101 fNbTrackletsOffline(0),
102 fNbTrackletsStandalone(0),
103 fAbsoluteGain(0),
104 fCH2dSum(0),
105 fPH2dSum(0),
106 fCH2dSM(0),
107 fPH2dSM(0),
108 fHisto2d(kTRUE),
109 fVector2d(kFALSE),
110 fVdriftLinear(kTRUE),
111 fNbTimeBins(0),
112 fSelectedTrigger(new TObjArray()),
113 fRejected(kTRUE),
114 fEsdTrackCuts(0),
115 fRequirePrimaryVertex(kFALSE),
116 fVtxTPC(kFALSE),
117 fVtxSPD(kFALSE),
118 fMinNbContributors(0),
119 fRangePrimaryVertexZ(9999999.0),
120 fLow(0),
121 fHigh(30),
122 fFillZero(kFALSE),
123 fNormalizeNbOfCluster(kFALSE),
124 fRelativeScale(0.0),
125 fMaxCluster(100.0),
126 fNbMaxCluster(2),
127 fOfflineTracks(kFALSE),
128 fStandaloneTracks(kFALSE),
4c865c34 129 fVersionGainUsed(0),
130 fSubVersionGainUsed(0),
131 fVersionVdriftUsed(0),
132 fSubVersionVdriftUsed(0),
98937691 133 fCalDetGain(0x0),
134 fMaxEvent(0),
135 fCounter(0),
136 fDebug(0)
137{
138 //
139 // Default constructor
140 //
141
142 fNz[0] = 0;
143 fNz[1] = 0;
144 fNz[2] = 0;
145
146 fNrphi[0] = 0;
147 fNrphi[1] = 0;
148 fNrphi[2] = 0;
149
150 // Define input and output slots here
151 // Input slot #0 works with a TChain
152 DefineInput(0, TChain::Class());
153
154 // Output slot #0 writes into a TList container
01239968 155 DefineOutput(1, TList::Class());
98937691 156
157
158}
159//____________________________________________________________________________________
160AliTRDCalibTask::~AliTRDCalibTask()
161{
162 //
163 // AliTRDCalibTask destructor
164 //
165
166 // Pointeur
167 if(fNEvents) delete fNEvents;
168 if(fNbTRDTrack) delete fNbTRDTrack;
169 if(fNbTRDTrackOffline) delete fNbTRDTrackOffline;
170 if(fNbTRDTrackStandalone) delete fNbTRDTrackStandalone;
171 if(fNbTPCTRDtrack) delete fNbTPCTRDtrack;
172 if(fNbTimeBin) delete fNbTimeBin;
173 if(fNbTimeBinOffline) delete fNbTimeBinOffline;
174 if(fNbTimeBinStandalone) delete fNbTimeBinStandalone;
175 if(fNbClusters) delete fNbClusters;
176 if(fNbClustersOffline) delete fNbClustersOffline;
177 if(fNbClustersStandalone) delete fNbClustersStandalone;
178 if(fNbTracklets) delete fNbTracklets;
179 if(fNbTrackletsOffline) delete fNbTrackletsOffline;
180 if(fNbTrackletsStandalone) delete fNbTrackletsStandalone;
181 if(fAbsoluteGain) delete fAbsoluteGain;
182 if(fCH2dSum) delete fCH2dSum;
183 if(fPH2dSum) delete fPH2dSum;
184 if(fCH2dSM) delete fCH2dSM;
185 if(fPH2dSM) delete fPH2dSM;
186 if(fCalDetGain) delete fCalDetGain;
187
188 if(fSelectedTrigger) {
189 fSelectedTrigger->Delete();
190 delete fSelectedTrigger;
191 }
192 if(fEsdTrackCuts) {
193 delete fEsdTrackCuts;
194 }
195
196}
01239968 197
198/*
98937691 199//________________________________________________________________________
200void AliTRDCalibTask::ConnectInputData(Option_t *)
201{
202 // Connect ESD or AOD here
01239968 203 // Called once per event
98937691 204
01239968 205 cout << "AliTRDCalibTask::ConnectInputData() IN" << endl;
206
207
208 // TTree* tree = dynamic_cast<TTree*> (GetInputData(0)); //pointer wird "umgecastet" auf anderen Variablentyp
209 // if (!tree) {
98937691 210 //Printf("ERROR: Could not read chain from input slot 0");
01239968 211 // } else {
98937691 212
01239968 213 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
214
215 if (!esdH) {
216 //Printf("ERROR: Could not get ESDInputHandler");
217 } else {
218 fESD = esdH->GetEvent();
219 // esdH->SetActiveBranches("ESDfriend*");
220 if ((esdH->GetTree())->GetBranch("ESDfriend.")) fESDfriend = esdH->GetESDfriend();
221 //else printf("No friend ESD\n");
222 //Printf("*** CONNECTED NEW EVENT ****");
98937691 223 }
01239968 224
225
226 // }
227 //cout << "AliTRDCalibTask::ConnectInputData() OUT" << endl;
228
98937691 229}
01239968 230*/
231
98937691 232//________________________________________________________________________
01239968 233void AliTRDCalibTask::UserCreateOutputObjects()
98937691 234{
235 //
236 // Create the histos
237 //
01239968 238 //cout << "AliTRDCalibTask::CreateOutputObjects() IN" << endl;
98937691 239
240 // Number of time bins
241 if(fNbTimeBins==0) {
242 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
243 fNbTimeBins = cal->GetNumberOfTimeBinsDCS();
244 if(fNbTimeBins <= 0){
245 AliWarning(Form("No of TimeBins from DB [%d] use default [30]", fNbTimeBins));
246 fNbTimeBins = 30;
247 }
248 }
249
250 // instance calibration
251 fTRDCalibraFillHisto = AliTRDCalibraFillHisto::Instance();
252 fTRDCalibraFillHisto->SetHisto2d(fHisto2d); // choose to use histograms
253 fTRDCalibraFillHisto->SetVector2d(fVector2d); // choose to use vectors
254 fTRDCalibraFillHisto->SetCH2dOn(); // choose to calibrate the gain
255 fTRDCalibraFillHisto->SetPH2dOn(); // choose to calibrate the drift velocity
256 fTRDCalibraFillHisto->SetPRF2dOn(); // choose to look at the PRF
257 fTRDCalibraFillHisto->SetLinearFitterOn(fVdriftLinear); // Other possibility vdrift VDRIFT
258 fTRDCalibraFillHisto->SetLinearFitterDebugOn(fVdriftLinear); // Other possibility vdrift
4c865c34 259 fTRDCalibraFillHisto->SetVersionGainUsed(fVersionGainUsed); // Gain Used
260 fTRDCalibraFillHisto->SetSubVersionGainUsed(fSubVersionGainUsed); // Gain Used
261 fTRDCalibraFillHisto->SetVersionVdriftUsed(fVersionVdriftUsed); // Vdrift Used
262 fTRDCalibraFillHisto->SetSubVersionVdriftUsed(fSubVersionVdriftUsed); // Vdrift Used
98937691 263 for(Int_t k = 0; k < 3; k++){
264 if(((fNz[k] != 10) && (fNrphi[k] != 10)) && ((fNz[k] != 100) && (fNrphi[k] != 100))) {
265 fTRDCalibraFillHisto->SetNz(k,fNz[k]); // Mode calibration
266 fTRDCalibraFillHisto->SetNrphi(k,fNrphi[k]); // Mode calibration
267 }
268 else {
269 if((fNz[k] == 100) && (fNrphi[k] == 100)) {
270 if(fVector2d) AliInfo("The mode all together is not supported by the vector method");
271 fTRDCalibraFillHisto->SetAllTogether(k);
272 }
273 if((fNz[k] == 10) && (fNrphi[k] == 10)) {
274 if(fVector2d) AliInfo("The mode per supermodule is not supported by the vector method");
275 fTRDCalibraFillHisto->SetPerSuperModule(k);
276 }
277 }
278 }
279 // Variables for how to fill
280 fTRDCalibraFillHisto->SetFillWithZero(fFillZero);
281 fTRDCalibraFillHisto->SetNormalizeNbOfCluster(fNormalizeNbOfCluster);
282 fTRDCalibraFillHisto->SetMaxCluster(fMaxCluster);
283 fTRDCalibraFillHisto->SetNbMaxCluster(fNbMaxCluster);
284
285 // Init with 30 timebins
286 fTRDCalibraFillHisto->Init2Dhistos(fNbTimeBins); // initialise the histos
287 fTRDCalibraFillHisto->SetNumberClusters(fLow); // At least 11 clusters
288 fTRDCalibraFillHisto->SetNumberClustersf(fHigh); // At least 11 clusters
289 fRelativeScale = fTRDCalibraFillHisto->GetRelativeScale(); // Get the relative scale for the gain
290
291 // For testing only
292 if(fDebug > 2) fTRDCalibraFillHisto->SetDebugLevel(1); //debug stuff
293
294 // output list
295 fListHist = new TList();
296 if(fHisto2d) {
297 fListHist->Add(fTRDCalibraFillHisto->GetCH2d());
298 fListHist->Add(fTRDCalibraFillHisto->GetPH2d());
299 fListHist->Add(fTRDCalibraFillHisto->GetPRF2d());
300 }
301 if(fVdriftLinear) fListHist->Add((TObject *) fTRDCalibraFillHisto->GetVdriftLinearFit());
302 if(fVector2d) fListHist->Add((TObject *) fTRDCalibraFillHisto->GetCalibraVector()); //calibra vector
303 fNEvents = new TH1I("NEvents","NEvents", 2, 0, 2);
304 fListHist->Add(fNEvents);
305
306 // absolute gain calibration even without AliESDfriend
307 Int_t nBinsPt = 25;
308 Double_t minPt = 0.001;
309 Double_t maxPt = 10.0;
310
311 Double_t *binLimLogPt = new Double_t[nBinsPt+1];
312 Double_t *binLimPt = new Double_t[nBinsPt+1];
313 for(Int_t i=0; i<=nBinsPt; i++) binLimLogPt[i]=(Double_t)TMath::Log10(minPt) + (TMath::Log10(maxPt)-TMath::Log10(minPt))/nBinsPt*(Double_t)i ;
314 for(Int_t i=0; i<=nBinsPt; i++) binLimPt[i]=(Double_t)TMath::Power(10,binLimLogPt[i]);
315
316 fAbsoluteGain = new TH2F("AbsoluteGain","AbsoluteGain", 200, 0.0, 700.0, nBinsPt, binLimPt);
317 fAbsoluteGain->SetYTitle("Momentum at TRD");
318 fAbsoluteGain->SetXTitle("charge deposit [a.u]");
319 fAbsoluteGain->SetZTitle("counts");
320 fAbsoluteGain->SetStats(0);
321 fAbsoluteGain->Sumw2();
322 fListHist->Add(fAbsoluteGain);
323
324
325
326 /////////////////////////////////////////
327 // First debug level
328 ///////////////////////////////////////
329 if(fDebug > 0) {
330
331 // Standart with AliESDfriend
332 fPH2dSM = new TProfile2D("PH2dSM","Nz10Nrphi10"
333 ,fNbTimeBins,-0.05,(Double_t)((fNbTimeBins-0.5)/10.0)
334 ,18,0,18);
335 fPH2dSM->SetYTitle("Det/pad groups");
336 fPH2dSM->SetXTitle("time [#mus]");
337 fPH2dSM->SetZTitle("<PH> [a.u.]");
338 fPH2dSM->SetStats(0);
339 //
340 fCH2dSM = new TH2I("CH2dSM","Nz10Nrphi10",50,0,300,18,0,18);
341 fCH2dSM->SetYTitle("Det/pad groups");
342 fCH2dSM->SetXTitle("charge deposit [a.u]");
343 fCH2dSM->SetZTitle("counts");
344 fCH2dSM->SetStats(0);
345 fCH2dSM->Sumw2();
346 //
347 fPH2dSum = new TProfile2D("PH2dSum","Nz100Nrphi100"
348 ,fNbTimeBins,-0.05,(Double_t)((fNbTimeBins-0.5)/10.0)
349 ,1,0,1);
350 fPH2dSum->SetYTitle("Det/pad groups");
351 fPH2dSum->SetXTitle("time [#mus]");
352 fPH2dSum->SetZTitle("<PH> [a.u.]");
353 fPH2dSum->SetStats(0);
354 //
355 fCH2dSum = new TH2I("CH2dSum","Nz100Nrphi100",50,0,300,1,0,1);
356 fCH2dSum->SetYTitle("Det/pad groups");
357 fCH2dSum->SetXTitle("charge deposit [a.u]");
358 fCH2dSum->SetZTitle("counts");
359 fCH2dSum->SetStats(0);
360 fCH2dSum->Sumw2();
361
362 // Add them
363 fListHist->Add(fPH2dSM);
364 fListHist->Add(fCH2dSM);
365 fListHist->Add(fPH2dSum);
366 fListHist->Add(fCH2dSum);
367 }
368
369 /////////////////////////////////////////
370 // Second debug level
371 ///////////////////////////////////////
372 if(fDebug > 1) {
373
374 fNbTRDTrack = new TH1F("TRDTrack","TRDTrack",50,0,50);
375 fNbTRDTrack->Sumw2();
376 fNbTRDTrackOffline = new TH1F("TRDTrackOffline","TRDTrackOffline",50,0,50);
377 fNbTRDTrackOffline->Sumw2();
378 fNbTRDTrackStandalone = new TH1F("TRDTrackStandalone","TRDTrackStandalone",50,0,50);
379 fNbTRDTrackStandalone->Sumw2();
380 fNbTPCTRDtrack = new TH2F("NbTPCTRDtrack","NbTPCTRDtrack",100,0,100,100,0,100);
381 fNbTPCTRDtrack->Sumw2();
382 //
383 fNbTimeBin = new TH1F("NbTimeBin","NbTimeBin",35,0,35);
384 fNbTimeBin->Sumw2();
385 fNbTimeBinOffline = new TH1F("NbTimeBinOffline","NbTimeBinOffline",35,0,35);
386 fNbTimeBinOffline->Sumw2();
387 fNbTimeBinStandalone = new TH1F("NbTimeBinStandalone","NbTimeBinStandalone",35,0,35);
388 fNbTimeBinStandalone->Sumw2();
389 //
390 fNbClusters = new TH1F("NbClusters","",35,0,35);
391 fNbClusters->Sumw2();
392 fNbClustersOffline = new TH1F("NbClustersOffline","",35,0,35);
393 fNbClustersOffline->Sumw2();
394 fNbClustersStandalone = new TH1F("NbClustersStandalone","",35,0,35);
395 fNbClustersStandalone->Sumw2();
396 //
397 fNbTracklets = new TH1F("NbTracklets","NbTracklets",540,0.,540.);
398 fNbTracklets->Sumw2();
399 fNbTrackletsOffline = new TH1F("NbTrackletsOffline","NbTrackletsOffline",540,0.,540.);
400 fNbTrackletsOffline->Sumw2();
401 fNbTrackletsStandalone = new TH1F("NbTrackletsStandalone","NbTrackletsStandalone",540,0.,540.);
402 fNbTrackletsStandalone->Sumw2();
403
404 fListHist->Add(fNbTRDTrack);
405 fListHist->Add(fNbTRDTrackOffline);
406 fListHist->Add(fNbTRDTrackStandalone);
407 fListHist->Add(fNbTPCTRDtrack);
408
409 fListHist->Add(fNbTimeBin);
410 fListHist->Add(fNbTimeBinOffline);
411 fListHist->Add(fNbTimeBinStandalone);
412 fListHist->Add(fNbClusters);
413 fListHist->Add(fNbClustersOffline);
414 fListHist->Add(fNbClustersStandalone);
415 fListHist->Add(fNbTracklets);
416 fListHist->Add(fNbTrackletsOffline);
417 fListHist->Add(fNbTrackletsStandalone);
418
419 }
01239968 420 //cout << "AliTRDCalibTask::UserCreateOutputObjects() OUT" << endl;
421}
98937691 422
57185ead 423
01239968 424//________________________________________________________________________
425void AliTRDCalibTask::UserExec(Option_t *)
426{
427 //
428 // Filling of the histos
429 //
430 //cout << "AliTRDCalibTask::Exec() IN" << endl;
98937691 431
01239968 432 // AliLog::SetGlobalLogLevel(AliLog::kError);
433 // cout << "AliTRDCalibTask::Exec() 1" << endl;
434 fESD = dynamic_cast<AliESDEvent*>(fInputEvent);
435 if(!fESD){
436 AliError("ESD Event missing");
437 PostData(1, fListHist);
438 return;
439 }
440
441 //printf("Counter %d\n",fCounter);
442
443 fCounter++;
444 //cout << "maxEvent = " << fMaxEvent << endl;
445 //if(fCounter%100==0) cout << "fCounter = " << fCounter << endl;
446 if((fMaxEvent != 0) && (fMaxEvent < fCounter)) return;
447 //if(fCounter%100==0) cout << "fCounter1 = " << fCounter << endl;
448 //cout << "event = " << fCounter << endl;
449
450 //printf("Counter %d\n",fCounter);
451
452 ///////////////////
453 // Check trigger
454 ///////////////////
455 Bool_t pass = kTRUE;
456 Int_t numberOfTriggerSelected = fSelectedTrigger->GetEntriesFast();
457 //printf("numberofTriggerSelected %d\n",numberOfTriggerSelected);
458 if(fRejected) {
459 pass = kTRUE;
460 for(Int_t k = 0; k < numberOfTriggerSelected; k++){
461 const TObjString *const obString=(TObjString*)fSelectedTrigger->At(k);
462 const TString tString=obString->GetString();
463 if(fESD->IsTriggerClassFired((const char*)tString)) {
464 pass = kFALSE;
465 }
466 }
467 }
468 else {
469 pass = kFALSE;
470 for(Int_t k = 0; k < numberOfTriggerSelected; k++){
471 const TObjString *const obString=(TObjString*)fSelectedTrigger->At(k);
472 const TString tString=obString->GetString();
473 if(fESD->IsTriggerClassFired((const char*)tString)) {
474 pass = kTRUE;
475 }
476 }
477 }
478 if(!pass) {
479 PostData(1, fListHist);
480 return;
481 }
482 //printf("Class Fired %s\n",(const char*)fESD->GetFiredTriggerClasses());
483 //printf("Trigger passed\n");
484
485 ///////////////////////////////
486 // Require a primary vertex
487 //////////////////////////////
488 if(fRequirePrimaryVertex) {
489 const AliESDVertex* vtxESD = 0x0;
490 if (fVtxTPC) vtxESD = fESD->GetPrimaryVertexTPC() ;
491 else if (fVtxSPD) vtxESD = fESD->GetPrimaryVertexSPD() ;
492 else vtxESD = fESD->GetPrimaryVertexTracks() ;
493 if(!vtxESD){
494 PostData(1, fListHist);
495 return;
496 }
497 Int_t nCtrb = vtxESD->GetNContributors();
498 if(nCtrb < fMinNbContributors) {
499 PostData(1, fListHist);
500 return;
501 }
502 Double_t zPosition = vtxESD->GetZ();
503 if(TMath::Abs(zPosition) > fRangePrimaryVertexZ) {
504 PostData(1, fListHist);
505 return;
506 }
507
508 }
509
510 //printf("Primary vertex passed\n");
511
512 fNEvents->Fill(1);
513
514 // In total
515 Int_t nbTrdTracks = 0;
516 // standalone
517 Int_t nbTrdTracksStandalone = 0;
518 // offline
519 Int_t nbTrdTracksOffline = 0;
520 // TPC
521 Int_t nbtrackTPC = 0;
522
523 Double_t nbTracks = fESD->GetNumberOfTracks();
524 //printf("Number of tracks %f\n",nbTracks);
525
526 if (nbTracks <= 0.0) {
527
528 if(fDebug > 1) {
529 fNbTRDTrack->Fill(nbTrdTracks);
530 fNbTRDTrackStandalone->Fill(nbTrdTracksStandalone);
531 fNbTRDTrackOffline->Fill(nbTrdTracksOffline);
532 }
533 PostData(1, fListHist);
534 return;
535 }
536
4c865c34 537
01239968 538 fESDfriend = dynamic_cast<AliESDfriend*> (fESD->FindListObject("AliESDfriend"));
539 if(!fESDfriend){
540 AliError("fESDfriend not available");
541 PostData(1, fListHist);
542 return;
543 }
544
545 //printf("has friends\n");
98937691 546
01239968 547 /*
548 ////////////////////////////////////
98937691 549 // Check the number of TPC tracks
550 ///////////////////////////////////
551 //printf("Nb of tracks %f\n",nbTracks);
552 for(Int_t itrk = 0; itrk < nbTracks; itrk++){
553 // Get ESD track
554 fkEsdTrack = fESD->GetTrack(itrk);
555 ULong_t status = fkEsdTrack->GetStatus();
556 if(status&(AliESDtrack::kTPCout)) nbtrackTPC++;
01239968 557 if((status&(AliESDtrack::kTRDout)) && (!(status&(AliESDtrack::kTRDin)))) {
558 nbTrdTracks++;
559 nbTrdTracksStandalone++;
560 }
561 if((status&(AliESDtrack::kTRDin))) {
562 nbTrdTracks++;
563 nbTrdTracksOffline++;
98937691 564 }
565 }
01239968 566
98937691 567 if((nbtrackTPC>0) && (nbTrdTracks > (3.0*nbtrackTPC))) pass = kFALSE;
568
569 if(fDebug > 1) {
570
571 fNbTRDTrack->Fill(nbTrdTracks);
572 fNbTRDTrackStandalone->Fill(nbTrdTracksStandalone);
573 fNbTRDTrackOffline->Fill(nbTrdTracksOffline);
574 fNbTPCTRDtrack->Fill(nbTrdTracks,nbtrackTPC);
575
576 }
577
578 if(!pass) {
01239968 579 PostData(1, fListHist);
98937691 580 return;
581 }
01239968 582 */
583
584 /////////////////////////////////////
585 // Loop on AliESDtrack
586 ////////////////////////////////////
587 //printf("Nb of tracks %f\n",nbTracks);
588 for(int itrk=0; itrk < nbTracks; ++itrk){
98937691 589
01239968 590 // Get ESD track
591 fkEsdTrack = fESD->GetTrack(itrk);
592 if(!fkEsdTrack) continue;
593 ULong_t status = fkEsdTrack->GetStatus();
594 if(status&(AliESDtrack::kTPCout)) ++nbtrackTPC;
595
596 // Quality cuts on the AliESDtrack
597 if((fEsdTrackCuts) && (!fEsdTrackCuts->IsSelected((AliVParticle *)fkEsdTrack))) {
598 //printf("Not a good track\n");
599 continue;
600 }
601
602 // First Absolute gain calibration
603 Int_t trdNTracklets = (Int_t) fkEsdTrack->GetTRDntracklets();
604 Int_t trdNTrackletsPID = (Int_t) fkEsdTrack->GetTRDntrackletsPID();
605 if((trdNTracklets > 0) && (trdNTrackletsPID > 0)) {
606 for(Int_t iPlane = 0; iPlane < 6; ++iPlane){
607 //Double_t slide = fkEsdTrack->GetTRDslice(iPlane);
608 //printf("Number of slide %d\n",fkEsdTrack->GetNumberOfTRDslices());
609 //Double_t momentum = fkEsdTrack->GetTRDmomentum(iPlane);
610 //printf("momentum %f, slide %f\n",momentum,slide);
611 if(fkEsdTrack->GetTRDslice(iPlane) > 0.0)
612 fAbsoluteGain->Fill(fkEsdTrack->GetTRDslice(iPlane)*8.0/100.0,
613 fkEsdTrack->GetTRDmomentum(iPlane));
614 }
615 }
616
617 // Other cuts
618 Bool_t good = kTRUE;
619 Bool_t standalonetrack = kFALSE;
620 Bool_t offlinetrack = kFALSE;
621 //ULong_t status = fkEsdTrack->GetStatus();
622
623 fFriendTrack = fESDfriend->GetTrack(itrk);
4c865c34 624 if(!fFriendTrack) {
625 //printf("No friend track %d\n",itrk);
626 continue;
627 }
01239968 628 //////////////////////////////////////
629 // Loop on calibration objects
630 //////////////////////////////////////
631 Int_t icalib=0;
632 Int_t nTRDtrackV1=0;
633 while((fCalibObject = (TObject *)(fFriendTrack->GetCalibObject(icalib++)))){
4c865c34 634 //printf("Name %s\n",fCalibObject->IsA()->GetName());
01239968 635 if(strcmp(fCalibObject->IsA()->GetName(), "AliTRDtrackV1") != 0) continue;
636 //printf("Find the calibration object\n");
637 ++nTRDtrackV1;
638
639 if((status&(AliESDtrack::kTRDout)) && (!(status&(AliESDtrack::kTRDin)))) {
640 standalonetrack = kTRUE;
641 }
642 if((status&(AliESDtrack::kTRDin))) {
643 offlinetrack = kTRUE;
644 }
645 if(fOfflineTracks){
646 if(!offlinetrack){
647 good = kFALSE;
648 }
649 }
650 else if(fStandaloneTracks){
651 if(!standalonetrack){
652 good = kFALSE;
653 }
654 }
655
656 fTrdTrack = (AliTRDtrackV1 *)fCalibObject;
657 if(good) {
658 //cout << "good" << endl;
659 fTRDCalibraFillHisto->UpdateHistogramsV1(fTrdTrack);
660 //printf("Fill fTRDCalibraFillHisto\n");
661 }
662
663 //////////////////////////////////
664 // Debug
665 ////////////////////////////////
666
667 if(fDebug > 0) {
668
669 //printf("Enter debug\n");
670
671 Int_t nbtracklets = 0;
672
673 // Check some stuff
674 Bool_t standalonetracklet = kFALSE;
675 const AliTRDseedV1 *tracklet = 0x0;
676 //////////////////////////////////////
677 // Loop tracklets
678 /////////////////////////////////////
679 Int_t nbclusters=0;
680 Double_t phtb[AliTRDseedV1::kNtb];
681 memset(phtb, 0, AliTRDseedV1::kNtb*sizeof(Double_t));
682 Double_t sum = 0.0;
683 Float_t normalisation = 6.67;
684 Int_t detector = 0;
685 Int_t sector = 0;
686 for(Int_t itr = 0; itr < 6; ++itr){
687
688 if(!(tracklet = fTrdTrack->GetTracklet(itr))) continue;
689 if(!tracklet->IsOK()) continue;
690 ++nbtracklets;
691 standalonetracklet = kFALSE;
692 if(tracklet->IsStandAlone()) standalonetracklet = kTRUE;
693
694 nbclusters = 0;
695 memset(phtb, 0, AliTRDseedV1::kNtb*sizeof(Double_t));
696 sum = 0.0;
697 detector = 0;
698 sector = 0;
699 //Int_t crossrow = 0;
700
701 // Check no shared clusters
702 //for(int icc=AliTRDseedV1::kNtb; icc<AliTRDseedV1::kNclusters; icc++){
703 // if((fcl = tracklet->GetClusters(icc))) crossrow = 1;
704 // }
705
706 // Loop on clusters
707 Int_t time = 0;
708 Float_t ch = 0;
709 Float_t qcl = 0;
710 for(int ic=0; ic<AliTRDseedV1::kNtb; ++ic){
711
712 if(!(fCl = tracklet->GetClusters(ic))) continue;
713 ++nbclusters;
714 time = fCl->GetPadTime();
715 ch = tracklet->GetdQdl(ic);
716 qcl = TMath::Abs(fCl->GetQ());
717 detector = fCl->GetDetector();
718 // Add the charge if shared cluster
719 if((ic+AliTRDseedV1::kNtb) < AliTRDseedV1::kNclusters) {
720 if((fCl = tracklet->GetClusters(ic+AliTRDseedV1::kNtb))) {
721 qcl += TMath::Abs(fCl->GetQ());
722 //printf("Add the cluster charge\n");
723 }
724 }
725 if((time>-1) && (time<fNbTimeBins)) phtb[time]=qcl;
726 if((fCalDetGain) && (fCalDetGain->GetValue(detector) > 0.0)) sum += ch*fCalDetGain->GetValue(detector)/normalisation;
727 else sum += ch/normalisation;
728
729 if(fDebug > 1) {
730 fNbTimeBin->Fill(time);
731 if(tracklet->IsStandAlone()) fNbTimeBinStandalone->Fill(time);
732 else fNbTimeBinOffline->Fill(time);
733 }
734 }
735 sector = AliTRDgeometry::GetSector(detector);
736
737 if(fDebug > 1) {
738 fNbTracklets->Fill(detector);
739 if(tracklet->IsStandAlone()) fNbTrackletsStandalone->Fill(detector);
740 else fNbTrackletsOffline->Fill(detector);
741
742 fNbClusters->Fill(nbclusters);
743 if(tracklet->IsStandAlone()) fNbClustersStandalone->Fill(nbclusters);
744 else fNbClustersOffline->Fill(nbclusters);
745 }
746
747 if(fDebug > 0) {
748 if((nbclusters > fLow) && (nbclusters < fHigh)){
749 if(fRelativeScale > 0.0) sum = sum/fRelativeScale;
750 fCH2dSM->Fill(sum,sector+0.5);
751 fCH2dSum->Fill(sum,0.5);
752 Bool_t checknoise = kTRUE;
753 if(fMaxCluster > 0) {
754 if(phtb[0] > fMaxCluster) checknoise = kFALSE;
755 if(fNbTimeBins > fNbMaxCluster) {
756 for(Int_t k = (fNbTimeBins-fNbMaxCluster); k < fNbTimeBins; k++){
757 if(phtb[k] > fMaxCluster) checknoise = kFALSE;
758 }
759 }
760 }
761 if(checknoise) {
762 for(int ic=0; ic<fNbTimeBins; ic++){
763 if(fFillZero) {
764 fPH2dSum->Fill((Double_t)(ic/10.0),0.5,(Double_t)phtb[ic]);
765 fPH2dSM->Fill((Double_t)(ic/10.0),sector+0.5,(Double_t)phtb[ic]);
766 }
767 else {
768 if(phtb[ic] > 0.0) {
769 fPH2dSum->Fill((Double_t)(ic/10.0),0.0,(Double_t)phtb[ic]);
770 fPH2dSM->Fill((Double_t)(ic/10.0),sector+0.5,(Double_t)phtb[ic]);
771 }
772 }
773 }
774 }
775 }
776 }
777 } // loop on tracklets
778
779 } // debug
780
781 }// while calibration objects
782 if(nTRDtrackV1 > 0) {
783 ++nbTrdTracks;
784 if((status&(AliESDtrack::kTRDout)) && (!(status&(AliESDtrack::kTRDin)))) {
785 ++nbTrdTracksStandalone;
786 }
787 if((status&(AliESDtrack::kTRDin))) {
788 ++nbTrdTracksOffline;
789 }
790 }
791 //delete fFriendTrack;
792 } // loop ESD track
793
794 if(fDebug > 1) {
795 fNbTRDTrack->Fill(nbTrdTracks);
796 fNbTRDTrackStandalone->Fill(nbTrdTracksStandalone);
797 fNbTRDTrackOffline->Fill(nbTrdTracksOffline);
798 fNbTPCTRDtrack->Fill(nbTrdTracks,nbtrackTPC);
799 }
800
801 // Post output data
802 PostData(1, fListHist);
803 //cout << "AliTRDCalibTask::Exec() OUT" << endl;
804}
98937691 805
98937691 806//________________________________________________________________________
807void AliTRDCalibTask::Terminate(Option_t *)
808{
809 //
810 // Terminate
811 //
812
813 if(fTRDCalibraFillHisto) fTRDCalibraFillHisto->DestroyDebugStreamer();
814
815
816}
817//_______________________________________________________
818Bool_t AliTRDCalibTask::Load(const Char_t *filename)
819{
820 //
821 // Generic container loader
822 //
823
824 if(!TFile::Open(filename)){
825 //AliWarning(Form("Couldn't open file %s.", filename));
826 return kFALSE;
827 }
828 TList *o = 0x0;
829 if(!(o = (TList*)gFile->Get(GetName()))){
830 //AliWarning("Missing histogram container.");
831 return kFALSE;
832 }
833 fListHist = (TList*)o->Clone(GetName());
834 gFile->Close();
835 return kTRUE;
836}
57185ead 837//_______________________________________________________
838Bool_t AliTRDCalibTask::Load(TList *lister)
839{
840 //
841 // Generic container loader
842 //
843
844 fListHist = (TList*)lister->Clone(GetName());
845 return kTRUE;
846}
98937691 847//________________________________________________________________________
848void AliTRDCalibTask::Plot()
849{
850 //
851 // Plot the histos stored in the TList
852 //
853
854 if(!fListHist) return;
855
856 /////////////////////////////////////
857 // Take the debug stuff
858 /////////////////////////////////////
859
860 TH1I *nEvents = (TH1I *) fListHist->FindObject("NEvents");
861
862 TH2F *absoluteGain = (TH2F *) fListHist->FindObject("AbsoluteGain");
863
864 TH1F *trdTrack = (TH1F *) fListHist->FindObject("TRDTrack");
865 TH1F *trdTrackOffline = (TH1F *) fListHist->FindObject("TRDTrackOffline");
866 TH1F *trdTrackStandalone = (TH1F *) fListHist->FindObject("TRDTrackStandalone");
867
868 TH2F *tpctrdTrack = (TH2F *) fListHist->FindObject("NbTPCTRDtrack");
869
870 TH1F *nbTimeBin = (TH1F *) fListHist->FindObject("NbTimeBin");
871 TH1F *nbTimeBinOffline = (TH1F *) fListHist->FindObject("NbTimeBinOffline");
872 TH1F *nbTimeBinStandalone = (TH1F *) fListHist->FindObject("NbTimeBinStandalone");
873
874 TH1F *nbClusters = (TH1F *) fListHist->FindObject("NbClusters");
875 TH1F *nbClustersOffline = (TH1F *) fListHist->FindObject("NbClustersOffline");
876 TH1F *nbClustersStandalone = (TH1F *) fListHist->FindObject("NbClustersStandalone");
877
878 TH1F *nbTracklets = (TH1F *) fListHist->FindObject("NbTracklets");
879 TH1F *nbTrackletsOffline = (TH1F *) fListHist->FindObject("NbTrackletsOffline");
880 TH1F *nbTrackletsStandalone = (TH1F *) fListHist->FindObject("NbTrackletsStandalone");
881
882 /////////////////////////////////////
883 // Take the calibration objects
884 /////////////////////////////////////
885
886 TH2I *ch2d = (TH2I *) fListHist->FindObject("CH2d");
887 TProfile2D *ph2d = (TProfile2D *) fListHist->FindObject("PH2d");
888
889 TH2I *ch2dSum = (TH2I *) fListHist->FindObject("CH2dSum");
890 TProfile2D *ph2dSum = (TProfile2D *) fListHist->FindObject("PH2dSum");
891
892 TH2I *ch2dSM = (TH2I *) fListHist->FindObject("CH2dSM");
893 TProfile2D *ph2dSM = (TProfile2D *) fListHist->FindObject("PH2dSM");
894
895 AliTRDCalibraVdriftLinearFit *linearfit = (AliTRDCalibraVdriftLinearFit *) fListHist->FindObject("AliTRDCalibraVdriftLinearFit");
896
897 ////////////////////////////////////////////////
898 // Add the AliTRDCalibraVdriftLinearFit
899 ///////////////////////////////////////////////
900
901 Int_t first = 0;
902 TH2S *histolinearfitsum = 0x0;
903
904 if(linearfit) {
905 for(Int_t det = 0; det < 540; det++) {
906 if(linearfit->GetLinearFitterHisto(det)){
907 if(TMath::Abs(first)<0.0001){
908 histolinearfitsum = linearfit->GetLinearFitterHisto(det);
909 first += 1;
910 }
911 else {
912 histolinearfitsum ->Add(linearfit->GetLinearFitterHisto(det));
913 }
914 }
915 }
916 }
917
918 ///////////////////////////
919 // Style
920 //////////////////////////
921
922 gStyle->SetPalette(1);
923 gStyle->SetOptStat(1111);
924 gStyle->SetOptFit(1111);
925 gStyle->SetPadBorderMode(0);
926 gStyle->SetCanvasColor(10);
927 gStyle->SetPadLeftMargin(0.13);
928 gStyle->SetPadRightMargin(0.13);
929
930 /////////////////////////
931 // Plot
932 ////////////////////////
933
934 if(nEvents) {
935
936 TCanvas *debugEvents = new TCanvas("cNEvents","cNEvents",10,10,510,510);
937 debugEvents->cd(1);
938 if(nEvents) nEvents->Draw();
939
940 }
941
942 if(absoluteGain) {
943
944 TCanvas *debugAbsoluteGain = new TCanvas("cAbsoluteGain","cAbsoluteGain",10,10,510,510);
945 debugAbsoluteGain->cd(1);
946 if(absoluteGain) absoluteGain->Draw();
947
948 }
949
950 if(trdTrack || tpctrdTrack) {
951
952 TCanvas *debugtrdtpcTrack = new TCanvas("TRDtracktpctrdtrack","TRDtracktpctrdtrack",10,10,510,510);
953 debugtrdtpcTrack->Divide(2,1);
954 debugtrdtpcTrack->cd(1);
955 if(trdTrack) trdTrack->Draw();
956 if(trdTrackOffline) trdTrackOffline->Draw("same");
957 if(trdTrackStandalone) trdTrackStandalone->Draw("same");
958 TLegend *leg = new TLegend(0.4,0.6,0.89,0.89);
959 if(trdTrack) leg->AddEntry(trdTrack,"All","p");
960 if(trdTrackOffline) leg->AddEntry(trdTrackOffline,"Offline","p");
961 if(trdTrackStandalone) leg->AddEntry(trdTrackStandalone,"Standalone","p");
962 leg->Draw("same");
963 debugtrdtpcTrack->cd(2);
964 if(tpctrdTrack) tpctrdTrack->Draw();
965 TLine *line = new TLine(0.0,0.0,100.0,100.0);
966 line->Draw("same");
967
968 }
969
970 if(nbTimeBin || nbTracklets || nbClusters) {
971
972 TCanvas *debugTracklets = new TCanvas("TRDtimebintrackletcluster","TRDtimebintrackletcluster",10,10,510,510);
973 debugTracklets->Divide(3,1);
974 debugTracklets->cd(1);
975 if(nbTimeBin) nbTimeBin->Draw();
976 if(nbTimeBinOffline) nbTimeBinOffline->Draw("same");
977 if(nbTimeBinStandalone) nbTimeBinStandalone->Draw("same");
978 TLegend *lega = new TLegend(0.4,0.6,0.89,0.89);
979 if(nbTimeBin) lega->AddEntry(nbTimeBin,"All","p");
980 if(nbTimeBinOffline) lega->AddEntry(nbTimeBinOffline,"Offline","p");
981 if(nbTimeBinStandalone) lega->AddEntry(nbTimeBinStandalone,"Standalone","p");
982 lega->Draw("same");
983 debugTracklets->cd(2);
984 if(nbTracklets) nbTracklets->Draw();
985 if(nbTrackletsOffline) nbTrackletsOffline->Draw("same");
986 if(nbTrackletsStandalone) nbTrackletsStandalone->Draw("same");
987 TLegend *legb = new TLegend(0.4,0.6,0.89,0.89);
988 if(nbTracklets) legb->AddEntry(nbTracklets,"All","p");
989 if(nbTrackletsOffline) legb->AddEntry(nbTrackletsOffline,"Offline","p");
990 if(nbTrackletsStandalone) legb->AddEntry(nbTrackletsStandalone,"Standalone","p");
991 legb->Draw("same");
992 debugTracklets->cd(3);
993 if(nbClusters) nbClusters->Draw();
994 if(nbClustersOffline) nbClustersOffline->Draw("same");
995 if(nbClustersStandalone) nbClustersStandalone->Draw("same");
996 TLegend *legc = new TLegend(0.4,0.6,0.89,0.89);
997 if(nbClusters) legc->AddEntry(nbClusters,"All","p");
998 if(nbClustersOffline) legc->AddEntry(nbClustersOffline,"Offline","p");
999 if(nbClustersStandalone) legc->AddEntry(nbClustersStandalone,"Standalone","p");
1000 legc->Draw("same");
1001
1002 }
1003
1004 if(ch2dSum || ph2dSum || histolinearfitsum) {
1005
1006 TCanvas *debugSum = new TCanvas("SumCalibrationObjects","SumCalibrationObjects",10,10,510,510);
1007 debugSum->Divide(3,1);
1008 debugSum->cd(1);
1009 if(ch2dSum) ch2dSum->Draw("lego");
1010 debugSum->cd(2);
1011 if(ph2dSum) ph2dSum->Draw("lego");
1012 debugSum->cd(3);
1013 if(histolinearfitsum) histolinearfitsum->Draw();
1014
1015 }
1016
1017 if(ch2dSM || ph2dSM) {
1018
1019 TCanvas *debugSM = new TCanvas("SMCalibrationObjects","SMCalibrationObjects",10,10,510,510);
1020 debugSM->Divide(2,1);
1021 debugSM->cd(1);
1022 if(ch2dSM) ch2dSM->Draw("lego");
1023 debugSM->cd(2);
1024 if(ph2dSM) ph2dSM->Draw("lego");
1025
1026 }
1027
1028 if(ch2d || ph2d) {
1029
1030 TCanvas *debug = new TCanvas("CalibrationObjects","CalibrationObjects",10,10,510,510);
1031 debug->Divide(2,1);
1032 debug->cd(1);
1033 if(ch2d) ch2d->Draw("lego");
1034 debug->cd(2);
1035 if(ph2d) ph2d->Draw("lego");
1036
1037 }
1038
21185a48 1039}
57185ead 1040//_______________________________________________________________________________________
1041void AliTRDCalibTask::AddTask(const AliTRDCalibTask * calibTask) {
1042
1043 //
1044 // Add stats
1045 //
1046
1047 TList *listcalibTask = calibTask->GetList();
1048 if(!listcalibTask) return;
1049
1050 TH1I *nEvents = (TH1I *) listcalibTask->FindObject("NEvents");
1051 TH2F *absoluteGain = (TH2F *) listcalibTask->FindObject("AbsoluteGain");
1052
1053 TH1F *trdTrack = (TH1F *) listcalibTask->FindObject("TRDTrack");
1054 TH1F *trdTrackOffline = (TH1F *) listcalibTask->FindObject("TRDTrackOffline");
1055 TH1F *trdTrackStandalone = (TH1F *) listcalibTask->FindObject("TRDTrackStandalone");
1056
1057 TH2F *tpctrdTrack = (TH2F *) listcalibTask->FindObject("NbTPCTRDtrack");
1058
1059 TH1F *nbTimeBin = (TH1F *) listcalibTask->FindObject("NbTimeBin");
1060 TH1F *nbTimeBinOffline = (TH1F *) listcalibTask->FindObject("NbTimeBinOffline");
1061 TH1F *nbTimeBinStandalone = (TH1F *) listcalibTask->FindObject("NbTimeBinStandalone");
1062
1063 TH1F *nbClusters = (TH1F *) listcalibTask->FindObject("NbClusters");
1064 TH1F *nbClustersOffline = (TH1F *) listcalibTask->FindObject("NbClustersOffline");
1065 TH1F *nbClustersStandalone = (TH1F *) listcalibTask->FindObject("NbClustersStandalone");
1066
1067 TH1F *nbTracklets = (TH1F *) listcalibTask->FindObject("NbTracklets");
1068 TH1F *nbTrackletsOffline = (TH1F *) listcalibTask->FindObject("NbTrackletsOffline");
1069 TH1F *nbTrackletsStandalone = (TH1F *) listcalibTask->FindObject("NbTrackletsStandalone");
1070
1071 TH2I *ch2d = (TH2I *) listcalibTask->FindObject("CH2d");
1072 TProfile2D *ph2d = (TProfile2D *) listcalibTask->FindObject("PH2d");
1073 TProfile2D *prf2d = (TProfile2D *) listcalibTask->FindObject("PRF2d");
1074
1075 TH2I *ch2dSum = (TH2I *) listcalibTask->FindObject("CH2dSum");
1076 TProfile2D *ph2dSum = (TProfile2D *) listcalibTask->FindObject("PH2dSum");
1077
1078 TH2I *ch2dSM = (TH2I *) listcalibTask->FindObject("CH2dSM");
1079 TProfile2D *ph2dSM = (TProfile2D *) listcalibTask->FindObject("PH2dSM");
1080
1081 AliTRDCalibraVdriftLinearFit *linearfit = (AliTRDCalibraVdriftLinearFit *) listcalibTask->FindObject("AliTRDCalibraVdriftLinearFit");
1082 AliTRDCalibraVector *calibraVector = (AliTRDCalibraVector *) listcalibTask->FindObject("AliTRDCalibraVector");
1083
1084 //
1085
1086 TH1I *inEvents = (TH1I *) fListHist->FindObject("NEvents");
1087 TH2F *iabsoluteGain = (TH2F *) fListHist->FindObject("AbsoluteGain");
1088
1089 TH1F *itrdTrack = (TH1F *) fListHist->FindObject("TRDTrack");
1090 TH1F *itrdTrackOffline = (TH1F *) fListHist->FindObject("TRDTrackOffline");
1091 TH1F *itrdTrackStandalone = (TH1F *) fListHist->FindObject("TRDTrackStandalone");
1092
1093 TH2F *itpctrdTrack = (TH2F *) fListHist->FindObject("NbTPCTRDtrack");
21185a48 1094
57185ead 1095 TH1F *inbTimeBin = (TH1F *) fListHist->FindObject("NbTimeBin");
1096 TH1F *inbTimeBinOffline = (TH1F *) fListHist->FindObject("NbTimeBinOffline");
1097 TH1F *inbTimeBinStandalone = (TH1F *) fListHist->FindObject("NbTimeBinStandalone");
1098
1099 TH1F *inbClusters = (TH1F *) fListHist->FindObject("NbClusters");
1100 TH1F *inbClustersOffline = (TH1F *) fListHist->FindObject("NbClustersOffline");
1101 TH1F *inbClustersStandalone = (TH1F *) fListHist->FindObject("NbClustersStandalone");
1102
1103 TH1F *inbTracklets = (TH1F *) fListHist->FindObject("NbTracklets");
1104 TH1F *inbTrackletsOffline = (TH1F *) fListHist->FindObject("NbTrackletsOffline");
1105 TH1F *inbTrackletsStandalone = (TH1F *) fListHist->FindObject("NbTrackletsStandalone");
1106
1107 TH2I *ich2d = (TH2I *) fListHist->FindObject("CH2d");
1108 TProfile2D *iph2d = (TProfile2D *) fListHist->FindObject("PH2d");
1109 TProfile2D *iprf2d = (TProfile2D *) fListHist->FindObject("PRF2d");
1110
1111 TH2I *ich2dSum = (TH2I *) fListHist->FindObject("CH2dSum");
1112 TProfile2D *iph2dSum = (TProfile2D *) fListHist->FindObject("PH2dSum");
1113
1114 TH2I *ich2dSM = (TH2I *) fListHist->FindObject("CH2dSM");
1115 TProfile2D *iph2dSM = (TProfile2D *) fListHist->FindObject("PH2dSM");
1116
1117 AliTRDCalibraVdriftLinearFit *ilinearfit = (AliTRDCalibraVdriftLinearFit *) fListHist->FindObject("AliTRDCalibraVdriftLinearFit");
1118 AliTRDCalibraVector *icalibraVector = (AliTRDCalibraVector *) fListHist->FindObject("AliTRDCalibraVector");
1119
1120
1121 // Add
1122
1123 if(nEvents) {
1124 if(inEvents) {
1125 inEvents->Add(nEvents);
1126 //printf("Add Events\n");
1127 }
1128 else {
1129 //printf("Create new Events\n");
1130 inEvents = new TH1I(*nEvents);
1131 fListHist->Add(inEvents);
1132 }
1133 }
1134
1135 if(absoluteGain) {
1136 if(iabsoluteGain) iabsoluteGain->Add(absoluteGain);
1137 else {
1138 iabsoluteGain = new TH2F(*absoluteGain);
1139 fListHist->Add(iabsoluteGain);
1140 }
1141 }
1142
1143 if(trdTrack) {
1144 if(itrdTrack) itrdTrack->Add(trdTrack);
1145 else {
1146 itrdTrack = new TH1F(*trdTrack);
1147 fListHist->Add(itrdTrack);
1148 }
1149 }
1150
1151 if(trdTrackOffline) {
1152 if(itrdTrackOffline) itrdTrackOffline->Add(trdTrackOffline);
1153 else {
1154 itrdTrackOffline = new TH1F(*trdTrackOffline);
1155 fListHist->Add(itrdTrackOffline);
1156 }
1157 }
1158
1159 if(trdTrackStandalone) {
1160 if(itrdTrackStandalone) itrdTrackStandalone->Add(trdTrackStandalone);
1161 else {
1162 itrdTrackStandalone = new TH1F(*trdTrackStandalone);
1163 fListHist->Add(itrdTrackStandalone);
1164 }
1165 }
1166
1167 if(tpctrdTrack) {
1168 if(itpctrdTrack) itpctrdTrack->Add(tpctrdTrack);
1169 else {
1170 itpctrdTrack = new TH2F(*tpctrdTrack);
1171 fListHist->Add(itpctrdTrack);
1172 }
1173 }
1174
1175 if(nbTimeBin) {
1176 if(inbTimeBin) inbTimeBin->Add(nbTimeBin);
1177 else {
1178 inbTimeBin = new TH1F(*inbTimeBin);
1179 fListHist->Add(inbTimeBin);
1180 }
1181 }
1182
1183 if(nbTimeBinOffline) {
1184 if(inbTimeBinOffline) inbTimeBinOffline->Add(nbTimeBinOffline);
1185 else {
1186 inbTimeBinOffline = new TH1F(*nbTimeBinOffline);
1187 fListHist->Add(inbTimeBinOffline);
1188 }
1189 }
1190
1191 if(nbTimeBinStandalone) {
1192 if(inbTimeBinStandalone) inbTimeBinStandalone->Add(nbTimeBinStandalone);
1193 else {
1194 inbTimeBinStandalone = new TH1F(*nbTimeBinStandalone);
1195 fListHist->Add(inbTimeBinStandalone);
1196 }
1197 }
1198
1199 if(nbClusters) {
1200 if(inbClusters) inbClusters->Add(nbClusters);
1201 else {
1202 inbClusters = new TH1F(*nbClusters);
1203 fListHist->Add(inbClusters);
1204 }
1205 }
1206
1207 if(nbClustersOffline) {
1208 if(inbClustersOffline) inbClustersOffline->Add(nbClustersOffline);
1209 else {
1210 inbClustersOffline = new TH1F(*nbClustersOffline);
1211 fListHist->Add(inbClustersOffline);
1212 }
1213 }
1214
1215 if(nbClustersStandalone) {
1216 if(inbClustersStandalone) inbClustersStandalone->Add(nbClustersStandalone);
1217 else {
1218 inbClustersStandalone = new TH1F(*nbClustersStandalone);
1219 fListHist->Add(inbClustersStandalone);
1220 }
1221 }
1222
1223 if(nbTracklets) {
1224 if(inbTracklets) inbTracklets->Add(nbTracklets);
1225 else {
1226 inbTracklets = new TH1F(*nbTracklets);
1227 fListHist->Add(inbTracklets);
1228 }
1229 }
1230
1231 if(nbTrackletsOffline) {
1232 if(inbTrackletsOffline) inbTrackletsOffline->Add(nbTrackletsOffline);
1233 else {
1234 inbTrackletsOffline = new TH1F(*nbTrackletsOffline);
1235 fListHist->Add(inbTrackletsOffline);
1236 }
1237 }
1238
1239 if(nbTrackletsStandalone) {
1240 if(inbTrackletsStandalone) inbTrackletsStandalone->Add(nbTrackletsStandalone);
1241 else {
1242 inbTrackletsStandalone = new TH1F(*nbTrackletsStandalone);
1243 fListHist->Add(inbTrackletsStandalone);
1244 }
1245 }
1246
1247 if(ch2d) {
1248 if(ich2d) ich2d->Add(ch2d);
1249 else {
1250 ich2d = new TH2I(*ch2d);
1251 fListHist->Add(ich2d);
1252 }
1253 }
1254
1255 if(ph2d) {
1256 if(iph2d) iph2d->Add(ph2d);
1257 else {
1258 iph2d = new TProfile2D(*ph2d);
1259 fListHist->Add(iph2d);
1260 }
1261 }
1262
1263 if(prf2d) {
1264 if(iprf2d) iprf2d->Add(prf2d);
1265 else {
1266 iprf2d = new TProfile2D(*prf2d);
1267 fListHist->Add(iprf2d);
1268 }
1269 }
1270
1271 if(ch2dSum) {
1272 if(ich2dSum) ich2dSum->Add(ch2dSum);
1273 else {
1274 ich2dSum = new TH2I(*ch2dSum);
1275 fListHist->Add(ich2dSum);
1276 }
1277 }
1278
1279 if(ph2dSum) {
1280 if(iph2dSum) iph2dSum->Add(ph2dSum);
1281 else {
1282 iph2dSum = new TProfile2D(*ph2dSum);
1283 fListHist->Add(iph2dSum);
1284 }
1285 }
1286
1287 if(ch2dSM) {
1288 if(ich2dSM) ich2dSM->Add(ch2dSM);
1289 else {
1290 ich2dSM = new TH2I(*ch2dSM);
1291 fListHist->Add(ich2dSM);
1292 }
1293 }
1294
1295 if(ph2dSM) {
1296 if(iph2dSM) iph2dSM->Add(ph2dSM);
1297 else {
1298 iph2dSM = new TProfile2D(*ph2dSM);
1299 fListHist->Add(iph2dSM);
1300 }
1301 }
1302
1303 if(linearfit) {
1304 if(ilinearfit) ilinearfit->Add(linearfit);
1305 else {
1306 ilinearfit = new AliTRDCalibraVdriftLinearFit(*linearfit);
1307 fListHist->Add(ilinearfit);
1308 }
1309 }
1310
1311 if(calibraVector) {
1312 if(icalibraVector) icalibraVector->Add(calibraVector);
1313 else {
1314 icalibraVector = new AliTRDCalibraVector(*calibraVector);
1315 fListHist->Add(icalibraVector);
1316 }
1317 }
1318
1319}
1320//________________________________________________________________________________
1321Long64_t AliTRDCalibTask::Merge(TCollection *li) {
1322
1323 //
1324 // merge component
1325 //
1326
1327 TIterator* iter = li->MakeIterator();
1328 AliTRDCalibTask* cal = 0;
1329
1330 while ((cal = (AliTRDCalibTask*)iter->Next())) {
1331 if (!cal->InheritsFrom(AliTRDCalibTask::Class())) {
1332 Error("Merge","Attempt to add object of class %s to a %s", cal->ClassName(), this->ClassName());
1333 return -1;
1334 }
1335
1336 // add histograms here...
1337 this->AddTask(cal);
1338
1339 }
1340
1341 return 0;
1342
1343}
01239968 1344