Updates, making buffer and managers aware of each others work
[u/mrichter/AliRoot.git] / TPC / AliTPCcalibTime.cxx
CommitLineData
c74c5f6c 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/*
74235403 17Comments to be written here:
c74c5f6c 18
74235403 191. What do we calibrate.
20
21 Time dependence of gain and drift velocity in order to account for changes in: temperature, pressure, gas composition.
c74c5f6c 22
23 AliTPCcalibTime *calibTime = new AliTPCcalibTime("cosmicTime","cosmicTime",0, 1213.9e+06, 1213.96e+06, 0.04e+04, 0.04e+04);
24
74235403 252. How to interpret results
26
273. Simple example
c74c5f6c 28
74235403 29 a) determine the required time range:
c74c5f6c 30
74235403 31 AliXRDPROOFtoolkit tool;
32 TChain * chain = tool.MakeChain("pass2.txt","esdTree",0,6000);
33 chain->Draw("GetTimeStamp()")
c74c5f6c 34
74235403 35 b) analyse calibration object on Proof in calibration train
c74c5f6c 36
74235403 37 AliTPCcalibTime *calibTime = new AliTPCcalibTime("cosmicTime","cosmicTime", StartTimeStamp, EndTimeStamp, IntegrationTimeVdrift);
c74c5f6c 38
74235403 39 c) plot results
40 .x ~/NimStyle.C
2be25cc9 41 gSystem->Load("libANALYSIS");
42 gSystem->Load("libTPCcalib");
c74c5f6c 43
dde68d36 44 TFile f("CalibObjectsTrain1.root");
45 AliTPCcalibTime *calib = (AliTPCcalibTime *)f->Get("calibTime");
46 calib->GetHistoDrift("all")->Projection(2,0)->Draw()
47 calib->GetFitDrift("all")->Draw("lp")
da6c0bc9 48
74235403 494. Analysis using debug streamers.
da6c0bc9 50
74235403 51 gSystem->AddIncludePath("-I$ALICE_ROOT/TPC/macros");
52 gROOT->LoadMacro("$ALICE_ROOT/TPC/macros/AliXRDPROOFtoolkit.cxx+")
53 AliXRDPROOFtoolkit tool;
3e55050f 54 TChain * chainTime = tool.MakeChainRandom("time.txt","trackInfo",0,10000);
817766d5 55
3e55050f 56 AliXRDPROOFtoolkit::FilterList("timetpctpc.txt","* tpctpc",1)
57 AliXRDPROOFtoolkit::FilterList("timetoftpc.txt","* toftpc",1)
58 AliXRDPROOFtoolkit::FilterList("timeitstpc.txt","* itstpc",1)
59 AliXRDPROOFtoolkit::FilterList("timelaser.txt","* laserInfo",1)
60 TChain * chainTPCTPC = tool.MakeChainRandom("timetpctpc.txt.Good","tpctpc",0,10000);
817766d5 61 TChain * chainTPCITS = tool.MakeChainRandom("timeitstpc.txt.Good","itstpc",0,10000);
3e55050f 62 TChain * chainTPCTOF = tool.MakeChainRandom("timetoftpc.txt.Good","toftpc",0,10000);
817766d5 63 TChain * chainLaser = tool.MakeChainRandom("timelaser.txt.Good","laserInfo",0,10000);
74235403 64 chainTime->Lookup();
dde68d36 65 chainLaser->Lookup();
c74c5f6c 66*/
67
c74c5f6c 68#include "Riostream.h"
2811495d 69#include "TDatabasePDG.h"
70#include "TGraphErrors.h"
c74c5f6c 71#include "TH1F.h"
c74c5f6c 72#include "THnSparse.h"
73#include "TList.h"
74#include "TMath.h"
2811495d 75#include "TTimeStamp.h"
76#include "TTree.h"
c74c5f6c 77#include "TVectorD.h"
2811495d 78//#include "TChain.h"
79//#include "TFile.h"
80
81#include "AliDCSSensor.h"
82#include "AliDCSSensorArray.h"
c74c5f6c 83#include "AliESDEvent.h"
c74c5f6c 84#include "AliESDInputHandler.h"
2811495d 85#include "AliESDVertex.h"
86#include "AliESDfriend.h"
c74c5f6c 87#include "AliLog.h"
817766d5 88#include "AliRelAlignerKalman.h"
2811495d 89#include "AliTPCCalROC.h"
90#include "AliTPCParam.h"
c74c5f6c 91#include "AliTPCTracklet.h"
da6c0bc9 92#include "AliTPCcalibDB.h"
93#include "AliTPCcalibLaser.h"
2811495d 94#include "AliTPCcalibTime.h"
95#include "AliTPCclusterMI.h"
96#include "AliTPCseed.h"
817766d5 97#include "AliTrackPointArray.h"
2811495d 98#include "AliTracker.h"
70036ef3 99#include "AliKFVertex.h"
660f0543 100#include <AliLog.h>
101
c74c5f6c 102ClassImp(AliTPCcalibTime)
103
104
105AliTPCcalibTime::AliTPCcalibTime()
660f0543 106 :AliTPCcalibBase(),
107 fMemoryMode(1), // 0 -do not fill THnSparse with residuals 1- fill only important QA THn 2 - Fill all THnsparse for calibration
da6c0bc9 108 fLaser(0), // pointer to laser calibration
109 fDz(0), // current delta z
d3ce44cb 110 fCutMaxD(3), // maximal distance in rfi ditection
111 fCutMaxDz(25), // maximal distance in rfi ditection
c74c5f6c 112 fCutTheta(0.03), // maximal distan theta
2be25cc9 113 fCutMinDir(-0.99), // direction vector products
b842d904 114 fCutTracks(100),
97d3fea0 115 fArrayLaserA(0), //laser fit parameters C
116 fArrayLaserC(0), //laser fit parameters A
dde68d36 117 fArrayDz(0), //NEW! Tmap of V drifts for different triggers
817766d5 118 fAlignITSTPC(0), //alignemnt array ITS TPC match
119 fAlignTRDTPC(0), //alignemnt array TRD TPC match
120 fAlignTOFTPC(0), //alignemnt array TOF TPC match
97d3fea0 121 fTimeKalmanBin(60*15), //time bin width for kalman - 15 minutes default
2be25cc9 122 fTimeBins(0),
123 fTimeStart(0),
124 fTimeEnd(0),
125 fPtBins(0),
126 fPtStart(0),
127 fPtEnd(0),
128 fVdriftBins(0),
129 fVdriftStart(0),
130 fVdriftEnd(0),
131 fRunBins(0),
132 fRunStart(0),
133 fRunEnd(0)
c74c5f6c 134{
6ba68367 135 //
136 // default constructor
137 //
c74c5f6c 138 AliInfo("Default Constructor");
2be25cc9 139 for (Int_t i=0;i<3;i++) {
140 fHistVdriftLaserA[i]=0;
141 fHistVdriftLaserC[i]=0;
142 }
d3ce44cb 143 for (Int_t i=0;i<10;i++) {
74235403 144 fCosmiMatchingHisto[i]=0;
145 }
391ffdb2 146 //
147 for (Int_t i=0;i<5;i++) {
b9908d0b 148 fResHistoTPCCE[i]=0;
391ffdb2 149 fResHistoTPCITS[i]=0;
150 fResHistoTPCTRD[i]=0;
0b736a46 151 fResHistoTPCTOF[i]=0;
391ffdb2 152 fResHistoTPCvertex[i]=0;
70036ef3 153 fTPCVertex[i]=0;
154 }
155 for (Int_t i=0;i<12;i++) {
156 fTPCVertex[i]=0;
391ffdb2 157 }
660f0543 158 static Int_t counter=0;
159 if (1) {
160 TTimeStamp s;
161 Int_t time=s;
162 AliInfo(Form("Counter Constructor\t%d\t%d",counter,time));
163 counter++;
164 }
165
c74c5f6c 166}
167
660f0543 168AliTPCcalibTime::AliTPCcalibTime(const Text_t *name, const Text_t *title, UInt_t StartTime, UInt_t EndTime, Int_t deltaIntegrationTimeVdrift, Int_t memoryMode)
c74c5f6c 169 :AliTPCcalibBase(),
660f0543 170 fMemoryMode(memoryMode), // 0 -do not fill THnSparse with residuals 1- fill only important QA THn 2 - Fill all THnsparse for calibration
d3ce44cb 171 fLaser(0), // pointer to laser calibration
172 fDz(0), // current delta z
173 fCutMaxD(5*0.5356), // maximal distance in rfi ditection
dde68d36 174 fCutMaxDz(40), // maximal distance in rfi ditection
d3ce44cb 175 fCutTheta(5*0.004644),// maximal distan theta
176 fCutMinDir(-0.99), // direction vector products
b842d904 177 fCutTracks(100),
97d3fea0 178 fArrayLaserA(new TObjArray(1000)), //laser fit parameters C
179 fArrayLaserC(new TObjArray(1000)), //laser fit parameters A
dde68d36 180 fArrayDz(0), //Tmap of V drifts for different triggers
817766d5 181 fAlignITSTPC(0), //alignemnt array ITS TPC match
182 fAlignTRDTPC(0), //alignemnt array TRD TPC match
183 fAlignTOFTPC(0), //alignemnt array TOF TPC match
97d3fea0 184 fTimeKalmanBin(60*15), //time bin width for kalman - 15 minutes default
2be25cc9 185 fTimeBins(0),
186 fTimeStart(0),
187 fTimeEnd(0),
188 fPtBins(0),
189 fPtStart(0),
190 fPtEnd(0),
191 fVdriftBins(0),
192 fVdriftStart(0),
193 fVdriftEnd(0),
194 fRunBins(0),
195 fRunStart(0),
196 fRunEnd(0)
c74c5f6c 197{
6ba68367 198 //
199 // Non deafaul constructor - to be used in the Calibration setups
200 //
201
c74c5f6c 202 SetName(name);
203 SetTitle(title);
2be25cc9 204 for (Int_t i=0;i<3;i++) {
205 fHistVdriftLaserA[i]=0;
206 fHistVdriftLaserC[i]=0;
207 }
c74c5f6c 208
391ffdb2 209 for (Int_t i=0;i<5;i++) {
b9908d0b 210 fResHistoTPCCE[i]=0;
391ffdb2 211 fResHistoTPCITS[i]=0;
212 fResHistoTPCTRD[i]=0;
0b736a46 213 fResHistoTPCTOF[i]=0;
391ffdb2 214 fResHistoTPCvertex[i]=0;
215 }
216
217
c74c5f6c 218 AliInfo("Non Default Constructor");
74235403 219 fTimeBins =(EndTime-StartTime)/deltaIntegrationTimeVdrift;
2be25cc9 220 fTimeStart =StartTime; //(((TObjString*)(mapGRP->GetValue("fAliceStartTime")))->GetString()).Atoi();
221 fTimeEnd =EndTime; //(((TObjString*)(mapGRP->GetValue("fAliceStopTime")))->GetString()).Atoi();
dde68d36 222 fPtBins = 400;
2be25cc9 223 fPtStart = -0.04;
224 fPtEnd = 0.04;
dde68d36 225 fVdriftBins = 500;
226 fVdriftStart= -0.1;
227 fVdriftEnd = 0.1;
32100b1d 228 fRunBins = 1000001;
dde68d36 229 fRunStart = -1.5;
32100b1d 230 fRunEnd = 999999.5;
2be25cc9 231
232 Int_t binsVdriftLaser[4] = {fTimeBins , fPtBins , fVdriftBins*20, fRunBins };
233 Double_t xminVdriftLaser[4] = {fTimeStart, fPtStart, fVdriftStart , fRunStart};
234 Double_t xmaxVdriftLaser[4] = {fTimeEnd , fPtEnd , fVdriftEnd , fRunEnd };
dde68d36 235 TString axisTitle[4]={
236 "T",
237 "#delta_{P/T}",
238 "value",
239 "run"
240 };
241 TString histoName[3]={
242 "Loffset",
243 "Lcorr",
244 "Lgy"
245 };
2be25cc9 246
dde68d36 247
2be25cc9 248 for (Int_t i=0;i<3;i++) {
249 fHistVdriftLaserA[i] = new THnSparseF("HistVdriftLaser","HistVdriftLaser;time;p/T ratio;Vdrift;run",4,binsVdriftLaser,xminVdriftLaser,xmaxVdriftLaser);
250 fHistVdriftLaserC[i] = new THnSparseF("HistVdriftLaser","HistVdriftLaser;time;p/T ratio;Vdrift;run",4,binsVdriftLaser,xminVdriftLaser,xmaxVdriftLaser);
dde68d36 251 fHistVdriftLaserA[i]->SetName(histoName[i]);
252 fHistVdriftLaserC[i]->SetName(histoName[i]);
253 for (Int_t iaxis=0; iaxis<4;iaxis++){
254 fHistVdriftLaserA[i]->GetAxis(iaxis)->SetName(axisTitle[iaxis]);
255 fHistVdriftLaserC[i]->GetAxis(iaxis)->SetName(axisTitle[iaxis]);
256 }
2be25cc9 257 }
258 fBinsVdrift[0] = fTimeBins;
259 fBinsVdrift[1] = fPtBins;
260 fBinsVdrift[2] = fVdriftBins;
261 fBinsVdrift[3] = fRunBins;
262 fXminVdrift[0] = fTimeStart;
263 fXminVdrift[1] = fPtStart;
264 fXminVdrift[2] = fVdriftStart;
265 fXminVdrift[3] = fRunStart;
266 fXmaxVdrift[0] = fTimeEnd;
267 fXmaxVdrift[1] = fPtEnd;
268 fXmaxVdrift[2] = fVdriftEnd;
269 fXmaxVdrift[3] = fRunEnd;
270
dde68d36 271 fArrayDz=new TObjArray();
817766d5 272 fAlignITSTPC = new TObjArray; //alignemnt array ITS TPC match
273 fAlignTRDTPC = new TObjArray; //alignemnt array ITS TPC match
274 fAlignTOFTPC = new TObjArray; //alignemnt array ITS TPC match
3e55050f 275 fAlignITSTPC->SetOwner(kTRUE);
276 fAlignTRDTPC->SetOwner(kTRUE);
277 fAlignTOFTPC->SetOwner(kTRUE);
278
c74c5f6c 279
d3ce44cb 280 fCosmiMatchingHisto[0]=new TH1F("Cosmics matching","p0-all" ,100,-10*0.5356 ,10*0.5356 );
281 fCosmiMatchingHisto[1]=new TH1F("Cosmics matching","p1-all" ,100,-10*4.541 ,10*4.541 );
282 fCosmiMatchingHisto[2]=new TH1F("Cosmics matching","p2-all" ,100,-10*0.01134 ,10*0.01134 );
283 fCosmiMatchingHisto[3]=new TH1F("Cosmics matching","p3-all" ,100,-10*0.004644,10*0.004644);
284 fCosmiMatchingHisto[4]=new TH1F("Cosmics matching","p4-all" ,100,-10*0.03773 ,10*0.03773 );
285 fCosmiMatchingHisto[5]=new TH1F("Cosmics matching","p0-isPair",100,-10*0.5356 ,10*0.5356 );
286 fCosmiMatchingHisto[6]=new TH1F("Cosmics matching","p1-isPair",100,-10*4.541 ,10*4.541 );
287 fCosmiMatchingHisto[7]=new TH1F("Cosmics matching","p2-isPair",100,-10*0.01134 ,10*0.01134 );
288 fCosmiMatchingHisto[8]=new TH1F("Cosmics matching","p3-isPair",100,-10*0.004644,10*0.004644);
289 fCosmiMatchingHisto[9]=new TH1F("Cosmics matching","p4-isPair",100,-10*0.03773 ,10*0.03773 );
70036ef3 290 for (Int_t i=0;i<12;i++) {
291 fTPCVertex[i]=0;
292 }
391ffdb2 293 BookDistortionMaps();
70036ef3 294
74235403 295}
c74c5f6c 296
297AliTPCcalibTime::~AliTPCcalibTime(){
298 //
6ba68367 299 // Virtual Destructor
c74c5f6c 300 //
660f0543 301 static Int_t counter=0;
302 if (1) {
303 TTimeStamp s;
304 Int_t time=s;
305 AliInfo(Form("Counter Destructor\t%s\t%d\t%d",GetName(),counter,time));
306 counter++;
307 }
d3ce44cb 308 for(Int_t i=0;i<3;i++){
309 if(fHistVdriftLaserA[i]){
310 delete fHistVdriftLaserA[i];
311 fHistVdriftLaserA[i]=NULL;
312 }
313 if(fHistVdriftLaserC[i]){
314 delete fHistVdriftLaserC[i];
315 fHistVdriftLaserC[i]=NULL;
316 }
317 }
dde68d36 318 if(fArrayDz){
319 fArrayDz->SetOwner();
320 fArrayDz->Delete();
321 delete fArrayDz;
322 fArrayDz=NULL;
2be25cc9 323 }
d3ce44cb 324 for(Int_t i=0;i<5;i++){
325 if(fCosmiMatchingHisto[i]){
326 delete fCosmiMatchingHisto[i];
327 fCosmiMatchingHisto[i]=NULL;
328 }
74235403 329 }
391ffdb2 330
331 for (Int_t i=0;i<5;i++) {
b9908d0b 332 delete fResHistoTPCCE[i];
391ffdb2 333 delete fResHistoTPCITS[i];
334 delete fResHistoTPCTRD[i];
0b736a46 335 delete fResHistoTPCTOF[i];
391ffdb2 336 delete fResHistoTPCvertex[i];
b9908d0b 337 fResHistoTPCCE[i]=0;
391ffdb2 338 fResHistoTPCITS[i]=0;
339 fResHistoTPCTRD[i]=0;
0b736a46 340 fResHistoTPCTOF[i]=0;
391ffdb2 341 fResHistoTPCvertex[i]=0;
342 }
343
70036ef3 344 if (fTPCVertex) {
345 for (Int_t i=0;i<12;i++) delete fTPCVertex[i];
346 }
347
3e55050f 348 fAlignITSTPC->SetOwner(kTRUE);
349 fAlignTRDTPC->SetOwner(kTRUE);
350 fAlignTOFTPC->SetOwner(kTRUE);
351
817766d5 352 fAlignITSTPC->Delete();
353 fAlignTRDTPC->Delete();
354 fAlignTOFTPC->Delete();
3e55050f 355 delete fAlignITSTPC;
356 delete fAlignTRDTPC;
357 delete fAlignTOFTPC;
c74c5f6c 358}
2be25cc9 359
2811495d 360Bool_t AliTPCcalibTime::IsLaser(const AliESDEvent *const /*event*/){
6ba68367 361 //
362 // Indicator is laser event not yet implemented - to be done using trigger info or event specie
363 //
dde68d36 364 return kTRUE; //More accurate creteria to be added
da6c0bc9 365}
2811495d 366Bool_t AliTPCcalibTime::IsCosmics(const AliESDEvent *const /*event*/){
6ba68367 367 //
368 // Indicator is cosmic event not yet implemented - to be done using trigger info or event specie
369 //
370
dde68d36 371 return kTRUE; //More accurate creteria to be added
372}
2811495d 373Bool_t AliTPCcalibTime::IsBeam(const AliESDEvent *const /*event*/){
6ba68367 374 //
375 // Indicator is physic event not yet implemented - to be done using trigger info or event specie
376 //
377
dde68d36 378 return kTRUE; //More accurate creteria to be added
379}
380void AliTPCcalibTime::ResetCurrent(){
381 fDz=0; //Reset current dz
2be25cc9 382}
6ba68367 383
384
385
2be25cc9 386void AliTPCcalibTime::Process(AliESDEvent *event){
6ba68367 387 //
388 // main function to make calibration
389 //
2be25cc9 390 if(!event) return;
391 if (event->GetNumberOfTracks()<2) return;
392 ResetCurrent();
dde68d36 393 if(IsLaser (event)) ProcessLaser (event);
394 if(IsCosmics(event)) ProcessCosmic(event);
395 if(IsBeam (event)) ProcessBeam (event);
2be25cc9 396}
397
398void AliTPCcalibTime::ProcessLaser(AliESDEvent *event){
c74c5f6c 399 //
2be25cc9 400 // Fit drift velocity using laser
401 //
402 // 0. cuts
dde68d36 403 const Int_t kMinTracks = 40; // minimal number of laser tracks
404 const Int_t kMinTracksSide = 20; // minimal number of tracks per side
405 const Float_t kMaxDeltaZ = 30.; // maximal trigger delay
406 const Float_t kMaxDeltaV = 0.05; // maximal deltaV
2be25cc9 407 const Float_t kMaxRMS = 0.1; // maximal RMS of tracks
dde68d36 408 //
2be25cc9 409 /*
410 TCut cutRMS("sqrt(laserA.fElements[4])<0.1&&sqrt(laserC.fElements[4])<0.1");
411 TCut cutZ("abs(laserA.fElements[0]-laserC.fElements[0])<3");
412 TCut cutV("abs(laserA.fElements[1]-laserC.fElements[1])<0.01");
413 TCut cutY("abs(laserA.fElements[2]-laserC.fElements[2])<2");
414 TCut cutAll = cutRMS+cutZ+cutV+cutY;
415 */
416 if (event->GetNumberOfTracks()<kMinTracks) return;
c74c5f6c 417 //
2be25cc9 418 if(!fLaser) fLaser = new AliTPCcalibLaser("laserTPC","laserTPC",kFALSE);
419 fLaser->Process(event);
420 if (fLaser->GetNtracks()<kMinTracks) return; // small amount of tracks cut
dde68d36 421 if (fLaser->fFitAside->GetNrows()==0 && fLaser->fFitCside->GetNrows()==0) return; // no fit neither a or C side
c74c5f6c 422 //
2be25cc9 423 // debug streamer - activate stream level
424 // Use it for tuning of the cuts
da6c0bc9 425 //
dde68d36 426 // cuts to be applied
427 //
428 Int_t isReject[2]={0,0};
429 //
430 // not enough tracks
431 if (TMath::Abs((*fLaser->fFitAside)[3]) < kMinTracksSide) isReject[0]|=1;
432 if (TMath::Abs((*fLaser->fFitCside)[3]) < kMinTracksSide) isReject[1]|=1;
433 // unreasonable z offset
434 if (TMath::Abs((*fLaser->fFitAside)[0])>kMaxDeltaZ) isReject[0]|=2;
435 if (TMath::Abs((*fLaser->fFitCside)[0])>kMaxDeltaZ) isReject[1]|=2;
436 // unreasonable drift velocity
437 if (TMath::Abs((*fLaser->fFitAside)[1]-1)>kMaxDeltaV) isReject[0]|=4;
438 if (TMath::Abs((*fLaser->fFitCside)[1]-1)>kMaxDeltaV) isReject[1]|=4;
439 // big chi2
440 if (TMath::Sqrt(TMath::Abs((*fLaser->fFitAside)[4]))>kMaxRMS ) isReject[0]|=8;
441 if (TMath::Sqrt(TMath::Abs((*fLaser->fFitCside)[4]))>kMaxRMS ) isReject[1]|=8;
442
443
444
445
2be25cc9 446 if (fStreamLevel>0){
447 printf("Trigger: %s\n",event->GetFiredTriggerClasses().Data());
448
da6c0bc9 449 TTreeSRedirector *cstream = GetDebugStreamer();
450 if (cstream){
451 TTimeStamp tstamp(fTime);
2be25cc9 452 (*cstream)<<"laserInfo"<<
da6c0bc9 453 "run="<<fRun<< // run number
454 "event="<<fEvent<< // event number
455 "time="<<fTime<< // time stamp of event
456 "trigger="<<fTrigger<< // trigger
457 "mag="<<fMagF<< // magnetic field
da6c0bc9 458 //laser
dde68d36 459 "rejectA="<<isReject[0]<<
460 "rejectC="<<isReject[1]<<
2be25cc9 461 "laserA.="<<fLaser->fFitAside<<
462 "laserC.="<<fLaser->fFitCside<<
463 "laserAC.="<<fLaser->fFitACside<<
464 "trigger="<<event->GetFiredTriggerClasses()<<
da6c0bc9 465 "\n";
466 }
467 }
2be25cc9 468 //
2be25cc9 469 // fill histos
470 //
471 TVectorD vdriftA(5), vdriftC(5),vdriftAC(5);
472 vdriftA=*(fLaser->fFitAside);
473 vdriftC=*(fLaser->fFitCside);
474 vdriftAC=*(fLaser->fFitACside);
475 Int_t npointsA=0, npointsC=0;
476 Float_t chi2A=0, chi2C=0;
477 npointsA= TMath::Nint(vdriftA[3]);
478 chi2A= vdriftA[4];
479 npointsC= TMath::Nint(vdriftC[3]);
480 chi2C= vdriftC[4];
2be25cc9 481
97d3fea0 482 if (npointsA>kMinTracksSide || npointsC>kMinTracksSide){
483 TVectorD *fitA = new TVectorD(6);
484 TVectorD *fitC = new TVectorD(6);
485 for (Int_t ipar=0; ipar<5; ipar++){
486 (*fitA)[ipar]=vdriftA[ipar];
487 (*fitC)[ipar]=vdriftC[ipar];
488 }
489 (*fitA)[5]=fTime;
490 (*fitC)[5]=fTime;
491 fArrayLaserA->AddLast(fitA);
492 fArrayLaserC->AddLast(fitC);
493 }
494 //
495
2be25cc9 496 TTimeStamp tstamp(fTime);
497 Double_t ptrelative0 = AliTPCcalibDB::GetPTRelative(tstamp,fRun,0);
498 Double_t ptrelative1 = AliTPCcalibDB::GetPTRelative(tstamp,fRun,1);
dde68d36 499 Double_t driftA=0, driftC=0;
500 if (vdriftA[1]>1.-kMaxDeltaV) driftA = 1./vdriftA[1]-1.;
501 if (vdriftC[1]>1.-kMaxDeltaV) driftC = 1./vdriftC[1]-1.;
502 //
503 Double_t vecDriftLaserA[4]={fTime,(ptrelative0+ptrelative1)/2.0,driftA,event->GetRunNumber()};
504 Double_t vecDriftLaserC[4]={fTime,(ptrelative0+ptrelative1)/2.0,driftC,event->GetRunNumber()};
505 // Double_t vecDrift[4] ={fTime,(ptrelative0+ptrelative1)/2.0,1./((*(fLaser->fFitACside))[1])-1,event->GetRunNumber()};
506
507 for (Int_t icalib=0;icalib<3;icalib++){
508 if (icalib==0){ //z0 shift
509 vecDriftLaserA[2]=vdriftA[0]/250.;
510 vecDriftLaserC[2]=vdriftC[0]/250.;
2be25cc9 511 }
dde68d36 512 if (icalib==1){ //vdrel shift
513 vecDriftLaserA[2]=driftA;
514 vecDriftLaserC[2]=driftC;
2be25cc9 515 }
dde68d36 516 if (icalib==2){ //gy shift - full gy - full drift
517 vecDriftLaserA[2]=vdriftA[2]/250.;
518 vecDriftLaserC[2]=vdriftC[2]/250.;
2be25cc9 519 }
391ffdb2 520 //if (isReject[0]==0) fHistVdriftLaserA[icalib]->Fill(vecDriftLaserA);
521 //if (isReject[1]==0) fHistVdriftLaserC[icalib]->Fill(vecDriftLaserC);
522 fHistVdriftLaserA[icalib]->Fill(vecDriftLaserA);
523 fHistVdriftLaserC[icalib]->Fill(vecDriftLaserC);
2be25cc9 524 }
2be25cc9 525}
c74c5f6c 526
2811495d 527void AliTPCcalibTime::ProcessCosmic(const AliESDEvent *const event){
6ba68367 528 //
529 // process Cosmic event - track matching A side C side
530 //
c74c5f6c 531 if (!event) {
532 Printf("ERROR: ESD not available");
533 return;
534 }
535 if (event->GetTimeStamp() == 0 ) {
536 Printf("no time stamp!");
537 return;
538 }
74235403 539
2be25cc9 540 //fd
c74c5f6c 541 // Find cosmic pairs
542 //
543 // Track0 is choosen in upper TPC part
544 // Track1 is choosen in lower TPC part
545 //
cc65e4f5 546 const Int_t kMinClustersCross =30;
547 const Int_t kMinClusters =80;
c74c5f6c 548 Int_t ntracks=event->GetNumberOfTracks();
549 if (ntracks==0) return;
74235403 550 if (ntracks > fCutTracks) return;
551
a390f11f 552 if (GetDebugLevel()>20) printf("Hallo world: Im here\n");
3e0d9569 553 AliESDfriend *esdFriend=(AliESDfriend*)(((AliESDEvent*)event)->FindListObject("AliESDfriend"));
c74c5f6c 554
555 TObjArray tpcSeeds(ntracks);
556 Double_t vtxx[3]={0,0,0};
557 Double_t svtxx[3]={0.000001,0.000001,100.};
558 AliESDVertex vtx(vtxx,svtxx);
559 //
560 // track loop
561 //
cc65e4f5 562 TArrayI clusterSideA(ntracks);
563 TArrayI clusterSideC(ntracks);
c74c5f6c 564 for (Int_t i=0;i<ntracks;++i) {
cc65e4f5 565 clusterSideA[i]=0;
566 clusterSideC[i]=0;
74235403 567 AliESDtrack *track = event->GetTrack(i);
568
569 const AliExternalTrackParam * trackIn = track->GetInnerParam();
570 const AliExternalTrackParam * trackOut = track->GetOuterParam();
571 if (!trackIn) continue;
572 if (!trackOut) continue;
573
6ba68367 574 AliESDfriendTrack *friendTrack = esdFriend->GetTrack(i);
b1c27e4f 575 if (!friendTrack) continue;
3e55050f 576 if (friendTrack) ProcessSame(track,friendTrack,event);
6ba68367 577 if (friendTrack) ProcessAlignITS(track,friendTrack,event,esdFriend);
0dac7b3a 578 if (friendTrack) ProcessAlignTRD(track,friendTrack);
817766d5 579 if (friendTrack) ProcessAlignTOF(track,friendTrack);
74235403 580 TObject *calibObject;
581 AliTPCseed *seed = 0;
582 for (Int_t l=0;(calibObject=friendTrack->GetCalibObject(l));++l) if ((seed=dynamic_cast<AliTPCseed*>(calibObject))) break;
cc65e4f5 583 if (seed) {
584 tpcSeeds.AddAt(seed,i);
585 Int_t nA=0, nC=0;
586 for (Int_t irow=159;irow>0;irow--) {
587 AliTPCclusterMI *cl=seed->GetClusterPointer(irow);
588 if (!cl) continue;
589 if ((cl->GetDetector()%36)<18) nA++;
590 if ((cl->GetDetector()%36)>=18) nC++;
591 }
592 clusterSideA[i]=nA;
593 clusterSideC[i]=nC;
594 }
c74c5f6c 595 }
c74c5f6c 596 if (ntracks<2) return;
597 //
598 // Find pairs
599 //
d3ce44cb 600
c74c5f6c 601 for (Int_t i=0;i<ntracks;++i) {
74235403 602 AliESDtrack *track0 = event->GetTrack(i);
c74c5f6c 603 // track0 - choosen upper part
604 if (!track0) continue;
605 if (!track0->GetOuterParam()) continue;
606 if (track0->GetOuterParam()->GetAlpha()<0) continue;
607 Double_t d1[3];
608 track0->GetDirection(d1);
609 for (Int_t j=0;j<ntracks;++j) {
610 if (i==j) continue;
74235403 611 AliESDtrack *track1 = event->GetTrack(j);
612 //track 1 lower part
613 if (!track1) continue;
614 if (!track1->GetOuterParam()) continue;
cc65e4f5 615 if (track0->GetTPCNcls()+ track1->GetTPCNcls()< kMinClusters) continue;
616 Int_t nAC = TMath::Max( TMath::Min(clusterSideA[i], clusterSideC[j]),
617 TMath::Min(clusterSideC[i], clusterSideA[j]));
618 if (nAC<kMinClustersCross) continue;
619 Int_t nA0=clusterSideA[i];
620 Int_t nC0=clusterSideC[i];
621 Int_t nA1=clusterSideA[j];
622 Int_t nC1=clusterSideC[j];
3e55050f 623 // if (track1->GetOuterParam()->GetAlpha()>0) continue;
74235403 624 //
625 Double_t d2[3];
626 track1->GetDirection(d2);
627
628 AliTPCseed * seed0 = (AliTPCseed*) tpcSeeds.At(i);
629 AliTPCseed * seed1 = (AliTPCseed*) tpcSeeds.At(j);
630 if (! seed0) continue;
631 if (! seed1) continue;
632 Float_t dir = (d1[0]*d2[0] + d1[1]*d2[1] + d1[2]*d2[2]);
633 Float_t dist0 = track0->GetLinearD(0,0);
634 Float_t dist1 = track1->GetLinearD(0,0);
635 //
636 // conservative cuts - convergence to be guarantied
637 // applying before track propagation
3e55050f 638 if (TMath::Abs(TMath::Abs(dist0)-TMath::Abs(dist1))>fCutMaxD) continue; // distance to the 0,0
639 if (TMath::Abs(dir)<TMath::Abs(fCutMinDir)) continue; // direction vector product
74235403 640 Float_t bz = AliTracker::GetBz();
641 Float_t dvertex0[2]; //distance to 0,0
642 Float_t dvertex1[2]; //distance to 0,0
643 track0->GetDZ(0,0,0,bz,dvertex0);
644 track1->GetDZ(0,0,0,bz,dvertex1);
645 if (TMath::Abs(dvertex0[1])>250) continue;
646 if (TMath::Abs(dvertex1[1])>250) continue;
647 //
648 //
649 //
650 Float_t dmax = TMath::Max(TMath::Abs(dist0),TMath::Abs(dist1));
651 AliExternalTrackParam param0(*track0);
652 AliExternalTrackParam param1(*track1);
653 //
654 // Propagate using Magnetic field and correct fo material budget
655 //
9963b5e2 656 AliTracker::PropagateTrackTo(&param0,dmax+1,TDatabasePDG::Instance()->GetParticle("e-")->Mass(),3,kTRUE);
657 AliTracker::PropagateTrackTo(&param1,dmax+1,TDatabasePDG::Instance()->GetParticle("e-")->Mass(),3,kTRUE);
74235403 658 //
659 // Propagate rest to the 0,0 DCA - z should be ignored
660 //
661 //Bool_t b0 = ;
662 param0.PropagateToDCA(&vtx,bz,1000);
663 //Bool_t b1 =
664 param1.PropagateToDCA(&vtx,bz,1000);
74235403 665 param0.GetDZ(0,0,0,bz,dvertex0);
666 param1.GetDZ(0,0,0,bz,dvertex1);
dde68d36 667 Double_t xyz0[3];
668 Double_t xyz1[3];
74235403 669 param0.GetXYZ(xyz0);
670 param1.GetXYZ(xyz1);
671 Bool_t isPair = IsPair(&param0,&param1);
d3ce44cb 672 Bool_t isCross = IsCross(track0, track1);
dde68d36 673 Bool_t isSame = IsSame(track0, track1);
d3ce44cb 674
dde68d36 675 THnSparse* hist=new THnSparseF("","HistVdrift;time;p/T ratio;Vdrift;run",4,fBinsVdrift,fXminVdrift,fXmaxVdrift);
676 TString shortName=hist->ClassName();
677 shortName+="_MEAN_VDRIFT_COSMICS_";
678 delete hist;
679 hist=NULL;
680
3e55050f 681 if((isSame) || (isCross && isPair)){
682 if (track0->GetTPCNcls()+ track1->GetTPCNcls()> 80) {
74235403 683 fDz = param0.GetZ() - param1.GetZ();
cc65e4f5 684 Double_t sign=(nA0>nA1)? 1:-1;
685 fDz*=sign;
74235403 686 TTimeStamp tstamp(fTime);
687 Double_t ptrelative0 = AliTPCcalibDB::GetPTRelative(tstamp,fRun,0);
688 Double_t ptrelative1 = AliTPCcalibDB::GetPTRelative(tstamp,fRun,1);
dde68d36 689 Double_t vecDrift[4]={fTime,(ptrelative0+ptrelative1)/2.0,fDz/500.0,event->GetRunNumber()};
690 THnSparse* curHist=NULL;
691 TString name="";
692
693 name=shortName;
694 name+=event->GetFiredTriggerClasses();
695 name.ToUpper();
696 curHist=(THnSparseF*)fArrayDz->FindObject(name);
74235403 697 if(!curHist){
dde68d36 698 curHist=new THnSparseF(name,"HistVdrift;time;p/T ratio;Vdrift;run",4,fBinsVdrift,fXminVdrift,fXmaxVdrift);
699 fArrayDz->AddLast(curHist);
74235403 700 }
dde68d36 701// curHist=(THnSparseF*)(fMapDz->GetValue(event->GetFiredTriggerClasses()));
702// if(!curHist){
703// curHist=new THnSparseF(event->GetFiredTriggerClasses(),"HistVdrift;time;p/T ratio;Vdrift;run",4,fBinsVdrift,fXminVdrift,fXmaxVdrift);
704// fMapDz->Add(new TObjString(event->GetFiredTriggerClasses()),curHist);
705// }
706 curHist->Fill(vecDrift);
74235403 707
dde68d36 708 name=shortName;
709 name+="ALL";
710 name.ToUpper();
711 curHist=(THnSparseF*)fArrayDz->FindObject(name);
74235403 712 if(!curHist){
dde68d36 713 curHist=new THnSparseF(name,"HistVdrift;time;p/T ratio;Vdrift;run",4,fBinsVdrift,fXminVdrift,fXmaxVdrift);
714 fArrayDz->AddLast(curHist);
74235403 715 }
dde68d36 716// curHist=(THnSparseF*)(fMapDz->GetValue("all"));
717// if(!curHist){
718// curHist=new THnSparseF("all","HistVdrift;time;p/T ratio;Vdrift;run",4,fBinsVdrift,fXminVdrift,fXmaxVdrift);
719// fMapDz->Add(new TObjString("all"),curHist);
720// }
721 curHist->Fill(vecDrift);
74235403 722 }
723 }
d3ce44cb 724 TTreeSRedirector *cstream = GetDebugStreamer();
725 if (fStreamLevel>0){
726 if (cstream){
727 (*cstream)<<"trackInfo"<<
728 "tr0.="<<track0<<
729 "tr1.="<<track1<<
730 "p0.="<<&param0<<
731 "p1.="<<&param1<<
cc65e4f5 732 "nAC="<<nAC<<
733 "nA0="<<nA0<<
734 "nA1="<<nA1<<
735 "nC0="<<nC0<<
736 "nC1="<<nC1<<
d3ce44cb 737 "isPair="<<isPair<<
738 "isCross="<<isCross<<
dde68d36 739 "isSame="<<isSame<<
d3ce44cb 740 "fDz="<<fDz<<
741 "fRun="<<fRun<<
742 "fTime="<<fTime<<
743 "\n";
744 }
745 }
c74c5f6c 746 } // end 2nd order loop
747 } // end 1st order loop
74235403 748
2be25cc9 749 if (fStreamLevel>0){
750 TTreeSRedirector *cstream = GetDebugStreamer();
751 if (cstream){
2be25cc9 752 (*cstream)<<"timeInfo"<<
753 "run="<<fRun<< // run number
754 "event="<<fEvent<< // event number
755 "time="<<fTime<< // time stamp of event
756 "trigger="<<fTrigger<< // trigger
757 "mag="<<fMagF<< // magnetic field
758 // Environment values
2be25cc9 759 //
760 // accumulated values
761 //
762 "fDz="<<fDz<< //! current delta z
2be25cc9 763 "trigger="<<event->GetFiredTriggerClasses()<<
764 "\n";
765 }
766 }
a390f11f 767 if (GetDebugLevel()>20) printf("Trigger: %s\n",event->GetFiredTriggerClasses().Data());
c74c5f6c 768}
769
70036ef3 770void AliTPCcalibTime::ProcessBeam(const AliESDEvent *const event){
771 //
772 //
773 //
774 const Int_t kMinClusters =80;
775 const Int_t kMinTracks =2; // minimal number of tracks to define the vertex
776 const Double_t kMaxTgl =1.2; // maximal Tgl (z angle)
777 const Double_t kMinPt =0.2; // minimal pt
778 const Double_t kMaxD0 =10; // cut on distance to the primary vertex first guess
779 const Double_t kMaxZ0 =20;
780 const Double_t kMaxD =5; // cut on distance to the primary vertex
781 const Double_t kMaxZ =4; // maximal z distance between tracks form the same side
782 const Double_t kMaxChi2 =15; // maximal chi2 of the TPCvertex
783 const Double_t kCumulCovarXY=0.01; //increase the error of cumul vertex 100 microns profile
784 const Double_t kCumulCovarZ=250.; //increase the error of cumul vertex
785
786 Float_t dca0[2]={0,0};
787 Double_t dcaVertex[2]={0,0};
788
789 Int_t ntracks=event->GetNumberOfTracks();
790 if (ntracks==0) return;
791 if (ntracks > fCutTracks) return;
792 //
793 AliESDfriend *esdFriend=(AliESDfriend*)(((AliESDEvent*)event)->FindListObject("AliESDfriend"));
794 //
795 // Divide tracks to A and C side tracks - using the cluster indexes
796 TObjArray tracksA(ntracks);
797 TObjArray tracksC(ntracks);
6ba68367 798 //
70036ef3 799 AliESDVertex *vertexSPD = (AliESDVertex *)event->GetPrimaryVertexSPD();
800 AliESDVertex *vertex = (AliESDVertex *)event->GetPrimaryVertex();
801 AliESDVertex *vertexTracks = (AliESDVertex *)event->GetPrimaryVertexTracks();
802 Double_t vertexZA[10000], vertexZC[10000];
6ba68367 803 //
70036ef3 804 Int_t ntracksA= 0;
805 Int_t ntracksC= 0;
806 //
807 for (Int_t itrack=0;itrack<ntracks;itrack++) {
808 AliESDtrack *track = event->GetTrack(itrack);
809 AliESDfriendTrack *friendTrack = esdFriend->GetTrack(itrack);
810 if (!friendTrack) continue;
811 if (TMath::Abs(track->GetTgl())>kMaxTgl) continue;
812 if (TMath::Abs(track->Pt())<kMinPt) continue;
813 const AliExternalTrackParam * trackIn = track->GetInnerParam();
814 TObject *calibObject=0;
815 AliTPCseed *seed = 0;
816 Int_t nA=0, nC=0;
817 for (Int_t l=0;(calibObject=friendTrack->GetCalibObject(l));++l) if ((seed=dynamic_cast<AliTPCseed*>(calibObject))) break;
818 if (seed) {
819 for (Int_t irow=159;irow>0;irow--) {
820 AliTPCclusterMI *cl=seed->GetClusterPointer(irow);
821 if (!cl) continue;
822 if ((cl->GetDetector()%36)<18) nA++;
823 if ((cl->GetDetector()%36)>=18) nC++;
824 }
825 if ((nA>kMinClusters || nC>kMinClusters) && (nA*nC==0) ){
826 track->GetImpactParameters(dca0[0],dca0[1]);
827 if (TMath::Abs(dca0[0])>kMaxD0) continue;
828 if (TMath::Abs(dca0[1])>kMaxZ0) continue;
829 AliExternalTrackParam pTPCvertex(*trackIn);
830 if (!AliTracker::PropagateTrackToBxByBz(&pTPCvertex,4.+4.*TMath::Abs(dca0[0]),0.1,2,kTRUE)) continue;
831 pTPCvertex.PropagateToDCA(vertex,AliTracker::GetBz(), kMaxD, dcaVertex,0);
832 if (TMath::Abs(dcaVertex[0])>kMaxD) continue;
833 if (nA>kMinClusters &&nC==0) { tracksA.AddLast(pTPCvertex.Clone()); vertexZA[ntracksA++] = pTPCvertex.GetZ();}
834 if (nC>kMinClusters &&nA==0) {tracksC.AddLast(pTPCvertex.Clone()); vertexZC[ntracksC++] = pTPCvertex.GetZ();}
835 }
836 }
837 }
838 Double_t medianZA=TMath::Median(ntracksA, vertexZA);
839 Double_t medianZC=TMath::Median(ntracksC, vertexZC);
840 Int_t flags=0;
841 static Double_t deltaZ[1000]={0};
842 static Int_t counterZ=0;
843 static AliKFVertex cumulVertexA, cumulVertexC, cumulVertexAC; // cumulative vertex
844 AliKFVertex vertexA, vertexC;
845 //
846 ntracksA= tracksA.GetEntriesFast();
847 ntracksC= tracksC.GetEntriesFast();
848 if (ntracksA>kMinTracks && ntracksC>kMinTracks){
849 deltaZ[counterZ%1000]=medianZA-medianZC;
850 counterZ+=1;
851 Double_t medianDelta=(counterZ>=1000)? TMath::Median(1000, deltaZ): TMath::Median(counterZ, deltaZ);
852 if (TMath::Abs(medianDelta-(medianZA-medianZC))>kMaxZ) flags+=16;
853 // increse the error of cumulative vertex at the beginning of event
854 cumulVertexA.Covariance(0,0)+=kCumulCovarXY*kCumulCovarXY;
855 cumulVertexA.Covariance(1,1)+=kCumulCovarXY*kCumulCovarXY;
856 cumulVertexA.Covariance(2,2)+=kCumulCovarZ*kCumulCovarZ;
857 cumulVertexC.Covariance(0,0)+=kCumulCovarXY*kCumulCovarXY;
858 cumulVertexC.Covariance(1,1)+=kCumulCovarXY*kCumulCovarXY;
859 cumulVertexC.Covariance(2,2)+=kCumulCovarZ*kCumulCovarZ;
860 cumulVertexAC.Covariance(0,0)+=kCumulCovarXY*kCumulCovarXY;
861 cumulVertexAC.Covariance(1,1)+=kCumulCovarXY*kCumulCovarXY;
862 cumulVertexAC.Covariance(2,2)+=kCumulCovarZ*kCumulCovarZ;
863 //
864 for (Int_t iA=0; iA<ntracksA; iA++){
865 if (flags!=0) continue;
866 AliExternalTrackParam *aliTrack = (AliExternalTrackParam *)tracksA.At(iA);
867 if (TMath::Abs(aliTrack->GetZ()-medianZA)>kMaxZ) continue;
868 AliKFParticle part(*aliTrack,211);
869 vertexA+=part;
870 cumulVertexA+=part;
871 cumulVertexAC+=part;
872 }
873 for (Int_t iC=0; iC<ntracksC; iC++){
874 if (flags!=0) continue;
875 AliExternalTrackParam *aliTrack = (AliExternalTrackParam *)tracksC.At(iC);
876 if (TMath::Abs(aliTrack->GetZ()-medianZC)>kMaxZ) continue;
877 AliKFParticle part(*aliTrack,211);
878 vertexC+=part;
879 cumulVertexC+=part;
880 cumulVertexAC+=part;
881 }
882 if (vertexA.GetNDF()<kMinTracks) flags+=32;
883 if (vertexC.GetNDF()<kMinTracks) flags+=32;
884 if (TMath::Abs(vertexA.Z()-medianZA)>kMaxZ) flags+=1; //apply cuts
885 if (TMath::Abs(vertexC.Z()-medianZC)>kMaxZ) flags+=2;
886 if (TMath::Abs(vertexA.GetChi2()/vertexA.GetNDF()+vertexC.GetChi2()/vertexC.GetNDF())> kMaxChi2) flags+=4;
887 if (flags==0 &&cumulVertexC.GetNDF()>20&&cumulVertexA.GetNDF()){
888 Double_t cont[2]={0,fTime};
889 //
890 cont[0]= cumulVertexA.X();
891 fTPCVertex[0]->Fill(cont);
892 cont[0]= cumulVertexC.X();
893 fTPCVertex[1]->Fill(cont);
894 cont[0]= 0.5*(cumulVertexA.X()-cumulVertexC.X());
895 fTPCVertex[2]->Fill(cont);
896 cont[0]= 0.5*(cumulVertexA.X()+cumulVertexC.X())-vertex->GetX();
897 fTPCVertex[3]->Fill(cont);
898 //
899 cont[0]= cumulVertexA.Y();
900 fTPCVertex[4]->Fill(cont);
901 cont[0]= cumulVertexC.Y();
902 fTPCVertex[5]->Fill(cont);
903 cont[0]= 0.5*(cumulVertexA.Y()-cumulVertexC.Y());
904 fTPCVertex[6]->Fill(cont);
905 cont[0]= 0.5*(cumulVertexA.Y()+cumulVertexC.Y())-vertex->GetY();
906 fTPCVertex[7]->Fill(cont);
907 //
908 //
909 cont[0]= 0.5*(cumulVertexA.Z()+cumulVertexC.Z());
910 fTPCVertex[8]->Fill(cont);
911 cont[0]= 0.5*(cumulVertexA.Z()-cumulVertexC.Z());
912 fTPCVertex[9]->Fill(cont);
913 cont[0]= 0.5*(cumulVertexA.Z()-cumulVertexC.Z());
914 fTPCVertex[10]->Fill(cont);
915 cont[0]= 0.5*(cumulVertexA.Z()+cumulVertexC.Z())-vertex->GetZ();
916 fTPCVertex[11]->Fill(cont);
917 }
918 //
919 TTreeSRedirector *cstream = GetDebugStreamer();
920 if (cstream){
921 /*
922 TCut cutChi2= "sqrt(vA.fChi2/vA.fNDF+vC.fChi2/vC.fNDF)<10"; // chi2 Cut e.g 10
923 TCut cutXY= "sqrt((vA.fP[0]-vC.fP[0])^2+(vA.fP[0]-vC.fP[1])^2)<5"; // vertex Cut
924 TCut cutZ= "abs(vA.fP[2]-mZA)<3&&abs(vC.fP[2]-mZC)<5"; // vertex Cut
925 tree->Draw("sqrt(vA.fChi2/vA.fNDF)","sqrt(vA.fChi2/vA.fNDF)<100","")
926
927 */
660f0543 928 //vertexA.Print();
929 //vertexC.Print();
70036ef3 930 (*cstream)<<"vertexTPC"<<
931 "flags="<<flags<< // rejection flags
932 "vSPD.="<<vertexSPD<< // SPD vertex
933 "vT.="<<vertexTracks<< // track vertex
934 "v.="<<vertex<< // esd vertex
935 "mZA="<<medianZA<< // median Z position at vertex A side
936 "mZC="<<medianZC<< // median Z position at vertex C side
937 "mDelta="<<medianDelta<< // median delta A side -C side
938 "counter="<<counterZ<< // counter Z
939 //
940 "vA.="<<&vertexA<< // vertex A side
941 "vC.="<<&vertexC<< // vertex C side
942 "cvA.="<<&cumulVertexA<< // cumulative vertex A side
943 "cvC.="<<&cumulVertexC<< // cumulative vertex C side
944 "cvAC.="<<&cumulVertexAC<< // cumulative vertex A+C side
945 "nA="<<ntracksA<< // contributors
946 "nC="<<ntracksC<< // contributors
947 "\n";
948 }
949 }
950 tracksA.Delete();
951 tracksC.Delete();
dde68d36 952}
953
6ba68367 954void AliTPCcalibTime::Analyze(){
955 //
956 // Special macro to analyze result of calibration and extract calibration entries
957 // Not yet ported to the Analyze function yet
958 //
959}
74235403 960
2811495d 961THnSparse* AliTPCcalibTime::GetHistoDrift(const char* name) const
962{
6ba68367 963 //
964 // Get histogram for given trigger mask
965 //
dde68d36 966 TIterator* iterator = fArrayDz->MakeIterator();
967 iterator->Reset();
968 TString newName=name;
969 newName.ToUpper();
970 THnSparse* newHist=new THnSparseF(newName,"HistVdrift;time;p/T ratio;Vdrift;run",4,fBinsVdrift,fXminVdrift,fXmaxVdrift);
971 THnSparse* addHist=NULL;
972 while((addHist=(THnSparseF*)iterator->Next())){
973 if(!addHist) continue;
974 TString histName=addHist->GetName();
975 if(!histName.Contains(newName)) continue;
976 addHist->Print();
977 newHist->Add(addHist);
74235403 978 }
dde68d36 979 return newHist;
74235403 980}
981
2811495d 982TObjArray* AliTPCcalibTime::GetHistoDrift() const
983{
6ba68367 984 //
985 // return array of histograms
986 //
dde68d36 987 return fArrayDz;
74235403 988}
989
990TGraphErrors* AliTPCcalibTime::GetGraphDrift(const char* name){
6ba68367 991 //
992 // Make a drift velocity (delta Z) graph
993 //
dde68d36 994 THnSparse* histoDrift=GetHistoDrift(name);
995 TGraphErrors* graphDrift=NULL;
996 if(histoDrift){
997 graphDrift=FitSlices(histoDrift,2,0,400,100,0.05,0.95, kTRUE);
998 TString end=histoDrift->GetName();
999 Int_t pos=end.Index("_");
1000 end=end(pos,end.Capacity()-pos);
1001 TString graphName=graphDrift->ClassName();
1002 graphName+=end;
1003 graphName.ToUpper();
1004 graphDrift->SetName(graphName);
74235403 1005 }
1006 return graphDrift;
1007}
1008
dde68d36 1009TObjArray* AliTPCcalibTime::GetGraphDrift(){
6ba68367 1010 //
1011 // make a array of drift graphs
1012 //
dde68d36 1013 TObjArray* arrayGraphDrift=new TObjArray();
1014 TIterator* iterator=fArrayDz->MakeIterator();
74235403 1015 iterator->Reset();
dde68d36 1016 THnSparse* addHist=NULL;
1017 while((addHist=(THnSparseF*)iterator->Next())) arrayGraphDrift->AddLast(GetGraphDrift(addHist->GetName()));
1018 return arrayGraphDrift;
74235403 1019}
1020
dde68d36 1021AliSplineFit* AliTPCcalibTime::GetFitDrift(const char* name){
6ba68367 1022 //
1023 // Make a fit AliSplinefit of drift velocity
1024 //
d3ce44cb 1025 TGraph* graphDrift=GetGraphDrift(name);
dde68d36 1026 AliSplineFit* fitDrift=NULL;
74235403 1027 if(graphDrift && graphDrift->GetN()){
dde68d36 1028 fitDrift=new AliSplineFit();
1029 fitDrift->SetGraph(graphDrift);
1030 fitDrift->SetMinPoints(graphDrift->GetN()+1);
1031 fitDrift->InitKnots(graphDrift,2,0,0.001);
1032 fitDrift->SplineFit(0);
1033 TString end=graphDrift->GetName();
1034 Int_t pos=end.Index("_");
1035 end=end(pos,end.Capacity()-pos);
1036 TString fitName=fitDrift->ClassName();
1037 fitName+=end;
1038 fitName.ToUpper();
1039 //fitDrift->SetName(fitName);
74235403 1040 delete graphDrift;
dde68d36 1041 graphDrift=NULL;
74235403 1042 }
1043 return fitDrift;
1044}
1045
74235403 1046
2811495d 1047Long64_t AliTPCcalibTime::Merge(TCollection *const li) {
6ba68367 1048 //
1049 // Object specific merging procedure
1050 //
c74c5f6c 1051 TIterator* iter = li->MakeIterator();
1052 AliTPCcalibTime* cal = 0;
660f0543 1053 //
c74c5f6c 1054 while ((cal = (AliTPCcalibTime*)iter->Next())) {
1055 if (!cal->InheritsFrom(AliTPCcalibTime::Class())) {
1056 Error("Merge","Attempt to add object of class %s to a %s", cal->ClassName(), this->ClassName());
1057 return -1;
1058 }
2be25cc9 1059 for (Int_t imeas=0; imeas<3; imeas++){
1060 if (cal->GetHistVdriftLaserA(imeas) && cal->GetHistVdriftLaserA(imeas)){
1061 fHistVdriftLaserA[imeas]->Add(cal->GetHistVdriftLaserA(imeas));
1062 fHistVdriftLaserC[imeas]->Add(cal->GetHistVdriftLaserC(imeas));
1063 }
1064 }
9112627b 1065 //
70036ef3 1066 if (fTPCVertex && cal->fTPCVertex)
1067 for (Int_t imeas=0; imeas<12; imeas++){
660f0543 1068 if (fTPCVertex[imeas] && cal->fTPCVertex[imeas]) fTPCVertex[imeas]->Add(cal->fTPCVertex[imeas]);
70036ef3 1069 }
1070
660f0543 1071 if (fMemoryMode>0) for (Int_t imeas=0; imeas<5; imeas++){
1072 if (fMemoryMode>1){
1073 if ( cal->GetResHistoTPCCE(imeas) && cal->GetResHistoTPCCE(imeas)){
1074 fResHistoTPCCE[imeas]->Add(cal->fResHistoTPCCE[imeas]);
1075 }else{
1076 fResHistoTPCCE[imeas]=(THnSparse*)cal->fResHistoTPCCE[imeas]->Clone();
1077 }
b9908d0b 1078 }
660f0543 1079 //
1080 if ((fMemoryMode>0) &&cal->GetResHistoTPCITS(imeas) && cal->GetResHistoTPCITS(imeas)){
1081 if (fMemoryMode>1 || (imeas%2)==1) fResHistoTPCITS[imeas]->Add(cal->fResHistoTPCITS[imeas]);
1082 if (fMemoryMode>1) fResHistoTPCvertex[imeas]->Add(cal->fResHistoTPCvertex[imeas]);
33fc6b9e 1083 }
660f0543 1084 //
1085 if ((fMemoryMode>1) && cal->fResHistoTPCTRD[imeas]){
33fc6b9e 1086 if (fResHistoTPCTRD[imeas])
1087 fResHistoTPCTRD[imeas]->Add(cal->fResHistoTPCTRD[imeas]);
1088 else
1089 fResHistoTPCTRD[imeas]=(THnSparse*)cal->fResHistoTPCTRD[imeas]->Clone();
1090 }
660f0543 1091 //
1092 if ((fMemoryMode>1) && cal->fResHistoTPCTOF[imeas]){
33fc6b9e 1093 if (fResHistoTPCTOF[imeas])
1094 fResHistoTPCTOF[imeas]->Add(cal->fResHistoTPCTOF[imeas]);
1095 else
1096 fResHistoTPCTOF[imeas]=(THnSparse*)cal->fResHistoTPCTOF[imeas]->Clone();
9112627b 1097 }
660f0543 1098 //
97d3fea0 1099 if (cal->fArrayLaserA){
1100 fArrayLaserA->Expand(fArrayLaserA->GetEntriesFast()+cal->fArrayLaserA->GetEntriesFast());
1101 fArrayLaserC->Expand(fArrayLaserC->GetEntriesFast()+cal->fArrayLaserC->GetEntriesFast());
1102 for (Int_t ical=0; ical<cal->fArrayLaserA->GetEntriesFast(); ical++){
1103 if (cal->fArrayLaserA->UncheckedAt(ical)) fArrayLaserA->AddLast(cal->fArrayLaserA->UncheckedAt(ical)->Clone());
1104 if (cal->fArrayLaserC->UncheckedAt(ical)) fArrayLaserC->AddLast(cal->fArrayLaserC->UncheckedAt(ical)->Clone());
1105 }
1106 }
1107
9112627b 1108 }
dde68d36 1109 TObjArray* addArray=cal->GetHistoDrift();
1110 if(!addArray) return 0;
1111 TIterator* iterator = addArray->MakeIterator();
2be25cc9 1112 iterator->Reset();
dde68d36 1113 THnSparse* addHist=NULL;
660f0543 1114 if ((fMemoryMode>1)) while((addHist=(THnSparseF*)iterator->Next())){
dde68d36 1115 if(!addHist) continue;
2be25cc9 1116 addHist->Print();
dde68d36 1117 THnSparse* localHist=(THnSparseF*)fArrayDz->FindObject(addHist->GetName());
2be25cc9 1118 if(!localHist){
1119 localHist=new THnSparseF(addHist->GetName(),"HistVdrift;time;p/T ratio;Vdrift;run",4,fBinsVdrift,fXminVdrift,fXmaxVdrift);
dde68d36 1120 fArrayDz->AddLast(localHist);
2be25cc9 1121 }
1122 localHist->Add(addHist);
1123 }
391ffdb2 1124
d3ce44cb 1125 for(Int_t i=0;i<10;i++) if (cal->GetCosmiMatchingHisto(i)) fCosmiMatchingHisto[i]->Add(cal->GetCosmiMatchingHisto(i));
3e55050f 1126 //
1127 // Merge alignment
1128 //
1129 for (Int_t itype=0; itype<3; itype++){
1130 //
1131 //
1132 TObjArray *arr0= 0;
1133 TObjArray *arr1= 0;
1134 if (itype==0) {arr0=fAlignITSTPC; arr1=cal->fAlignITSTPC;}
1135 if (itype==1) {arr0=fAlignTRDTPC; arr1=cal->fAlignTRDTPC;}
1136 if (itype==2) {arr0=fAlignTOFTPC; arr1=cal->fAlignTOFTPC;}
1137 if (!arr1) continue;
1138 if (!arr0) arr0=new TObjArray(arr1->GetEntriesFast());
1139 if (arr1->GetEntriesFast()>arr0->GetEntriesFast()){
1140 arr0->Expand(arr1->GetEntriesFast());
1141 }
1142 for (Int_t i=0;i<arr1->GetEntriesFast(); i++){
1143 AliRelAlignerKalman *kalman1 = (AliRelAlignerKalman *)arr1->UncheckedAt(i);
1144 AliRelAlignerKalman *kalman0 = (AliRelAlignerKalman *)arr0->UncheckedAt(i);
1145 if (!kalman1) continue;
1146 if (!kalman0) {arr0->AddAt(new AliRelAlignerKalman(*kalman1),i); continue;}
1147 kalman0->SetRejectOutliers(kFALSE);
1148 kalman0->Merge(kalman1);
1149 }
1150 }
1151
c74c5f6c 1152 }
c74c5f6c 1153 return 0;
c74c5f6c 1154}
1155
c74c5f6c 1156Bool_t AliTPCcalibTime::IsPair(AliExternalTrackParam *tr0, AliExternalTrackParam *tr1){
c74c5f6c 1157 /*
1158 // 0. Same direction - OPOSITE - cutDir +cutT
1159 TCut cutDir("cutDir","dir<-0.99")
1160 // 1.
1161 TCut cutT("cutT","abs(Tr1.fP[3]+Tr0.fP[3])<0.03")
1162 //
1163 // 2. The same rphi
1164 TCut cutD("cutD","abs(Tr0.fP[0]+Tr1.fP[0])<5")
1165 //
c74c5f6c 1166 TCut cutPt("cutPt","abs(Tr1.fP[4]+Tr0.fP[4])<1&&abs(Tr0.fP[4])+abs(Tr1.fP[4])<10");
1167 // 1/Pt diff cut
1168 */
1169 const Double_t *p0 = tr0->GetParameter();
1170 const Double_t *p1 = tr1->GetParameter();
74235403 1171 fCosmiMatchingHisto[0]->Fill(p0[0]+p1[0]);
1172 fCosmiMatchingHisto[1]->Fill(p0[1]-p1[1]);
d3ce44cb 1173 fCosmiMatchingHisto[2]->Fill(tr1->GetAlpha()-tr0->GetAlpha()+TMath::Pi());
74235403 1174 fCosmiMatchingHisto[3]->Fill(p0[3]+p1[3]);
1175 fCosmiMatchingHisto[4]->Fill(p0[4]+p1[4]);
1176
c74c5f6c 1177 if (TMath::Abs(p0[3]+p1[3])>fCutTheta) return kFALSE;
1178 if (TMath::Abs(p0[0]+p1[0])>fCutMaxD) return kFALSE;
da6c0bc9 1179 if (TMath::Abs(p0[1]-p1[1])>fCutMaxDz) return kFALSE;
c74c5f6c 1180 Double_t d0[3], d1[3];
1181 tr0->GetDirection(d0);
1182 tr1->GetDirection(d1);
1183 if (d0[0]*d1[0] + d0[1]*d1[1] + d0[2]*d1[2] >fCutMinDir) return kFALSE;
74235403 1184
d3ce44cb 1185 fCosmiMatchingHisto[5]->Fill(p0[0]+p1[0]);
1186 fCosmiMatchingHisto[6]->Fill(p0[1]-p1[1]);
1187 fCosmiMatchingHisto[7]->Fill(tr1->GetAlpha()-tr0->GetAlpha()+TMath::Pi());
1188 fCosmiMatchingHisto[8]->Fill(p0[3]+p1[3]);
1189 fCosmiMatchingHisto[9]->Fill(p0[4]+p1[4]);
1190
c74c5f6c 1191 return kTRUE;
1192}
2811495d 1193Bool_t AliTPCcalibTime::IsCross(AliESDtrack *const tr0, AliESDtrack *const tr1){
cc65e4f5 1194 //
1195 // check if the cosmic pair of tracks crossed A/C side
1196 //
1197 Bool_t result= tr0->GetOuterParam()->GetZ()*tr1->GetOuterParam()->GetZ()<0;
1198 if (result==kFALSE) return result;
1199 result=kTRUE;
1200 return result;
d3ce44cb 1201}
1202
2811495d 1203Bool_t AliTPCcalibTime::IsSame(AliESDtrack *const tr0, AliESDtrack *const tr1){
3e55050f 1204 //
1205 // track crossing the CE
1206 // 0. minimal number of clusters
1207 // 1. Same sector +-1
1208 // 2. Inner and outer track param on opposite side
1209 // 3. Outer and inner track parameter close each to other
1210 // 3.
1211 Bool_t result=kTRUE;
1212 //
1213 // inner and outer on opposite sides in z
1214 //
1215 const Int_t knclCut0 = 30;
1216 const Double_t kalphaCut = 0.4;
1217 //
1218 // 0. minimal number of clusters
1219 //
1220 if (tr0->GetTPCNcls()<knclCut0) return kFALSE;
1221 if (tr1->GetTPCNcls()<knclCut0) return kFALSE;
1222 //
1223 // 1. alpha cut - sector+-1
1224 //
1225 if (TMath::Abs(tr0->GetOuterParam()->GetAlpha()-tr1->GetOuterParam()->GetAlpha())>kalphaCut) return kFALSE;
1226 //
1227 // 2. Z crossing
1228 //
1229 if (tr0->GetOuterParam()->GetZ()*tr0->GetInnerParam()->GetZ()>0) result&=kFALSE;
1230 if (tr1->GetOuterParam()->GetZ()*tr1->GetInnerParam()->GetZ()>0) result&=kFALSE;
1231 if (result==kFALSE){
1232 return result;
1233 }
1234 //
1235 //
1236 const Double_t *p0I = tr0->GetInnerParam()->GetParameter();
1237 const Double_t *p1I = tr1->GetInnerParam()->GetParameter();
1238 const Double_t *p0O = tr0->GetOuterParam()->GetParameter();
1239 const Double_t *p1O = tr1->GetOuterParam()->GetParameter();
1240 //
1241 if (TMath::Abs(p0I[0]-p1I[0])>fCutMaxD) result&=kFALSE;
1242 if (TMath::Abs(p0I[1]-p1I[1])>fCutMaxDz) result&=kFALSE;
1243 if (TMath::Abs(p0I[2]-p1I[2])>fCutTheta) result&=kFALSE;
1244 if (TMath::Abs(p0I[3]-p1I[3])>fCutTheta) result&=kFALSE;
1245 if (TMath::Abs(p0O[0]-p1O[0])>fCutMaxD) result&=kFALSE;
1246 if (TMath::Abs(p0O[1]-p1O[1])>fCutMaxDz) result&=kFALSE;
1247 if (TMath::Abs(p0O[2]-p1O[2])>fCutTheta) result&=kFALSE;
1248 if (TMath::Abs(p0O[3]-p1O[3])>fCutTheta) result&=kFALSE;
1249 if (result==kTRUE){
1250 result=kTRUE; // just to put break point here
1251 }
1252 return result;
dde68d36 1253}
1254
31aa7c5c 1255
2811495d 1256void AliTPCcalibTime::ProcessSame(AliESDtrack *const track, AliESDfriendTrack *const friendTrack, const AliESDEvent *const event){
3e55050f 1257 //
1258 // Process TPC tracks crossing CE
1259 //
1260 // 0. Select only track crossing the CE
1261 // 1. Cut on the track length
b9908d0b 1262 // 2. Refit the the track on A and C side separatelly
3e55050f 1263 // 3. Fill time histograms
1264 const Int_t kMinNcl=100;
1265 const Int_t kMinNclS=25; // minimul number of clusters on the sides
b9908d0b 1266 const Double_t pimass=TDatabasePDG::Instance()->GetParticle("pi+")->Mass();
1267 const Double_t kMaxDy=1; // maximal distance in y
1268 const Double_t kMaxDsnp=0.05; // maximal distance in snp
1269 const Double_t kMaxDtheta=0.05; // maximal distance in theta
1270
3e55050f 1271 if (!friendTrack->GetTPCOut()) return;
1272 //
1273 // 0. Select only track crossing the CE
1274 //
1275 if (track->GetInnerParam()->GetZ()*friendTrack->GetTPCOut()->GetZ()>0) return;
1276 //
1277 // 1. cut on track length
1278 //
1279 if (track->GetTPCNcls()<kMinNcl) return;
1280 //
1281 // 2. Refit track sepparatel on A and C side
1282 //
1283 TObject *calibObject;
1284 AliTPCseed *seed = 0;
1285 for (Int_t l=0;(calibObject=friendTrack->GetCalibObject(l));++l) {
1286 if ((seed=dynamic_cast<AliTPCseed*>(calibObject))) break;
1287 }
1288 if (!seed) return;
1289 //
1290 AliExternalTrackParam trackIn(*track->GetInnerParam());
1291 AliExternalTrackParam trackOut(*track->GetOuterParam());
1292 Double_t cov[3]={0.01,0.,0.01}; //use the same errors
1293 Double_t xyz[3]={0,0.,0.0};
1294 Double_t bz =0;
1295 Int_t nclIn=0,nclOut=0;
70036ef3 1296 trackIn.ResetCovariance(1000.);
1297 trackOut.ResetCovariance(1000.);
3e55050f 1298 //
1299 //2.a Refit inner
1300 //
b9908d0b 1301 Int_t sideIn=0;
3e55050f 1302 for (Int_t irow=0;irow<159;irow++) {
1303 AliTPCclusterMI *cl=seed->GetClusterPointer(irow);
1304 if (!cl) continue;
1305 if (cl->GetX()<80) continue;
b9908d0b 1306 if (sideIn==0){
1307 if (cl->GetDetector()%36<18) sideIn=1;
1308 if (cl->GetDetector()%36>=18) sideIn=-1;
1309 }
1310 if (sideIn== -1 && (cl->GetDetector()%36)<18) break;
1311 if (sideIn== 1 &&(cl->GetDetector()%36)>=18) break;
3e55050f 1312 Int_t sector = cl->GetDetector();
1313 Float_t dalpha = TMath::DegToRad()*(sector%18*20.+10.)-trackIn.GetAlpha();
1314 if (TMath::Abs(dalpha)>0.01){
1315 if (!trackIn.Rotate(TMath::DegToRad()*(sector%18*20.+10.))) break;
1316 }
1317 Double_t r[3]={cl->GetX(),cl->GetY(),cl->GetZ()};
1318 trackIn.GetXYZ(xyz);
1319 bz = AliTracker::GetBz(xyz);
b9908d0b 1320 AliTracker::PropagateTrackToBxByBz(&trackIn,r[0],1.,pimass,kFALSE);
3e55050f 1321 if (!trackIn.PropagateTo(r[0],bz)) break;
1322 nclIn++;
1323 trackIn.Update(&r[1],cov);
1324 }
1325 //
1326 //2.b Refit outer
b9908d0b 1327 //
1328 Int_t sideOut=0;
3e55050f 1329 for (Int_t irow=159;irow>0;irow--) {
1330 AliTPCclusterMI *cl=seed->GetClusterPointer(irow);
1331 if (!cl) continue;
1332 if (cl->GetX()<80) continue;
b9908d0b 1333 if (sideOut==0){
1334 if (cl->GetDetector()%36<18) sideOut=1;
1335 if (cl->GetDetector()%36>=18) sideOut=-1;
1336 if (sideIn==sideOut) break;
1337 }
1338 if (sideOut== -1 && (cl->GetDetector()%36)<18) break;
1339 if (sideOut== 1 &&(cl->GetDetector()%36)>=18) break;
1340 //
3e55050f 1341 Int_t sector = cl->GetDetector();
1342 Float_t dalpha = TMath::DegToRad()*(sector%18*20.+10.)-trackOut.GetAlpha();
1343 if (TMath::Abs(dalpha)>0.01){
1344 if (!trackOut.Rotate(TMath::DegToRad()*(sector%18*20.+10.))) break;
1345 }
1346 Double_t r[3]={cl->GetX(),cl->GetY(),cl->GetZ()};
1347 trackOut.GetXYZ(xyz);
1348 bz = AliTracker::GetBz(xyz);
b9908d0b 1349 AliTracker::PropagateTrackToBxByBz(&trackOut,r[0],1.,pimass,kFALSE);
3e55050f 1350 if (!trackOut.PropagateTo(r[0],bz)) break;
1351 nclOut++;
1352 trackOut.Update(&r[1],cov);
1353 }
1354 trackOut.Rotate(trackIn.GetAlpha());
1355 Double_t meanX = (trackIn.GetX()+trackOut.GetX())*0.5;
1356 trackIn.PropagateTo(meanX,bz);
1357 trackOut.PropagateTo(meanX,bz);
b9908d0b 1358 if (TMath::Abs(trackIn.GetY()-trackOut.GetY())>kMaxDy) return;
1359 if (TMath::Abs(trackIn.GetSnp()-trackOut.GetSnp())>kMaxDsnp) return;
1360 if (TMath::Abs(trackIn.GetTgl()-trackOut.GetTgl())>kMaxDtheta) return;
1361 if (TMath::Min(nclIn,nclOut)>kMinNclS){
1362 FillResHistoTPCCE(&trackIn,&trackOut);
1363 }
3e55050f 1364 TTreeSRedirector *cstream = GetDebugStreamer();
1365 if (cstream){
1366 TVectorD gxyz(3);
1367 trackIn.GetXYZ(gxyz.GetMatrixArray());
1368 TTimeStamp tstamp(fTime);
3e55050f 1369 (*cstream)<<"tpctpc"<<
1370 "run="<<fRun<< // run number
1371 "event="<<fEvent<< // event number
1372 "time="<<fTime<< // time stamp of event
1373 "trigger="<<fTrigger<< // trigger
1374 "mag="<<fMagF<< // magnetic field
3e55050f 1375 //
b9908d0b 1376 "sideIn="<<sideIn<< // side at inner part
1377 "sideOut="<<sideOut<< // side at puter part
3e55050f 1378 "xyz.="<<&gxyz<< // global position
1379 "tIn.="<<&trackIn<< // refitterd track in
1380 "tOut.="<<&trackOut<< // refitter track out
1381 "nclIn="<<nclIn<< //
1382 "nclOut="<<nclOut<< //
1383 "\n";
1384 }
1385 //
1386 // 3. Fill time histograms
1387 // Debug stremaer expression
1388 // chainTPCTPC->Draw("(tIn.fP[1]-tOut.fP[1])*sign(-tIn.fP[3]):tIn.fP[3]","min(nclIn,nclOut)>30","")
1389 if (TMath::Min(nclIn,nclOut)>kMinNclS){
1390 fDz = trackOut.GetZ()-trackIn.GetZ();
1391 if (trackOut.GetTgl()<0) fDz*=-1.;
1392 TTimeStamp tstamp(fTime);
1393 Double_t ptrelative0 = AliTPCcalibDB::GetPTRelative(tstamp,fRun,0);
1394 Double_t ptrelative1 = AliTPCcalibDB::GetPTRelative(tstamp,fRun,1);
1395 Double_t vecDrift[4]={fTime,(ptrelative0+ptrelative1)/2.0,fDz/500.0,event->GetRunNumber()};
1396 //
1397 // fill histograms per trigger class and itegrated
1398 //
1399 THnSparse* curHist=NULL;
1400 for (Int_t itype=0; itype<2; itype++){
1401 TString name="MEAN_VDRIFT_CROSS_";
1402 if (itype==0){
1403 name+=event->GetFiredTriggerClasses();
1404 name.ToUpper();
1405 }else{
1406 name+="ALL";
1407 }
1408 curHist=(THnSparseF*)fArrayDz->FindObject(name);
1409 if(!curHist){
1410 curHist=new THnSparseF(name,"HistVdrift;time;p/T ratio;Vdrift;run",4,fBinsVdrift,fXminVdrift,fXmaxVdrift);
1411 fArrayDz->AddLast(curHist);
1412 }
1413 curHist->Fill(vecDrift);
1414 }
1415 }
1416
1417}
817766d5 1418
2811495d 1419void AliTPCcalibTime::ProcessAlignITS(AliESDtrack *const track, AliESDfriendTrack *const friendTrack, const AliESDEvent *const event, AliESDfriend *const esdFriend){
817766d5 1420 //
3e55050f 1421 // Process track - Update TPC-ITS alignment
1422 // Updates:
1423 // 0. Apply standartd cuts
1424 // 1. Recalucluate the current statistic median/RMS
1425 // 2. Apply median+-rms cut
1426 // 3. Update kalman filter
1427 //
1428 const Int_t kMinTPC = 80; // minimal number of TPC cluster
1429 const Int_t kMinITS = 3; // minimal number of ITS cluster
1430 const Double_t kMinZ = 10; // maximal dz distance
b96c3aef 1431 const Double_t kMaxDy = 2.; // maximal dy distance
70036ef3 1432 const Double_t kMaxAngle= 0.05; // maximal angular distance
3e55050f 1433 const Double_t kSigmaCut= 5; // maximal sigma distance to median
1434 const Double_t kVdErr = 0.1; // initial uncertainty of the vd correction
97d3fea0 1435 const Double_t kT0Err = 3.; // initial uncertainty of the T0 time
3e55050f 1436 const Double_t kVdYErr = 0.05; // initial uncertainty of the vd correction
1437 const Double_t kOutCut = 1.0; // outlyer cut in AliRelAlgnmentKalman
b96c3aef 1438 const Double_t kMinPt = 0.3; // minimal pt
be67055b 1439 const Int_t kN=50; // deepnes of history
3e55050f 1440 static Int_t kglast=0;
1441 static Double_t* kgdP[4]={new Double_t[kN], new Double_t[kN], new Double_t[kN], new Double_t[kN]};
1442 /*
1443 0. Standrd cuts:
1444 TCut cut="abs(pTPC.fP[2]-pITS.fP[2])<0.01&&abs(pTPC.fP[3]-pITS.fP[3])<0.01&&abs(pTPC.fP[2]-pITS.fP[2])<1";
1445 */
817766d5 1446 //
3e55050f 1447 // 0. Apply standard cuts
817766d5 1448 //
1449 Int_t dummycl[1000];
817766d5 1450 if (track->GetTPCNcls()<kMinTPC) return; // minimal amount of clusters cut
b842d904 1451 if (track->GetITSclusters(dummycl)<kMinITS) return; // minimal amount of clusters
b96c3aef 1452 if (!track->IsOn(AliESDtrack::kTPCrefit)) return;
3e55050f 1453 if (!friendTrack->GetITSOut()) return;
817766d5 1454 if (!track->GetInnerParam()) return;
1455 if (!track->GetOuterParam()) return;
b842d904 1456 if (track->GetInnerParam()->Pt()<kMinPt) return;
817766d5 1457 // exclude crossing track
1458 if (track->GetOuterParam()->GetZ()*track->GetInnerParam()->GetZ()<0) return;
70036ef3 1459 if (TMath::Abs(track->GetInnerParam()->GetZ())<kMinZ/3.) return;
b96c3aef 1460 if (track->GetInnerParam()->GetX()>90) return;
817766d5 1461 //
1462 AliExternalTrackParam &pTPC=(AliExternalTrackParam &)(*(track->GetInnerParam()));
b842d904 1463 AliExternalTrackParam pITS(*(friendTrack->GetITSOut())); // ITS standalone if possible
1464 AliExternalTrackParam pITS2(*(friendTrack->GetITSOut())); //TPC-ITS track
1465 pITS2.Rotate(pTPC.GetAlpha());
be67055b 1466 // pITS2.PropagateTo(pTPC.GetX(),fMagF);
1467 AliTracker::PropagateTrackToBxByBz(&pITS2,pTPC.GetX(),0.1,0.1,kFALSE);
1468
b842d904 1469 AliESDfriendTrack *itsfriendTrack=0;
1470 //
1471 // try to find standalone ITS track corresponing to the TPC if possible
1472 //
1473 Bool_t hasAlone=kFALSE;
1474 Int_t ntracks=event->GetNumberOfTracks();
1475 for (Int_t i=0; i<ntracks; i++){
1476 AliESDtrack *trackS = event->GetTrack(i);
1477 if (trackS->GetTPCNcls()>0) continue; //continue if has TPC info
6ba68367 1478 itsfriendTrack = esdFriend->GetTrack(i);
b842d904 1479 if (!itsfriendTrack) continue;
1480 if (!itsfriendTrack->GetITSOut()) continue;
1481 if (TMath::Abs(pITS2.GetTgl()-itsfriendTrack->GetITSOut()->GetTgl())> kMaxAngle) continue;
1482 pITS=(*(itsfriendTrack->GetITSOut()));
1483 //
1484 pITS.Rotate(pTPC.GetAlpha());
be67055b 1485 //pITS.PropagateTo(pTPC.GetX(),fMagF);
1486 AliTracker::PropagateTrackToBxByBz(&pITS,pTPC.GetX(),0.1,0.1,kFALSE);
b842d904 1487 if (TMath::Abs(pITS2.GetY()-pITS.GetY())> kMaxDy) continue;
1488 hasAlone=kTRUE;
1489 }
1490 if (!hasAlone) pITS=pITS2;
1491 //
3e55050f 1492 if (TMath::Abs(pITS.GetY()-pTPC.GetY()) >kMaxDy) return;
1493 if (TMath::Abs(pITS.GetSnp()-pTPC.GetSnp())>kMaxAngle) return;
1494 if (TMath::Abs(pITS.GetTgl()-pTPC.GetTgl())>kMaxAngle) return;
1495 //
1496 // 1. Update median and RMS info
1497 //
b322e06a 1498 TVectorD vecDelta(5),vecMedian(5), vecRMS(5);
3e55050f 1499 TVectorD vecDeltaN(5);
1500 Double_t sign=(pITS.GetParameter()[1]>0)? 1.:-1.;
1501 vecDelta[4]=0;
1502 for (Int_t i=0;i<4;i++){
1503 vecDelta[i]=(pITS.GetParameter()[i]-pTPC.GetParameter()[i])*sign;
1504 kgdP[i][kglast%kN]=vecDelta[i];
1505 }
1506 kglast=(kglast+1);
1507 Int_t entries=(kglast<kN)?kglast:kN;
1508 for (Int_t i=0;i<4;i++){
1509 vecMedian[i] = TMath::Median(entries,kgdP[i]);
1510 vecRMS[i] = TMath::RMS(entries,kgdP[i]);
1511 vecDeltaN[i] = 0;
1512 if (vecRMS[i]>0.){
1513 vecDeltaN[i] = (vecDelta[i]-vecMedian[i])/vecRMS[i];
1514 vecDeltaN[4]+= TMath::Abs(vecDeltaN[i]); //sum of abs residuals
1515 }
1516 }
817766d5 1517 //
3e55050f 1518 // 2. Apply median+-rms cut
817766d5 1519 //
3e55050f 1520 if (kglast<3) return; //median and RMS to be defined
1521 if ( vecDeltaN[4]/4.>kSigmaCut) return;
1522 //
1523 // 3. Update alignment
817766d5 1524 //
97d3fea0 1525 Int_t htime = (fTime-fTimeKalmanBin/2)/fTimeKalmanBin; //time bins number
4486a91f 1526 if (fAlignITSTPC->GetEntriesFast()<htime){
817766d5 1527 fAlignITSTPC->Expand(htime*2+20);
1528 }
1529 AliRelAlignerKalman* align = (AliRelAlignerKalman*)fAlignITSTPC->At(htime);
1530 if (!align){
3e55050f 1531 // make Alignment object if doesn't exist
817766d5 1532 align=new AliRelAlignerKalman();
3e55050f 1533 align->SetRunNumber(fRun);
1534 (*align->GetStateCov())(6,6)=kVdErr*kVdErr;
97d3fea0 1535 (*align->GetStateCov())(7,7)=kT0Err*kT0Err;
3e55050f 1536 (*align->GetStateCov())(8,8)=kVdYErr*kVdYErr;
1537 align->SetOutRejSigma(kOutCut+kOutCut*kN);
1538 align->SetRejectOutliers(kFALSE);
1539
1540 align->SetTPCvd(AliTPCcalibDB::Instance()->GetParameters()->GetDriftV()/1000000.);
817766d5 1541 align->SetMagField(fMagF);
1542 fAlignITSTPC->AddAt(align,htime);
1543 }
817766d5 1544 align->AddTrackParams(&pITS,&pTPC);
5647625c 1545 Double_t averageTime = fTime;
1546 if (align->GetTimeStamp()>0&&align->GetNUpdates()>0){
97d3fea0 1547 averageTime=((Double_t(align->GetTimeStamp())*Double_t(align->GetNUpdates())+Double_t(fTime)))/(Double_t(align->GetNUpdates())+1.);
5647625c 1548 }
1549 align->SetTimeStamp(Int_t(averageTime));
1550
3e55050f 1551 align->SetRunNumber(fRun );
391ffdb2 1552 Float_t dca[2],cov[3];
1553 track->GetImpactParameters(dca,cov);
882f5c06 1554 if (TMath::Abs(dca[0])<kMaxDy){
391ffdb2 1555 FillResHistoTPCITS(&pTPC,&pITS);
1556 FillResHistoTPC(track);
1557 }
3e55050f 1558 //
1559 Int_t nupdates=align->GetNUpdates();
1560 align->SetOutRejSigma(kOutCut+kOutCut*kN/Double_t(nupdates));
1561 align->SetRejectOutliers(kFALSE);
817766d5 1562 TTreeSRedirector *cstream = GetDebugStreamer();
1563 if (cstream && align->GetState() && align->GetState()->GetNrows()>2 ){
817766d5 1564 TVectorD gpTPC(3), gdTPC(3);
1565 TVectorD gpITS(3), gdITS(3);
1566 pTPC.GetXYZ(gpTPC.GetMatrixArray());
1567 pTPC.GetDirection(gdTPC.GetMatrixArray());
1568 pITS.GetXYZ(gpITS.GetMatrixArray());
1569 pITS.GetDirection(gdITS.GetMatrixArray());
1570 (*cstream)<<"itstpc"<<
1571 "run="<<fRun<< // run number
1572 "event="<<fEvent<< // event number
1573 "time="<<fTime<< // time stamp of event
1574 "trigger="<<fTrigger<< // trigger
1575 "mag="<<fMagF<< // magnetic field
817766d5 1576 //
b842d904 1577 "hasAlone="<<hasAlone<< // has ITS standalone ?
1578 "track.="<<track<< // track info
3e55050f 1579 "nmed="<<kglast<< // number of entries to define median and RMS
1580 "vMed.="<<&vecMedian<< // median of deltas
1581 "vRMS.="<<&vecRMS<< // rms of deltas
1582 "vDelta.="<<&vecDelta<< // delta in respect to median
1583 "vDeltaN.="<<&vecDeltaN<< // normalized delta in respect to median
1584 "t.="<<track<< // ful track - find proper cuts
1585 "a.="<<align<< // current alignment
b842d904 1586 "pITS.="<<&pITS<< // track param ITS
1587 "pITS2.="<<&pITS2<< // track param ITS+TPC
3e55050f 1588 "pTPC.="<<&pTPC<< // track param TPC
1589 "gpTPC.="<<&gpTPC<< // global position TPC
1590 "gdTPC.="<<&gdTPC<< // global direction TPC
1591 "gpITS.="<<&gpITS<< // global position ITS
1592 "gdITS.="<<&gdITS<< // global position ITS
817766d5 1593 "\n";
1594 }
817766d5 1595}
3e55050f 1596
1597
1598
1599
2811495d 1600void AliTPCcalibTime::ProcessAlignTRD(AliESDtrack *const track, AliESDfriendTrack *const friendTrack){
0dac7b3a 1601 //
3e55050f 1602 // Process track - Update TPC-TRD alignment
1603 // Updates:
1604 // 0. Apply standartd cuts
1605 // 1. Recalucluate the current statistic median/RMS
1606 // 2. Apply median+-rms cut
1607 // 3. Update kalman filter
1608 //
1609 const Int_t kMinTPC = 80; // minimal number of TPC cluster
1610 const Int_t kMinTRD = 50; // minimal number of TRD cluster
1611 const Double_t kMinZ = 20; // maximal dz distance
9112627b 1612 const Double_t kMaxDy = 5.; // maximal dy distance
1613 const Double_t kMaxAngle= 0.1; // maximal angular distance
1614 const Double_t kSigmaCut= 10; // maximal sigma distance to median
3e55050f 1615 const Double_t kVdErr = 0.1; // initial uncertainty of the vd correction
97d3fea0 1616 const Double_t kT0Err = 3.; // initial uncertainty of the T0 time
3e55050f 1617 const Double_t kVdYErr = 0.05; // initial uncertainty of the vd correction
1618 const Double_t kOutCut = 1.0; // outlyer cut in AliRelAlgnmentKalman
be67055b 1619 const Double_t kRefX = 275; // reference X
1620 const Int_t kN=50; // deepnes of history
3e55050f 1621 static Int_t kglast=0;
1622 static Double_t* kgdP[4]={new Double_t[kN], new Double_t[kN], new Double_t[kN], new Double_t[kN]};
0dac7b3a 1623 //
3e55050f 1624 // 0. Apply standard cuts
0dac7b3a 1625 //
1626 Int_t dummycl[1000];
1627 if (track->GetTRDclusters(dummycl)<kMinTRD) return; // minimal amount of clusters
1628 if (track->GetTPCNcls()<kMinTPC) return; // minimal amount of clusters cut
3e55050f 1629 if (!friendTrack->GetTRDIn()) return;
be67055b 1630 if (!track->IsOn(AliESDtrack::kTRDrefit)) return;
1631 if (!track->IsOn(AliESDtrack::kTRDout)) return;
0dac7b3a 1632 if (!track->GetInnerParam()) return;
be67055b 1633 if (!friendTrack->GetTPCOut()) return;
0dac7b3a 1634 // exclude crossing track
be67055b 1635 if (friendTrack->GetTPCOut()->GetZ()*track->GetInnerParam()->GetZ()<0) return;
3e55050f 1636 if (TMath::Abs(track->GetInnerParam()->GetZ())<kMinZ) return;
0dac7b3a 1637 //
be67055b 1638 AliExternalTrackParam &pTPC=(AliExternalTrackParam &)(*(friendTrack->GetTPCOut()));
1639 AliTracker::PropagateTrackToBxByBz(&pTPC,kRefX,0.1,0.1,kFALSE);
0dac7b3a 1640 AliExternalTrackParam pTRD(*(friendTrack->GetTRDIn()));
3e55050f 1641 pTRD.Rotate(pTPC.GetAlpha());
be67055b 1642 // pTRD.PropagateTo(pTPC.GetX(),fMagF);
1643 AliTracker::PropagateTrackToBxByBz(&pTRD,pTPC.GetX(),0.1,0.1,kFALSE);
1644
3e55050f 1645 ((Double_t*)pTRD.GetCovariance())[2]+=3.*3.; // increas sys errors
1646 ((Double_t*)pTRD.GetCovariance())[9]+=0.1*0.1; // increse sys errors
1647
1648 if (TMath::Abs(pTRD.GetY()-pTPC.GetY()) >kMaxDy) return;
1649 if (TMath::Abs(pTRD.GetSnp()-pTPC.GetSnp())>kMaxAngle) return;
9112627b 1650 // if (TMath::Abs(pTRD.GetTgl()-pTPC.GetTgl())>kMaxAngle) return;
0dac7b3a 1651 //
3e55050f 1652 // 1. Update median and RMS info
0dac7b3a 1653 //
b322e06a 1654 TVectorD vecDelta(5),vecMedian(5), vecRMS(5);
3e55050f 1655 TVectorD vecDeltaN(5);
1656 Double_t sign=(pTRD.GetParameter()[1]>0)? 1.:-1.;
1657 vecDelta[4]=0;
1658 for (Int_t i=0;i<4;i++){
1659 vecDelta[i]=(pTRD.GetParameter()[i]-pTPC.GetParameter()[i])*sign;
1660 kgdP[i][kglast%kN]=vecDelta[i];
1661 }
1662 kglast=(kglast+1);
1663 Int_t entries=(kglast<kN)?kglast:kN;
1664 for (Int_t i=0;i<4;i++){
1665 vecMedian[i] = TMath::Median(entries,kgdP[i]);
be67055b 1666
3e55050f 1667 vecRMS[i] = TMath::RMS(entries,kgdP[i]);
1668 vecDeltaN[i] = 0;
1669 if (vecRMS[i]>0.){
1670 vecDeltaN[i] = (vecDelta[i]-vecMedian[i])/vecRMS[i];
1671 vecDeltaN[4]+= TMath::Abs(vecDeltaN[i]); //sum of abs residuals
1672 }
1673 }
1674 //
1675 // 2. Apply median+-rms cut
1676 //
1677 if (kglast<3) return; //median and RMS to be defined
1678 if ( vecDeltaN[4]/4.>kSigmaCut) return;
1679 //
1680 // 3. Update alignment
0dac7b3a 1681 //
5647625c 1682 //Int_t htime = fTime/3600; //time in hours
97d3fea0 1683 Int_t htime = (Int_t)(fTime-fTimeKalmanBin/2)/fTimeKalmanBin; //time in half hour
4486a91f 1684 if (fAlignTRDTPC->GetEntriesFast()<htime){
0dac7b3a 1685 fAlignTRDTPC->Expand(htime*2+20);
1686 }
1687 AliRelAlignerKalman* align = (AliRelAlignerKalman*)fAlignTRDTPC->At(htime);
1688 if (!align){
3e55050f 1689 // make Alignment object if doesn't exist
0dac7b3a 1690 align=new AliRelAlignerKalman();
3e55050f 1691 align->SetRunNumber(fRun);
1692 (*align->GetStateCov())(6,6)=kVdErr*kVdErr;
97d3fea0 1693 (*align->GetStateCov())(7,7)=kT0Err*kT0Err;
3e55050f 1694 (*align->GetStateCov())(8,8)=kVdYErr*kVdYErr;
1695 align->SetOutRejSigma(kOutCut+kOutCut*kN);
1696 align->SetRejectOutliers(kFALSE);
1697 align->SetTPCvd(AliTPCcalibDB::Instance()->GetParameters()->GetDriftV()/1000000.);
0dac7b3a 1698 align->SetMagField(fMagF);
1699 fAlignTRDTPC->AddAt(align,htime);
1700 }
0dac7b3a 1701 align->AddTrackParams(&pTRD,&pTPC);
5647625c 1702 //align->SetTimeStamp(fTime);
1703 Double_t averageTime = fTime;
1704 if (align->GetTimeStamp()>0 && align->GetNUpdates()>0) {
1705 averageTime = (((Double_t)fTime) + ((Double_t)align->GetTimeStamp())*align->GetNUpdates()) / (align->GetNUpdates() + 1.);
1706 //printf("align->GetTimeStamp() %d, align->GetNUpdates() %d \n", align->GetTimeStamp(), align->GetNUpdates());
1707 }
1708 align->SetTimeStamp((Int_t)averageTime);
1709
1710 //printf("fTime %d, averageTime %d \n", fTime, (Int_t)averageTime);
1711
3e55050f 1712 align->SetRunNumber(fRun );
0b736a46 1713 Float_t dca[2],cov[3];
1714 track->GetImpactParameters(dca,cov);
1715 if (TMath::Abs(dca[0])<kMaxDy){
1716 FillResHistoTPCTRD(&pTPC,&pTRD); //only primaries
1717 }
3e55050f 1718 //
1719 Int_t nupdates=align->GetNUpdates();
1720 align->SetOutRejSigma(kOutCut+kOutCut*kN/Double_t(nupdates));
1721 align->SetRejectOutliers(kFALSE);
0dac7b3a 1722 TTreeSRedirector *cstream = GetDebugStreamer();
1723 if (cstream && align->GetState() && align->GetState()->GetNrows()>2 ){
0dac7b3a 1724 TVectorD gpTPC(3), gdTPC(3);
1725 TVectorD gpTRD(3), gdTRD(3);
1726 pTPC.GetXYZ(gpTPC.GetMatrixArray());
1727 pTPC.GetDirection(gdTPC.GetMatrixArray());
1728 pTRD.GetXYZ(gpTRD.GetMatrixArray());
1729 pTRD.GetDirection(gdTRD.GetMatrixArray());
3e55050f 1730 (*cstream)<<"trdtpc"<<
0dac7b3a 1731 "run="<<fRun<< // run number
1732 "event="<<fEvent<< // event number
1733 "time="<<fTime<< // time stamp of event
1734 "trigger="<<fTrigger<< // trigger
1735 "mag="<<fMagF<< // magnetic field
0dac7b3a 1736 //
3e55050f 1737 "nmed="<<kglast<< // number of entries to define median and RMS
1738 "vMed.="<<&vecMedian<< // median of deltas
1739 "vRMS.="<<&vecRMS<< // rms of deltas
1740 "vDelta.="<<&vecDelta<< // delta in respect to median
1741 "vDeltaN.="<<&vecDeltaN<< // normalized delta in respect to median
1742 "t.="<<track<< // ful track - find proper cuts
1743 "a.="<<align<< // current alignment
1744 "pTRD.="<<&pTRD<< // track param TRD
1745 "pTPC.="<<&pTPC<< // track param TPC
1746 "gpTPC.="<<&gpTPC<< // global position TPC
1747 "gdTPC.="<<&gdTPC<< // global direction TPC
1748 "gpTRD.="<<&gpTRD<< // global position TRD
1749 "gdTRD.="<<&gdTRD<< // global position TRD
0dac7b3a 1750 "\n";
1751 }
0dac7b3a 1752}
817766d5 1753
1754
2811495d 1755void AliTPCcalibTime::ProcessAlignTOF(AliESDtrack *const track, AliESDfriendTrack *const friendTrack){
817766d5 1756 //
817766d5 1757 //
3e55050f 1758 // Process track - Update TPC-TOF alignment
1759 // Updates:
1760 // -1. Make a TOF "track"
1761 // 0. Apply standartd cuts
1762 // 1. Recalucluate the current statistic median/RMS
1763 // 2. Apply median+-rms cut
1764 // 3. Update kalman filter
1765 //
1766 const Int_t kMinTPC = 80; // minimal number of TPC cluster
b842d904 1767 // const Double_t kMinZ = 10; // maximal dz distance
3e55050f 1768 const Double_t kMaxDy = 5.; // maximal dy distance
70036ef3 1769 const Double_t kMaxAngle= 0.05; // maximal angular distance
3e55050f 1770 const Double_t kSigmaCut= 5; // maximal sigma distance to median
1771 const Double_t kVdErr = 0.1; // initial uncertainty of the vd correction
97d3fea0 1772 const Double_t kT0Err = 3.; // initial uncertainty of the T0 time
3e55050f 1773 const Double_t kVdYErr = 0.05; // initial uncertainty of the vd correction
1774
1775 const Double_t kOutCut = 1.0; // outlyer cut in AliRelAlgnmentKalman
be67055b 1776 const Int_t kN=50; // deepnes of history
3e55050f 1777 static Int_t kglast=0;
1778 static Double_t* kgdP[4]={new Double_t[kN], new Double_t[kN], new Double_t[kN], new Double_t[kN]};
817766d5 1779 //
3e55050f 1780 // -1. Make a TOF track-
1781 // Clusters are not in friends - use alingment points
1782 //
1783 if (track->GetTOFsignal()<=0) return;
1784 if (!friendTrack->GetTPCOut()) return;
1785 if (!track->GetInnerParam()) return;
be67055b 1786 if (!friendTrack->GetTPCOut()) return;
817766d5 1787 const AliTrackPointArray *points=friendTrack->GetTrackPointArray();
1788 if (!points) return;
be67055b 1789 AliExternalTrackParam pTPC(*(friendTrack->GetTPCOut()));
3e55050f 1790 AliExternalTrackParam pTOF(pTPC);
1791 Double_t mass = TDatabasePDG::Instance()->GetParticle("mu+")->Mass();
817766d5 1792 Int_t npoints = points->GetNPoints();
1793 AliTrackPoint point;
3e55050f 1794 Int_t naccept=0;
817766d5 1795 //
1796 for (Int_t ipoint=0;ipoint<npoints;ipoint++){
817766d5 1797 points->GetPoint(point,ipoint);
1798 Float_t xyz[3];
1799 point.GetXYZ(xyz);
1800 Double_t r=TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
3e55050f 1801 if (r<350) continue;
817766d5 1802 if (r>400) continue;
3e55050f 1803 AliTracker::PropagateTrackToBxByBz(&pTPC,r,mass,2.,kTRUE);
1804 AliTracker::PropagateTrackToBxByBz(&pTPC,r,mass,0.1,kTRUE);
1805 AliTrackPoint lpoint = point.Rotate(pTPC.GetAlpha());
1806 pTPC.PropagateTo(lpoint.GetX(),fMagF);
1807 pTOF=pTPC;
817766d5 1808 ((Double_t*)pTOF.GetParameter())[0] =lpoint.GetY();
1809 ((Double_t*)pTOF.GetParameter())[1] =lpoint.GetZ();
3e55050f 1810 ((Double_t*)pTOF.GetCovariance())[0]+=3.*3./12.;
1811 ((Double_t*)pTOF.GetCovariance())[2]+=3.*3./12.;
0dac7b3a 1812 ((Double_t*)pTOF.GetCovariance())[5]+=0.1*0.1;
1813 ((Double_t*)pTOF.GetCovariance())[9]+=0.1*0.1;
3e55050f 1814 naccept++;
1815 }
1816 if (naccept==0) return; // no tof match clusters
1817 //
1818 // 0. Apply standard cuts
1819 //
1820 if (track->GetTPCNcls()<kMinTPC) return; // minimal amount of clusters cut
1821 // exclude crossing track
be67055b 1822 if (friendTrack->GetTPCOut()->GetZ()*track->GetInnerParam()->GetZ()<0) return;
3e55050f 1823 //
1824 if (TMath::Abs(pTOF.GetY()-pTPC.GetY()) >kMaxDy) return;
1825 if (TMath::Abs(pTOF.GetSnp()-pTPC.GetSnp())>kMaxAngle) return;
1826 if (TMath::Abs(pTOF.GetTgl()-pTPC.GetTgl())>kMaxAngle) return;
1827 //
1828 // 1. Update median and RMS info
1829 //
b322e06a 1830 TVectorD vecDelta(5),vecMedian(5), vecRMS(5);
3e55050f 1831 TVectorD vecDeltaN(5);
1832 Double_t sign=(pTOF.GetParameter()[1]>0)? 1.:-1.;
1833 vecDelta[4]=0;
1834 for (Int_t i=0;i<4;i++){
1835 vecDelta[i]=(pTOF.GetParameter()[i]-pTPC.GetParameter()[i])*sign;
1836 kgdP[i][kglast%kN]=vecDelta[i];
1837 }
1838 kglast=(kglast+1);
1839 Int_t entries=(kglast<kN)?kglast:kN;
1840 Bool_t isOK=kTRUE;
1841 for (Int_t i=0;i<4;i++){
1842 vecMedian[i] = TMath::Median(entries,kgdP[i]);
1843 vecRMS[i] = TMath::RMS(entries,kgdP[i]);
1844 vecDeltaN[i] = 0;
1845 if (vecRMS[i]>0.){
1846 vecDeltaN[i] = (vecDelta[i]-vecMedian[i])/(vecRMS[i]+1.);
1847 vecDeltaN[4]+= TMath::Abs(vecDeltaN[i]); //sum of abs residuals
1848 if (TMath::Abs(vecDeltaN[i])>kSigmaCut) isOK=kFALSE;
817766d5 1849 }
3e55050f 1850 }
1851 //
1852 // 2. Apply median+-rms cut
1853 //
1854 if (kglast<10) return; //median and RMS to be defined
1855 if (!isOK) return;
1856 //
1857 // 3. Update alignment
1858 //
5647625c 1859 //Int_t htime = fTime/3600; //time in hours
97d3fea0 1860 Int_t htime = (Int_t)(fTime-fTimeKalmanBin)/fTimeKalmanBin; //time bin
4486a91f 1861 if (fAlignTOFTPC->GetEntriesFast()<htime){
3e55050f 1862 fAlignTOFTPC->Expand(htime*2+20);
1863 }
1864 AliRelAlignerKalman* align = (AliRelAlignerKalman*)fAlignTOFTPC->At(htime);
1865 if (!align){
1866 // make Alignment object if doesn't exist
1867 align=new AliRelAlignerKalman();
1868 align->SetRunNumber(fRun);
1869 (*align->GetStateCov())(6,6)=kVdErr*kVdErr;
97d3fea0 1870 (*align->GetStateCov())(7,7)=kT0Err*kT0Err;
3e55050f 1871 (*align->GetStateCov())(8,8)=kVdYErr*kVdYErr;
1872 align->SetOutRejSigma(kOutCut+kOutCut*kN);
1873 align->SetRejectOutliers(kFALSE);
1874 align->SetTPCvd(AliTPCcalibDB::Instance()->GetParameters()->GetDriftV()/1000000.);
1875 align->SetMagField(fMagF);
1876 fAlignTOFTPC->AddAt(align,htime);
1877 }
1878 align->AddTrackParams(&pTOF,&pTPC);
0b736a46 1879 Float_t dca[2],cov[3];
1880 track->GetImpactParameters(dca,cov);
1881 if (TMath::Abs(dca[0])<kMaxDy){
1882 FillResHistoTPCTOF(&pTPC,&pTOF);
1883 }
5647625c 1884 //align->SetTimeStamp(fTime);
1885 Double_t averageTime = fTime;
1886 if (align->GetTimeStamp()>0 && align->GetNUpdates()>0) {
1887 averageTime = (((Double_t)fTime) + ((Double_t)align->GetTimeStamp())*align->GetNUpdates()) / (align->GetNUpdates() + 1.);
1888 //printf("align->GetTimeStamp() %d, align->GetNUpdates() %d \n", align->GetTimeStamp(), align->GetNUpdates());
1889 }
1890 align->SetTimeStamp((Int_t)averageTime);
1891
1892 //printf("fTime %d, averageTime %d \n", fTime, (Int_t)averageTime);
1893
3e55050f 1894 align->SetRunNumber(fRun );
1895 //
1896 Int_t nupdates=align->GetNUpdates();
1897 align->SetOutRejSigma(kOutCut+kOutCut*kN/Double_t(nupdates));
1898 align->SetRejectOutliers(kFALSE);
1899 TTreeSRedirector *cstream = GetDebugStreamer();
1900 if (cstream && align->GetState() && align->GetState()->GetNrows()>2 ){
3e55050f 1901 TVectorD gpTPC(3), gdTPC(3);
1902 TVectorD gpTOF(3), gdTOF(3);
1903 pTPC.GetXYZ(gpTPC.GetMatrixArray());
1904 pTPC.GetDirection(gdTPC.GetMatrixArray());
1905 pTOF.GetXYZ(gpTOF.GetMatrixArray());
1906 pTOF.GetDirection(gdTOF.GetMatrixArray());
1907 (*cstream)<<"toftpc"<<
1908 "run="<<fRun<< // run number
1909 "event="<<fEvent<< // event number
1910 "time="<<fTime<< // time stamp of event
1911 "trigger="<<fTrigger<< // trigger
1912 "mag="<<fMagF<< // magnetic field
3e55050f 1913 //
1914 "nmed="<<kglast<< // number of entries to define median and RMS
1915 "vMed.="<<&vecMedian<< // median of deltas
1916 "vRMS.="<<&vecRMS<< // rms of deltas
1917 "vDelta.="<<&vecDelta<< // delta in respect to median
1918 "vDeltaN.="<<&vecDeltaN<< // normalized delta in respect to median
1919 "t.="<<track<< // ful track - find proper cuts
1920 "a.="<<align<< // current alignment
1921 "pTOF.="<<&pTOF<< // track param TOF
1922 "pTPC.="<<&pTPC<< // track param TPC
1923 "gpTPC.="<<&gpTPC<< // global position TPC
1924 "gdTPC.="<<&gdTPC<< // global direction TPC
1925 "gpTOF.="<<&gpTOF<< // global position TOF
1926 "gdTOF.="<<&gdTOF<< // global position TOF
1927 "\n";
817766d5 1928 }
817766d5 1929}
3e55050f 1930
1931
391ffdb2 1932void AliTPCcalibTime::BookDistortionMaps(){
1933 //
1934 // Book ndimensional histograms of distortions/residuals
1935 // Only primary tracks are selected for analysis
1936 //
1937
b9908d0b 1938 Double_t xminTrack[5], xmaxTrack[5];
1939 Int_t binsTrack[5];
1940 TString axisName[5];
1941 TString axisTitle[5];
391ffdb2 1942 //
882f5c06 1943 binsTrack[0] =50;
391ffdb2 1944 axisName[0] ="#Delta";
1945 axisTitle[0] ="#Delta";
1946 //
70036ef3 1947 binsTrack[1] =44;
1948 xminTrack[1] =-1.1; xmaxTrack[1]=1.1;
391ffdb2 1949 axisName[1] ="tanTheta";
1950 axisTitle[1] ="tan(#Theta)";
1951 //
70036ef3 1952 binsTrack[2] =180;
391ffdb2 1953 xminTrack[2] =-TMath::Pi(); xmaxTrack[2]=TMath::Pi();
1954 axisName[2] ="phi";
1955 axisTitle[2] ="#phi";
1956 //
1957 binsTrack[3] =20;
1958 xminTrack[3] =-1.; xmaxTrack[3]=1.; // 0.33 GeV cut
1959 axisName[3] ="snp";
b9908d0b 1960 axisTitle[3] ="snp";
1961 //
1962 binsTrack[4] =10;
1963 xminTrack[4] =120.; xmaxTrack[4]=215.; // crossing radius for CE only
1964 axisName[4] ="r";
1965 axisTitle[4] ="r(cm)";
391ffdb2 1966 //
1967 // delta y
be67055b 1968 xminTrack[0] =-1.5; xmaxTrack[0]=1.5; //
b9908d0b 1969 fResHistoTPCCE[0] = new THnSparseS("TPCCE#Delta_{Y} (cm)","#Delta_{Y} (cm)", 5, binsTrack,xminTrack, xmaxTrack);
391ffdb2 1970 fResHistoTPCITS[0] = new THnSparseS("TPCITS#Delta_{Y} (cm)","#Delta_{Y} (cm)", 4, binsTrack,xminTrack, xmaxTrack);
1971 fResHistoTPCvertex[0] = new THnSparseS("TPCVertex#Delta_{Y} (cm)","#Delta_{Y} (cm)", 4, binsTrack,xminTrack, xmaxTrack);
be67055b 1972 xminTrack[0] =-1.5; xmaxTrack[0]=1.5; //
391ffdb2 1973 fResHistoTPCTRD[0] = new THnSparseS("TPCTRD#Delta_{Y} (cm)","#Delta_{Y} (cm)", 4, binsTrack,xminTrack, xmaxTrack);
0b736a46 1974 xminTrack[0] =-5; xmaxTrack[0]=5; //
1975 fResHistoTPCTOF[0] = new THnSparseS("TPCTOF#Delta_{Y} (cm)","#Delta_{Y} (cm)", 4, binsTrack,xminTrack, xmaxTrack);
391ffdb2 1976 //
1977 // delta z
9112627b 1978 xminTrack[0] =-3.; xmaxTrack[0]=3.; //
b9908d0b 1979 fResHistoTPCCE[1] = new THnSparseS("TPCCE#Delta_{Z} (cm)","#Delta_{Z} (cm)", 5, binsTrack,xminTrack, xmaxTrack);
391ffdb2 1980 fResHistoTPCITS[1] = new THnSparseS("TPCITS#Delta_{Z} (cm)","#Delta_{Z} (cm)", 4, binsTrack,xminTrack, xmaxTrack);
1981 fResHistoTPCvertex[1] = new THnSparseS("TPCVertex#Delta_{Z} (cm)","#Delta_{Z} (cm)", 4, binsTrack,xminTrack, xmaxTrack);
1982 fResHistoTPCTRD[1] = new THnSparseS("TPCTRD#Delta_{Z} (cm)","#Delta_{Z} (cm)", 4, binsTrack,xminTrack, xmaxTrack);
0b736a46 1983 xminTrack[0] =-5.; xmaxTrack[0]=5.; //
1984 fResHistoTPCTOF[1] = new THnSparseS("TPCTOF#Delta_{Z} (cm)","#Delta_{Z} (cm)", 4, binsTrack,xminTrack, xmaxTrack);
391ffdb2 1985 //
1986 // delta snp-P2
882f5c06 1987 xminTrack[0] =-0.015; xmaxTrack[0]=0.015; //
b9908d0b 1988 fResHistoTPCCE[2] = new THnSparseS("TPCCE#Delta_{#phi}","#Delta_{#phi}", 5, binsTrack,xminTrack, xmaxTrack);
391ffdb2 1989 fResHistoTPCITS[2] = new THnSparseS("TPCITS#Delta_{#phi}","#Delta_{#phi}", 4, binsTrack,xminTrack, xmaxTrack);
9112627b 1990 fResHistoTPCvertex[2] = new THnSparseS("TPCITSv#Delta_{#phi}","#Delta_{#phi}", 4, binsTrack,xminTrack, xmaxTrack);
391ffdb2 1991 fResHistoTPCTRD[2] = new THnSparseS("TPCTRD#Delta_{#phi}","#Delta_{#phi}", 4, binsTrack,xminTrack, xmaxTrack);
0b736a46 1992 fResHistoTPCTOF[2] = new THnSparseS("TPCTOF#Delta_{#phi}","#Delta_{#phi}", 4, binsTrack,xminTrack, xmaxTrack);
391ffdb2 1993 //
1994 // delta theta-P3
9112627b 1995 xminTrack[0] =-0.025; xmaxTrack[0]=0.025; //
b9908d0b 1996 fResHistoTPCCE[3] = new THnSparseS("TPCCE#Delta_{#theta}","#Delta_{#theta}", 5, binsTrack,xminTrack, xmaxTrack);
391ffdb2 1997 fResHistoTPCITS[3] = new THnSparseS("TPCITS#Delta_{#theta}","#Delta_{#theta}", 4, binsTrack,xminTrack, xmaxTrack);
9112627b 1998 fResHistoTPCvertex[3] = new THnSparseS("TPCITSv#Delta_{#theta}","#Delta_{#theta}", 4, binsTrack,xminTrack, xmaxTrack);
391ffdb2 1999 fResHistoTPCTRD[3] = new THnSparseS("TPCTRD#Delta_{#theta}","#Delta_{#theta}", 4, binsTrack,xminTrack, xmaxTrack);
0b736a46 2000 fResHistoTPCTOF[3] = new THnSparseS("TPCTOF#Delta_{#theta}","#Delta_{#theta}", 4, binsTrack,xminTrack, xmaxTrack);
391ffdb2 2001 //
2002 // delta theta-P4
9112627b 2003 xminTrack[0] =-0.2; xmaxTrack[0]=0.2; //
b9908d0b 2004 fResHistoTPCCE[4] = new THnSparseS("TPCCE#Delta_{1/pt}","#Delta_{1/pt}", 5, binsTrack,xminTrack, xmaxTrack);
391ffdb2 2005 fResHistoTPCITS[4] = new THnSparseS("TPCITS#Delta_{1/pt}","#Delta_{1/pt}", 4, binsTrack,xminTrack, xmaxTrack);
9112627b 2006 fResHistoTPCvertex[4] = new THnSparseS("TPCITSv#Delta_{1/pt}","#Delta_{1/pt}", 4, binsTrack,xminTrack, xmaxTrack);
391ffdb2 2007 fResHistoTPCTRD[4] = new THnSparseS("TPCTRD#Delta_{1/pt}","#Delta_{1/pt}", 4, binsTrack,xminTrack, xmaxTrack);
0b736a46 2008 fResHistoTPCTOF[4] = new THnSparseS("TPCTOF#Delta_{1/pt}","#Delta_{1/pt}", 4, binsTrack,xminTrack, xmaxTrack);
391ffdb2 2009 //
2010 for (Int_t ivar=0;ivar<4;ivar++){
b9908d0b 2011 for (Int_t ivar2=0;ivar2<5;ivar2++){
2012 fResHistoTPCCE[ivar]->GetAxis(ivar2)->SetName(axisName[ivar2].Data());
2013 fResHistoTPCCE[ivar]->GetAxis(ivar2)->SetTitle(axisTitle[ivar2].Data());
2014 if (ivar2<4){
2015 fResHistoTPCITS[ivar]->GetAxis(ivar2)->SetName(axisName[ivar2].Data());
2016 fResHistoTPCITS[ivar]->GetAxis(ivar2)->SetTitle(axisTitle[ivar2].Data());
2017 fResHistoTPCTRD[ivar]->GetAxis(ivar2)->SetName(axisName[ivar2].Data());
2018 fResHistoTPCTRD[ivar]->GetAxis(ivar2)->SetTitle(axisTitle[ivar2].Data());
2019 fResHistoTPCvertex[ivar]->GetAxis(ivar2)->SetName(axisName[ivar2].Data());
2020 fResHistoTPCvertex[ivar]->GetAxis(ivar2)->SetTitle(axisTitle[ivar2].Data());
2021 }
391ffdb2 2022 }
2023 }
70036ef3 2024 //
2025 // Book vertex: time histograms
2026 //
2027 Int_t binsVertex[2]={500, fTimeBins};
2028 Double_t aminVertex[2]={-5,fTimeStart};
2029 Double_t amaxVertex[2]={5, fTimeEnd};
2030 const char* hnames[12]={"TPCXAside", "TPCXCside","TPCXACdiff","TPCXAPCdiff",
2031 "TPCYAside", "TPCYCside","TPCYACdiff","TPCYAPCdiff",
2032 "TPCZAPCside", "TPCZAMCside","TPCZACdiff","TPCZAPCdiff"};
2033 const char* anames[12]={"x (cm) - A side ", "x (cm) - C side","#Delta_{x} (cm) - TPC-A-C","#Delta_{x} (cm) - TPC-Common",
2034 "y (cm) - A side ", "y (cm) - C side","#Delta_{x} (cm) - TPC-A-C","#Delta_{y} (cm) - TPC-Common",
2035 "z (cm)", "#Delta_{Z} (cm) A-C side","#Delta_{x} (cm) - TPC-A-C","#Delta_{Z} (cm) TPC-common"};
2036 for (Int_t ihis=0; ihis<12; ihis++) {
2037 if (ihis>=8) aminVertex[0]=-20.;
2038 if (ihis>=8) amaxVertex[0]=20.;
2039 fTPCVertex[ihis]=new THnSparseF(hnames[ihis],hnames[ihis],2,binsVertex,aminVertex,amaxVertex);
2040 fTPCVertex[ihis]->GetAxis(1)->SetTitle("Time");
2041 fTPCVertex[ihis]->GetAxis(0)->SetTitle(anames[ihis]);
2042 }
391ffdb2 2043}
2044
2045
b9908d0b 2046void AliTPCcalibTime::FillResHistoTPCCE(const AliExternalTrackParam * pTPCIn, const AliExternalTrackParam * pTPCOut ){
2047 //
2048 // fill residual histograms pTPCOut-pTPCin - trac crossing CE
2049 // Histogram
2050 //
660f0543 2051 if (fMemoryMode<2) return;
b9908d0b 2052 Double_t histoX[5];
2053 Double_t xyz[3];
2054 pTPCIn->GetXYZ(xyz);
2055 Double_t phi= TMath::ATan2(xyz[1],xyz[0]);
2056 histoX[1]= pTPCIn->GetTgl();
2057 histoX[2]= phi;
2058 histoX[3]= pTPCIn->GetSnp();
2059 histoX[4]= pTPCIn->GetX();
2060 AliExternalTrackParam lout(*pTPCOut);
2061 lout.Rotate(pTPCIn->GetAlpha());
2062 lout.PropagateTo(pTPCIn->GetX(),fMagF);
2063 //
2064 for (Int_t ihisto=0; ihisto<5; ihisto++){
2065 histoX[0]=lout.GetParameter()[ihisto]-pTPCIn->GetParameter()[ihisto];
2066 fResHistoTPCCE[ihisto]->Fill(histoX);
2067 }
2068}
391ffdb2 2069void AliTPCcalibTime::FillResHistoTPCITS(const AliExternalTrackParam * pTPCIn, const AliExternalTrackParam * pITSOut ){
2070 //
2071 // fill residual histograms pTPCIn-pITSOut
2072 // Histogram is filled only for primary tracks
2073 //
2074 Double_t histoX[4];
2075 Double_t xyz[3];
2076 pTPCIn->GetXYZ(xyz);
2077 Double_t phi= TMath::ATan2(xyz[1],xyz[0]);
2078 histoX[1]= pTPCIn->GetTgl();
2079 histoX[2]= phi;
2080 histoX[3]= pTPCIn->GetSnp();
9112627b 2081 AliExternalTrackParam lits(*pITSOut);
2082 lits.Rotate(pTPCIn->GetAlpha());
2083 lits.PropagateTo(pTPCIn->GetX(),fMagF);
391ffdb2 2084 //
2085 for (Int_t ihisto=0; ihisto<5; ihisto++){
9112627b 2086 histoX[0]=pTPCIn->GetParameter()[ihisto]-lits.GetParameter()[ihisto];
391ffdb2 2087 fResHistoTPCITS[ihisto]->Fill(histoX);
2088 }
2089}
2090
2091
2092void AliTPCcalibTime::FillResHistoTPC(const AliESDtrack * pTrack){
2093 //
2094 // fill residual histograms pTPC - vertex
2095 // Histogram is filled only for primary tracks
2096 //
660f0543 2097 if (fMemoryMode<2) return;
391ffdb2 2098 Double_t histoX[4];
2099 const AliExternalTrackParam * pTPCIn = pTrack->GetInnerParam();
be67055b 2100 AliExternalTrackParam pTPCvertex(*(pTrack->GetInnerParam()));
9112627b 2101 //
2102 AliExternalTrackParam lits(*pTrack);
be67055b 2103 if (TMath::Abs(pTrack->GetY())>3) return; // beam pipe
2104 pTPCvertex.Rotate(lits.GetAlpha());
2105 //pTPCvertex.PropagateTo(pTPCvertex->GetX(),fMagF);
2106 AliTracker::PropagateTrackToBxByBz(&pTPCvertex,lits.GetX(),0.1,2,kFALSE);
2107 AliTracker::PropagateTrackToBxByBz(&pTPCvertex,lits.GetX(),0.1,0.1,kFALSE);
391ffdb2 2108 Double_t xyz[3];
2109 pTPCIn->GetXYZ(xyz);
2110 Double_t phi= TMath::ATan2(xyz[1],xyz[0]);
2111 histoX[1]= pTPCIn->GetTgl();
2112 histoX[2]= phi;
2113 histoX[3]= pTPCIn->GetSnp();
2114 //
2115 Float_t dca[2], cov[3];
2116 pTrack->GetImpactParametersTPC(dca,cov);
882f5c06 2117 for (Int_t ihisto=0; ihisto<5; ihisto++){
be67055b 2118 histoX[0]=pTPCvertex.GetParameter()[ihisto]-lits.GetParameter()[ihisto];
2119 // if (ihisto<2) histoX[0]=dca[ihisto];
9112627b 2120 fResHistoTPCvertex[ihisto]->Fill(histoX);
391ffdb2 2121 }
2122}
2123
2124
2125void AliTPCcalibTime::FillResHistoTPCTRD(const AliExternalTrackParam * pTPCOut, const AliExternalTrackParam * pTRDIn ){
2126 //
2127 // fill resuidual histogram TPCout-TRDin
2128 //
660f0543 2129 if (fMemoryMode<2) return;
391ffdb2 2130 Double_t histoX[4];
2131 Double_t xyz[3];
2132 pTPCOut->GetXYZ(xyz);
2133 Double_t phi= TMath::ATan2(xyz[1],xyz[0]);
2134 histoX[1]= pTPCOut->GetTgl();
2135 histoX[2]= phi;
2136 histoX[3]= pTPCOut->GetSnp();
2137 //
882f5c06 2138 AliExternalTrackParam ltrd(*pTRDIn);
2139 ltrd.Rotate(pTPCOut->GetAlpha());
be67055b 2140 // ltrd.PropagateTo(pTPCOut->GetX(),fMagF);
2141 AliTracker::PropagateTrackToBxByBz(&ltrd,pTPCOut->GetX(),0.1,0.1,kFALSE);
882f5c06 2142
391ffdb2 2143 for (Int_t ihisto=0; ihisto<5; ihisto++){
882f5c06 2144 histoX[0]=pTPCOut->GetParameter()[ihisto]-ltrd.GetParameter()[ihisto];
391ffdb2 2145 fResHistoTPCTRD[ihisto]->Fill(histoX);
2146 }
2147
2148}
0b736a46 2149
2150void AliTPCcalibTime::FillResHistoTPCTOF(const AliExternalTrackParam * pTPCOut, const AliExternalTrackParam * pTOFIn ){
2151 //
2152 // fill resuidual histogram TPCout-TOFin
2153 // track propagated to the TOF position
660f0543 2154 if (fMemoryMode<2) return;
0b736a46 2155 Double_t histoX[4];
2156 Double_t xyz[3];
2157
2158 AliExternalTrackParam ltpc(*pTPCOut);
2159 ltpc.Rotate(pTOFIn->GetAlpha());
2160 AliTracker::PropagateTrackToBxByBz(&ltpc,pTOFIn->GetX(),0.1,0.1,kFALSE);
2161 //
2162 ltpc.GetXYZ(xyz);
2163 Double_t phi= TMath::ATan2(xyz[1],xyz[0]);
2164 histoX[1]= ltpc.GetTgl();
2165 histoX[2]= phi;
2166 histoX[3]= ltpc.GetSnp();
2167 //
2168 for (Int_t ihisto=0; ihisto<2; ihisto++){
2169 histoX[0]=ltpc.GetParameter()[ihisto]-pTOFIn->GetParameter()[ihisto];
2170 fResHistoTPCTOF[ihisto]->Fill(histoX);
2171 }
2172
2173}