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