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