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