removing obsolete function DumpMaterialBudget
[u/mrichter/AliRoot.git] / TPC / AliTPCcalibCosmic.cxx
CommitLineData
76c58ee2 1
2
f7f33dec 3/**************************************************************************
4 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * *
6 * Author: The ALICE Off-line Project. *
7 * Contributors are mentioned in the code where appropriate. *
8 * *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
17
54b76c13 18/*
108953e9 19 Comments to be written here:
54b76c13 20 1. What do we calibrate.
21 2. How to interpret results
22 3. Simple example
23 4. Analysis using debug streamers.
24
25
26
27 3.Simple example
28 // To make cosmic scan the user interaction neccessary
29 //
236f5592 30
b9908d0b 31 */
54b76c13 32
33
34
f7f33dec 35#include "Riostream.h"
36#include "TChain.h"
37#include "TTree.h"
38#include "TH1F.h"
39#include "TH2F.h"
40#include "TList.h"
41#include "TMath.h"
42#include "TCanvas.h"
43#include "TFile.h"
54b76c13 44#include "TF1.h"
91fd44c9 45#include "THnSparse.h"
9963b5e2 46#include "TDatabasePDG.h"
f7f33dec 47
54b76c13 48#include "AliTPCclusterMI.h"
f7f33dec 49#include "AliTPCseed.h"
50#include "AliESDVertex.h"
51#include "AliESDEvent.h"
52#include "AliESDfriend.h"
53#include "AliESDInputHandler.h"
54b76c13 54#include "AliAnalysisManager.h"
f7f33dec 55
56#include "AliTracker.h"
f7a1cc68 57#include "AliMagF.h"
54b76c13 58#include "AliTPCCalROC.h"
76c58ee2 59#include "AliTPCParam.h"
f7f33dec 60#include "AliLog.h"
61
62#include "AliTPCcalibCosmic.h"
f7f33dec 63#include "TTreeStream.h"
64#include "AliTPCTracklet.h"
3326b323 65//#include "AliESDcosmic.h"
76c58ee2 66#include "AliRecoParam.h"
67#include "AliMultiplicity.h"
68#include "AliTPCTransform.h"
69#include "AliTPCcalibDB.h"
70#include "AliTPCseed.h"
71#include "AliGRPObject.h"
72#include "AliTPCCorrection.h"
f7f33dec 73ClassImp(AliTPCcalibCosmic)
74
75
76AliTPCcalibCosmic::AliTPCcalibCosmic()
77 :AliTPCcalibBase(),
9b27d39b 78 fHistNTracks(0),
79 fClusters(0),
80 fModules(0),
81 fHistPt(0),
9b27d39b 82 fDeDx(0),
54b76c13 83 fDeDxMIP(0),
84 fMIPvalue(1),
9b27d39b 85 fCutMaxD(5), // maximal distance in rfi ditection
a6dc0cf6 86 fCutMaxDz(40), // maximal distance in z ditection
9b27d39b 87 fCutTheta(0.03), // maximal distan theta
76c58ee2 88 fCutMinDir(-0.99), // direction vector products
89 fCosmicTree(0) // tree with cosmic data
f7f33dec 90{
236f5592 91 //
92 // CONSTRUCTOR - SEE COMMENTS ABOVE
93 //
54b76c13 94 AliInfo("Default Constructor");
91fd44c9 95 for (Int_t ihis=0; ihis<6;ihis++){
96 fHistoDelta[ihis]=0;
97 fHistoPull[ihis]=0;
8a92e133 98 }
99 for (Int_t ihis=0; ihis<4;ihis++){
100 fHistodEdxMax[ihis] =0;
101 fHistodEdxTot[ihis] =0;
91fd44c9 102 }
f7f33dec 103}
104
105
106AliTPCcalibCosmic::AliTPCcalibCosmic(const Text_t *name, const Text_t *title)
107 :AliTPCcalibBase(),
9b27d39b 108 fHistNTracks(0),
109 fClusters(0),
110 fModules(0),
111 fHistPt(0),
9b27d39b 112 fDeDx(0),
54b76c13 113 fDeDxMIP(0),
114 fMIPvalue(1),
a6dc0cf6 115 fCutMaxD(5), // maximal distance in rfi ditection
116 fCutMaxDz(40), // maximal distance in z ditection
9b27d39b 117 fCutTheta(0.03), // maximal distan theta
76c58ee2 118 fCutMinDir(-0.99), // direction vector products
119 fCosmicTree(0) // tree with cosmic data
f7f33dec 120{
236f5592 121 //
122 // cONSTRUCTOR - SEE COMENTS ABOVE
123 //
f7f33dec 124 SetName(name);
125 SetTitle(title);
54b76c13 126
127 fHistNTracks = new TH1F("ntracks","Number of Tracks per Event; number of tracks per event; number of tracks",501,-0.5,500.5);
128 fClusters = new TH1F("signal","Number of Clusters per track; number of clusters per track n_{cl}; counts",160,0,160);
129 fModules = new TH2F("sector","Acorde hits; z (cm); x(cm)",1200,-650,650,600,-700,700);
130 fHistPt = new TH1F("Pt","Pt distribution; p_{T} (GeV); counts",2000,0,50);
131 fDeDx = new TH2F("DeDx","dEdx; momentum p (GeV); TPC signal (a.u.)",500,0.01,100.,500,2.,1000);
f7f33dec 132 BinLogX(fDeDx);
54b76c13 133 fDeDxMIP = new TH1F("DeDxMIP","MIP region; TPC signal (a.u.);counts ",500,2.,1000);
91fd44c9 134 Init();
9b27d39b 135 AliInfo("Non Default Constructor");
bca20570 136 //
f7f33dec 137}
138
139AliTPCcalibCosmic::~AliTPCcalibCosmic(){
140 //
236f5592 141 // destructor
f7f33dec 142 //
91fd44c9 143 for (Int_t ihis=0; ihis<6;ihis++){
144 delete fHistoDelta[ihis];
145 delete fHistoPull[ihis];
91fd44c9 146 }
8a92e133 147 for (Int_t ihis=0; ihis<4;ihis++){
148 delete fHistodEdxTot[ihis];
149 delete fHistodEdxMax[ihis];
150 }
151
152 delete fHistNTracks; // histogram showing number of ESD tracks per event
153 delete fClusters; // histogram showing the number of clusters per track
154 delete fModules; // 2d histogram of tracks which are propagated to the ACORDE scintillator array
155 delete fHistPt; // Pt histogram of reconstructed tracks
156 delete fDeDx; // dEdx spectrum showing the different particle types
157 delete fDeDxMIP; // TPC signal close to the MIP region of muons 0.4 < p < 0.45 GeV
f7f33dec 158}
159
160
91fd44c9 161void AliTPCcalibCosmic::Init(){
162 //
163 // init component
164 // Make performance histograms
165 //
166
167 // tracking performance bins
168 // 0 - delta of interest
169 // 1 - min (track0, track1) number of clusters
170 // 2 - R - vertex radius
171 // 3 - P1 - mean z
172 // 4 - P2 - snp(phi) at inner wall of TPC
173 // 5 - P3 - tan(theta) at inner wall of TPC
174 // 6 - P4 - 1/pt mean
175 // 7 - pt - pt mean
176 // 8 - alpha
76c58ee2 177 // 9 - is corss indicator
178 Int_t ndim=10;
179 Double_t xminTrack[10], xmaxTrack[10];
180 Int_t binsTrack[10];
181 TString axisName[10];
91fd44c9 182 //
183 binsTrack[0] =100;
184 axisName[0] ="#Delta";
185 //
186 binsTrack[1] =8;
187 xminTrack[1] =80; xmaxTrack[1]=160;
188 axisName[1] ="N_{cl}";
189 //
190 binsTrack[2] =10;
191 xminTrack[2] =0; xmaxTrack[2]=90; //
192 axisName[2] ="dca_{r} (cm)";
193 //
194 binsTrack[3] =25;
195 xminTrack[3] =-250; xmaxTrack[3]=250; //
196 axisName[3] ="z (cm)";
197 //
198 binsTrack[4] =10;
199 xminTrack[4] =-0.8; xmaxTrack[4]=0.8; //
200 axisName[4] ="sin(#phi)";
201 //
202 binsTrack[5] =10;
203 xminTrack[5] =-1; xmaxTrack[5]=1; //
8a92e133 204 axisName[5] ="tan(#theta)";
91fd44c9 205 //
a390f11f 206 binsTrack[6] =40;
207 xminTrack[6] =-2; xmaxTrack[6]=2; //
91fd44c9 208 axisName[6] ="1/pt (1/GeV)";
209 //
76c58ee2 210 binsTrack[7] =50;
211 xminTrack[7] =1; xmaxTrack[7]=1000; //
8a92e133 212 axisName[7] ="pt (GeV)";
91fd44c9 213 //
a390f11f 214 binsTrack[8] =18;
91fd44c9 215 xminTrack[8] =0; xmaxTrack[8]=TMath::Pi(); //
216 axisName[8] ="alpha";
217 //
76c58ee2 218 binsTrack[9] =3;
219 xminTrack[9] =-0.1; xmaxTrack[9]=2.1; //
220 axisName[9] ="cross";
221 //
91fd44c9 222 // delta y
223 xminTrack[0] =-1; xmaxTrack[0]=1; //
76c58ee2 224 fHistoDelta[0] = new THnSparseS("#Delta_{Y} (cm)","#Delta_{Y} (cm)", ndim, binsTrack,xminTrack, xmaxTrack);
91fd44c9 225 xminTrack[0] =-5; xmaxTrack[0]=5; //
76c58ee2 226 fHistoPull[0] = new THnSparseS("#Delta_{Y} (unit)","#Delta_{Y} (unit)", ndim, binsTrack,xminTrack, xmaxTrack);
91fd44c9 227 //
228 // delta z
229 xminTrack[0] =-1; xmaxTrack[0]=1; //
76c58ee2 230 fHistoDelta[1] = new THnSparseS("#Delta_{Z} (cm)","#Delta_{Z} (cm)", ndim, binsTrack,xminTrack, xmaxTrack);
91fd44c9 231 xminTrack[0] =-5; xmaxTrack[0]=5; //
76c58ee2 232 fHistoPull[1] = new THnSparseS("#Delta_{Z} (unit)","#Delta_{Z} (unit)", ndim, binsTrack,xminTrack, xmaxTrack);
91fd44c9 233 //
234 // delta P2
235 xminTrack[0] =-10; xmaxTrack[0]=10; //
76c58ee2 236 fHistoDelta[2] = new THnSparseS("#Delta_{#phi} (mrad)","#Delta_{#phi} (mrad)", ndim, binsTrack,xminTrack, xmaxTrack);
91fd44c9 237 xminTrack[0] =-5; xmaxTrack[0]=5; //
76c58ee2 238 fHistoPull[2] = new THnSparseS("#Delta_{#phi} (unit)","#Delta_{#phi} (unit)", ndim, binsTrack,xminTrack, xmaxTrack);
91fd44c9 239 //
240 // delta P3
241 xminTrack[0] =-10; xmaxTrack[0]=10; //
76c58ee2 242 fHistoDelta[3] = new THnSparseS("#Delta_{#theta} (mrad)","#Delta_{#theta} (mrad)", ndim, binsTrack,xminTrack, xmaxTrack);
91fd44c9 243 xminTrack[0] =-5; xmaxTrack[0]=5; //
76c58ee2 244 fHistoPull[3] = new THnSparseS("#Delta_{#theta} (unit)","#Delta_{#theta} (unit)", ndim, binsTrack,xminTrack, xmaxTrack);
91fd44c9 245 //
246 // delta P4
247 xminTrack[0] =-0.2; xmaxTrack[0]=0.2; //
76c58ee2 248 fHistoDelta[4] = new THnSparseS("#Delta_{1/pt} (1/GeV)","#Delta_{1/pt} (1/GeV)", ndim, binsTrack,xminTrack, xmaxTrack);
91fd44c9 249 xminTrack[0] =-5; xmaxTrack[0]=5; //
76c58ee2 250 fHistoPull[4] = new THnSparseS("#Delta_{1/pt} (unit)","#Delta_{1/pt} (unit)", ndim, binsTrack,xminTrack, xmaxTrack);
91fd44c9 251
252 //
253 // delta Pt
254 xminTrack[0] =-0.5; xmaxTrack[0]=0.5; //
76c58ee2 255 fHistoDelta[5] = new THnSparseS("#Delta_{pt}/p_{t}","#Delta_{pt}/p_{t}", ndim, binsTrack,xminTrack, xmaxTrack);
91fd44c9 256 xminTrack[0] =-5; xmaxTrack[0]=5; //
76c58ee2 257 fHistoPull[5] = new THnSparseS("#Delta_{pt}/p_{t} (unit)","#Delta_{pt}/p_{t} (unit)", ndim, binsTrack,xminTrack, xmaxTrack);
91fd44c9 258 //
8a92e133 259
260 for (Int_t idedx=0;idedx<4;idedx++){
261 xminTrack[0] =0.5; xmaxTrack[0]=1.5; //
262 binsTrack[1] =40;
263 xminTrack[1] =10; xmaxTrack[1]=160;
264
265 fHistodEdxMax[idedx] = new THnSparseS(Form("dEdx_{MaxUp}/dEdx_{MaxDown}_Pad%d",idedx),
266 Form("dEdx_{MaxUp}/dEdx_{MaxDown}_Pad%d",idedx),
76c58ee2 267 ndim, binsTrack,xminTrack, xmaxTrack);
8a92e133 268 fHistodEdxTot[idedx] = new THnSparseS(Form("dEdx_{TotUp}/dEdx_{TotDown}_Pad%d",idedx),
269 Form("dEdx_{TotUp}/dEdx_{TotDown}_Pad%d",idedx),
76c58ee2 270 ndim, binsTrack,xminTrack, xmaxTrack);
8a92e133 271 }
272
273
274
91fd44c9 275 for (Int_t ivar=0;ivar<6;ivar++){
76c58ee2 276 for (Int_t ivar2=0;ivar2<ndim;ivar2++){
91fd44c9 277 fHistoDelta[ivar]->GetAxis(ivar2)->SetName(axisName[ivar2].Data());
278 fHistoDelta[ivar]->GetAxis(ivar2)->SetTitle(axisName[ivar2].Data());
279 fHistoPull[ivar]->GetAxis(ivar2)->SetName(axisName[ivar2].Data());
280 fHistoPull[ivar]->GetAxis(ivar2)->SetTitle(axisName[ivar2].Data());
281 BinLogX(fHistoDelta[ivar],7);
282 BinLogX(fHistoPull[ivar],7);
8a92e133 283 if (ivar<4){
284 fHistodEdxMax[ivar]->GetAxis(ivar2)->SetName(axisName[ivar2].Data());
285 fHistodEdxMax[ivar]->GetAxis(ivar2)->SetTitle(axisName[ivar2].Data());
286 fHistodEdxTot[ivar]->GetAxis(ivar2)->SetName(axisName[ivar2].Data());
287 fHistodEdxTot[ivar]->GetAxis(ivar2)->SetTitle(axisName[ivar2].Data());
288 BinLogX(fHistodEdxMax[ivar],7);
289 BinLogX(fHistodEdxTot[ivar],7);
290 }
91fd44c9 291 }
292 }
293}
294
295
296void AliTPCcalibCosmic::Add(const AliTPCcalibCosmic* cosmic){
297 //
236f5592 298 // merge the content of the cosmic componentnts
91fd44c9 299 //
300 for (Int_t ivar=0; ivar<6;ivar++){
301 if (fHistoDelta[ivar] && cosmic->fHistoDelta[ivar]){
302 fHistoDelta[ivar]->Add(cosmic->fHistoDelta[ivar]);
303 }
304 if (fHistoPull[ivar] && cosmic->fHistoPull[ivar]){
305 fHistoPull[ivar]->Add(cosmic->fHistoPull[ivar]);
306 }
307 }
8a92e133 308 for (Int_t ivar=0; ivar<4;ivar++){
309 if (fHistodEdxMax[ivar] && cosmic->fHistodEdxMax[ivar]){
310 fHistodEdxMax[ivar]->Add(cosmic->fHistodEdxMax[ivar]);
311 }
312 if (fHistodEdxTot[ivar] && cosmic->fHistodEdxTot[ivar]){
313 fHistodEdxTot[ivar]->Add(cosmic->fHistodEdxTot[ivar]);
314 }
315 }
76c58ee2 316 if (cosmic->fCosmicTree){
317 if (!fCosmicTree) {
318 fCosmicTree = new TTree("pairs","pairs");
319 fCosmicTree->SetDirectory(0);
320 }
321 AliTPCcalibCosmic::AddTree(fCosmicTree,cosmic->fCosmicTree);
322 }
91fd44c9 323}
324
9b27d39b 325
326
327
f7f33dec 328void AliTPCcalibCosmic::Process(AliESDEvent *event) {
9b27d39b 329 //
236f5592 330 // Process of the ESD event - fill calibration components
9b27d39b 331 //
f7f33dec 332 if (!event) {
333 Printf("ERROR: ESD not available");
334 return;
9b27d39b 335 }
76273318 336 AliESDfriend *esdFriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
337 if (!esdFriend) {
338 Printf("ERROR: esdFriend not available");
f7f33dec 339 return;
340 }
2acad464 341
76c58ee2 342 //
343 //Int_t isOK=kTRUE;
344 // COSMIC not signed properly
345 // UInt_t specie = event->GetEventSpecie(); // select only cosmic events
346 //if (specie==AliRecoParam::kCosmic || specie==AliRecoParam::kCalib) {
347 // isOK = kTRUE;
348 //}
349 //if (!isOK) return;
350 // Work around
351 FindCosmicPairs(event);
352 return;
353 const AliMultiplicity *multiplicity = event->GetMultiplicity();
354 Int_t ntracklets = multiplicity->GetNumberOfTracklets();
355 if (ntracklets>6) return; // filter out "normal" event with high multiplicity
356 const TString &trigger = event->GetFiredTriggerClasses();
357 if (trigger.Contains("C0OB0")==0) return;
358
108953e9 359
54b76c13 360 FindPairs(event); // nearly everything takes place in find pairs...
361
2acad464 362 if (GetDebugLevel()>20) printf("Hallo world: Im here and processing an event\n");
9b27d39b 363 Int_t ntracks=event->GetNumberOfTracks();
364 fHistNTracks->Fill(ntracks);
15e48021 365
54b76c13 366}
9b27d39b 367
f7f33dec 368
76c58ee2 369void AliTPCcalibCosmic::FillHistoPerformance(const AliExternalTrackParam *par0, const AliExternalTrackParam *par1, const AliExternalTrackParam *inner0, const AliExternalTrackParam */*inner1*/, AliTPCseed *seed0, AliTPCseed *seed1, const AliExternalTrackParam *param0Combined , Int_t cross){
91fd44c9 370 //
a390f11f 371 // par0,par1 - parameter of tracks at DCA 0
372 // inner0,inner1 - parameter of tracks at the TPC entrance
373 // seed0, seed1 - detailed track information
374 // param0Combined - Use combined track parameters for binning
91fd44c9 375 //
8a92e133 376 Int_t kMinCldEdx =20;
377 Int_t ncl0 = seed0->GetNumberOfClusters();
378 Int_t ncl1 = seed1->GetNumberOfClusters();
91fd44c9 379 const Double_t kpullCut = 10;
76c58ee2 380 Double_t x[10];
91fd44c9 381 Double_t xyz0[3];
382 Double_t xyz1[3];
383 par0->GetXYZ(xyz0);
384 par1->GetXYZ(xyz1);
385 Double_t radius0 = TMath::Sqrt(xyz0[0]*xyz0[0]+xyz0[1]*xyz0[1]);
386 Double_t radius1 = TMath::Sqrt(xyz1[0]*xyz1[0]+xyz1[1]*xyz1[1]);
387 inner0->GetXYZ(xyz0);
388 Double_t alpha = TMath::ATan2(xyz0[1],xyz0[0]);
389 // bin parameters
390 x[1] = TMath::Min(ncl0,ncl1);
391 x[2] = (radius0+radius1)*0.5;
a390f11f 392 x[3] = param0Combined->GetZ();
393 x[4] = inner0->GetSnp();
394 x[5] = param0Combined->GetTgl();
395 x[6] = param0Combined->GetSigned1Pt();
396 x[7] = param0Combined->Pt();
91fd44c9 397 x[8] = alpha;
76c58ee2 398 x[9] = cross;
91fd44c9 399 // deltas
400 Double_t delta[6];
401 Double_t sigma[6];
402 delta[0] = (par0->GetY()+par1->GetY());
403 delta[1] = (par0->GetZ()-par1->GetZ());
404 delta[2] = (par0->GetAlpha()-par1->GetAlpha()-TMath::Pi());
405 delta[3] = (par0->GetTgl()+par1->GetTgl());
406 delta[4] = (par0->GetParameter()[4]+par1->GetParameter()[4]);
407 delta[5] = (par0->Pt()-par1->Pt())/((par0->Pt()+par1->Pt())*0.5);
408 //
409 sigma[0] = TMath::Sqrt(par0->GetSigmaY2()+par1->GetSigmaY2());
410 sigma[1] = TMath::Sqrt(par0->GetSigmaZ2()+par1->GetSigmaZ2());
411 sigma[2] = TMath::Sqrt(par0->GetSigmaSnp2()+par1->GetSigmaSnp2());
412 sigma[3] = TMath::Sqrt(par0->GetSigmaTgl2()+par1->GetSigmaTgl2());
413 sigma[4] = TMath::Sqrt(par0->GetSigma1Pt2()+par1->GetSigma1Pt2());
414 sigma[5] = sigma[4]*((par0->Pt()+par1->Pt())*0.5);
415 //
416 Bool_t isOK = kTRUE;
417 for (Int_t ivar=0;ivar<6;ivar++){
418 if (sigma[ivar]==0) isOK=kFALSE;
419 x[0]= delta[ivar]/sigma[ivar];
420 if (TMath::Abs(x[0])>kpullCut) isOK = kFALSE;
421 }
422 //
423
424 if (isOK) for (Int_t ivar=0;ivar<6;ivar++){
76c58ee2 425 x[0]= delta[ivar]; // Modifiation 10.10 use not normalized deltas
426 if (ivar==2 || ivar ==3) x[0]*=1000; // angles in radian
91fd44c9 427 fHistoDelta[ivar]->Fill(x);
428 if (sigma[ivar]>0){
429 x[0]= delta[ivar]/sigma[ivar];
430 fHistoPull[ivar]->Fill(x);
431 }
432 }
8a92e133 433
434 //
435 // Fill dedx performance
436 //
437 for (Int_t ipad=0; ipad<4;ipad++){
438 //
439 //
440 //
441 Int_t row0=0;
442 Int_t row1=160;
443 if (ipad==0) row1=63;
444 if (ipad==1) {row0=63; row1=63+64;}
445 if (ipad==2) {row0=128;}
446 Int_t nclUp = TMath::Nint(seed0->CookdEdxAnalytical(0.01,0.7,0,row0,row1,2));
447 Int_t nclDown = TMath::Nint(seed1->CookdEdxAnalytical(0.01,0.7,0,row0,row1,2));
448 Int_t minCl = TMath::Min(nclUp,nclDown);
449 if (minCl<kMinCldEdx) continue;
450 x[1] = minCl;
451 //
452 Float_t dEdxTotUp = seed0->CookdEdxAnalytical(0.01,0.7,0,row0,row1);
453 Float_t dEdxTotDown = seed1->CookdEdxAnalytical(0.01,0.7,0,row0,row1);
454 Float_t dEdxMaxUp = seed0->CookdEdxAnalytical(0.01,0.7,1,row0,row1);
455 Float_t dEdxMaxDown = seed1->CookdEdxAnalytical(0.01,0.7,1,row0,row1);
456 //
457 if (dEdxTotDown<=0) continue;
458 if (dEdxMaxDown<=0) continue;
459 x[0]=dEdxTotUp/dEdxTotDown;
460 fHistodEdxTot[ipad]->Fill(x);
461 x[0]=dEdxMaxUp/dEdxMaxDown;
462 fHistodEdxMax[ipad]->Fill(x);
463 }
464
465
91fd44c9 466
467}
468
236f5592 469void AliTPCcalibCosmic::FindPairs(const AliESDEvent *event){
9b27d39b 470 //
471 // Find cosmic pairs
04087794 472 //
473 // Track0 is choosen in upper TPC part
474 // Track1 is choosen in lower TPC part
9b27d39b 475 //
2acad464 476 if (GetDebugLevel()>20) printf("Hallo world: Im here\n");
76273318 477 AliESDfriend *esdFriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
9b27d39b 478 Int_t ntracks=event->GetNumberOfTracks();
9b27d39b 479 TObjArray tpcSeeds(ntracks);
480 if (ntracks==0) return;
481 Double_t vtxx[3]={0,0,0};
482 Double_t svtxx[3]={0.000001,0.000001,100.};
483 AliESDVertex vtx(vtxx,svtxx);
484 //
485 //track loop
486 //
54b76c13 487 for (Int_t i=0;i<ntracks;++i) {
488 AliESDtrack *track = event->GetTrack(i);
489 fClusters->Fill(track->GetTPCNcls());
490
491 const AliExternalTrackParam * trackIn = track->GetInnerParam();
492 const AliExternalTrackParam * trackOut = track->GetOuterParam();
493 if (!trackIn) continue;
494 if (!trackOut) continue;
860b3d93 495 if (ntracks>4 && TMath::Abs(trackIn->GetTgl())<0.0015) continue; // filter laser
496
497
76273318 498 AliESDfriendTrack *friendTrack = esdFriend->GetTrack(i);
b9908d0b 499 if (!friendTrack) continue;
9b27d39b 500 TObject *calibObject;
b9908d0b 501 AliTPCseed *seed = 0;
9b27d39b 502 for (Int_t l=0;(calibObject=friendTrack->GetCalibObject(l));++l) {
503 if ((seed=dynamic_cast<AliTPCseed*>(calibObject))) break;
504 }
505 if (seed) tpcSeeds.AddAt(seed,i);
54b76c13 506
507 Double_t meanP = 0.5*(trackIn->GetP() + trackOut->GetP());
508 if (seed && track->GetTPCNcls() > 80 + 60/(1+TMath::Exp(-meanP+5))) {
15e48021 509 fDeDx->Fill(meanP, seed->CookdEdxNorm(0.0,0.45,0,0,159));
54b76c13 510 //
15e48021 511 if (meanP > 0.4 && meanP < 0.45) fDeDxMIP->Fill(seed->CookdEdxNorm(0.0,0.45,0,0,159));
54b76c13 512 //
82628455 513 // if (GetDebugLevel()>0&&meanP>0.2&&seed->CookdEdxNorm(0.0,0.45,0,0,159)>300) {
514// //TFile *curfile = AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile();
515// //if (curfile) printf(">>> p+ in file: %s \t event: %i \t Number of ESD tracks: %i \n", curfile->GetName(), (int)event->GetEventNumberInFile(), (int)ntracks);
516// // if (track->GetOuterParam()->GetAlpha()<0) cout << " Polartiy: " << track->GetSign() << endl;
517// }
54b76c13 518
519 }
520
9b27d39b 521 }
54b76c13 522
9b27d39b 523 if (ntracks<2) return;
524 //
525 // Find pairs
526 //
527 for (Int_t i=0;i<ntracks;++i) {
528 AliESDtrack *track0 = event->GetTrack(i);
04087794 529 // track0 - choosen upper part
530 if (!track0) continue;
531 if (!track0->GetOuterParam()) continue;
532 if (track0->GetOuterParam()->GetAlpha()<0) continue;
e9362f9d 533 Double_t dir0[3];
534 track0->GetDirection(dir0);
04087794 535 for (Int_t j=0;j<ntracks;++j) {
536 if (i==j) continue;
537 AliESDtrack *track1 = event->GetTrack(j);
538 //track 1 lower part
539 if (!track1) continue;
540 if (!track1->GetOuterParam()) continue;
541 if (track1->GetOuterParam()->GetAlpha()>0) continue;
542 //
e9362f9d 543 Double_t dir1[3];
544 track1->GetDirection(dir1);
54b76c13 545
9b27d39b 546 AliTPCseed * seed0 = (AliTPCseed*) tpcSeeds.At(i);
547 AliTPCseed * seed1 = (AliTPCseed*) tpcSeeds.At(j);
548 if (! seed0) continue;
549 if (! seed1) continue;
15e48021 550 Float_t dedx0 = seed0->CookdEdxNorm(0.05,0.55,0,0,159);
551 Float_t dedx1 = seed1->CookdEdxNorm(0.05,0.55,0,0,159);
bca20570 552 //
15e48021 553 Float_t dedx0I = seed0->CookdEdxNorm(0.05,0.55,0,0,63);
554 Float_t dedx1I = seed1->CookdEdxNorm(0.05,0.55,0,0,63);
bca20570 555 //
15e48021 556 Float_t dedx0O = seed0->CookdEdxNorm(0.05,0.55,0,64,159);
557 Float_t dedx1O = seed1->CookdEdxNorm(0.05,0.55,0,64,159);
bca20570 558 //
e9362f9d 559 Float_t dir = (dir0[0]*dir1[0] + dir0[1]*dir1[1] + dir0[2]*dir1[2]);
9b27d39b 560 Float_t d0 = track0->GetLinearD(0,0);
561 Float_t d1 = track1->GetLinearD(0,0);
562 //
563 // conservative cuts - convergence to be guarantied
564 // applying before track propagation
565 if (TMath::Abs(d0+d1)>fCutMaxD) continue; // distance to the 0,0
566 if (dir>fCutMinDir) continue; // direction vector product
567 Float_t bz = AliTracker::GetBz();
568 Float_t dvertex0[2]; //distance to 0,0
569 Float_t dvertex1[2]; //distance to 0,0
570 track0->GetDZ(0,0,0,bz,dvertex0);
571 track1->GetDZ(0,0,0,bz,dvertex1);
572 if (TMath::Abs(dvertex0[1])>250) continue;
573 if (TMath::Abs(dvertex1[1])>250) continue;
574 //
575 //
576 //
577 Float_t dmax = TMath::Max(TMath::Abs(d0),TMath::Abs(d1));
578 AliExternalTrackParam param0(*track0);
579 AliExternalTrackParam param1(*track1);
580 //
581 // Propagate using Magnetic field and correct fo material budget
582 //
a390f11f 583 Double_t sign0=-1;
584 Double_t sign1=1;
585 Double_t maxsnp=0.90;
9963b5e2 586 AliTracker::PropagateTrackToBxByBz(&param0,dmax+1,TDatabasePDG::Instance()->GetParticle("e-")->Mass(),3,kTRUE,maxsnp,sign0);
587 AliTracker::PropagateTrackToBxByBz(&param1,dmax+1,TDatabasePDG::Instance()->GetParticle("e-")->Mass(),3,kTRUE,maxsnp,sign1);
9b27d39b 588 //
589 // Propagate rest to the 0,0 DCA - z should be ignored
590 //
591 Bool_t b0 = param0.PropagateToDCA(&vtx,bz,1000);
592 Bool_t b1 = param1.PropagateToDCA(&vtx,bz,1000);
593 //
594 param0.GetDZ(0,0,0,bz,dvertex0);
595 param1.GetDZ(0,0,0,bz,dvertex1);
a6dc0cf6 596 if (TMath::Abs(param0.GetZ()-param1.GetZ())>fCutMaxDz) continue;
9b27d39b 597 //
598 Double_t xyz0[3];//,pxyz0[3];
599 Double_t xyz1[3];//,pxyz1[3];
600 param0.GetXYZ(xyz0);
601 param1.GetXYZ(xyz1);
602 Bool_t isPair = IsPair(&param0,&param1);
603 //
54b76c13 604 if (isPair) FillAcordeHist(track0);
76c58ee2 605 if (isPair &&param0.Pt()>1) {
606 const TString &trigger = event->GetFiredTriggerClasses();
607 UInt_t specie = event->GetEventSpecie();
608 printf("COSMIC ?\t%s\t%d\t%f\t%f\n", trigger.Data(),specie, param0.GetZ(), param1.GetZ());
609 }
15e48021 610 //
611 // combined track params
612 //
613 AliExternalTrackParam *par0U=MakeCombinedTrack(&param0,&param1);
614 AliExternalTrackParam *par1U=MakeCombinedTrack(&param1,&param0);
76c58ee2 615
54b76c13 616 //
9b27d39b 617 if (fStreamLevel>0){
618 TTreeSRedirector * cstream = GetDebugStreamer();
108953e9 619 //printf("My stream=%p\n",(void*)cstream);
e9362f9d 620 AliExternalTrackParam *ip0 = (AliExternalTrackParam *)track0->GetInnerParam();
621 AliExternalTrackParam *ip1 = (AliExternalTrackParam *)track1->GetInnerParam();
622 AliExternalTrackParam *op0 = (AliExternalTrackParam *)track0->GetOuterParam();
623 AliExternalTrackParam *op1 = (AliExternalTrackParam *)track1->GetOuterParam();
624 Bool_t isCrossI = ip0->GetZ()*ip1->GetZ()<0;
625 Bool_t isCrossO = op0->GetZ()*op1->GetZ()<0;
626 Double_t alpha0 = TMath::ATan2(dir0[1],dir0[0]);
627 Double_t alpha1 = TMath::ATan2(dir1[1],dir1[0]);
91fd44c9 628 //
629 //
630 //
76c58ee2 631 Int_t cross =0; // 0 no cross, 2 cross on both sides
632 if (isCrossI) cross+=1;
633 if (isCrossO) cross+=1;
634 FillHistoPerformance(&param0, &param1, ip0, ip1, seed0, seed1,par0U, cross);
9b27d39b 635 if (cstream) {
636 (*cstream) << "Track0" <<
108953e9 637 "run="<<fRun<< // run number
638 "event="<<fEvent<< // event number
639 "time="<<fTime<< // time stamp of event
640 "trigger="<<fTrigger<< // trigger
15e48021 641 "triggerClass="<<&fTriggerClass<< // trigger
108953e9 642 "mag="<<fMagF<< // magnetic field
9b27d39b 643 "dir="<<dir<< // direction
54b76c13 644 "OK="<<isPair<< // will be accepted
9b27d39b 645 "b0="<<b0<< // propagate status
646 "b1="<<b1<< // propagate status
e9362f9d 647 "crossI="<<isCrossI<< // cross inner
648 "crossO="<<isCrossO<< // cross outer
649 //
9b27d39b 650 "Orig0.=" << track0 << // original track 0
651 "Orig1.=" << track1 << // original track 1
652 "Tr0.="<<&param0<< // track propagated to the DCA 0,0
653 "Tr1.="<<&param1<< // track propagated to the DCA 0,0
e9362f9d 654 "Ip0.="<<ip0<< // inner param - upper
655 "Ip1.="<<ip1<< // inner param - lower
656 "Op0.="<<op0<< // outer param - upper
657 "Op1.="<<op1<< // outer param - lower
15e48021 658 "Up0.="<<par0U<< // combined track 0
659 "Up1.="<<par1U<< // combined track 1
e9362f9d 660 //
9b27d39b 661 "v00="<<dvertex0[0]<< // distance using kalman
662 "v01="<<dvertex0[1]<< //
663 "v10="<<dvertex1[0]<< //
664 "v11="<<dvertex1[1]<< //
665 "d0="<<d0<< // linear distance to 0,0
666 "d1="<<d1<< // linear distance to 0,0
667 //
e9362f9d 668 //
669 //
670 "x00="<<xyz0[0]<< // global position close to vertex
9b27d39b 671 "x01="<<xyz0[1]<<
672 "x02="<<xyz0[2]<<
673 //
e9362f9d 674 "x10="<<xyz1[0]<< // global position close to vertex
9b27d39b 675 "x11="<<xyz1[1]<<
676 "x12="<<xyz1[2]<<
677 //
e9362f9d 678 "alpha0="<<alpha0<<
679 "alpha1="<<alpha1<<
680 "dir00="<<dir0[0]<< // direction upper
681 "dir01="<<dir0[1]<<
682 "dir02="<<dir0[2]<<
683 //
684 "dir10="<<dir1[0]<< // direction lower
685 "dir11="<<dir1[1]<<
686 "dir12="<<dir1[2]<<
687 //
688 //
54b76c13 689 "Seed0.=" << seed0 << // original seed 0
690 "Seed1.=" << seed1 << // original seed 1
bca20570 691 //
692 "dedx0="<<dedx0<< // dedx0 - all
693 "dedx1="<<dedx1<< // dedx1 - all
694 //
54b76c13 695 "dedx0I="<<dedx0I<< // dedx0 - inner ROC
696 "dedx1I="<<dedx1I<< // dedx1 - inner ROC
bca20570 697 //
54b76c13 698 "dedx0O="<<dedx0O<< // dedx0 - outer ROC
699 "dedx1O="<<dedx1O<< // dedx1 - outer ROC
9b27d39b 700 "\n";
701 }
15e48021 702 }
703 delete par0U;
704 delete par1U;
9b27d39b 705 }
706 }
707}
708
9b27d39b 709
bca20570 710
711
54b76c13 712void AliTPCcalibCosmic::FillAcordeHist(AliESDtrack *upperTrack) {
713
714 // Pt cut to select straight tracks which can be easily propagated to ACORDE which is outside the magnetic field
715 if (upperTrack->Pt() < 10 || upperTrack->GetTPCNcls() < 80) return;
716
76273318 717 const Double_t acordePlane = 850.; // distance of the central Acorde detectors to the beam line at y =0
54b76c13 718 const Double_t roof = 210.5; // distance from x =0 to end of magnet roof
719
720 Double_t r[3];
721 upperTrack->GetXYZ(r);
722 Double_t d[3];
723 upperTrack->GetDirection(d);
724 Double_t x,z;
76273318 725 z = r[2] + (d[2]/d[1])*(acordePlane - r[1]);
726 x = r[0] + (d[0]/d[1])*(acordePlane - r[1]);
54b76c13 727
728 if (x > roof) {
76273318 729 x = r[0] + (d[0]/(d[0]+d[1]))*(acordePlane+roof-r[0]-r[1]);
730 z = r[2] + (d[2]/(d[0]+d[1]))*(acordePlane+roof-r[0]-r[1]);
54b76c13 731 }
732 if (x < -roof) {
76273318 733 x = r[0] + (d[0]/(d[1]-d[0]))*(acordePlane+roof+r[0]-r[1]);
734 z = r[2] + (d[2]/(d[1]-d[0]))*(acordePlane+roof+r[0]-r[1]);
54b76c13 735 }
736
737 fModules->Fill(z, x);
738
739}
740
741
742
3326b323 743Long64_t AliTPCcalibCosmic::Merge(TCollection *const li) {
236f5592 744 //
745 // component merging
746 //
bca20570 747
748 TIterator* iter = li->MakeIterator();
749 AliTPCcalibCosmic* cal = 0;
750
751 while ((cal = (AliTPCcalibCosmic*)iter->Next())) {
752 if (!cal->InheritsFrom(AliTPCcalibCosmic::Class())) {
860b3d93 753 //Error("Merge","Attempt to add object of class %s to a %s", cal->ClassName(), this->ClassName());
bca20570 754 return -1;
755 }
756
54b76c13 757 fHistNTracks->Add(cal->GetHistNTracks());
758 fClusters->Add(cal-> GetHistClusters());
759 fModules->Add(cal->GetHistAcorde());
760 fHistPt->Add(cal->GetHistPt());
761 fDeDx->Add(cal->GetHistDeDx());
762 fDeDxMIP->Add(cal->GetHistMIP());
91fd44c9 763 Add(cal);
bca20570 764 }
bca20570 765 return 0;
9b27d39b 766
f7f33dec 767}
768
54b76c13 769
236f5592 770Bool_t AliTPCcalibCosmic::IsPair(AliExternalTrackParam *tr0, AliExternalTrackParam *tr1) const{
9b27d39b 771 //
772 //
773 /*
774 // 0. Same direction - OPOSITE - cutDir +cutT
775 TCut cutDir("cutDir","dir<-0.99")
776 // 1.
777 TCut cutT("cutT","abs(Tr1.fP[3]+Tr0.fP[3])<0.03")
778 //
779 // 2. The same rphi
780 TCut cutD("cutD","abs(Tr0.fP[0]+Tr1.fP[0])<5")
781 //
782 //
783 //
784 TCut cutPt("cutPt","abs(Tr1.fP[4]+Tr0.fP[4])<1&&abs(Tr0.fP[4])+abs(Tr1.fP[4])<10");
785 // 1/Pt diff cut
786 */
787 const Double_t *p0 = tr0->GetParameter();
788 const Double_t *p1 = tr1->GetParameter();
789 if (TMath::Abs(p0[3]+p1[3])>fCutTheta) return kFALSE;
a6dc0cf6 790 if (TMath::Abs(p0[1]-p1[1])>fCutMaxDz) return kFALSE;
9b27d39b 791 if (TMath::Abs(p0[0]+p1[0])>fCutMaxD) return kFALSE;
a6dc0cf6 792
9b27d39b 793 Double_t d0[3], d1[3];
794 tr0->GetDirection(d0);
795 tr1->GetDirection(d1);
796 if (d0[0]*d1[0] + d0[1]*d1[1] + d0[2]*d1[2] >fCutMinDir) return kFALSE;
797 //
798 return kTRUE;
799}
54b76c13 800
801
802
803Double_t AliTPCcalibCosmic::CalculateMIPvalue(TH1F * hist) {
236f5592 804 //
805 // Calculate the MIP value - gaussian fit used
806 //
54b76c13 807
808 TF1 * funcDoubleGaus = new TF1("funcDoubleGaus", "gaus(0)+gaus(3)",0,1000);
809 funcDoubleGaus->SetParameters(hist->GetEntries()*0.75,hist->GetMean()/1.3,hist->GetMean()*0.10,
810 hist->GetEntries()*0.25,hist->GetMean()*1.3,hist->GetMean()*0.10);
811 hist->Fit(funcDoubleGaus);
3326b323 812 Double_t aMIPvalue = TMath::Min(funcDoubleGaus->GetParameter(1),funcDoubleGaus->GetParameter(4));
54b76c13 813
814 delete funcDoubleGaus;
815
3326b323 816 return aMIPvalue;
54b76c13 817
818}
9b27d39b 819
820
f7f33dec 821
54b76c13 822
57dc06f2 823void AliTPCcalibCosmic::CalculateBetheParams(TH2F */*hist*/, Double_t * /*initialParam*/) {
824 //
825 // Not implemented yet
826 //
54b76c13 827 return;
828
829}
830
831
3326b323 832void AliTPCcalibCosmic::BinLogX(THnSparse *const h, Int_t axisDim) {
91fd44c9 833
834 // Method for the correct logarithmic binning of histograms
835
836 TAxis *axis = h->GetAxis(axisDim);
837 int bins = axis->GetNbins();
838
839 Double_t from = axis->GetXmin();
840 Double_t to = axis->GetXmax();
3326b323 841 Double_t *newBins = new Double_t[bins + 1];
91fd44c9 842
3326b323 843 newBins[0] = from;
91fd44c9 844 Double_t factor = pow(to/from, 1./bins);
845
846 for (int i = 1; i <= bins; i++) {
3326b323 847 newBins[i] = factor * newBins[i-1];
91fd44c9 848 }
3326b323 849 axis->Set(bins, newBins);
4ce766eb 850 delete [] newBins;
91fd44c9 851
852}
853
854
3326b323 855void AliTPCcalibCosmic::BinLogX(TH1 *const h) {
f7f33dec 856
857 // Method for the correct logarithmic binning of histograms
858
859 TAxis *axis = h->GetXaxis();
860 int bins = axis->GetNbins();
861
862 Double_t from = axis->GetXmin();
863 Double_t to = axis->GetXmax();
3326b323 864 Double_t *newBins = new Double_t[bins + 1];
f7f33dec 865
3326b323 866 newBins[0] = from;
f7f33dec 867 Double_t factor = pow(to/from, 1./bins);
868
869 for (int i = 1; i <= bins; i++) {
3326b323 870 newBins[i] = factor * newBins[i-1];
f7f33dec 871 }
3326b323 872 axis->Set(bins, newBins);
4ce766eb 873 delete [] newBins;
f7f33dec 874
875}
876
7b18d067 877
860b3d93 878AliExternalTrackParam *AliTPCcalibCosmic::MakeTrack(const AliExternalTrackParam *track0, const AliExternalTrackParam *track1){
879 //
236f5592 880 // Make a atrack using the kalman update of track0 and track1
860b3d93 881 //
882 AliExternalTrackParam *par1R= new AliExternalTrackParam(*track1);
883 par1R->Rotate(track0->GetAlpha());
15e48021 884 par1R->PropagateTo(track0->GetX(),AliTracker::GetBz());
860b3d93 885 //
886 //
887 Double_t * param = (Double_t*)par1R->GetParameter();
888 Double_t * covar = (Double_t*)par1R->GetCovariance();
15e48021 889
860b3d93 890 param[0]*=1; //OK
891 param[1]*=1; //OK
892 param[2]*=1; //?
893 param[3]*=-1; //OK
894 param[4]*=-1; //OK
895 //
896 covar[6] *=-1.; covar[7] *=-1.; covar[8] *=-1.;
897 //covar[10]*=-1.; covar[11]*=-1.; covar[12]*=-1.;
898 covar[13]*=-1.;
860b3d93 899 return par1R;
900}
901
15e48021 902AliExternalTrackParam *AliTPCcalibCosmic::MakeCombinedTrack(const AliExternalTrackParam *track0, const AliExternalTrackParam *track1){
903 //
904 // Make combined track
905 //
906 //
907 AliExternalTrackParam * par1T = MakeTrack(track0,track1);
908 AliExternalTrackParam * par0U = new AliExternalTrackParam(*track0);
909 //
910 UpdateTrack(*par0U,*par1T);
911 delete par1T;
912 return par0U;
913}
914
915
860b3d93 916void AliTPCcalibCosmic::UpdateTrack(AliExternalTrackParam &track1, const AliExternalTrackParam &track2){
917 //
918 // Update track 1 with track 2
919 //
920 //
921 //
922 TMatrixD vecXk(5,1); // X vector
923 TMatrixD covXk(5,5); // X covariance
924 TMatrixD matHk(5,5); // vector to mesurement
925 TMatrixD measR(5,5); // measurement error
926 TMatrixD vecZk(5,1); // measurement
927 //
928 TMatrixD vecYk(5,1); // Innovation or measurement residual
929 TMatrixD matHkT(5,5);
930 TMatrixD matSk(5,5); // Innovation (or residual) covariance
931 TMatrixD matKk(5,5); // Optimal Kalman gain
932 TMatrixD mat1(5,5); // update covariance matrix
933 TMatrixD covXk2(5,5); //
934 TMatrixD covOut(5,5);
935 //
936 Double_t *param1=(Double_t*) track1.GetParameter();
937 Double_t *covar1=(Double_t*) track1.GetCovariance();
938 Double_t *param2=(Double_t*) track2.GetParameter();
939 Double_t *covar2=(Double_t*) track2.GetCovariance();
940 //
941 // copy data to the matrix
942 for (Int_t ipar=0; ipar<5; ipar++){
860b3d93 943 for (Int_t jpar=0; jpar<5; jpar++){
944 covXk(ipar,jpar) = covar1[track1.GetIndex(ipar, jpar)];
945 measR(ipar,jpar) = covar2[track2.GetIndex(ipar, jpar)];
15e48021 946 matHk(ipar,jpar)=0;
947 mat1(ipar,jpar)=0;
860b3d93 948 }
15e48021 949 vecXk(ipar,0) = param1[ipar];
950 vecZk(ipar,0) = param2[ipar];
951 matHk(ipar,ipar)=1;
952 mat1(ipar,ipar)=0;
860b3d93 953 }
954 //
955 //
956 //
957 //
860b3d93 958 //
959 vecYk = vecZk-matHk*vecXk; // Innovation or measurement residual
960 matHkT=matHk.T(); matHk.T();
961 matSk = (matHk*(covXk*matHkT))+measR; // Innovation (or residual) covariance
962 matSk.Invert();
963 matKk = (covXk*matHkT)*matSk; // Optimal Kalman gain
964 vecXk += matKk*vecYk; // updated vector
860b3d93 965 covXk2 = (mat1-(matKk*matHk));
966 covOut = covXk2*covXk;
967 //
968 //
969 //
970 // copy from matrix to parameters
971 if (0) {
972 vecXk.Print();
973 vecZk.Print();
974 //
975 measR.Print();
976 covXk.Print();
977 covOut.Print();
978 //
979 track1.Print();
980 track2.Print();
981 }
982
983 for (Int_t ipar=0; ipar<5; ipar++){
984 param1[ipar]= vecXk(ipar,0) ;
985 for (Int_t jpar=0; jpar<5; jpar++){
986 covar1[track1.GetIndex(ipar, jpar)]=covOut(ipar,jpar);
987 }
988 }
989}
990
860b3d93 991
992
236f5592 993void AliTPCcalibCosmic::FindCosmicPairs(const AliESDEvent * event) {
76c58ee2 994 //
995 // find cosmic pairs trigger by random trigger
996 //
997 //
998 AliESDVertex *vertexSPD = (AliESDVertex *)event->GetPrimaryVertexSPD();
999 AliESDVertex *vertexTPC = (AliESDVertex *)event->GetPrimaryVertexTPC();
1000 AliESDfriend *esdFriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
1001 const Double_t kMinPt=1;
1002 const Double_t kMinPtMax=0.8;
1003 const Double_t kMinNcl=50;
1004 const Double_t kMaxDelta[5]={2,600,0.02,0.02,0.1};
1005 Int_t ntracks=event->GetNumberOfTracks();
5b129619 1006 // Float_t dcaTPC[2]={0,0};
1007 // Float_t covTPC[3]={0,0,0};
76c58ee2 1008
1009 UInt_t specie = event->GetEventSpecie(); // skip laser events
1010 if (specie==AliRecoParam::kCalib) return;
1011
1012
1013
1014 for (Int_t itrack0=0;itrack0<ntracks;itrack0++) {
1015 AliESDtrack *track0 = event->GetTrack(itrack0);
1016 if (!track0) continue;
1017 if (!track0->IsOn(AliESDtrack::kTPCrefit)) continue;
1018
1019 if (TMath::Abs(AliTracker::GetBz())>1&&track0->Pt()<kMinPt) continue;
1020 if (track0->GetTPCncls()<kMinNcl) continue;
1021 if (TMath::Abs(track0->GetY())<kMaxDelta[0]) continue;
1022 if (track0->GetKinkIndex(0)>0) continue;
1023 const Double_t * par0=track0->GetParameter(); //track param at rhe DCA
1024 //rm primaries
1025 //
1026 //track0->GetImpactParametersTPC(dcaTPC,covTPC);
1027 //if (TMath::Abs(dcaTPC[0])<kMaxDelta[0]) continue;
1028 //if (TMath::Abs(dcaTPC[1])<kMaxDelta[0]*2) continue;
5b129619 1029 // const AliExternalTrackParam * trackIn0 = track0->GetInnerParam();
76c58ee2 1030 for (Int_t itrack1=itrack0+1;itrack1<ntracks;itrack1++) {
1031 AliESDtrack *track1 = event->GetTrack(itrack1);
1032 if (!track1) continue;
1033 if (!track1->IsOn(AliESDtrack::kTPCrefit)) continue;
1034 if (track1->GetKinkIndex(0)>0) continue;
1035 if (TMath::Abs(AliTracker::GetBz())>1&&track1->Pt()<kMinPt) continue;
1036 if (track1->GetTPCncls()<kMinNcl) continue;
1037 if (TMath::Abs(AliTracker::GetBz())>1&&TMath::Max(track1->Pt(), track0->Pt())<kMinPtMax) continue;
1038 if (TMath::Abs(track1->GetY())<kMaxDelta[0]) continue;
1039 //track1->GetImpactParametersTPC(dcaTPC,covTPC);
1040 // if (TMath::Abs(dcaTPC[0])<kMaxDelta[0]) continue;
1041 //if (TMath::Abs(dcaTPC[1])<kMaxDelta[0]*2) continue;
1042 //
1043 const Double_t* par1=track1->GetParameter(); //track param at rhe DCA
1044 //
1045 Bool_t isPair=kTRUE;
1046 for (Int_t ipar=0; ipar<5; ipar++){
1047 if (ipar==4&&TMath::Abs(AliTracker::GetBz())<1) continue; // 1/pt not defined for B field off
1048 if (TMath::Abs(TMath::Abs(par0[ipar])-TMath::Abs(par1[ipar]))>kMaxDelta[ipar]) isPair=kFALSE;
1049 }
1050 if (!isPair) continue;
1051 if (TMath::Abs(TMath::Abs(track0->GetAlpha()-track1->GetAlpha())-TMath::Pi())>kMaxDelta[2]) isPair=kFALSE;
1052 //delta with correct sign
1053 /*
1054 TCut cut0="abs(t1.fP[0]+t0.fP[0])<2"
1055 TCut cut3="abs(t1.fP[3]+t0.fP[3])<0.02"
1056 TCut cut4="abs(t1.fP[4]+t0.fP[4])<0.2"
1057 */
1058 if (TMath::Abs(par0[0]+par1[0])>kMaxDelta[0]) isPair=kFALSE; //delta y opposite sign
1059 if (TMath::Abs(par0[3]+par1[3])>kMaxDelta[3]) isPair=kFALSE; //delta tgl opposite sign
1060 if (TMath::Abs(AliTracker::GetBz())>1 && TMath::Abs(par0[4]+par1[4])>kMaxDelta[4]) isPair=kFALSE; //delta 1/pt opposite sign
1061 if (!isPair) continue;
5b129619 1062 // const AliExternalTrackParam * trackIn1 = track1->GetInnerParam();
76c58ee2 1063 //
1064 //
1065 TTreeSRedirector * pcstream = GetDebugStreamer();
1066 Int_t ntracksSPD = vertexSPD->GetNContributors();
1067 Int_t ntracksTPC = vertexTPC->GetNContributors();
1068 //
1069 AliESDfriendTrack *friendTrack0 = esdFriend->GetTrack(itrack0);
1070 if (!friendTrack0) continue;
1071 AliESDfriendTrack *friendTrack1 = esdFriend->GetTrack(itrack1);
1072 if (!friendTrack1) continue;
1073 TObject *calibObject;
1074 AliTPCseed *seed0 = 0;
1075 AliTPCseed *seed1 = 0;
1076 //
1077 for (Int_t l=0;(calibObject=friendTrack0->GetCalibObject(l));++l) {
1078 if ((seed0=dynamic_cast<AliTPCseed*>(calibObject))) break;
1079 }
1080 for (Int_t l=0;(calibObject=friendTrack1->GetCalibObject(l));++l) {
1081 if ((seed1=dynamic_cast<AliTPCseed*>(calibObject))) break;
1082 }
1083 //
1084 if (pcstream){
1085 (*pcstream)<<"pairs"<<
1086 "run="<<fRun<< // run number
1087 "event="<<fEvent<< // event number
1088 "time="<<fTime<< // time stamp of event
1089 "trigger="<<fTrigger<< // trigger
1090 "triggerClass="<<&fTriggerClass<< // trigger
1091 "mag="<<fMagF<< // magnetic field
1092 //
1093 "nSPD="<<ntracksSPD<<
1094 "nTPC="<<ntracksTPC<<
1095 "vSPD.="<<vertexSPD<< //primary vertex -SPD
1096 "vTPC.="<<vertexTPC<< //primary vertex -TPC
1097 "t0.="<<track0<< //track0
1098 "t1.="<<track1<< //track1
1099 "ft0.="<<friendTrack0<< //track0
1100 "ft1.="<<friendTrack1<< //track1
1101 "s0.="<<seed0<< //track0
1102 "s1.="<<seed1<< //track1
1103 "\n";
1104 }
1105 if (!fCosmicTree) {
1106 fCosmicTree = new TTree("pairs","pairs");
1107 fCosmicTree->SetDirectory(0);
1108 }
1109 if (fCosmicTree->GetEntries()==0){
1110 //
1111 fCosmicTree->SetDirectory(0);
1112 fCosmicTree->Branch("t0.",&track0);
1113 fCosmicTree->Branch("t1.",&track1);
1114 fCosmicTree->Branch("ft0.",&friendTrack0);
1115 fCosmicTree->Branch("ft1.",&friendTrack1);
1116 }else{
1117 fCosmicTree->SetBranchAddress("t0.",&track0);
1118 fCosmicTree->SetBranchAddress("t1.",&track1);
1119 fCosmicTree->SetBranchAddress("ft0.",&friendTrack0);
1120 fCosmicTree->SetBranchAddress("ft1.",&friendTrack1);
1121 }
1122 fCosmicTree->Fill();
1123 }
1124 }
1125}
1126
1127
1128void AliTPCcalibCosmic::Terminate(){
1129 //
1130 // copy the cosmic tree to memory resident tree
1131 //
1132 static Int_t counter=0;
1133 printf("AliTPCcalibCosmic::Terminate\t%d\n",counter);
1134 counter++;
1135 AliTPCcalibBase::Terminate();
1136}
1137
860b3d93 1138
76c58ee2 1139void AliTPCcalibCosmic::AddTree(TTree* treeOutput, TTree * treeInput){
1140 //
1141 // Add the content of tree:
1142 // Notice automatic copy of tree in ROOT does not work for such complicated tree
1143 //
1144 AliESDtrack *track0=new AliESDtrack;
1145 AliESDtrack *track1=new AliESDtrack;
1146 AliESDfriendTrack *ftrack0=new AliESDfriendTrack;
1147 AliESDfriendTrack *ftrack1=new AliESDfriendTrack;
1148 treeInput->SetBranchAddress("t0.",&track0);
1149 treeInput->SetBranchAddress("t1.",&track1);
1150 treeInput->SetBranchAddress("ft0.",&ftrack0);
1151 treeInput->SetBranchAddress("ft1.",&ftrack1);
1152 if (treeOutput->GetEntries()==0){
1153 //
1154 treeOutput->SetDirectory(0);
1155 treeOutput->Branch("t0.",&track0);
1156 treeOutput->Branch("t1.",&track1);
1157 treeOutput->Branch("ft0.",&ftrack0);
1158 treeOutput->Branch("ft1.",&ftrack1);
1159 }else{
1160 treeOutput->SetBranchAddress("t0.",&track0);
1161 treeOutput->SetBranchAddress("t1.",&track1);
1162 treeOutput->SetBranchAddress("ft0.",&ftrack0);
1163 treeOutput->SetBranchAddress("ft1.",&ftrack1);
1164 }
1165 Int_t entries= treeInput->GetEntries();
1166 for (Int_t i=0; i<entries; i++){
1167 treeInput->GetEntry(i);
1168 treeOutput->Fill();
1169 }
1170}
1171
1172
1173
1174void AliTPCcalibCosmic::MakeFitTree(TTree * treeInput, TTreeSRedirector *pcstream, const TObjArray * corrArray, Int_t step, Int_t run){
1175 //
1176 // Make fit tree
1177 // refit the tracks with original points + corrected points for each correction
1178 // Input:
1179 // treeInput - tree with cosmic tracks
1180 // pcstream - debug output
1181
1182 // Algorithm:
1183 // Loop over pair of cosmic tracks:
1184 // 1. Find trigger offset between cosmic event and "physic" trigger
1185 // 2. Refit tracks with current transformation
1186 // 3. Refit tracks using additional "primitive" distortion on top
1187 // Best correction estimated as linear combination of corrections
1188 // minimizing the observed distortions
1189 // Observed distortions - matching in the y,z, snp, theta and 1/pt
1190 //
1191 const Double_t kResetCov=20.;
1192 const Double_t kMaxDelta[5]={1,40,0.03,0.01,0.2};
1193 const Double_t kSigma=2.;
1194 const Double_t kMaxTime=1050;
1195 const Double_t kMaxSnp=0.8;
1196 Int_t ncorr=corrArray->GetEntries();
1197 AliTPCTransform *transform = AliTPCcalibDB::Instance()->GetTransform() ;
1198 AliTPCParam *param = AliTPCcalibDB::Instance()->GetParameters();
1199 AliGRPObject* grp = AliTPCcalibDB::Instance()->GetGRP(run);
1200 Double_t time=0.5*(grp->GetTimeStart() +grp->GetTimeEnd());
1201 transform->SetCurrentRun(run);
5b129619 1202 transform->SetCurrentTimeStamp(TMath::Nint(time));
76c58ee2 1203 Double_t covar[15];
1204 for (Int_t i=0;i<15;i++) covar[i]=0;
1205 covar[0]=kSigma*kSigma;
1206 covar[2]=kSigma*kSigma;
1207 covar[5]=kSigma*kSigma/Float_t(150*150);
1208 covar[9]=kSigma*kSigma/Float_t(150*150);
1209 covar[14]=0.2*0.2;
1210 Double_t *distortions = new Double_t[ncorr+1];
1211
1212 AliESDtrack *track0=new AliESDtrack;
1213 AliESDtrack *track1=new AliESDtrack;
1214 AliESDfriendTrack *ftrack0=new AliESDfriendTrack;
1215 AliESDfriendTrack *ftrack1=new AliESDfriendTrack;
1216 treeInput->SetBranchAddress("t0.",&track0);
1217 treeInput->SetBranchAddress("t1.",&track1);
1218 treeInput->SetBranchAddress("ft0.",&ftrack0);
1219 treeInput->SetBranchAddress("ft1.",&ftrack1);
1220 Int_t entries= treeInput->GetEntries();
1221 for (Int_t i=0; i<entries; i+=step){
1222 treeInput->GetEntry(i);
1223 if (i%20==0) printf("%d\n",i);
1224 if (!ftrack0->GetTPCOut()) continue;
1225 if (!ftrack1->GetTPCOut()) continue;
1226 AliTPCseed *seed0=0;
1227 AliTPCseed *seed1=0;
1228 TObject *calibObject;
1229 for (Int_t l=0;(calibObject=ftrack0->GetCalibObject(l));++l) {
1230 if ((seed0=dynamic_cast<AliTPCseed*>(calibObject))) break;
1231 }
1232 for (Int_t l=0;(calibObject=ftrack1->GetCalibObject(l));++l) {
1233 if ((seed1=dynamic_cast<AliTPCseed*>(calibObject))) break;
1234 }
1235 if (!seed0) continue;
1236 if (!seed1) continue;
1237 if (TMath::Abs(seed0->GetSnp())>kMaxSnp) continue;
1238 if (TMath::Abs(seed1->GetSnp())>kMaxSnp) continue;
1239 //
1240 //
1241 Int_t nclA0=0, nclC0=0; // number of clusters
1242 Int_t nclA1=0, nclC1=0; // number of clusters
1243 Int_t ncl0=0,ncl1=0;
1244 Double_t rmin0=300, rmax0=-300; // variables to estimate the time0 - trigger offset
1245 Double_t rmin1=300, rmax1=-300;
1246 Double_t tmin0=2000, tmax0=-2000;
1247 Double_t tmin1=2000, tmax1=-2000;
1248 //
1249 //
1250 // calculate trigger offset usig "missing clusters"
1251 for (Int_t irow=0; irow<159; irow++){
1252 AliTPCclusterMI *cluster0=seed0->GetClusterPointer(irow);
1253 if (cluster0 &&cluster0->GetX()>10){
1254 if (cluster0->GetX()<rmin0) { rmin0=cluster0->GetX(); tmin0=cluster0->GetTimeBin();}
1255 if (cluster0->GetX()>rmax0) { rmax0=cluster0->GetX(); tmax0=cluster0->GetTimeBin();}
1256 ncl0++;
1257 if (cluster0->GetDetector()%36<18) nclA0++;
1258 if (cluster0->GetDetector()%36>=18) nclC0++;
1259 }
1260 AliTPCclusterMI *cluster1=seed1->GetClusterPointer(irow);
1261 if (cluster1&&cluster1->GetX()>10){
1262 if (cluster1->GetX()<rmin1) { rmin1=cluster1->GetX(); tmin1=cluster1->GetTimeBin();}
1263 if (cluster1->GetX()>rmax1) { rmax1=cluster1->GetX(); tmax1=cluster1->GetTimeBin();}
1264 ncl1++;
1265 if (cluster1->GetDetector()%36<18) nclA1++;
1266 if (cluster1->GetDetector()%36>=18) nclC1++;
1267 }
1268 }
1269 Int_t cosmicType=0; // types of cosmic topology
1270 if ((nclA0>nclC0) && (nclA1>nclC1)) cosmicType=0; // AA side
1271 if ((nclA0<nclC0) && (nclA1<nclC1)) cosmicType=1; // CC side
1272 if ((nclA0>nclC0) && (nclA1<nclC1)) cosmicType=2; // AC side
1273 if ((nclA0<nclC0) && (nclA1>nclC1)) cosmicType=3; // CA side
1274 //if ((nclA0>nclC0) && (nclA1<nclC1)) cosmicType=6; // AC side out of time
1275 //if ((nclA0>nclC0) && (nclA1<nclC1)) cosmicType=7; // CA side out of time
1276 //
1277 Double_t deltaTime = 0; // correction for trigger not in time - equalizing the time arival
1278 if ((cosmicType>1)&&TMath::Abs(track1->GetZ()-track0->GetZ())>4){
1279 cosmicType+=4;
1280 deltaTime=0.5*(track1->GetZ()-track0->GetZ())/param->GetZWidth();
1281 if (nclA0>nclC0) deltaTime*=-1; // if A side track
1282 }
1283 //
1284 TVectorD vectorDT(8);
1285 Int_t crossCounter=0;
1286 Double_t deltaTimeCross = AliTPCcalibCosmic::GetDeltaTime(rmin0, rmax0, rmin1, rmax1, tmin0, tmax0, tmin1, tmax1, TMath::Abs(track0->GetY()),vectorDT);
1287 Bool_t isOKTrigger=kTRUE;
1288 for (Int_t ic=0; ic<6;ic++) {
1289 if (TMath::Abs(vectorDT[ic])>0) {
1290 if (vectorDT[ic]+vectorDT[6]<0) isOKTrigger=kFALSE;
1291 if (vectorDT[ic]+vectorDT[7]>kMaxTime) isOKTrigger=kFALSE;
1292 if (isOKTrigger){
1293 crossCounter++;
1294 }
1295 }
1296 }
1297 Double_t deltaTimeCluster=deltaTime;
1298 if ((cosmicType==0 || cosmicType==1) && crossCounter>0){
1299 deltaTimeCluster=deltaTimeCross;
1300 cosmicType+=8;
1301 }
1302 if (nclA0*nclC0>0 || nclA1*nclC1>0) cosmicType+=16; // mixed A side C side - bad for visualization
1303 //
1304 // Apply current transformation
1305 //
1306 //
1307 for (Int_t irow=0; irow<159; irow++){
1308 AliTPCclusterMI *cluster0=seed0->GetClusterPointer(irow);
1309 if (cluster0 &&cluster0->GetX()>10){
1310 Double_t x0[3]={cluster0->GetRow(),cluster0->GetPad(),cluster0->GetTimeBin()+deltaTimeCluster};
1311 Int_t index0[1]={cluster0->GetDetector()};
1312 transform->Transform(x0,index0,0,1);
1313 cluster0->SetX(x0[0]);
1314 cluster0->SetY(x0[1]);
1315 cluster0->SetZ(x0[2]);
1316 //
1317 }
1318 AliTPCclusterMI *cluster1=seed1->GetClusterPointer(irow);
1319 if (cluster1&&cluster1->GetX()>10){
1320 Double_t x1[3]={cluster1->GetRow(),cluster1->GetPad(),cluster1->GetTimeBin()+deltaTimeCluster};
1321 Int_t index1[1]={cluster1->GetDetector()};
1322 transform->Transform(x1,index1,0,1);
1323 cluster1->SetX(x1[0]);
1324 cluster1->SetY(x1[1]);
1325 cluster1->SetZ(x1[2]);
1326 }
1327 }
1328 //
1329 //
1330 Double_t alpha=track0->GetAlpha(); // rotation frame
1331 Double_t cos = TMath::Cos(alpha);
1332 Double_t sin = TMath::Sin(alpha);
1333 Double_t mass = TDatabasePDG::Instance()->GetParticle("mu+")->Mass();
1334 AliExternalTrackParam btrack0=*(ftrack0->GetTPCOut());
1335 AliExternalTrackParam btrack1=*(ftrack1->GetTPCOut());
1336 btrack0.Rotate(alpha);
1337 btrack1.Rotate(alpha);
1338 // change the sign for track 1
1339 Double_t* par1=(Double_t*)btrack0.GetParameter();
1340 par1[3]*=-1;
1341 par1[4]*=-1;
1342 btrack0.AddCovariance(covar);
1343 btrack1.AddCovariance(covar);
1344 btrack0.ResetCovariance(kResetCov);
1345 btrack1.ResetCovariance(kResetCov);
1346 Bool_t isOK=kTRUE;
1347 Bool_t isOKT=kTRUE;
1348 TObjArray tracks0(ncorr+1);
1349 TObjArray tracks1(ncorr+1);
1350 //
1351 Double_t dEdx0Tot=seed0->CookdEdxAnalytical(0.02,0.6,kTRUE);
1352 Double_t dEdx1Tot=seed1->CookdEdxAnalytical(0.02,0.6,kTRUE);
1353 Double_t dEdx0Max=seed0->CookdEdxAnalytical(0.02,0.6,kFALSE);
1354 Double_t dEdx1Max=seed1->CookdEdxAnalytical(0.02,0.6,kFALSE);
1355 //if (TMath::Abs((dEdx0Max+1)/(dEdx0Tot+1)-1.)>0.1) isOK=kFALSE;
1356 //if (TMath::Abs((dEdx1Max+1)/(dEdx1Tot+1)-1.)>0.1) isOK=kFALSE;
1357 ncl0=0; ncl1=0;
1358 for (Int_t icorr=-1; icorr<ncorr; icorr++){
1359 AliExternalTrackParam rtrack0=btrack0;
1360 AliExternalTrackParam rtrack1=btrack1;
1361 AliTPCCorrection *corr = 0;
1362 if (icorr>=0) corr = (AliTPCCorrection*)corrArray->At(icorr);
1363 //
1364 for (Int_t irow=159; irow>0; irow--){
1365 AliTPCclusterMI *cluster=seed0->GetClusterPointer(irow);
1366 if (!cluster) continue;
1367 if (!isOKT) break;
1368 Double_t rD[3]={cluster->GetX(),cluster->GetY(),cluster->GetZ()};
1369 transform->RotatedGlobal2Global(cluster->GetDetector()%36,rD); // transform to global
1370 Float_t r[3]={rD[0],rD[1],rD[2]};
1371 if (corr){
1372 corr->DistortPoint(r, cluster->GetDetector());
1373 }
1374 //
1375 Double_t cov[3]={0.01,0.,0.01};
1376 Double_t lx =cos*r[0]+sin*r[1];
1377 Double_t ly =-sin*r[0]+cos*r[1];
1378 rD[1]=ly; rD[0]=lx; rD[2]=r[2]; //transform to track local
1379 if (!AliTracker::PropagateTrackToBxByBz(&rtrack0, lx,mass,1.,kFALSE)) isOKT=kFALSE;;
1380 if (!rtrack0.Update(&rD[1],cov)) isOKT =kFALSE;
1381 if (icorr<0) ncl0++;
1382 }
1383 //
1384 for (Int_t irow=159; irow>0; irow--){
1385 AliTPCclusterMI *cluster=seed1->GetClusterPointer(irow);
1386 if (!cluster) continue;
1387 if (!isOKT) break;
1388 Double_t rD[3]={cluster->GetX(),cluster->GetY(),cluster->GetZ()};
1389 transform->RotatedGlobal2Global(cluster->GetDetector()%36,rD);
1390 Float_t r[3]={rD[0],rD[1],rD[2]};
1391 if (corr){
1392 corr->DistortPoint(r, cluster->GetDetector());
1393 }
1394 //
1395 Double_t cov[3]={0.01,0.,0.01};
1396 Double_t lx =cos*r[0]+sin*r[1];
1397 Double_t ly =-sin*r[0]+cos*r[1];
1398 rD[1]=ly; rD[0]=lx; rD[2]=r[2];
1399 if (!AliTracker::PropagateTrackToBxByBz(&rtrack1, lx,mass,1.,kFALSE)) isOKT=kFALSE;
1400 if (!rtrack1.Update(&rD[1],cov)) isOKT=kFALSE;
1401 if (icorr<0) ncl1++;
1402 }
1403 if (!AliTracker::PropagateTrackToBxByBz(&rtrack0, 0,mass,10.,kFALSE)) isOKT=kFALSE;
1404 if (!AliTracker::PropagateTrackToBxByBz(&rtrack1, 0,mass,10.,kFALSE)) isOKT=kFALSE;
1405 if (!AliTracker::PropagateTrackToBxByBz(&rtrack0, 0,mass,1.,kFALSE)) isOKT=kFALSE;
1406 if (!AliTracker::PropagateTrackToBxByBz(&rtrack1, 0,mass,1.,kFALSE)) isOKT=kFALSE;
1407 const Double_t *param0=rtrack0.GetParameter();
1408 const Double_t *param1=rtrack1.GetParameter();
1409 for (Int_t ipar=0; ipar<4; ipar++){
1410 if (TMath::Abs(param1[ipar]-param0[ipar])>kMaxDelta[ipar]) isOK=kFALSE;
1411 }
1412 tracks0.AddAt(rtrack0.Clone(), icorr+1);
1413 tracks1.AddAt(rtrack1.Clone(), icorr+1);
1414 AliExternalTrackParam out0=*(ftrack0->GetTPCOut());
1415 AliExternalTrackParam out1=*(ftrack1->GetTPCOut());
1416 Int_t nentries=TMath::Min(ncl0,ncl1);
1417
1418 if (icorr<0) {
1419 (*pcstream)<<"cosmic"<<
1420 "isOK="<<isOK<< // correct all propagation update and also residuals
1421 "isOKT="<<isOKT<< // correct all propagation update
1422 "isOKTrigger="<<isOKTrigger<< // correct? estimate of trigger offset
1423 "id="<<cosmicType<<
1424 //
1425 //
1426 "cross="<<crossCounter<<
1427 "vDT.="<<&vectorDT<<
1428 //
1429 "dTime="<<deltaTime<< // delta time using the A-c side cross
1430 "dTimeCross="<<deltaTimeCross<< // delta time using missing clusters
1431 //
1432 "dEdx0Max="<<dEdx0Max<<
1433 "dEdx0Tot="<<dEdx0Tot<<
1434 "dEdx1Max="<<dEdx1Max<<
1435 "dEdx1Tot="<<dEdx1Tot<<
1436 //
1437 "track0.="<<track0<< // original track 0
1438 "track1.="<<track1<< // original track 1
1439 "out0.="<<&out0<< // outer track 0
1440 "out1.="<<&out1<< // outer track 1
1441 "rtrack0.="<<&rtrack0<< // refitted track with current transform
1442 "rtrack1.="<<&rtrack1<< //
1443 "ncl0="<<ncl0<<
1444 "ncl1="<<ncl1<<
1445 "entries="<<nentries<< // number of clusters
1446 "\n";
1447 }
1448 }
1449 //
1450
1451 if (isOK){
1452 Int_t nentries=TMath::Min(ncl0,ncl1);
1453 for (Int_t ipar=0; ipar<5; ipar++){
1454 for (Int_t icorr=-1; icorr<ncorr; icorr++){
1455 AliTPCCorrection *corr = 0;
1456 if (icorr>=0) corr = (AliTPCCorrection*)corrArray->At(icorr);
1457 //
1458 AliExternalTrackParam *param0=(AliExternalTrackParam *) tracks0.At(icorr+1);
1459 AliExternalTrackParam *param1=(AliExternalTrackParam *) tracks1.At(icorr+1);
1460 distortions[icorr+1]=param1->GetParameter()[ipar]-param0->GetParameter()[ipar];
1461 if (icorr>=0){
1462 distortions[icorr+1]-=distortions[0];
1463 }
1464 //
1465 if (icorr<0){
1466 Double_t bz=AliTrackerBase::GetBz();
1467 Double_t gxyz[3];
1468 param0->GetXYZ(gxyz);
1469 Int_t dtype=20;
1470 Double_t theta=param0->GetParameter()[3];
1471 Double_t phi = alpha;
1472 Double_t snp = track0->GetInnerParam()->GetSnp();
1473 Double_t mean= distortions[0];
1474 Int_t index = param0->GetIndex(ipar,ipar);
1475 Double_t rms=TMath::Sqrt(param1->GetCovariance()[index]+param1->GetCovariance()[index]);
1476 if (crossCounter<1) rms*=1;
1477 Double_t sector=9*phi/TMath::Pi();
1478 Double_t dsec = sector-TMath::Nint(sector+0.5);
1479 Double_t gx=gxyz[0],gy=gxyz[1],gz=gxyz[2];
1480 Double_t refX=TMath::Sqrt(gx*gx+gy*gy);
1481 Double_t dRrec=0;
1482 // Double_t pt=(param0->GetSigned1Pt()+param1->GetSigned1Pt())*0.5;
1483 Double_t pt=(param0->GetSigned1Pt()+param1->GetSigned1Pt())*0.5;
1484
1485 (*pcstream)<<"fit"<< // dump valus for fit
1486 "run="<<run<< //run number
1487 "bz="<<bz<< // magnetic filed used
1488 "dtype="<<dtype<< // detector match type 20
1489 "ptype="<<ipar<< // parameter type
1490 "theta="<<theta<< // theta
1491 "phi="<<phi<< // phi
1492 "snp="<<snp<< // snp
1493 "mean="<<mean<< // mean dist value
1494 "rms="<<rms<< // rms
1495 "sector="<<sector<<
1496 "dsec="<<dsec<<
1497 //
1498 "refX="<<refX<< // reference radius
1499 "gx="<<gx<< // global position
1500 "gy="<<gy<< // global position
1501 "gz="<<gz<< // global position
1502 "dRrec="<<dRrec<< // delta Radius in reconstruction
1503 "pt="<<pt<< //1/pt
1504 "id="<<cosmicType<< //type of the cosmic used
1505 "entries="<<nentries;// number of entries in bin
1506 (*pcstream)<<"cosmicDebug"<<
1507 "p0.="<<param0<< // dump distorted track 0
1508 "p1.="<<param1; // dump distorted track 1
1509 }
1510 if (icorr>=0){
1511 (*pcstream)<<"fit"<<
1512 Form("%s=",corr->GetName())<<distortions[icorr+1]; // dump correction value
1513 (*pcstream)<<"cosmicDebug"<<
1514 Form("%s=",corr->GetName())<<distortions[icorr+1]<< // dump correction value
1515 Form("%sp0.=",corr->GetName())<<param0<< // dump distorted track 0
1516 Form("%sp1.=",corr->GetName())<<param1; // dump distorted track 1
1517 }
1518 } //loop corrections
1519 (*pcstream)<<"fit"<<"isOK="<<isOK<<"\n";
1520 (*pcstream)<<"cosmicDebug"<<"isOK="<<isOK<<"\n";
1521 } //loop over parameters
1522 } // dump results
1523 }//loop tracks
1524}
1525
1526
1527
1528Double_t AliTPCcalibCosmic::GetDeltaTime(Double_t rmin0, Double_t rmax0, Double_t rmin1, Double_t rmax1, Double_t tmin0, Double_t tmax0, Double_t tmin1, Double_t tmax1, Double_t dcaR, TVectorD &vectorDT)
1529{
1530 //
1531 // Estimate trigger offset between random cosmic event and "physics" trigger
1532 // Efficiency about 50 % of cases:
1533 // Cases:
1534 // 0. Tracks crossing A side and C side - no match in z - 30 % of cases
1535 // 1. Track only on one side and dissapear at small or at high radiuses - 50 % of cases
1536 // 1.a) rmax<Rc && tmax<Tcmax && tmax>tmin => deltaT=Tcmax-tmax
1537 // 1.b) rmin>Rcmin && tmin<Tcmax && tmin>tmax => deltaT=Tcmax-tmin
1538 // // case the z matching gives proper time
1539 // 1.c) rmax<Rc && tmax>Tcmin && tmax<tmin => deltaT=-tmax
1540 //
1541 // check algorithm:
1542 // TCut cutStop = "(min(rmax0,rmax1)<235||abs(rmin0-rmin1)>10)"; // tracks not registered for full time
1543
1544 // Combinations:
1545 // 0-1 - forbidden
1546 // 0-2 - forbidden
1547 // 0-3 - occur - wrong correlation
1548 // 1-2 - occur - wrong correlation
1549 // 1-3 - forbidden
1550 // 2-3 - occur - small number of outlyers -20%
1551 // Frequency:
1552 // 0 - 106
1553 // 1 - 265
1554 // 2 - 206
1555 // 3 - 367
1556 //
1557 const Double_t kMaxRCut=235; // max radius
1558 const Double_t kMinRCut=TMath::Max(dcaR,90.); // min radius
1559 const Double_t kMaxDCut=30; // max distance for minimal radius
1560 const Double_t kMinTime=110;
1561 const Double_t kMaxTime=950;
1562 Double_t deltaT=0;
1563 Int_t counter=0;
1564 vectorDT[6]=TMath::Min(TMath::Min(tmin0,tmin1),TMath::Min(tmax0,tmax1));
1565 vectorDT[7]=TMath::Max(TMath::Max(tmin0,tmin1),TMath::Max(tmax0,tmax1));
1566 if (TMath::Min(rmax0,rmax1)<kMaxRCut){
1567 // max cross - deltaT>0
1568 if (rmax0<kMaxRCut && tmax0 <kMaxTime && tmax0>tmin0) vectorDT[0]=kMaxTime-tmax0; // disapear at CE
1569 if (rmax1<kMaxRCut && tmax1 <kMaxTime && tmax1>tmin1) vectorDT[1]=kMaxTime-tmax1; // disapear at CE
1570 // min cross - deltaT<0 - OK they are correlated
1571 if (rmax0<kMaxRCut && tmax0 >kMinTime && tmax0<tmin0) vectorDT[2]=-tmax0; // disapear at ROC
1572 if (rmax1<kMaxRCut && tmax1 >kMinTime && tmax1<tmin1) vectorDT[3]=-tmax1; // disapear at ROC
1573 }
1574 if (rmin0> kMinRCut+kMaxDCut && tmin0 <kMaxTime && tmin0>tmax0) vectorDT[4]=kMaxTime-tmin0;
1575 if (rmin1> kMinRCut+kMaxDCut && tmin1 <kMaxTime && tmin1>tmax1) vectorDT[5]=kMaxTime-tmin1;
1576 Bool_t isOK=kTRUE;
1577 for (Int_t i=0; i<6;i++) {
1578 if (TMath::Abs(vectorDT[i])>0) {
1579 counter++;
1580 if (vectorDT[i]+vectorDT[6]<0) isOK=kFALSE;
1581 if (vectorDT[i]+vectorDT[7]>kMaxTime) isOK=kFALSE;
1582 if (isOK) deltaT=vectorDT[i];
1583 }
1584 }
1585 return deltaT;
1586}