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