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