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