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