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