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