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