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