1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 /**************************************************************************
20 * This class builds AliTPCtrack objects from generated tracks to feed *
21 * ITS tracking (V2). The AliTPCtrack is built from its first hit in *
22 * the TPC. The track is assigned a Kalman-like covariance matrix *
23 * depending on its pT and pseudorapidity and track parameters are *
24 * smeared according to this covariance matrix. *
25 * Output file contains sorted tracks, ready for matching with ITS. *
28 * Alice Internal Note 2003-011 *
30 * Test macro is: AliBarrelRec_TPCparam.C *
32 * 2002/10/01: Introduction of the database for pp collisions (B=0.4 T) *
33 * - Everything done separately for pions, kaons, protons, electrons and *
35 * - Now (only for pp) the tracks are built from the AliTrackReferences *
36 * which contain the position and momentum of all tracks at R = 83 cm; *
37 * This eliminates the loss of tracks due the dead zone of the TPC *
38 * where the 1st hit is not created. *
39 * - In AliBarrelRec_TPCparam.C there many possible ways of determining *
40 * the z coordinate of the primary vertex in pp events (from pixels, *
41 * from ITS tracks, smearing according to resolution given by tracks. *
43 * 2002/04/28: Major upgrade of the class *
44 * - Covariance matrices and pulls are now separeted for pions, kaons *
46 * - A parameterization of dE/dx in the TPC has been included and it is *
47 * used to assign a mass to each track according to a rough dE/dx PID. *
48 * - All the "numbers" have been moved to the file with the DataBase, *
49 * they are read as objects of the class AliTPCkineGrid, and assigned *
50 * to data memebers of the class AliTPCtrackerParam. *
51 * - All the code necessary to create a BataBase has been included in *
52 * class (see the macro AliTPCtrackingParamDB.C for the details). *
54 * Origin: Andrea Dainese, Padova - e-mail: andrea.dainese@pd.infn.it *
56 **************************************************************************/
58 // This is a dummy comment
62 //------- Root headers --------
63 #include <Riostream.h>
68 #include <TGraphErrors.h>
72 #include <TParticle.h>
76 //------ AliRoot headers ------
77 #include "AliGausCorr.h"
78 #include "AliTracker.h"
82 #include "AliRunLoader.h"
84 #include "AliTPCParamSR.h"
85 #include "AliTPCkineGrid.h"
86 #include "AliTPCtrack.h"
87 #include "AliTPCtrackerParam.h"
88 #include "AliTrackReference.h"
89 //-----------------------------
91 Double_t RegFunc(Double_t *x,Double_t *par) {
92 // This is the function used to regularize the covariance matrix
93 Double_t value = par[0]+par[1]/TMath::Power(x[0],par[2]);
97 // structure for DB building
107 Double_t dP0,dP1,dP2,dP3,dP4;
108 Double_t c00,c10,c11,c20,c21,c22,c30,c31,c32,c33,c40,c41,c42,c43,c44;
111 // cov matrix structure
113 Double_t c00,c10,c11,c20,c21,c22,c30,c31,c32,c33,c40,c41,c42,c43,c44;
116 ClassImp(AliTPCtrackerParam)
118 //-----------------------------------------------------------------------------
119 AliTPCtrackerParam::AliTPCtrackerParam(Int_t kcoll, Double_t kBz,
120 Int_t kn, const char* evfoldname):
121 fEvFolderName(evfoldname) {
122 //-----------------------------------------------------------------------------
123 // This is the class conctructor
124 //-----------------------------------------------------------------------------
126 fNevents = kn; // events to be processed
127 fBz = kBz; // value of the z component of L3 field (Tesla)
128 fColl = kcoll; // collision code (0: PbPb6000; 1: pp)
129 fSelAndSmear = kTRUE; // by default selection and smearing are done
132 cerr<<"AliTPCtrackerParam::AliTPCtrackerParam: Invalid field!\n";
133 cerr<<" Available: 0.4"<<endl;
135 if(fColl!=0 && fColl!=1) {
136 cerr<<"AliTPCtrackerParam::AliTPCtrackerParam: Invalid collision!\n";
137 cerr<<" Available: 0 -> PbPb6000"<<endl;
138 cerr<<" 1 -> pp"<<endl;
141 fDBfileName = gSystem->Getenv("ALICE_ROOT");
142 fDBfileName.Append("/TPC/CovMatrixDB_");
143 //fDBfileName = "CovMatrixDB_";
144 if(fColl==0) fDBfileName.Append("PbPb6000");
145 if(fColl==1) fDBfileName.Append("pp");
146 if(fBz==0.4) fDBfileName.Append("_B0.4T.root");
148 //-----------------------------------------------------------------------------
149 AliTPCtrackerParam::~AliTPCtrackerParam() {}
150 //____________________________________________________________________________
151 AliTPCtrackerParam::AliTPCtrackerParam( const AliTPCtrackerParam& p):TObject(p)
153 // dummy copy constructor
155 //----------------------------------------------------------------------------
156 AliTPCtrackerParam::AliTPCseedGeant::AliTPCseedGeant(
157 Double_t x,Double_t y,Double_t z,
158 Double_t px,Double_t py,Double_t pz,
160 //----------------------------------------------------------------------------
161 // Constructor of the geant seeds
162 //----------------------------------------------------------------------------
170 Double_t a = TMath::ATan2(y,x)*180./TMath::Pi();
172 fSector = (Int_t)(a/20.);
173 fAlpha = 10.+20.*fSector;
175 fAlpha *= TMath::Pi();
177 //-----------------------------------------------------------------------------
178 Int_t AliTPCtrackerParam::BuildTPCtracks(const TFile *inp, TFile *out) {
179 //-----------------------------------------------------------------------------
180 // This function creates the TPC parameterized tracks
181 //-----------------------------------------------------------------------------
183 Error("BuildTPCtracks","in and out parameters ignored. new io");
185 /********************************************/
186 AliRunLoader* rl = AliRunLoader::GetRunLoader(fEvFolderName);
189 Error("BuildTPCtracks","Can not get Run Loader from event folder named %s.",
190 fEvFolderName.Data());
193 AliLoader* tpcloader = rl->GetLoader("TPCLoader");
194 if (tpcloader == 0x0)
196 Error("BuildTPCtracks","Can not get TPC Loader from Run Loader.");
200 /********************************************/
203 TTree *covTreePi[50];
204 TTree *covTreeKa[50];
205 TTree *covTreePr[50];
206 TTree *covTreeEl[50];
207 TTree *covTreeMu[50];
210 cerr<<"+++\n+++ Reading DataBase from:\n+++ "<<
211 fDBfileName.Data()<<"\n+++\n";
212 // Read paramters from DB file
213 if(!ReadAllData(fDBfileName.Data())) {
214 cerr<<"AliTPCtrackerParam::BuildTPCtracks: \
215 Could not read data from DB\n\n"; return 1;
218 // Read the trees with regularized cov. matrices from DB
220 fileDB = TFile::Open(fDBfileName.Data());
221 Int_t nBinsPi = fDBgridPi.GetTotBins();
222 for(Int_t l=0; l<nBinsPi; l++) {
223 str = "/CovMatrices/Pions/CovTreePi_bin";
225 covTreePi[l] = (TTree*)fileDB->Get(str.Data());
227 Int_t nBinsKa = fDBgridKa.GetTotBins();
228 for(Int_t l=0; l<nBinsKa; l++) {
229 str = "/CovMatrices/Kaons/CovTreeKa_bin";
231 covTreeKa[l] = (TTree*)fileDB->Get(str.Data());
233 Int_t nBinsPr = fDBgridPr.GetTotBins();
234 for(Int_t l=0; l<nBinsPr; l++) {
236 str = "/CovMatrices/Pions/CovTreePi_bin";
238 str = "/CovMatrices/Protons/CovTreePr_bin";
241 covTreePr[l] = (TTree*)fileDB->Get(str.Data());
243 Int_t nBinsEl = fDBgridEl.GetTotBins();
244 for(Int_t l=0; l<nBinsEl; l++) {
245 str = "/CovMatrices/Electrons/CovTreeEl_bin";
247 covTreeEl[l] = (TTree*)fileDB->Get(str.Data());
249 Int_t nBinsMu = fDBgridMu.GetTotBins();
250 for(Int_t l=0; l<nBinsMu; l++) {
252 str = "/CovMatrices/Pions/CovTreePi_bin";
254 str = "/CovMatrices/Muons/CovTreeMu_bin";
257 covTreeMu[l] = (TTree*)fileDB->Get(str.Data());
260 } else cerr<<"\n ! Creating ALL TRUE tracks at TPC 1st hit !\n\n";
262 TFile *infile=(TFile*)inp;
265 // Get gAlice object from file
269 tpcloader->LoadHits("read");
271 if(!(gAlice=rl->GetAliRun())) {
272 cerr<<"Can not get gAlice from Run Loader !\n";
276 // Check if value in the galice file is equal to selected one (fBz)
277 AliMagF *fiel = (AliMagF*)gAlice->Field();
278 Double_t fieval=(Double_t)fiel->SolenoidField()/10.;
279 printf("Magnetic field is %6.2f Tesla\n",fieval);
281 cerr<<"AliTPCtrackerParam::BuildTPCtracks: Invalid field!"<<endl;
282 cerr<<"Field selected is: "<<fBz<<" T\n";
283 cerr<<"Field found on file is: "<<fieval<<" T\n";
288 AliTPC *tpc=(AliTPC*)gAlice->GetDetector("TPC");
289 Int_t ver = tpc->IsVersion();
290 cerr<<"+++ TPC version "<<ver<<" has been found !\n";
293 AliTPCParam *digp=(AliTPCParam*)infile->Get("75x40_100x60");
296 digp = new AliTPCParamSR();
298 else digp=(AliTPCParam*)infile->Get("75x40_100x60_150x60");
300 if(!digp) { cerr<<"TPC parameters have not been found !\n"; return 1; }
303 // Set the conversion constant between curvature and Pt
304 AliTracker::SetFieldMap(fiel,kTRUE);
307 AliTPCseedGeant *seed=0;
308 AliTPCtrack *tpctrack=0;
310 Int_t cl=0,bin,label,pdg,charge;
312 Int_t nParticles,nSeeds,arrentr;
314 //Int_t nSel=0,nAcc=0;
317 // loop over first n events in file
318 for(Int_t evt=0; evt<fNevents; evt++){
319 cerr<<"+++\n+++ Processing event "<<evt<<"\n+++\n";
322 // tree for TPC tracks
323 sprintf(tname,"TreeT_TPC_%d",evt);
324 TTree *tracktree = new TTree(tname,"Tree with TPC tracks");
325 tracktree->Branch("tracks","AliTPCtrack",&tpctrack,20000,0);
327 // array for TPC tracks
328 TObjArray tArray(20000);
330 // array for TPC seeds with geant info
331 TObjArray sArray(20000);
333 // get the particles stack
334 nParticles = (Int_t)gAlice->GetEvent(evt);
336 Bool_t *done = new Bool_t[nParticles];
337 Int_t *pdgCodes = new Int_t[nParticles];
338 Double_t *ptkine = new Double_t[nParticles];
339 Double_t *pzkine = new Double_t[nParticles];
341 // loop on particles and store pdg codes
342 for(Int_t l=0; l<nParticles; l++) {
343 part = (TParticle*)gAlice->GetMCApp()->Particle(l);
344 pdgCodes[l] = part->GetPdgCode();
345 ptkine[l] = part->Pt();
346 pzkine[l] = part->Pz();
349 cerr<<"+++\n+++ Number of particles in event "<<evt<<": "<<nParticles<<
352 cerr<<"\n ********** MAKING SEEDS *****************"<<endl<<endl;
355 // Create the seeds for the TPC tracks at the inner radius of TPC
357 // Get TreeH with hits
358 TTree *th = tpcloader->TreeH();
359 MakeSeedsFromHits(tpc,th,sArray);
361 // Get TreeTR with track references
362 TTree *ttr = rl->TreeTR();
363 MakeSeedsFromRefs(ttr,sArray);
367 nSeeds = sArray.GetEntries();
368 cerr<<"\n\n+++\n+++ Number of seeds: "<<nSeeds<<"\n+++\n";
371 cerr<<"\n ********** BUILDING TRACKS **************"<<endl<<endl;
373 // loop over entries in sArray
374 for(Int_t l=0; l<nSeeds; l++) {
375 //if(l%1000==0) cerr<<" --- Processing seed "
376 // <<l<<" of "<<nSeeds<<" ---\r";
378 seed = (AliTPCseedGeant*)sArray.At(l);
380 // this is TEMPORARY: only for reconstruction of pp production for charm
381 if(fColl==1) cl = CheckLabel(seed,nParticles,ptkine,pzkine);
385 label = seed->GetLabel();
387 // check if this track has already been processed
388 if(done[label]) continue;
389 // PDG code & electric charge
390 pdg = pdgCodes[label];
391 if(pdg>200 || pdg==-11 || pdg==-13) { charge=1; }
392 else if(pdg<-200 || pdg==11 || pdg==13) { charge=-1; }
394 pdg = TMath::Abs(pdg);
395 if(pdg>3000) pdg=211;
397 if(fSelAndSmear) SetParticle(pdg);
401 sEta = seed->GetEta();
403 // Apply selection according to TPC efficiency
404 //if(TMath::Abs(pdg)==211) nAcc++;
405 if(fSelAndSmear && !SelectedTrack(sPt,sEta)) continue;
406 //if(TMath::Abs(pdg)==211) nSel++;
408 // create AliTPCtrack object
409 BuildTrack(seed,charge);
412 bin = fDBgrid->GetBin(sPt,sEta);
415 fCovTree = covTreePi[bin];
418 fCovTree = covTreeKa[bin];
421 fCovTree = covTreePr[bin];
424 fCovTree = covTreeEl[bin];
427 fCovTree = covTreeMu[bin];
430 // deal with covariance matrix and smearing of parameters
433 // assign the track a dE/dx and make a rough PID
437 // put track in array
438 AliTPCtrack *iotrack = new AliTPCtrack(fTrack);
439 iotrack->SetLabel(label);
440 tArray.AddLast(iotrack);
441 // Mark track as "done" and register the pdg code
445 } // loop over entries in sArray
448 // sort array with TPC tracks (decreasing pT)
451 arrentr = tArray.GetEntriesFast();
452 for(Int_t l=0; l<arrentr; l++) {
453 tpctrack=(AliTPCtrack*)tArray.UncheckedAt(l);
458 // write the tree with tracks in the output file
468 printf("\n\n+++\n+++ Number of TPC tracks: %d\n+++\n",tracks);
469 //cerr<<"Average Eff: "<<(Float_t)nSel/nAcc<<endl;
477 if(fileDB) fileDB->Close();
481 //-----------------------------------------------------------------------------
482 void AliTPCtrackerParam::AnalyzedEdx(const Char_t *outName,Int_t pdg) {
483 //-----------------------------------------------------------------------------
484 // This function computes the dE/dx for pions, kaons, protons and electrons,
485 // in the [pT,eta] bins.
486 // Input file is CovMatrix_AllEvts.root.
487 //-----------------------------------------------------------------------------
489 gStyle->SetOptStat(0);
490 gStyle->SetOptFit(10001);
492 const char *part="PIONS";
496 // create a chain with compared tracks
497 TChain *cmptrkchain = new ("cmptrktree");
498 cmptrkchain.Add("CovMatrix_AllEvts.root");
499 //cmptrkchain.Add("CovMatrix_AllEvts_1.root");
500 //cmptrkchain.Add("CovMatrix_AllEvts_2.root");
501 //cmptrkchain.Add("CovMatrix_AllEvts_3.root");
505 TFile *infile = TFile::Open("CovMatrix_AllEvts.root");
506 TTree *cmptrktree = (TTree*)infile->Get("cmptrktree");
509 cmptrktree->SetBranchAddress("comptracks",&cmptrk);
510 Int_t entries = (Int_t)cmptrktree->GetEntries();
511 cerr<<" Number of entries: "<<entries<<endl;
513 InitializeKineGrid("DB");
514 InitializeKineGrid("dEdx");
541 const Int_t knTotBins = fDBgrid->GetTotBins();
543 cerr<<" Fit bins: "<<knTotBins<<endl;
546 Int_t *n = new Int_t[knTotBins];
547 Double_t *p = new Double_t[knTotBins];
548 Double_t *ep = new Double_t[knTotBins];
549 Double_t *mean = new Double_t[knTotBins];
550 Double_t *sigma = new Double_t[knTotBins];
552 for(Int_t l=0; l<knTotBins; l++) {
553 n[l] = 1; // set to 1 to avoid divisions by 0
554 p[l] = mean[l] = sigma[l] = ep[l] = 0.;
557 // loop on chain entries for the mean
558 for(Int_t l=0; l<entries; l++) {
559 cmptrktree->GetEvent(l);
560 if(TMath::Abs(cmptrk.pdg)!=pdg) continue;
561 bin = fDBgrid->GetBin(cmptrk.pt,cmptrk.eta);
563 mean[bin] += cmptrk.dEdx;
565 } // loop on chain entries
567 for(Int_t l=0; l<knTotBins; l++) {
570 n[l] = 1; // set to 1 to avoid divisions by 0
573 // loop on chain entries for the sigma
574 for(Int_t l=0; l<entries; l++) {
575 cmptrktree->GetEvent(l);
576 if(TMath::Abs(cmptrk.pdg)!=pdg) continue;
577 bin = fDBgrid->GetBin(cmptrk.pt,cmptrk.eta);
578 if(cmptrk.p<1. && TMath::Abs(cmptrk.p-p[bin])>0.025) continue;
580 sigma[bin] += (cmptrk.dEdx-mean[bin])*(cmptrk.dEdx-mean[bin]);
581 } // loop on chain entries
583 for(Int_t l=0; l<knTotBins; l++) {
584 sigma[l] = TMath::Sqrt(sigma[l]/n[l]);
588 TCanvas *canv = new TCanvas("canv","dEdx",0,0,900,700);
590 // create the graph for dEdx vs p
591 TGraphErrors *gr = new TGraphErrors(knTotBins,p,mean,ep,sigma);
592 TString title(" : dE/dx vs momentum"); title.Prepend(part);
593 TH2F *frame = new TH2F("frame1",title.Data(),2,0.1,50,2,0,ymax);
594 frame->SetXTitle("p [GeV/c]");
595 frame->SetYTitle("dE/dx [a.u.]");
602 for(Int_t i=0; i<knTotBins; i++) {
603 fdEdxMeanPi.SetParam(i,mean[i]);
604 fdEdxRMSPi.SetParam(i,sigma[i]);
608 for(Int_t i=0; i<knTotBins; i++) {
609 fdEdxMeanKa.SetParam(i,mean[i]);
610 fdEdxRMSKa.SetParam(i,sigma[i]);
614 for(Int_t i=0; i<knTotBins; i++) {
615 fdEdxMeanPr.SetParam(i,mean[i]);
616 fdEdxRMSPr.SetParam(i,sigma[i]);
620 for(Int_t i=0; i<knTotBins; i++) {
621 fdEdxMeanEl.SetParam(i,mean[i]);
622 fdEdxRMSEl.SetParam(i,sigma[i]);
626 for(Int_t i=0; i<knTotBins; i++) {
627 fdEdxMeanMu.SetParam(i,mean[i]);
628 fdEdxRMSMu.SetParam(i,sigma[i]);
633 // write results to file
634 WritedEdx(outName,pdg);
644 //-----------------------------------------------------------------------------
645 void AliTPCtrackerParam::AnalyzePulls(const Char_t *outName) {
646 //-----------------------------------------------------------------------------
647 // This function computes the pulls for pions, kaons and electrons,
648 // in the [pT,eta] bins.
649 // Input file is CovMatrix_AllEvts.root.
650 // Output file is pulls.root.
651 //-----------------------------------------------------------------------------
654 // create a chain with compared tracks
655 TChain *cmptrkchain = new ("cmptrktree");
656 cmptrkchain.Add("CovMatrix_AllEvts.root");
657 //cmptrkchain.Add("CovMatrix_AllEvts_1.root");
658 //cmptrkchain.Add("CovMatrix_AllEvts_2.root");
659 //cmptrkchain.Add("CovMatrix_AllEvts_3.root");
663 TFile *infile = TFile::Open("CovMatrix_AllEvts.root");
664 TTree *cmptrktree = (TTree*)infile->Get("cmptrktree");
667 cmptrktree->SetBranchAddress("comptracks",&cmptrk);
668 Int_t entries = (Int_t)cmptrktree->GetEntries();
669 cerr<<" Number of entries: "<<entries<<endl;
672 Char_t hname[100], htitle[100];
675 AliTPCkineGrid pulls[5];
676 TH1F *hDum = new TH1F("name","title",100,-7.,7.);
677 TF1 *g = new TF1("g","gaus");
679 InitializeKineGrid("pulls");
680 InitializeKineGrid("DB");
684 // loop on the particles Pi,Ka,Pr,El,Mu
685 for(Int_t part=0; part<5; part++) {
690 cerr<<" Processing pions ...\n";
694 cerr<<" Processing kaons ...\n";
698 cerr<<" Processing protons ...\n";
702 cerr<<" Processing electrons ...\n";
706 cerr<<" Processing muons ...\n";
710 SetParticle(thisPdg);
712 for(Int_t i=0;i<5;i++) {
713 pulls[i].~AliTPCkineGrid();
714 new(&pulls[i]) AliTPCkineGrid(*(fPulls+i));
716 nTotBins = fDBgrid->GetTotBins();
717 cerr<<"nTotBins = "<<nTotBins<<endl;
719 // create histograms for the all the bins
726 hPulls0 = new TH1F[nTotBins];
727 hPulls1 = new TH1F[nTotBins];
728 hPulls2 = new TH1F[nTotBins];
729 hPulls3 = new TH1F[nTotBins];
730 hPulls4 = new TH1F[nTotBins];
733 for(Int_t i=0; i<nTotBins; i++) {
734 sprintf(hname,"hPulls0%d",i);
735 sprintf(htitle,"P0 pulls for bin %d",i);
736 hDum->SetName(hname); hDum->SetTitle(htitle);
738 sprintf(hname,"hPulls1%d",i);
739 sprintf(htitle,"P1 pulls for bin %d",i);
740 hDum->SetName(hname); hDum->SetTitle(htitle);
742 sprintf(hname,"hPulls2%d",i);
743 sprintf(htitle,"P2 pulls for bin %d",i);
744 hDum->SetName(hname); hDum->SetTitle(htitle);
746 sprintf(hname,"hPulls3%d",i);
747 sprintf(htitle,"P3 pulls for bin %d",i);
748 hDum->SetName(hname); hDum->SetTitle(htitle);
750 sprintf(hname,"hPulls4%d",i);
751 sprintf(htitle,"P4 pulls for bin %d",i);
752 hDum->SetName(hname); hDum->SetTitle(htitle);
756 // loop on chain entries
757 for(Int_t i=0; i<entries; i++) {
758 cmptrktree->GetEvent(i);
759 if(TMath::Abs(cmptrk.pdg)!=thisPdg) continue;
760 // fill histograms with the pulls
761 bin = fDBgrid->GetBin(cmptrk.pt,cmptrk.eta);
762 //cerr<<" pt "<<cmptrk.pt<<" eta "<<cmptrk.eta<<" bin "<<bin<<endl;
763 hPulls0[bin].Fill(cmptrk.dP0/TMath::Sqrt(cmptrk.c00));
764 hPulls1[bin].Fill(cmptrk.dP1/TMath::Sqrt(cmptrk.c11));
765 hPulls2[bin].Fill(cmptrk.dP2/TMath::Sqrt(cmptrk.c22));
766 hPulls3[bin].Fill(cmptrk.dP3/TMath::Sqrt(cmptrk.c33));
767 hPulls4[bin].Fill(cmptrk.dP4/TMath::Sqrt(cmptrk.c44));
768 } // loop on chain entries
770 // compute the sigma of the distributions
771 for(Int_t i=0; i<nTotBins; i++) {
772 if(hPulls0[i].GetEntries()>10) {
773 g->SetRange(-3.*hPulls0[i].GetRMS(),3.*hPulls0[i].GetRMS());
774 hPulls0[i].Fit("g","R,Q,N");
775 pulls[0].SetParam(i,g->GetParameter(2));
776 } else pulls[0].SetParam(i,-1.);
777 if(hPulls1[i].GetEntries()>10) {
778 g->SetRange(-3.*hPulls1[i].GetRMS(),3.*hPulls1[i].GetRMS());
779 hPulls1[i].Fit("g","R,Q,N");
780 pulls[1].SetParam(i,g->GetParameter(2));
781 } else pulls[1].SetParam(i,-1.);
782 if(hPulls2[i].GetEntries()>10) {
783 g->SetRange(-3.*hPulls2[i].GetRMS(),3.*hPulls2[i].GetRMS());
784 hPulls2[i].Fit("g","R,Q,N");
785 pulls[2].SetParam(i,g->GetParameter(2));
786 } else pulls[2].SetParam(i,-1.);
787 if(hPulls3[i].GetEntries()>10) {
788 g->SetRange(-3.*hPulls3[i].GetRMS(),3.*hPulls3[i].GetRMS());
789 hPulls3[i].Fit("g","R,Q,N");
790 pulls[3].SetParam(i,g->GetParameter(2));
791 } else pulls[3].SetParam(i,-1.);
792 if(hPulls4[i].GetEntries()>10) {
793 g->SetRange(-3.*hPulls4[i].GetRMS(),3.*hPulls4[i].GetRMS());
794 hPulls4[i].Fit("g","R,Q,N");
795 pulls[4].SetParam(i,g->GetParameter(2));
796 } else pulls[4].SetParam(i,-1.);
802 for(Int_t i=0;i<5;i++) {
803 fPullsPi[i].~AliTPCkineGrid();
804 new(&fPullsPi[i]) AliTPCkineGrid(pulls[i]);
808 for(Int_t i=0;i<5;i++) {
809 fPullsKa[i].~AliTPCkineGrid();
810 new(&fPullsKa[i]) AliTPCkineGrid(pulls[i]);
814 for(Int_t i=0;i<5;i++) {
815 fPullsPr[i].~AliTPCkineGrid();
816 new(&fPullsPr[i]) AliTPCkineGrid(pulls[i]);
820 for(Int_t i=0;i<5;i++) {
821 fPullsEl[i].~AliTPCkineGrid();
822 new(&fPullsEl[i]) AliTPCkineGrid(pulls[i]);
826 for(Int_t i=0;i<5;i++) {
827 fPullsMu[i].~AliTPCkineGrid();
828 new(&fPullsMu[i]) AliTPCkineGrid(pulls[i]);
829 //cerr<<" mu pulls "<<i<<" "<<fPullsMu[i].GetParam(0)<<endl;
840 } // loop on particle species
842 // write pulls to file
848 //-----------------------------------------------------------------------------
849 void AliTPCtrackerParam::AnalyzeResolutions(Int_t pdg) {
850 //-----------------------------------------------------------------------------
851 // This function computes the resolutions:
855 // as a function of Pt
856 // Input file is CovMatrix_AllEvts.root.
857 //-----------------------------------------------------------------------------
860 // create a chain with compared tracks
861 TChain *cmptrkchain = new ("cmptrktree");
862 cmptrkchain.Add("CovMatrix_AllEvts.root");
863 //cmptrkchain.Add("CovMatrix_AllEvts_1.root");
864 //cmptrkchain.Add("CovMatrix_AllEvts_2.root");
865 //cmptrkchain.Add("CovMatrix_AllEvts_3.root");
869 TFile *infile = TFile::Open("CovMatrix_AllEvts.root");
870 TTree *cmptrktree = (TTree*)infile->Get("cmptrktree");
873 cmptrktree->SetBranchAddress("comptracks",&cmptrk);
874 Int_t entries = (Int_t)cmptrktree->GetEntries();
875 cerr<<" Number of entries: "<<entries<<endl;
880 InitializeKineGrid("DB");
881 InitializeKineGrid("eff");
885 const Int_t knPtBins = fEff->GetPointsPt();
886 cerr<<"knPtBins = "<<knPtBins<<endl;
887 Double_t *dP0 = new Double_t[knPtBins];
888 Double_t *dP4 = new Double_t[knPtBins];
889 Double_t *dPtToPt = new Double_t[knPtBins];
890 Double_t *pt = new Double_t[knPtBins];
891 fEff->GetArrayPt(pt);
894 TH1F *hDumP0 = new TH1F("nameP0","dy",100,-0.3,0.3);
895 TH1F *hDumP4 = new TH1F("nameP4","dC",100,-0.0005,0.0005);
896 TH1F *hDumPt = new TH1F("namePt","dp_{T}/p_{T}",100,-0.5,0.5);
898 TF1 *g = new TF1("g","gaus");
900 // create histograms for the all the bins
905 hP0 = new TH1F[knPtBins];
906 hP4 = new TH1F[knPtBins];
907 hPt = new TH1F[knPtBins];
909 for(Int_t i=0; i<knPtBins; i++) {
915 // loop on chain entries
916 for(Int_t i=0; i<entries; i++) {
917 cmptrktree->GetEvent(i);
918 if(TMath::Abs(cmptrk.pdg)!=pdg) continue;
919 // fill histograms with the residuals
920 bin = (Int_t)fDBgrid->GetBin(cmptrk.pt,cmptrk.eta)/fDBgrid->GetBinsEta();
921 //cerr<<" pt "<<cmptrk.pt<<" eta "<<cmptrk.eta<<" bin "<<bin<<endl;
922 hP0[bin].Fill(cmptrk.dP0);
923 hP4[bin].Fill(cmptrk.dP4);
924 hPt[bin].Fill(cmptrk.dpt/cmptrk.pt);
925 } // loop on chain entries
928 TCanvas *cP0res = new TCanvas("cP0res","cP0res",0,0,1200,700);
930 TCanvas *cP4res = new TCanvas("cP4res","cP4res",0,0,1200,700);
932 TCanvas *cPtres = new TCanvas("cPtres","cPtres",0,0,1200,700);
936 for(Int_t i=0; i<knPtBins; i++) {
937 cP0res->cd(i+1); hP0[i].Draw();
938 cP4res->cd(i+1); hP4[i].Draw();
939 cPtres->cd(i+1); hPt[i].Draw();
943 // compute the sigma of the distributions
944 for(Int_t i=0; i<knPtBins; i++) {
945 if(hP0[i].GetEntries()>10) {
946 g->SetRange(-3.*hP0[i].GetRMS(),3.*hP0[i].GetRMS());
947 hP0[i].Fit("g","R,Q,N");
948 dP0[i] = g->GetParameter(2);
950 if(hP4[i].GetEntries()>10) {
951 g->SetRange(-3.*hP4[i].GetRMS(),3.*hP4[i].GetRMS());
952 hP4[i].Fit("g","R,Q,N");
953 dP4[i] = g->GetParameter(2);
955 if(hPt[i].GetEntries()>10) {
956 g->SetRange(-3.*hPt[i].GetRMS(),3.*hPt[i].GetRMS());
957 hPt[i].Fit("g","R,Q,N");
958 dPtToPt[i] = 100.*g->GetParameter(2);
959 } else dPtToPt[i] = 0.;
963 TGraph *grdP0 = new TGraph(knPtBins,pt,dP0);
964 TGraph *grdP4 = new TGraph(knPtBins,pt,dP4);
965 TGraph *grdPtToPt = new TGraph(knPtBins,pt,dPtToPt);
967 grdP0->SetMarkerStyle(20); grdP0->SetMarkerColor(2); grdP0->SetMarkerSize(1.5);
968 grdP4->SetMarkerStyle(21); grdP4->SetMarkerColor(3); grdP4->SetMarkerSize(1.5);
969 grdPtToPt->SetMarkerStyle(22); grdPtToPt->SetMarkerColor(4); grdPtToPt->SetMarkerSize(1.5);
972 gStyle->SetOptStat(0);
973 TCanvas *c1 = new TCanvas("c1","dP0",0,0,900,700);
978 TH2F *frame1 = new TH2F("frame1","y resolution VS p_{T} in TPC",2,0.1,30,2,0,0.1);
979 frame1->SetXTitle("p_{T} [GeV/c]");
980 frame1->SetYTitle("#sigma(y) [cm]");
985 TCanvas *c2 = new TCanvas("c2","dP4",0,0,900,700);
990 TH2F *frame2 = new TH2F("frame2","C resolution VS p_{T} in TPC",2,0.1,30,2,0,0.0001);
991 frame2->SetXTitle("p_{T} [GeV/c]");
992 frame2->SetYTitle("#sigma(C) [1/cm]");
996 TCanvas *c3 = new TCanvas("c3","dPtToPt",0,0,900,700);
1002 TH2F *frame3 = new TH2F("frame3","Relative p_{T} resolution VS p_{T} in TPC",2,0.1,30,2,0.1,30.);
1003 frame3->SetXTitle("p_{T} [GeV/c]");
1004 frame3->SetYTitle("dp_{T}/p_{T} (%)");
1006 grdPtToPt->Draw("P");
1021 //-----------------------------------------------------------------------------
1022 void AliTPCtrackerParam::BuildTrack(AliTPCseedGeant *s,Int_t ch) {
1023 //-----------------------------------------------------------------------------
1024 // This function uses GEANT info to set true track parameters
1025 //-----------------------------------------------------------------------------
1026 Double_t xref = s->GetXL();
1027 Double_t xx[5],cc[15];
1028 cc[0]=cc[2]=cc[5]=cc[9]=cc[14]=10.;
1029 cc[1]=cc[3]=cc[4]=cc[6]=cc[7]=cc[8]=cc[10]=cc[11]=cc[12]=cc[13]=0.;
1032 TVector3 bfield(0.,0.,fBz);
1035 // radius [cm] of track projection in (x,y)
1036 Double_t rho = s->GetPt()*100./0.299792458/bfield.Z();
1037 // center of track projection in local reference frame
1041 // position (local) and momentum (local) at the seed
1042 // in the bending plane (z=0)
1043 sPos.SetXYZ(s->GetXL(),s->GetYL(),0.);
1044 sMom.SetXYZ(s->GetPx()*TMath::Cos(s->GetAlpha())+s->GetPy()*TMath::Sin(s->GetAlpha()),-s->GetPx()*TMath::Sin(s->GetAlpha())+s->GetPy()*TMath::Cos(s->GetAlpha()),0.);
1045 TVector3 vrho = sMom.Cross(bfield);
1049 TVector3 vcenter = sPos+vrho;
1051 Double_t x0 = vcenter.X();
1053 // fX = xref X-coordinate of this track (reference plane)
1054 // fAlpha = Alpha Rotation angle the local (TPC sector)
1055 // fP0 = YL Y-coordinate of a track
1056 // fP1 = ZG Z-coordinate of a track
1057 // fP2 = C*x0 x0 is center x in rotated frame
1058 // fP3 = Tgl tangent of the track momentum dip angle
1059 // fP4 = C track curvature
1062 xx[3] = s->GetPz()/s->GetPt();
1066 // create the object AliTPCtrack
1067 AliTPCtrack track(0,xx,cc,xref,s->GetAlpha());
1068 new(&fTrack) AliTPCtrack(track);
1072 //-----------------------------------------------------------------------------
1073 Int_t AliTPCtrackerParam::CheckLabel(AliTPCseedGeant *s,Int_t nPart,
1074 Double_t *ptkine,Double_t *pzkine) const {
1075 //-----------------------------------------------------------------------------
1076 // This function checks if the label of the seed has been correctly
1077 // assigned (to do only for pp charm production with AliRoot v3-08-02)
1078 //-----------------------------------------------------------------------------
1080 Int_t sLabel = s->GetLabel();
1081 Double_t sPt = s->GetPt();
1082 Double_t sPz = s->GetPz();
1084 // check if the label is correct (comparing momentum)
1086 TMath::Abs(sPt-ptkine[sLabel])*
1087 TMath::Abs(sPz-pzkine[sLabel])<0.001) return 0;
1089 if((sLabel-30)>=nPart) return 1;
1091 Double_t diff=0,mindiff=1000.;
1094 for(Int_t i=sLabel-30; i<sLabel; i++) {
1095 if(i<0 || i>=nPart) continue;
1096 diff = TMath::Abs(sPt-ptkine[i])*TMath::Abs(sPz-pzkine[i]);
1097 if(diff<mindiff) { mindiff = diff; bestLabel = i; }
1100 if(mindiff>0.001) return 1;
1101 s->SetLabel(bestLabel);
1105 //-----------------------------------------------------------------------------
1106 void AliTPCtrackerParam::CompareTPCtracks(
1107 const Char_t* galiceName,
1108 const Char_t* trkGeaName,
1109 const Char_t* trkKalName,
1110 const Char_t* covmatName,
1111 const Char_t* tpceffasciiName,
1112 const Char_t* tpceffrootName) {
1113 //-----------------------------------------------------------------------------
1114 // This function compares tracks from TPC Kalman Filter V2 with
1115 // geant tracks at TPC 1st hit. It gives:
1116 // - a tree with Kalman cov. matrix elements, resolutions, dEdx
1117 // - the efficiencies as a function of particle type, pT, eta
1118 //-----------------------------------------------------------------------------
1120 TFile *kalFile = TFile::Open(trkKalName);
1121 TFile *geaFile = TFile::Open(trkGeaName);
1122 TFile *galiceFile = TFile::Open(galiceName);
1124 // get the AliRun object
1125 AliRun *gAlice = (AliRun*)galiceFile->Get("gAlice");
1128 // create the tree for comparison results
1130 TTree *cmptrktree = new TTree("cmptrktree","results of track comparison");
1131 cmptrktree->Branch("comptracks",&cmptrk,"pdg/I:bin:r/D:p:pt:cosl:eta:dpt:dP0:dP1:dP2:dP3:dP4:c00:c10:c11:c20:c21:c22:c30:c31:c32:c33:c40:c41:c42:c43:c44:dEdx");
1133 InitializeKineGrid("eff");
1134 InitializeKineGrid("DB");
1135 Int_t effBins = fEffPi.GetTotPoints();
1136 Int_t effBinsPt = fEffPi.GetPointsPt();
1137 Double_t *pt = new Double_t[effBinsPt];
1138 fEffPi.GetArrayPt(pt);
1144 Double_t cc[15],dAlpha;
1145 Int_t pi=0,ka=0,mu=0,el=0,pr=0;
1146 Int_t *geaPi = new Int_t[effBins];
1147 Int_t *geaKa = new Int_t[effBins];
1148 Int_t *geaPr = new Int_t[effBins];
1149 Int_t *geaEl = new Int_t[effBins];
1150 Int_t *geaMu = new Int_t[effBins];
1151 Int_t *kalPi = new Int_t[effBins];
1152 Int_t *kalKa = new Int_t[effBins];
1153 Int_t *kalPr = new Int_t[effBins];
1154 Int_t *kalEl = new Int_t[effBins];
1155 Int_t *kalMu = new Int_t[effBins];
1156 Float_t *effPi = new Float_t[effBins];
1157 Float_t *effKa = new Float_t[effBins];
1158 Float_t *effPr = new Float_t[effBins];
1159 Float_t *effEl = new Float_t[effBins];
1160 Float_t *effMu = new Float_t[effBins];
1162 for(Int_t j=0; j<effBins; j++) {
1163 geaPi[j]=geaKa[j]=geaPr[j]=geaEl[j]=geaMu[j]=0;
1164 kalPi[j]=kalKa[j]=kalPr[j]=kalEl[j]=kalMu[j]=0;
1165 effPi[j]=effKa[j]=effPr[j]=effEl[j]=effMu[j]=-1.;
1170 // loop on events in file
1171 for(Int_t evt=0; evt<fNevents; evt++) {
1172 cerr<<"\n --- Reading tracks for event "<<evt<<" ---\n\n";
1173 sprintf(tname,"TreeT_TPC_%d",evt);
1175 // particles from TreeK
1176 const Int_t knparticles = gAlice->GetEvent(evt);
1178 Int_t *kalLab = new Int_t[knparticles];
1179 for(Int_t i=0; i<knparticles; i++) kalLab[i] = -1;
1182 // tracks from Kalman
1183 TTree *kaltree=(TTree*)kalFile->Get(tname);
1184 if(!kaltree) continue;
1185 AliTPCtrack *kaltrack=new AliTPCtrack;
1186 kaltree->SetBranchAddress("tracks",&kaltrack);
1187 Int_t kalEntries = (Int_t)kaltree->GetEntries();
1189 // tracks from 1st hit
1190 TTree *geatree=(TTree*)geaFile->Get(tname);
1191 if(!geatree) continue;
1192 AliTPCtrack *geatrack=new AliTPCtrack;
1193 geatree->SetBranchAddress("tracks",&geatrack);
1194 Int_t geaEntries = (Int_t)geatree->GetEntries();
1196 cerr<<"+++\n+++ Number of tracks: TPC Kalman = "<<kalEntries<<endl<<"+++ TPC 1st hit = "<<geaEntries<<endl<<"+++\n";
1198 // set pointers for TPC tracks:
1199 // the entry number of the track labelled l is stored in kalLab[l]
1200 Int_t fake=0,mult=0;
1201 for (Int_t j=0; j<kalEntries; j++) {
1202 kaltree->GetEvent(j);
1203 if(kaltrack->GetLabel()>=0) {
1204 if(kalLab[kaltrack->GetLabel()]!=-1) mult++;
1205 kalLab[kaltrack->GetLabel()] = j;
1210 cerr<<"+++ Number of fake tracks in TPC Kalman: "<<fake<<endl;
1211 cerr<<"+++ Number of multiply found tracks in TPC Kalman: "<<mult<<endl;
1214 // Read the labels of the seeds
1217 Bool_t *hasSeed = new Bool_t[knparticles];
1218 for(Int_t i=0; i<knparticles; i++) hasSeed[i] = kFALSE;
1219 sprintf(sname,"seedLabels.%d.dat",evt);
1220 FILE *seedFile = fopen(sname,"r");
1222 ncol = fscanf(seedFile,"%d",&sLabel);
1224 if(sLabel>0) hasSeed[sLabel]=kTRUE;
1229 cerr<<"Doing track comparison...\n";
1230 // loop on tracks at 1st hit
1231 for(Int_t j=0; j<geaEntries; j++) {
1232 geatree->GetEvent(j);
1234 label = geatrack->GetLabel();
1235 part = (TParticle*)gAlice->GetMCApp()->Particle(label);
1237 // use only injected tracks with fixed values of pT
1238 ptgener = part->Pt();
1240 for(Int_t l=0; l<fEffPi.GetPointsPt(); l++) {
1241 if(TMath::Abs(ptgener-pt[l])<0.01) usethis = kTRUE;
1243 if(!usethis) continue;
1245 // check if it has the seed
1246 //if(!hasSeed[label]) continue;
1249 // check if track is entirely contained in a TPC sector
1250 Bool_t out = kFALSE;
1251 for(Int_t l=0; l<10; l++) {
1252 Double_t x = 85. + (250.-85.)*(Double_t)l/9.;
1253 //cerr<<"x "<<x<<" X "<<geatrack->GetX()<<endl;
1254 Double_t y = geatrack->GetY() + (
1255 TMath::Sqrt(1-(geatrack->GetC()*geatrack->GetX()-geatrack->GetEta())*
1256 (geatrack->GetC()*geatrack->GetX()-geatrack->GetEta()))
1257 -TMath::Sqrt(1-(geatrack->GetC()*x-geatrack->GetEta())*
1258 (geatrack->GetC()*x-geatrack->GetEta()))
1261 //cerr<<"y "<<y<<" Y "<<geatrack->GetY()<<endl;
1262 if(y > 0.8*x*TMath::Tan(TMath::Pi()/18)) { out = kTRUE; break; }
1267 cmptrk.pdg = part->GetPdgCode();
1268 cmptrk.eta = part->Eta();
1269 cmptrk.r = TMath::Sqrt(part->Vx()*part->Vx()+part->Vy()*part->Vy());
1271 cmptrk.pt = 1/TMath::Abs(geatrack->Get1Pt());
1272 cmptrk.cosl = TMath::Cos(TMath::ATan(geatrack->GetTgl()));
1273 cmptrk.p = cmptrk.pt/cmptrk.cosl;
1276 bin = fDBgridPi.GetBin(cmptrk.pt,cmptrk.eta);
1278 if(abs(cmptrk.pdg)==211) geaPi[bin]++;
1279 if(abs(cmptrk.pdg)==321) geaKa[bin]++;
1280 if(abs(cmptrk.pdg)==2212) geaPr[bin]++;
1281 if(abs(cmptrk.pdg)==11) geaEl[bin]++;
1282 if(abs(cmptrk.pdg)==13) geaMu[bin]++;
1285 // check if there is the corresponding track in the TPC kalman and get it
1286 if(kalLab[label]==-1) continue;
1287 kaltree->GetEvent(kalLab[label]);
1289 // and go on only if it has xref = 84.57 cm (inner pad row)
1290 if(kaltrack->GetX()>90.) continue;
1292 if(abs(cmptrk.pdg)==211) { kalPi[bin]++; pi++; }
1293 if(abs(cmptrk.pdg)==321) { kalKa[bin]++; ka++; }
1294 if(abs(cmptrk.pdg)==2212) { kalPr[bin]++; pr++; }
1295 if(abs(cmptrk.pdg)==11) { kalEl[bin]++; el++; }
1296 if(abs(cmptrk.pdg)==13) { kalMu[bin]++; mu++; }
1298 kaltrack->PropagateTo(geatrack->GetX(),1.e-9,0.);
1300 cmptrk.dEdx = kaltrack->GetdEdx();
1302 // compute errors on parameters
1303 dAlpha = kaltrack->GetAlpha()-geatrack->GetAlpha();
1304 if(TMath::Abs(dAlpha)>0.1) { cerr<<" ! WRONG SECTOR !\n"; continue; }
1306 cmptrk.dP0 = kaltrack->GetY()-geatrack->GetY();
1307 cmptrk.dP1 = kaltrack->GetZ()-geatrack->GetZ();
1308 cmptrk.dP2 = kaltrack->GetEta()-geatrack->GetEta();
1309 cmptrk.dP3 = kaltrack->GetTgl()-geatrack->GetTgl();
1310 cmptrk.dP4 = kaltrack->GetC()-geatrack->GetC();
1311 cmptrk.dpt = 1/kaltrack->Get1Pt()-1/geatrack->Get1Pt();
1313 // get covariance matrix
1314 // beware: lines 3 and 4 in the matrix are inverted!
1315 kaltrack->GetCovariance(cc);
1323 cmptrk.c30 = cc[10];
1324 cmptrk.c31 = cc[11];
1325 cmptrk.c32 = cc[12];
1326 cmptrk.c33 = cc[14];
1330 cmptrk.c43 = cc[13];
1336 } // loop on tracks at TPC 1st hit
1339 //delete [] hasSeed;
1341 } // end loop on events in file
1344 cerr<<"+++\n+++ Number of compared tracks: "<<pi+ka+el+mu+pr<<endl;
1345 cerr<<"+++ Pions: "<<pi<<", Kaons: "<<ka<<", Protons : "<<pr<<", Electrons: "<<el<<", Muons: "<<mu<<endl;
1348 // Write tree to file
1349 TFile *outfile = new TFile(covmatName,"recreate");
1350 cmptrktree->Write();
1354 // Write efficiencies to ascii file
1355 FILE *effFile = fopen(tpceffasciiName,"w");
1356 //fprintf(effFile,"%d\n",kalEntries);
1357 for(Int_t j=0; j<effBins; j++) {
1358 if(geaPi[j]>=100) effPi[j]=(Float_t)kalPi[j]/geaPi[j];
1359 if(geaKa[j]>=100) effKa[j]=(Float_t)kalKa[j]/geaKa[j];
1360 if(geaPr[j]>=100) effPr[j]=(Float_t)kalPr[j]/geaPr[j];
1361 if(geaEl[j]>=500) effEl[j]=(Float_t)kalEl[j]/geaEl[j];
1362 if(geaMu[j]>=100) effMu[j]=(Float_t)kalMu[j]/geaMu[j];
1363 fprintf(effFile,"%f %f %f %f %f\n",effPi[j],effKa[j],effPr[j],effEl[j],effMu[j]);
1366 for(Int_t j=0; j<effBins; j++) {
1367 fprintf(effFile,"%d %d %d %d %d\n",geaPi[j],geaKa[j],geaPr[j],geaEl[j],geaMu[j]);
1369 for(Int_t j=0; j<effBins; j++) {
1370 fprintf(effFile,"%d %d %d %d %d\n",kalPi[j],kalKa[j],kalPr[j],kalEl[j],kalMu[j]);
1374 // Write efficiencies to root file
1375 for(Int_t j=0; j<effBins; j++) {
1376 fEffPi.SetParam(j,(Double_t)effPi[j]);
1377 fEffKa.SetParam(j,(Double_t)effKa[j]);
1378 fEffPr.SetParam(j,(Double_t)effPr[j]);
1379 fEffEl.SetParam(j,(Double_t)effEl[j]);
1380 fEffMu.SetParam(j,(Double_t)effMu[j]);
1382 WriteEffs(tpceffrootName);
1384 // delete AliRun object
1385 delete gAlice; gAlice=0;
1387 // close all input files
1390 galiceFile->Close();
1411 //-----------------------------------------------------------------------------
1412 void AliTPCtrackerParam::CookdEdx(Double_t pt,Double_t eta) {
1413 //-----------------------------------------------------------------------------
1414 // This function assigns the track a dE/dx and makes a rough PID
1415 //-----------------------------------------------------------------------------
1417 Double_t mean = fdEdxMean->GetValueAt(pt,eta);
1418 Double_t rms = fdEdxRMS->GetValueAt(pt,eta);
1420 Double_t dEdx = gRandom->Gaus(mean,rms);
1422 fTrack.SetdEdx(dEdx);
1424 AliTPCtrackParam t(fTrack);
1427 Double_t p = TMath::Sqrt(1.+t.GetTgl()*t.GetTgl())*pt;
1430 if (dEdx < 39.+ 12./(p+0.25)/(p+0.25)) {
1431 t.AssignMass(AliPID::ParticleMass(AliPID::kPion)); new(&fTrack) AliTPCtrack(t); return;
1433 if (dEdx < 39.+ 12./p/p) {
1434 t.AssignMass(AliPID::ParticleMass(AliPID::kKaon)); new(&fTrack) AliTPCtrack(t); return;
1436 t.AssignMass(AliPID::ParticleMass(AliPID::kProton)); new(&fTrack) AliTPCtrack(t); return;
1440 if (dEdx < 39.+ 12./(p+0.25)/(p+0.25)) {
1441 t.AssignMass(AliPID::ParticleMass(AliPID::kPion)); new(&fTrack) AliTPCtrack(t); return;
1443 t.AssignMass(AliPID::ParticleMass(AliPID::kProton)); new(&fTrack) AliTPCtrack(t); return;
1446 t.AssignMass(AliPID::ParticleMass(AliPID::kPion)); new(&fTrack) AliTPCtrack(t); return;
1448 //-----------------------------------------------------------------------------
1449 void AliTPCtrackerParam::CookTrack(Double_t pt,Double_t eta) {
1450 //-----------------------------------------------------------------------------
1451 // This function deals with covariance matrix and smearing
1452 //-----------------------------------------------------------------------------
1456 Double_t trkKine[1],trkRegPar[3];
1457 Double_t xref,alpha,xx[5],xxsm[5],cc[15];
1460 fCovTree->SetBranchAddress("matrix",&covmat);
1462 // get random entry from the tree
1463 treeEntries = (Int_t)fCovTree->GetEntries();
1464 fCovTree->GetEvent(gRandom->Integer(treeEntries));
1466 // get P and Cosl from track
1467 cosl = TMath::Cos(TMath::ATan(fTrack.GetTgl()));
1468 p = 1./TMath::Abs(fTrack.Get1Pt())/cosl;
1472 // get covariance matrix from regularized matrix
1473 for(Int_t l=0;l<3;l++) trkRegPar[l] = (*fRegPar)(0,l);
1474 cc[0] = covmat.c00*RegFunc(trkKine,trkRegPar);
1476 for(Int_t l=0;l<3;l++) trkRegPar[l] = (*fRegPar)(1,l);
1477 cc[2] = covmat.c11*RegFunc(trkKine,trkRegPar);
1478 for(Int_t l=0;l<3;l++) trkRegPar[l] = (*fRegPar)(2,l);
1479 cc[3] = covmat.c20*RegFunc(trkKine,trkRegPar);
1481 for(Int_t l=0;l<3;l++) trkRegPar[l] = (*fRegPar)(3,l);
1482 cc[5] = covmat.c22*RegFunc(trkKine,trkRegPar);
1484 for(Int_t l=0;l<3;l++) trkRegPar[l] = (*fRegPar)(4,l);
1485 cc[7] = covmat.c31*RegFunc(trkKine,trkRegPar);
1487 for(Int_t l=0;l<3;l++) trkRegPar[l] = (*fRegPar)(5,l);
1488 cc[9] = covmat.c33*RegFunc(trkKine,trkRegPar);
1489 for(Int_t l=0;l<3;l++) trkRegPar[l] = (*fRegPar)(6,l);
1490 cc[10]= covmat.c40*RegFunc(trkKine,trkRegPar);
1492 for(Int_t l=0;l<3;l++) trkRegPar[l] = (*fRegPar)(7,l);
1493 cc[12]= covmat.c42*RegFunc(trkKine,trkRegPar);
1495 for(Int_t l=0;l<3;l++) trkRegPar[l] = (*fRegPar)(8,l);
1496 cc[14]= covmat.c44*RegFunc(trkKine,trkRegPar);
1498 TMatrixD covMatSmear(5,5);
1500 covMatSmear = GetSmearingMatrix(cc,pt,eta);
1502 // get track original parameters
1503 xref =fTrack.GetX();
1504 alpha=fTrack.GetAlpha();
1505 xx[0]=fTrack.GetY();
1506 xx[1]=fTrack.GetZ();
1507 xx[2]=fTrack.GetX()*fTrack.GetC()-fTrack.GetSnp();
1508 xx[3]=fTrack.GetTgl();
1509 xx[4]=fTrack.GetC();
1511 // use smearing matrix to smear the original parameters
1512 SmearTrack(xx,xxsm,covMatSmear);
1514 AliTPCtrack track(0,xxsm,cc,xref,alpha);
1515 new(&fTrack) AliTPCtrack(track);
1519 //-----------------------------------------------------------------------------
1520 void AliTPCtrackerParam::DrawEffs(const Char_t* inName,Int_t pdg) {
1521 //-----------------------------------------------------------------------------
1522 // This function draws the TPC efficiencies in the [pT,eta] bins
1523 //-----------------------------------------------------------------------------
1528 const Int_t kn = fEff->GetPointsPt();
1529 Double_t *effsA = new Double_t[kn];
1530 Double_t *effsB = new Double_t[kn];
1531 Double_t *effsC = new Double_t[kn];
1532 Double_t *pt = new Double_t[kn];
1534 fEff->GetArrayPt(pt);
1535 for(Int_t i=0;i<kn;i++) {
1536 effsA[i] = fEff->GetParam(i,0);
1537 effsB[i] = fEff->GetParam(i,1);
1538 effsC[i] = fEff->GetParam(i,2);
1541 TGraph *grA = new TGraph(kn,pt,effsA);
1542 TGraph *grB = new TGraph(kn,pt,effsB);
1543 TGraph *grC = new TGraph(kn,pt,effsC);
1545 grA->SetMarkerStyle(20); grA->SetMarkerColor(2); grA->SetMarkerSize(1.5);
1546 grB->SetMarkerStyle(21); grB->SetMarkerColor(3); grB->SetMarkerSize(1.5);
1547 grC->SetMarkerStyle(22); grC->SetMarkerColor(4); grC->SetMarkerSize(1.5);
1549 TString title("Distribution of the TPC efficiencies");
1552 title.Prepend("PIONS - ");
1555 title.Prepend("KAONS - ");
1558 title.Prepend("PROTONS - ");
1561 title.Prepend("ELECTRONS - ");
1564 title.Prepend("MUONS - ");
1569 gStyle->SetOptStat(0);
1570 TCanvas *c = new TCanvas("c","effs",0,0,900,700);
1575 TH2F *frame = new TH2F("frame",title.Data(),2,0.1,30,2,0,1);
1576 frame->SetXTitle("p_{T} [GeV/c]");
1582 TLegend *leg = new TLegend(0.2,0.2,0.4,0.4);
1583 leg->AddEntry(grA,"|#eta|<0.3","p");
1584 leg->AddEntry(grB,"0.3<|#eta|<0.6","p");
1585 leg->AddEntry(grC,"0.6<|#eta|<0.9","p");
1586 leg->SetFillColor(0);
1596 //-----------------------------------------------------------------------------
1597 void AliTPCtrackerParam::DrawPulls(const Char_t* inName,Int_t pdg,
1599 //-----------------------------------------------------------------------------
1600 // This function draws the pulls in the [pT,eta] bins
1601 //-----------------------------------------------------------------------------
1606 const Int_t kn = (fPulls+par)->GetPointsPt();
1607 Double_t *pullsA = new Double_t[kn];
1608 Double_t *pullsB = new Double_t[kn];
1609 Double_t *pullsC = new Double_t[kn];
1610 Double_t *pt = new Double_t[kn];
1611 (fPulls+par)->GetArrayPt(pt);
1612 for(Int_t i=0;i<kn;i++) {
1613 pullsA[i] = (fPulls+par)->GetParam(i,0);
1614 pullsB[i] = (fPulls+par)->GetParam(i,1);
1615 pullsC[i] = (fPulls+par)->GetParam(i,2);
1618 TGraph *grA = new TGraph(kn,pt,pullsA);
1619 TGraph *grB = new TGraph(kn,pt,pullsB);
1620 TGraph *grC = new TGraph(kn,pt,pullsC);
1622 grA->SetMarkerStyle(20); grA->SetMarkerColor(2); grA->SetMarkerSize(1.5);
1623 grB->SetMarkerStyle(21); grB->SetMarkerColor(3); grB->SetMarkerSize(1.5);
1624 grC->SetMarkerStyle(22); grC->SetMarkerColor(4); grC->SetMarkerSize(1.5);
1626 TString title("Distribution of the pulls: ");
1629 title.Prepend("PIONS - ");
1632 title.Prepend("KAONS - ");
1635 title.Prepend("PROTONS - ");
1638 title.Prepend("ELECTRONS - ");
1641 title.Prepend("MUONS - ");
1652 title.Append(" #eta");
1655 title.Append("tg #lambda");
1662 gStyle->SetOptStat(0);
1663 TCanvas *c = new TCanvas("c","pulls",0,0,900,700);
1668 TH2F *frame = new TH2F("frame",title.Data(),2,0.1,30,2,0,2);
1669 frame->SetXTitle("p_{T} [GeV/c]");
1675 TLegend *leg = new TLegend(0.2,0.2,0.4,0.4);
1676 leg->AddEntry(grA,"|#eta|<0.3","p");
1677 leg->AddEntry(grB,"0.3<|#eta|<0.6","p");
1678 leg->AddEntry(grC,"0.6<|#eta|<0.9","p");
1679 leg->SetFillColor(0);
1689 //-----------------------------------------------------------------------------
1690 TMatrixD AliTPCtrackerParam::GetSmearingMatrix(Double_t* cc,Double_t pt,
1691 Double_t eta) const {
1692 //-----------------------------------------------------------------------------
1693 // This function stretches the covariance matrix according to the pulls
1694 //-----------------------------------------------------------------------------
1696 TMatrixD covMat(5,5);
1699 covMat(1,0)=cc[1]; covMat(0,1)=covMat(1,0);
1701 covMat(2,0)=cc[3]; covMat(0,2)=covMat(2,0);
1702 covMat(2,1)=cc[4]; covMat(1,2)=covMat(2,1);
1704 covMat(3,0)=cc[6]; covMat(0,3)=covMat(3,0);
1705 covMat(3,1)=cc[7]; covMat(1,3)=covMat(3,1);
1706 covMat(3,2)=cc[8]; covMat(2,3)=covMat(3,2);
1708 covMat(4,0)=cc[10]; covMat(0,4)=covMat(4,0);
1709 covMat(4,1)=cc[11]; covMat(1,4)=covMat(4,1);
1710 covMat(4,2)=cc[12]; covMat(2,4)=covMat(4,2);
1711 covMat(4,3)=cc[13]; covMat(3,4)=covMat(4,3);
1715 TMatrixD stretchMat(5,5);
1716 for(Int_t k=0;k<5;k++) {
1717 for(Int_t l=0;l<5;l++) {
1722 for(Int_t i=0;i<5;i++) {
1723 stretchMat(i,i) = (fPulls+i)->GetValueAt(pt,eta);
1724 if(stretchMat(i,i)==0.) stretchMat(i,i) = 1.;
1727 TMatrixD mat(stretchMat,TMatrixD::kMult,covMat);
1728 TMatrixD covMatSmear(mat,TMatrixD::kMult,stretchMat);
1732 //-----------------------------------------------------------------------------
1733 void AliTPCtrackerParam::InitializeKineGrid(Option_t* which) {
1734 //-----------------------------------------------------------------------------
1735 // This function initializes ([pt,eta] points) the data members AliTPCkineGrid
1736 // which = "DB" -> initialize fDBgrid... members
1737 // "eff" -> initialize fEff... members
1738 // "pulls" -> initialize fPulls... members
1739 // "dEdx" -> initialize fdEdx... members
1740 //-----------------------------------------------------------------------------
1742 const char *db = strstr(which,"DB");
1743 const char *eff = strstr(which,"eff");
1744 const char *pulls = strstr(which,"pulls");
1745 const char *dEdx = strstr(which,"dEdx");
1748 Int_t nEta=0, nPt=0;
1750 Double_t etaPoints[2] = {0.3,0.6};
1751 Double_t etaBins[3] = {0.15,0.45,0.75};
1753 Double_t ptPoints[9] = {0.4,0.6,0.8,1.2,1.7,3.,5.,8.,15.};
1754 Double_t ptBins[10] = {0.3,0.5,0.7,1.,1.5,2.,4.,6.,10.,20.};
1757 Double_t *eta=0,*pt=0;
1771 AliTPCkineGrid *dummy=0;
1774 dummy = new AliTPCkineGrid(nPt,nEta,pt,eta);
1775 new(&fDBgridPi) AliTPCkineGrid(*dummy);
1776 new(&fDBgridKa) AliTPCkineGrid(*dummy);
1777 new(&fDBgridPr) AliTPCkineGrid(*dummy);
1778 new(&fDBgridEl) AliTPCkineGrid(*dummy);
1779 new(&fDBgridMu) AliTPCkineGrid(*dummy);
1783 dummy = new AliTPCkineGrid(nPt,nEta,pt,eta);
1784 new(&fEffPi) AliTPCkineGrid(*dummy);
1785 new(&fEffKa) AliTPCkineGrid(*dummy);
1786 new(&fEffPr) AliTPCkineGrid(*dummy);
1787 new(&fEffEl) AliTPCkineGrid(*dummy);
1788 new(&fEffMu) AliTPCkineGrid(*dummy);
1792 dummy = new AliTPCkineGrid(nPt,nEta,pt,eta);
1793 for(Int_t i=0;i<5;i++) new(&fPullsPi[i]) AliTPCkineGrid(*dummy);
1794 for(Int_t i=0;i<5;i++) new(&fPullsKa[i]) AliTPCkineGrid(*dummy);
1795 for(Int_t i=0;i<5;i++) new(&fPullsPr[i]) AliTPCkineGrid(*dummy);
1796 for(Int_t i=0;i<5;i++) new(&fPullsEl[i]) AliTPCkineGrid(*dummy);
1797 for(Int_t i=0;i<5;i++) new(&fPullsMu[i]) AliTPCkineGrid(*dummy);
1801 dummy = new AliTPCkineGrid(nPt,nEta,pt,eta);
1802 new(&fdEdxMeanPi) AliTPCkineGrid(*dummy);
1803 new(&fdEdxRMSPi) AliTPCkineGrid(*dummy);
1804 new(&fdEdxMeanKa) AliTPCkineGrid(*dummy);
1805 new(&fdEdxRMSKa) AliTPCkineGrid(*dummy);
1806 new(&fdEdxMeanPr) AliTPCkineGrid(*dummy);
1807 new(&fdEdxRMSPr) AliTPCkineGrid(*dummy);
1808 new(&fdEdxMeanEl) AliTPCkineGrid(*dummy);
1809 new(&fdEdxRMSEl) AliTPCkineGrid(*dummy);
1810 new(&fdEdxMeanMu) AliTPCkineGrid(*dummy);
1811 new(&fdEdxRMSMu) AliTPCkineGrid(*dummy);
1817 //-----------------------------------------------------------------------------
1818 void AliTPCtrackerParam::MakeDataBase() {
1819 //-----------------------------------------------------------------------------
1820 // This function creates the DB file and store in it:
1821 // - TPC Efficiencies for pi,ka,pr,el,mu (AliTPCkineGrid class)
1822 // - Pulls for pi,ka,el (AliTPCkineGrid class)
1823 // - Regularization parameters for pi,ka,el (TMatrixD class)
1824 // - dE/dx parameterization for pi,ka,pr,el (AliTPCkineGrid class)
1825 // - Regularized cov. matrices for pi,ka,el (COVMATRIX structure)
1826 //-----------------------------------------------------------------------------
1828 // define some file names
1829 const char *effFile ="TPCeff.root";
1830 const char *pullsFile ="pulls.root";
1831 const char *regPiFile ="regPi.root";
1832 const char *regKaFile ="regKa.root";
1833 const char *regPrFile ="regPr.root";
1834 const char *regElFile ="regEl.root";
1835 const char *regMuFile ="regMu.root";
1836 const char *dEdxPiFile="dEdxPi.root";
1837 const char *dEdxKaFile="dEdxKa.root";
1838 const char *dEdxPrFile="dEdxPr.root";
1839 const char *dEdxElFile="dEdxEl.root";
1840 const char *dEdxMuFile="dEdxMu.root";
1841 const char *cmFile ="CovMatrix_AllEvts.root";
1843 Char_t *cmFile1 ="CovMatrix_AllEvts_1.root";
1844 Char_t *cmFile2 ="CovMatrix_AllEvts_2.root";
1845 Char_t *cmFile3 ="CovMatrix_AllEvts_3.root";
1848 // store the effieciencies
1850 WriteEffs(fDBfileName.Data());
1853 ReadPulls(pullsFile);
1854 WritePulls(fDBfileName.Data());
1856 //store the regularization parameters
1857 ReadRegParams(regPiFile,211);
1858 WriteRegParams(fDBfileName.Data(),211);
1859 ReadRegParams(regKaFile,321);
1860 WriteRegParams(fDBfileName.Data(),321);
1861 ReadRegParams(regPrFile,2212);
1862 WriteRegParams(fDBfileName.Data(),2212);
1863 ReadRegParams(regElFile,11);
1864 WriteRegParams(fDBfileName.Data(),11);
1865 ReadRegParams(regMuFile,13);
1866 WriteRegParams(fDBfileName.Data(),13);
1868 // store the dEdx parameters
1869 ReaddEdx(dEdxPiFile,211);
1870 WritedEdx(fDBfileName.Data(),211);
1871 ReaddEdx(dEdxKaFile,321);
1872 WritedEdx(fDBfileName.Data(),321);
1873 ReaddEdx(dEdxPrFile,2212);
1874 WritedEdx(fDBfileName.Data(),2212);
1875 ReaddEdx(dEdxElFile,11);
1876 WritedEdx(fDBfileName.Data(),11);
1877 ReaddEdx(dEdxMuFile,13);
1878 WritedEdx(fDBfileName.Data(),13);
1882 // store the regularized covariance matrices
1884 InitializeKineGrid("DB");
1886 const Int_t knBinsPi = fDBgridPi.GetTotBins();
1887 const Int_t knBinsKa = fDBgridKa.GetTotBins();
1888 const Int_t knBinsPr = fDBgridPr.GetTotBins();
1889 const Int_t knBinsEl = fDBgridEl.GetTotBins();
1890 const Int_t knBinsMu = fDBgridMu.GetTotBins();
1893 // create the trees for cov. matrices
1895 TTree *covTreePi1 = NULL;
1896 covTreePi1 = new TTree[knBinsPi];
1898 TTree *covTreeKa1 = NULL;
1899 covTreeKa1 = new TTree[knBinsKa];
1900 // trees for protons
1901 TTree *covTreePr1 = NULL;
1902 covTreePr1 = new TTree[knBinsPr];
1903 // trees for electrons
1904 TTree *covTreeEl1 = NULL;
1905 covTreeEl1 = new TTree[knBinsEl];
1907 TTree *covTreeMu1 = NULL;
1908 covTreeMu1 = new TTree[knBinsMu];
1910 Char_t hname[100], htitle[100];
1914 for(Int_t i=0; i<knBinsPi; i++) {
1915 sprintf(hname,"CovTreePi_bin%d",i);
1916 sprintf(htitle,"Tree with cov matrix elements for bin %d",i);
1917 covTreePi1[i].SetName(hname); covTreePi1[i].SetTitle(htitle);
1918 covTreePi1[i].Branch("matrix",&covmat,"c00/D:c10:c11:c20:c21:c22:c30:c31:c32:c33:c40:c41:c42:c43:c44",5000000);
1920 for(Int_t i=0; i<knBinsKa; i++) {
1921 sprintf(hname,"CovTreeKa_bin%d",i);
1922 sprintf(htitle,"Tree with cov matrix elements for bin %d",i);
1923 covTreeKa1[i].SetName(hname); covTreeKa1[i].SetTitle(htitle);
1924 covTreeKa1[i].Branch("matrix",&covmat,"c00/D:c10:c11:c20:c21:c22:c30:c31:c32:c33:c40:c41:c42:c43:c44",1000000);
1926 for(Int_t i=0; i<knBinsPr; i++) {
1927 sprintf(hname,"CovTreePr_bin%d",i);
1928 sprintf(htitle,"Tree with cov matrix elements for bin %d",i);
1929 covTreePr1[i].SetName(hname); covTreePr1[i].SetTitle(htitle);
1930 covTreePr1[i].Branch("matrix",&covmat,"c00/D:c10:c11:c20:c21:c22:c30:c31:c32:c33:c40:c41:c42:c43:c44",1000000);
1932 for(Int_t i=0; i<knBinsEl; i++) {
1933 sprintf(hname,"CovTreeEl_bin%d",i);
1934 sprintf(htitle,"Tree with cov matrix elements for bin %d",i);
1935 covTreeEl1[i].SetName(hname); covTreeEl1[i].SetTitle(htitle);
1936 covTreeEl1[i].Branch("matrix",&covmat,"c00/D:c10:c11:c20:c21:c22:c30:c31:c32:c33:c40:c41:c42:c43:c44",1000000);
1938 for(Int_t i=0; i<knBinsMu; i++) {
1939 sprintf(hname,"CovTreeMu_bin%d",i);
1940 sprintf(htitle,"Tree with cov matrix elements for bin %d",i);
1941 covTreeMu1[i].SetName(hname); covTreeMu1[i].SetTitle(htitle);
1942 covTreeMu1[i].Branch("matrix",&covmat,"c00/D:c10:c11:c20:c21:c22:c30:c31:c32:c33:c40:c41:c42:c43:c44",1000000);
1946 // create the chain with the compared tracks
1947 TChain *cmptrktree = new TChain("cmptrktree");
1948 cmptrkchain.Add(cmFile1);
1949 cmptrkchain.Add(cmFile2);
1950 cmptrkchain.Add(cmFile3);
1953 TFile *infile = TFile::Open(cmFile);
1954 TTree *cmptrktree = (TTree*)infile->Get("cmptrktree");
1957 cmptrktree->SetBranchAddress("comptracks",&cmptrk);
1958 Int_t entries = (Int_t)cmptrktree->GetEntries();
1959 cerr<<" Number of entries: "<<entries<<endl;
1961 Int_t trkPdg,trkBin;
1962 Double_t trkKine[1],trkRegPar[3];
1963 Int_t *nPerBinPi = new Int_t[knBinsPi];
1964 for(Int_t k=0;k<knBinsPi;k++) nPerBinPi[k]=0;
1965 Int_t *nPerBinKa = new Int_t[knBinsKa];
1966 for(Int_t k=0;k<knBinsKa;k++) nPerBinKa[k]=0;
1967 Int_t *nPerBinMu = new Int_t[knBinsMu];
1968 for(Int_t k=0;k<knBinsMu;k++) nPerBinMu[k]=0;
1969 Int_t *nPerBinEl = new Int_t[knBinsEl];
1970 for(Int_t k=0;k<knBinsEl;k++) nPerBinEl[k]=0;
1971 Int_t *nPerBinPr = new Int_t[knBinsPr];
1972 for(Int_t k=0;k<knBinsPr;k++) nPerBinPr[k]=0;
1974 // loop on chain entries
1975 for(Int_t l=0; l<entries; l++) {
1976 if(l % 10000 == 0) cerr<<"--- Processing track "<<l<<" of "<<entries<<" ---"<<endl;
1978 cmptrktree->GetEvent(l);
1980 trkPdg = TMath::Abs(cmptrk.pdg);
1981 // use only pions, kaons, protons, electrons, muons
1982 if(trkPdg!=211 && trkPdg!=321 && trkPdg!=2212 && trkPdg!=11 && trkPdg!=13) continue;
1983 SetParticle(trkPdg);
1984 trkBin = fDBgrid->GetBin(cmptrk.pt,cmptrk.eta);
1985 //cerr<<cmptrk.pt<<" "<<cmptrk.eta<<" "<<trkBin<<endl;
1987 if(trkPdg==211 && nPerBinPi[trkBin]>=5000) continue;
1988 if(trkPdg==321 && nPerBinKa[trkBin]>=5000) continue;
1989 if(trkPdg==2212 && nPerBinPr[trkBin]>=5000) continue;
1990 if(trkPdg==11 && nPerBinEl[trkBin]>=5000) continue;
1991 if(trkPdg==13 && nPerBinMu[trkBin]>=5000) continue;
1993 trkKine[0] = cmptrk.p;
1995 // get regularized covariance matrix
1996 for(Int_t k=0;k<3;k++) trkRegPar[k] = (*fRegPar)(0,k);
1997 covmat.c00 = cmptrk.c00/RegFunc(trkKine,trkRegPar);
1998 covmat.c10 = cmptrk.c10;
1999 for(Int_t k=0;k<3;k++) trkRegPar[k] = (*fRegPar)(1,k);
2000 covmat.c11 = cmptrk.c11/RegFunc(trkKine,trkRegPar);
2001 for(Int_t k=0;k<3;k++) trkRegPar[k] = (*fRegPar)(2,k);
2002 covmat.c20 = cmptrk.c20/RegFunc(trkKine,trkRegPar);
2003 covmat.c21 = cmptrk.c21;
2004 for(Int_t k=0;k<3;k++) trkRegPar[k] = (*fRegPar)(3,k);
2005 covmat.c22 = cmptrk.c22/RegFunc(trkKine,trkRegPar);
2006 covmat.c30 = cmptrk.c30;
2007 for(Int_t k=0;k<3;k++) trkRegPar[k] = (*fRegPar)(4,k);
2008 covmat.c31 = cmptrk.c31/RegFunc(trkKine,trkRegPar);
2009 covmat.c32 = cmptrk.c32;
2010 for(Int_t k=0;k<3;k++) trkRegPar[k] = (*fRegPar)(5,k);
2011 covmat.c33 = cmptrk.c33/RegFunc(trkKine,trkRegPar);
2012 for(Int_t k=0;k<3;k++) trkRegPar[k] = (*fRegPar)(6,k);
2013 covmat.c40 = cmptrk.c40/RegFunc(trkKine,trkRegPar);
2014 covmat.c41 = cmptrk.c41;
2015 for(Int_t k=0;k<3;k++) trkRegPar[k] = (*fRegPar)(7,k);
2016 covmat.c42 = cmptrk.c42/RegFunc(trkKine,trkRegPar);
2017 covmat.c43 = cmptrk.c43;
2018 for(Int_t k=0;k<3;k++) trkRegPar[k] = (*fRegPar)(8,k);
2019 covmat.c44 = cmptrk.c44/RegFunc(trkKine,trkRegPar);
2024 covTreePi1[trkBin].Fill();
2025 nPerBinPi[trkBin]++;
2028 covTreeKa1[trkBin].Fill();
2029 nPerBinKa[trkBin]++;
2031 case 2212: // protons
2032 covTreePr1[trkBin].Fill();
2033 nPerBinPr[trkBin]++;
2035 case 11: // electrons
2036 covTreeEl1[trkBin].Fill();
2037 nPerBinEl[trkBin]++;
2040 covTreeMu1[trkBin].Fill();
2041 nPerBinMu[trkBin]++;
2044 } // loop on chain entries
2046 // store all trees the DB file
2047 TFile *dbfile = new TFile(fDBfileName.Data(),"update");
2048 dbfile->mkdir("CovMatrices");
2049 gDirectory->cd("/CovMatrices");
2050 gDirectory->mkdir("Pions");
2051 gDirectory->mkdir("Kaons");
2052 gDirectory->mkdir("Protons");
2053 gDirectory->mkdir("Electrons");
2054 gDirectory->mkdir("Muons");
2056 gDirectory->cd("/CovMatrices/Pions");
2057 fDBgridPi.SetName("DBgridPi"); fDBgridPi.Write();
2058 for(Int_t i=0;i<knBinsPi;i++) covTreePi1[i].Write();
2060 gDirectory->cd("/CovMatrices/Kaons");
2061 fDBgridKa.SetName("DBgridKa"); fDBgridKa.Write();
2062 for(Int_t i=0;i<knBinsKa;i++) covTreeKa1[i].Write();
2064 gDirectory->cd("/CovMatrices/Protons");
2065 fDBgridPr.SetName("DBgridPr"); fDBgridPr.Write();
2066 for(Int_t i=0;i<knBinsPr;i++) covTreePr1[i].Write();
2068 gDirectory->cd("/CovMatrices/Electrons");
2069 fDBgridEl.SetName("DBgridEl"); fDBgridEl.Write();
2070 for(Int_t i=0;i<knBinsEl;i++) covTreeEl1[i].Write();
2072 gDirectory->cd("/CovMatrices/Muons");
2073 fDBgridMu.SetName("DBgridMu"); fDBgridMu.Write();
2074 for(Int_t i=0;i<knBinsMu;i++) covTreeMu1[i].Write();
2077 delete [] nPerBinPi;
2078 delete [] nPerBinKa;
2079 delete [] nPerBinPr;
2080 delete [] nPerBinEl;
2081 delete [] nPerBinMu;
2085 //-----------------------------------------------------------------------------
2086 void AliTPCtrackerParam::MakeSeedsFromHits(AliTPC *tpc,TTree *th,
2087 TObjArray &seedArray) const {
2088 //-----------------------------------------------------------------------------
2089 // This function makes the seeds for tracks from the 1st hits in the TPC
2090 //-----------------------------------------------------------------------------
2092 Double_t xg,yg,zg,px,py,pz,pt;
2094 Int_t nTracks=(Int_t)th->GetEntries();
2096 cerr<<"+++\n+++ Number of \"primary tracks\"(entries in TreeH): "<<nTracks<<
2099 AliTPChit *tpcHit=0;
2101 // loop over entries in TreeH
2102 for(Int_t l=0; l<nTracks; l++) {
2103 if(l%1000==0) cerr<<" --- Processing primary track "
2104 <<l<<" of "<<nTracks<<" ---\r";
2108 tpcHit=(AliTPChit*)tpc->FirstHit(-1);
2109 for( ; tpcHit; tpcHit=(AliTPChit*)tpc->NextHit() ) {
2110 if(tpcHit->fQ !=0.) continue;
2111 // Get particle momentum at hit
2112 px=tpcHit->X(); py=tpcHit->Y(); pz=tpcHit->Z();
2114 pt=TMath::Sqrt(px*px+py*py);
2115 // reject hits with Pt<mag*0.45 GeV/c
2116 if(pt<(fBz*0.45)) continue;
2119 label=tpcHit->Track();
2121 if((tpcHit=(AliTPChit*)tpc->NextHit())==0) break;
2122 if(tpcHit->fQ != 0.) continue;
2123 // Get global coordinates of hit
2124 xg=tpcHit->X(); yg=tpcHit->Y(); zg=tpcHit->Z();
2125 if(TMath::Sqrt(xg*xg+yg*yg)>90.) continue;
2128 AliTPCseedGeant *ioseed = new AliTPCseedGeant(xg,yg,zg,px,py,pz,label);
2130 // reject tracks which are not in the TPC acceptance
2131 if(!ioseed->InTPCAcceptance()) { delete ioseed; continue; }
2133 // put seed in array
2134 seedArray.AddLast(ioseed);
2137 } // loop over entries in TreeH
2141 //-----------------------------------------------------------------------------
2142 void AliTPCtrackerParam::MakeSeedsFromRefs(TTree *ttr,
2143 TObjArray &seedArray) const {
2144 //-----------------------------------------------------------------------------
2145 // This function makes the seeds for tracks from the track references
2146 //-----------------------------------------------------------------------------
2148 Double_t xg,yg,zg,px,py,pz,pt;
2152 TClonesArray *tkRefArray = new TClonesArray("AliTrackReference");
2154 TBranch *b =(TBranch*)ttr->GetBranch("TPC");
2155 if(!b) {cerr<<"TPC branch of TreeTR not found"<<endl; return; }
2156 b->SetAddress(&tkRefArray);
2157 Int_t nTkRef = (Int_t)b->GetEntries();
2158 cerr<<"+++\n+++ Number of entries in TreeTR(TPC): "<<nTkRef<<
2161 // loop on track references
2162 for(Int_t l=0; l<nTkRef; l++){
2163 if(l%1000==0) cerr<<" --- Processing primary track "
2164 <<l<<" of "<<nTkRef<<" ---\r";
2165 if(!b->GetEvent(l)) continue;
2166 nnn = tkRefArray->GetEntriesFast();
2168 if(nnn <= 0) continue;
2169 for(k=0; k<nnn; k++) {
2170 AliTrackReference *tkref = (AliTrackReference*)tkRefArray->UncheckedAt(k);
2178 label = tkref->GetTrack();
2180 pt=TMath::Sqrt(px*px+py*py);
2181 // reject hits with Pt<mag*0.45 GeV/c
2182 if(pt<(fBz*0.45)) continue;
2185 AliTPCseedGeant *ioseed = new AliTPCseedGeant(xg,yg,zg,px,py,pz,label);
2187 // reject if not at the inner part of TPC
2188 if(TMath::Abs(ioseed->GetXL()-82.9701) > 0.1) {
2189 delete ioseed; continue;
2192 // reject tracks which are not in the TPC acceptance
2193 if(!ioseed->InTPCAcceptance()) {
2194 delete ioseed; continue;
2197 // put seed in array
2198 seedArray.AddLast(ioseed);
2203 } // loop on track references
2210 //-----------------------------------------------------------------------------
2211 void AliTPCtrackerParam::MergeEvents(Int_t evFirst,Int_t evLast) {
2212 //-----------------------------------------------------------------------------
2213 // This function: 1) merges the files from track comparison
2214 // (beware: better no more than 100 events per file)
2215 // 2) computes the average TPC efficiencies
2216 //-----------------------------------------------------------------------------
2218 const char *outName="TPCeff.root";
2220 // merge files with tracks
2221 cerr<<" ******** MERGING FILES **********\n\n";
2223 // create the chain for the tree of compared tracks
2224 TChain ch1("cmptrktree");
2225 TChain ch2("cmptrktree");
2226 TChain ch3("cmptrktree");
2228 for(Int_t j=evFirst; j<=evLast; j++) {
2229 cerr<<"Processing event "<<j<<endl;
2231 TString covName("CovMatrix.");
2233 covName.Append(".root");
2235 if(gSystem->AccessPathName(covName.Data(),kFileExists)) continue;
2238 if(j<=100) ch1.Add(covName.Data());
2239 if(j>100 && j<=200) ch2.Add(covName.Data());
2240 if(j>200) ch3.Add(covName.Data());
2244 // merge chain in one file
2246 covOut = new TFile("CovMatrix_AllEvts_1.root","recreate");
2247 ch1.Merge(covOut,1000000000);
2250 covOut = new TFile("CovMatrix_AllEvts_2.root","recreate");
2251 ch2.Merge(covOut,1000000000);
2254 covOut = new TFile("CovMatrix_AllEvts_3.root","recreate");
2255 ch3.Merge(covOut,1000000000);
2261 cerr<<" ***** EFFICIENCIES ******\n\n";
2263 ReadEffs("TPCeff.1.root");
2265 Int_t n = fEffPi.GetTotPoints();
2266 Double_t *avEffPi = new Double_t[n];
2267 Double_t *avEffKa = new Double_t[n];
2268 Double_t *avEffPr = new Double_t[n];
2269 Double_t *avEffEl = new Double_t[n];
2270 Double_t *avEffMu = new Double_t[n];
2271 Int_t *evtsPi = new Int_t[n];
2272 Int_t *evtsKa = new Int_t[n];
2273 Int_t *evtsPr = new Int_t[n];
2274 Int_t *evtsEl = new Int_t[n];
2275 Int_t *evtsMu = new Int_t[n];
2277 for(Int_t j=0; j<n; j++) {
2278 avEffPi[j]=avEffKa[j]=avEffPr[j]=avEffEl[j]=avEffMu[j]=0.;
2279 evtsPi[j]=evtsKa[j]=evtsPr[j]=evtsEl[j]=evtsMu[j]=0;
2282 for(Int_t j=evFirst; j<=evLast; j++) {
2283 cerr<<"Processing event "<<j<<endl;
2285 TString effName("TPCeff.");
2287 effName.Append(".root");
2289 if(gSystem->AccessPathName(effName.Data(),kFileExists)) continue;
2291 ReadEffs(effName.Data());
2293 for(Int_t k=0; k<n; k++) {
2294 if(fEffPi.GetParam(k)>=0.) {avEffPi[k]+=fEffPi.GetParam(k); evtsPi[k]++;}
2295 if(fEffKa.GetParam(k)>=0.) {avEffKa[k]+=fEffKa.GetParam(k); evtsKa[k]++;}
2296 if(fEffPr.GetParam(k)>=0.) {avEffPr[k]+=fEffPr.GetParam(k); evtsPr[k]++;}
2297 if(fEffEl.GetParam(k)>=0.) {avEffEl[k]+=fEffEl.GetParam(k); evtsEl[k]++;}
2298 if(fEffMu.GetParam(k)>=0.) {avEffMu[k]+=fEffMu.GetParam(k); evtsMu[k]++;}
2303 // compute average efficiencies
2304 for(Int_t j=0; j<n; j++) {
2305 if(evtsPi[j]==0) evtsPi[j]++;
2306 fEffPi.SetParam(j,(Double_t)avEffPi[j]/evtsPi[j]);
2307 if(evtsKa[j]==0) evtsKa[j]++;
2308 fEffKa.SetParam(j,(Double_t)avEffKa[j]/evtsKa[j]);
2309 if(evtsPr[j]==0) evtsPr[j]++;
2310 fEffPr.SetParam(j,(Double_t)avEffPr[j]/evtsPr[j]);
2311 if(evtsEl[j]==0) evtsEl[j]++;
2312 fEffEl.SetParam(j,(Double_t)avEffEl[j]/evtsEl[j]);
2313 if(evtsMu[j]==0) evtsMu[j]++;
2314 fEffMu.SetParam(j,(Double_t)avEffMu[j]/evtsMu[j]);
2317 // write efficiencies to a file
2333 //-----------------------------------------------------------------------------
2334 Int_t AliTPCtrackerParam::ReadAllData(const Char_t* inName) {
2335 //-----------------------------------------------------------------------------
2336 // This function reads all parameters from the DB
2337 //-----------------------------------------------------------------------------
2339 if(!ReadEffs(inName)) return 0;
2340 if(!ReadPulls(inName)) return 0;
2341 if(!ReadRegParams(inName,211)) return 0;
2342 if(!ReadRegParams(inName,321)) return 0;
2343 if(!ReadRegParams(inName,2212)) return 0;
2344 if(!ReadRegParams(inName,11)) return 0;
2345 if(!ReadRegParams(inName,13)) return 0;
2346 if(!ReaddEdx(inName,211)) return 0;
2347 if(!ReaddEdx(inName,321)) return 0;
2348 if(!ReaddEdx(inName,2212)) return 0;
2349 if(!ReaddEdx(inName,11)) return 0;
2350 if(!ReaddEdx(inName,13)) return 0;
2351 if(!ReadDBgrid(inName)) return 0;
2355 //-----------------------------------------------------------------------------
2356 Int_t AliTPCtrackerParam::ReaddEdx(const Char_t* inName,Int_t pdg) {
2357 //-----------------------------------------------------------------------------
2358 // This function reads the dEdx parameters from the DB
2359 //-----------------------------------------------------------------------------
2361 if(gSystem->AccessPathName(inName,kFileExists)) {
2362 cerr<<"AliTPCtrackerParam::ReaddEdx: "<<inName<<" not found\n";
2365 TFile *inFile = TFile::Open(inName);
2368 fdEdxMean = (AliTPCkineGrid*)inFile->Get("/dEdx/Pions/dEdxMeanPi");
2369 fdEdxMeanPi.~AliTPCkineGrid();
2370 new(&fdEdxMeanPi) AliTPCkineGrid(*fdEdxMean);
2371 fdEdxRMS = (AliTPCkineGrid*)inFile->Get("/dEdx/Pions/dEdxRMSPi");
2372 fdEdxRMSPi.~AliTPCkineGrid();
2373 new(&fdEdxRMSPi) AliTPCkineGrid(*fdEdxRMS);
2376 fdEdxMean = (AliTPCkineGrid*)inFile->Get("/dEdx/Kaons/dEdxMeanKa");
2377 fdEdxMeanKa.~AliTPCkineGrid();
2378 new(&fdEdxMeanKa) AliTPCkineGrid(*fdEdxMean);
2379 fdEdxRMS = (AliTPCkineGrid*)inFile->Get("/dEdx/Kaons/dEdxRMSKa");
2380 fdEdxRMSKa.~AliTPCkineGrid();
2381 new(&fdEdxRMSKa) AliTPCkineGrid(*fdEdxRMS);
2384 fdEdxMean = (AliTPCkineGrid*)inFile->Get("/dEdx/Protons/dEdxMeanPr");
2385 fdEdxMeanPr.~AliTPCkineGrid();
2386 new(&fdEdxMeanPr) AliTPCkineGrid(*fdEdxMean);
2387 fdEdxRMS = (AliTPCkineGrid*)inFile->Get("/dEdx/Protons/dEdxRMSPr");
2388 fdEdxRMSPr.~AliTPCkineGrid();
2389 new(&fdEdxRMSPr) AliTPCkineGrid(*fdEdxRMS);
2392 fdEdxMean = (AliTPCkineGrid*)inFile->Get("/dEdx/Electrons/dEdxMeanEl");
2393 fdEdxMeanEl.~AliTPCkineGrid();
2394 new(&fdEdxMeanEl) AliTPCkineGrid(*fdEdxMean);
2395 fdEdxRMS = (AliTPCkineGrid*)inFile->Get("/dEdx/Electrons/dEdxRMSEl");
2396 fdEdxRMSEl.~AliTPCkineGrid();
2397 new(&fdEdxRMSEl) AliTPCkineGrid(*fdEdxRMS);
2401 fdEdxMean = (AliTPCkineGrid*)inFile->Get("/dEdx/Pions/dEdxMeanPi");
2402 fdEdxRMS = (AliTPCkineGrid*)inFile->Get("/dEdx/Pions/dEdxRMSPi");
2404 fdEdxMean = (AliTPCkineGrid*)inFile->Get("/dEdx/Muons/dEdxMeanMu");
2405 fdEdxRMS = (AliTPCkineGrid*)inFile->Get("/dEdx/Muons/dEdxRMSMu");
2407 fdEdxMeanMu.~AliTPCkineGrid();
2408 new(&fdEdxMeanMu) AliTPCkineGrid(*fdEdxMean);
2409 fdEdxRMSMu.~AliTPCkineGrid();
2410 new(&fdEdxRMSMu) AliTPCkineGrid(*fdEdxRMS);
2417 //-----------------------------------------------------------------------------
2418 Int_t AliTPCtrackerParam::ReadDBgrid(const Char_t* inName) {
2419 //-----------------------------------------------------------------------------
2420 // This function reads the kine grid from the DB
2421 //-----------------------------------------------------------------------------
2423 if(gSystem->AccessPathName(inName,kFileExists)) {
2424 cerr<<"AliTPCtrackerParam::ReadCovMatrices: "<<inName<<" not found\n";
2427 TFile *inFile = TFile::Open(inName);
2429 // first read the DB grid for the different particles
2430 fDBgrid = (AliTPCkineGrid*)inFile->Get("/CovMatrices/Pions/DBgridPi");
2431 fDBgridPi.~AliTPCkineGrid();
2432 new(&fDBgridPi) AliTPCkineGrid(*fDBgrid);
2433 fDBgrid = (AliTPCkineGrid*)inFile->Get("/CovMatrices/Kaons/DBgridKa");
2434 fDBgridKa.~AliTPCkineGrid();
2435 new(&fDBgridKa) AliTPCkineGrid(*fDBgrid);
2437 fDBgrid = (AliTPCkineGrid*)inFile->Get("/CovMatrices/Pions/DBgridPi");
2439 fDBgrid = (AliTPCkineGrid*)inFile->Get("/CovMatrices/Protons/DBgridPr");
2441 fDBgridPr.~AliTPCkineGrid();
2442 new(&fDBgridPr) AliTPCkineGrid(*fDBgrid);
2443 fDBgrid = (AliTPCkineGrid*)inFile->Get("/CovMatrices/Electrons/DBgridEl");
2444 fDBgridEl.~AliTPCkineGrid();
2445 new(&fDBgridEl) AliTPCkineGrid(*fDBgrid);
2447 fDBgrid = (AliTPCkineGrid*)inFile->Get("/CovMatrices/Pions/DBgridPi");
2449 fDBgrid = (AliTPCkineGrid*)inFile->Get("/CovMatrices/Muons/DBgridMu");
2451 fDBgridMu.~AliTPCkineGrid();
2452 new(&fDBgridMu) AliTPCkineGrid(*fDBgrid);
2458 //-----------------------------------------------------------------------------
2459 Int_t AliTPCtrackerParam::ReadEffs(const Char_t* inName) {
2460 //-----------------------------------------------------------------------------
2461 // This function reads the TPC efficiencies from the DB
2462 //-----------------------------------------------------------------------------
2464 if(gSystem->AccessPathName(inName,kFileExists)) {
2465 cerr<<"AliTPCtrackerParam::ReadEffs: "<<inName<<" not found\n";
2468 TFile *inFile = TFile::Open(inName);
2470 fEff = (AliTPCkineGrid*)inFile->Get("/Efficiencies/Pions/EffPi");
2471 fEffPi.~AliTPCkineGrid();
2472 new(&fEffPi) AliTPCkineGrid(*fEff);
2473 fEff = (AliTPCkineGrid*)inFile->Get("/Efficiencies/Kaons/EffKa");
2474 fEffKa.~AliTPCkineGrid();
2475 new(&fEffKa) AliTPCkineGrid(*fEff);
2476 fEff = (AliTPCkineGrid*)inFile->Get("/Efficiencies/Protons/EffPr");
2477 fEffPr.~AliTPCkineGrid();
2478 new(&fEffPr) AliTPCkineGrid(*fEff);
2479 fEff = (AliTPCkineGrid*)inFile->Get("/Efficiencies/Electrons/EffEl");
2480 fEffEl.~AliTPCkineGrid();
2481 new(&fEffEl) AliTPCkineGrid(*fEff);
2482 fEff = (AliTPCkineGrid*)inFile->Get("/Efficiencies/Muons/EffMu");
2483 fEffMu.~AliTPCkineGrid();
2484 new(&fEffMu) AliTPCkineGrid(*fEff);
2490 //-----------------------------------------------------------------------------
2491 Int_t AliTPCtrackerParam::ReadPulls(const Char_t* inName) {
2492 //-----------------------------------------------------------------------------
2493 // This function reads the pulls from the DB
2494 //-----------------------------------------------------------------------------
2496 if(gSystem->AccessPathName(inName,kFileExists)) {
2497 cerr<<"AliTPCtrackerParam::ReadPulls: "<<inName<<" not found\n";
2500 TFile *inFile = TFile::Open(inName);
2502 for(Int_t i=0; i<5; i++) {
2503 TString pi("/Pulls/Pions/PullsPi_"); pi+=i;
2504 TString ka("/Pulls/Kaons/PullsKa_"); ka+=i;
2505 TString pr("/Pulls/Protons/PullsPr_"); pr+=i;
2506 TString el("/Pulls/Electrons/PullsEl_"); el+=i;
2507 TString mu("/Pulls/Muons/PullsMu_"); mu+=i;
2509 fPulls = (AliTPCkineGrid*)inFile->Get(pi.Data());
2510 fPullsPi[i].~AliTPCkineGrid();
2511 new(&fPullsPi[i]) AliTPCkineGrid(*fPulls);
2513 fPulls = (AliTPCkineGrid*)inFile->Get(ka.Data());
2514 fPullsKa[i].~AliTPCkineGrid();
2515 new(&fPullsKa[i]) AliTPCkineGrid(*fPulls);
2518 fPulls = (AliTPCkineGrid*)inFile->Get(pi.Data());
2520 fPulls = (AliTPCkineGrid*)inFile->Get(pr.Data());
2522 fPullsPr[i].~AliTPCkineGrid();
2523 new(&fPullsPr[i]) AliTPCkineGrid(*fPulls);
2525 fPulls = (AliTPCkineGrid*)inFile->Get(el.Data());
2526 fPullsEl[i].~AliTPCkineGrid();
2527 new(&fPullsEl[i]) AliTPCkineGrid(*fPulls);
2530 fPulls = (AliTPCkineGrid*)inFile->Get(pi.Data());
2532 fPulls = (AliTPCkineGrid*)inFile->Get(mu.Data());
2534 fPullsMu[i].~AliTPCkineGrid();
2535 new(&fPullsMu[i]) AliTPCkineGrid(*fPulls);
2542 //-----------------------------------------------------------------------------
2543 Int_t AliTPCtrackerParam::ReadRegParams(const Char_t* inName,Int_t pdg) {
2544 //-----------------------------------------------------------------------------
2545 // This function reads the regularization parameters from the DB
2546 //-----------------------------------------------------------------------------
2548 if(gSystem->AccessPathName(inName,kFileExists)) {
2549 cerr<<"AliTPCtrackerParam::ReadRegParams: "<<inName<<" not found\n";
2552 TFile *inFile = TFile::Open(inName);
2555 fRegPar = (TMatrixD*)inFile->Get("/RegParams/Pions/RegPions");
2556 new(&fRegParPi) TMatrixD(*fRegPar);
2559 fRegPar = (TMatrixD*)inFile->Get("/RegParams/Kaons/RegKaons");
2560 new(&fRegParKa) TMatrixD(*fRegPar);
2564 fRegPar = (TMatrixD*)inFile->Get("/RegParams/Pions/RegPions");
2566 fRegPar = (TMatrixD*)inFile->Get("/RegParams/Protons/RegProtons");
2568 new(&fRegParPr) TMatrixD(*fRegPar);
2571 fRegPar = (TMatrixD*)inFile->Get("/RegParams/Electrons/RegElectrons");
2572 new(&fRegParEl) TMatrixD(*fRegPar);
2576 fRegPar = (TMatrixD*)inFile->Get("/RegParams/Pions/RegPions");
2578 fRegPar = (TMatrixD*)inFile->Get("/RegParams/Muons/RegMuons");
2580 new(&fRegParMu) TMatrixD(*fRegPar);
2587 //-----------------------------------------------------------------------------
2588 void AliTPCtrackerParam::RegularizeCovMatrix(const Char_t *outName,Int_t pdg) {
2589 //-----------------------------------------------------------------------------
2590 // This function regularizes the elements of the covariance matrix
2591 // that show a momentum depence:
2592 // c00, c11, c22, c33, c44, c20, c24, c40, c31
2593 // The regularization is done separately for pions, kaons, electrons:
2594 // give "Pion","Kaon" or "Electron" as first argument.
2595 //-----------------------------------------------------------------------------
2597 gStyle->SetOptStat(0);
2598 gStyle->SetOptFit(10001);
2601 const char *part="Pions - ";
2603 InitializeKineGrid("DB");
2605 const Int_t kfitbins = fDBgrid->GetBinsPt();
2606 cerr<<" Fit bins: "<<kfitbins<<endl;
2612 cerr<<" Processing pions ...\n";
2617 cerr<<" Processing kaons ...\n";
2619 case 2212: //protons
2622 cerr<<" Processing protons ...\n";
2624 case 11: // electrons
2626 part="Electrons - ";
2627 cerr<<" Processing electrons ...\n";
2632 cerr<<" Processing muons ...\n";
2638 // create a chain with compared tracks
2639 TChain *cmptrkchain = new ("cmptrktree");
2640 cmptrkchain.Add("CovMatrix_AllEvts.root");
2641 //cmptrkchain.Add("CovMatrix_AllEvts_1.root");
2642 //cmptrkchain.Add("CovMatrix_AllEvts_2.root");
2643 //cmptrkchain.Add("CovMatrix_AllEvts_3.root");
2647 TFile *infile = TFile::Open("CovMatrix_AllEvts.root");
2648 TTree *cmptrktree = (TTree*)infile->Get("cmptrktree");
2651 cmptrktree->SetBranchAddress("comptracks",&cmptrk);
2652 Int_t entries = (Int_t)cmptrktree->GetEntries();
2656 Int_t *n = new Int_t[kfitbins];
2657 Int_t *n00 = new Int_t[kfitbins];
2658 Int_t *n11 = new Int_t[kfitbins];
2659 Int_t *n20 = new Int_t[kfitbins];
2660 Int_t *n22 = new Int_t[kfitbins];
2661 Int_t *n31 = new Int_t[kfitbins];
2662 Int_t *n33 = new Int_t[kfitbins];
2663 Int_t *n40 = new Int_t[kfitbins];
2664 Int_t *n42 = new Int_t[kfitbins];
2665 Int_t *n44 = new Int_t[kfitbins];
2666 Double_t *p = new Double_t[kfitbins];
2667 Double_t *ep = new Double_t[kfitbins];
2668 Double_t *mean00 = new Double_t[kfitbins];
2669 Double_t *mean11 = new Double_t[kfitbins];
2670 Double_t *mean20 = new Double_t[kfitbins];
2671 Double_t *mean22 = new Double_t[kfitbins];
2672 Double_t *mean31 = new Double_t[kfitbins];
2673 Double_t *mean33 = new Double_t[kfitbins];
2674 Double_t *mean40 = new Double_t[kfitbins];
2675 Double_t *mean42 = new Double_t[kfitbins];
2676 Double_t *mean44 = new Double_t[kfitbins];
2677 Double_t *sigma00 = new Double_t[kfitbins];
2678 Double_t *sigma11 = new Double_t[kfitbins];
2679 Double_t *sigma20 = new Double_t[kfitbins];
2680 Double_t *sigma22 = new Double_t[kfitbins];
2681 Double_t *sigma31 = new Double_t[kfitbins];
2682 Double_t *sigma33 = new Double_t[kfitbins];
2683 Double_t *sigma40 = new Double_t[kfitbins];
2684 Double_t *sigma42 = new Double_t[kfitbins];
2685 Double_t *sigma44 = new Double_t[kfitbins];
2686 Double_t *rmean = new Double_t[kfitbins];
2687 Double_t *rsigma = new Double_t[kfitbins];
2690 for(Int_t l=0; l<kfitbins; l++) {
2692 n00[l]=n11[l]=n20[l]=n22[l]=n31[l]=n33[l]=n40[l]=n42[l]=n44[l]=1;
2694 mean00[l]=mean11[l]=mean20[l]=mean22[l]=mean31[l]=mean33[l]=mean40[l]=mean42[l]=mean44[l]=0.;
2695 sigma00[l]=sigma11[l]=sigma20[l]=sigma22[l]=sigma31[l]=sigma33[l]=sigma40[l]=sigma42[l]=sigma44[l]=0.;
2698 // loop on chain entries for mean
2699 for(Int_t l=0; l<entries; l++) {
2700 cmptrktree->GetEvent(l);
2701 if(TMath::Abs(cmptrk.pdg)!=thisPdg) continue;
2702 pbin = (Int_t)fDBgrid->GetBin(cmptrk.pt,cmptrk.eta)/fDBgrid->GetBinsEta();
2705 mean00[pbin]+=cmptrk.c00;
2706 mean11[pbin]+=cmptrk.c11;
2707 mean20[pbin]+=cmptrk.c20;
2708 mean22[pbin]+=cmptrk.c22;
2709 mean31[pbin]+=cmptrk.c31;
2710 mean33[pbin]+=cmptrk.c33;
2711 mean40[pbin]+=cmptrk.c40;
2712 mean42[pbin]+=cmptrk.c42;
2713 mean44[pbin]+=cmptrk.c44;
2714 } // loop on chain entries
2716 for(Int_t l=0; l<kfitbins; l++) {
2729 // loop on chain entries for sigma
2730 for(Int_t l=0; l<entries; l++) {
2731 cmptrktree->GetEvent(l);
2732 if(TMath::Abs(cmptrk.pdg)!=thisPdg) continue;
2733 pbin = (Int_t)fDBgrid->GetBin(cmptrk.pt,cmptrk.eta)/fDBgrid->GetBinsEta();
2734 if(TMath::Abs(cmptrk.c00-mean00[pbin])<0.4*mean00[pbin]) { n00[pbin]++;
2735 sigma00[pbin]+=(cmptrk.c00-mean00[pbin])*(cmptrk.c00-mean00[pbin]); }
2736 if(TMath::Abs(cmptrk.c11-mean11[pbin])<0.4*mean11[pbin]) { n11[pbin]++;
2737 sigma11[pbin]+=(cmptrk.c11-mean11[pbin])*(cmptrk.c11-mean11[pbin]); }
2738 if(TMath::Abs(cmptrk.c20-mean20[pbin])<0.4*mean20[pbin]) { n20[pbin]++;
2739 sigma20[pbin]+=(cmptrk.c20-mean20[pbin])*(cmptrk.c20-mean20[pbin]); }
2740 if(TMath::Abs(cmptrk.c22-mean22[pbin])<0.4*mean22[pbin]) { n22[pbin]++;
2741 sigma22[pbin]+=(cmptrk.c22-mean22[pbin])*(cmptrk.c22-mean22[pbin]); }
2742 if(TMath::Abs(cmptrk.c31-mean31[pbin])<-0.4*mean31[pbin]) { n31[pbin]++;
2743 sigma31[pbin]+=(cmptrk.c31-mean31[pbin])*(cmptrk.c31-mean31[pbin]); }
2744 if(TMath::Abs(cmptrk.c33-mean33[pbin])<0.4*mean33[pbin]) { n33[pbin]++;
2745 sigma33[pbin]+=(cmptrk.c33-mean33[pbin])*(cmptrk.c33-mean33[pbin]); }
2746 if(TMath::Abs(cmptrk.c40-mean40[pbin])<0.4*mean40[pbin]) { n40[pbin]++;
2747 sigma40[pbin]+=(cmptrk.c40-mean40[pbin])*(cmptrk.c40-mean40[pbin]); }
2748 if(TMath::Abs(cmptrk.c42-mean42[pbin])<0.4*mean42[pbin]) { n42[pbin]++;
2749 sigma42[pbin]+=(cmptrk.c42-mean42[pbin])*(cmptrk.c42-mean42[pbin]); }
2750 if(TMath::Abs(cmptrk.c44-mean44[pbin])<0.4*mean44[pbin]) { n44[pbin]++;
2751 sigma44[pbin]+=(cmptrk.c44-mean44[pbin])*(cmptrk.c44-mean44[pbin]); }
2752 } // loop on chain entries
2754 for(Int_t l=0; l<kfitbins; l++) {
2755 sigma00[l] = TMath::Sqrt(sigma00[l]/n00[l]);
2756 sigma11[l] = TMath::Sqrt(sigma11[l]/n11[l]);
2757 sigma20[l] = TMath::Sqrt(sigma20[l]/n20[l]);
2758 sigma22[l] = TMath::Sqrt(sigma22[l]/n22[l]);
2759 sigma31[l] = TMath::Sqrt(sigma31[l]/n31[l]);
2760 sigma33[l] = TMath::Sqrt(sigma33[l]/n33[l]);
2761 sigma40[l] = TMath::Sqrt(sigma40[l]/n40[l]);
2762 sigma42[l] = TMath::Sqrt(sigma42[l]/n42[l]);
2763 sigma44[l] = TMath::Sqrt(sigma44[l]/n44[l]);
2768 TF1 *func = new TF1("RegFunc",RegFunc,0.23,50.,3);
2769 func->SetParNames("A_meas","A_scatt","B");
2771 // line to draw on the plots
2772 TLine *lin = new TLine(-1,1,1.69,1);
2773 lin->SetLineStyle(2);
2774 lin->SetLineWidth(2);
2776 // matrix used to store fit results
2777 TMatrixD fitRes(9,3);
2781 // create the canvas
2782 TCanvas *canv00 = new TCanvas("canv00","c00",0,0,700,900);
2783 canv00->Divide(1,2);
2784 // create the graph for cov matrix
2785 TGraphErrors *gr00 = new TGraphErrors(kfitbins,p,mean00,ep,sigma00);
2786 TString title00("C(y,y)"); title00.Prepend(part);
2787 TH2F *frame00 = new TH2F("frame00",title00.Data(),2,0.1,50,2,0,5e-3);
2788 frame00->SetXTitle("p [GeV/c]");
2789 canv00->cd(1); gPad->SetLogx();
2792 // Sets initial values for parameters
2793 func->SetParameters(1.6e-3,1.9e-4,1.5);
2794 // Fit points in range defined by function
2795 gr00->Fit("RegFunc","R,Q");
2796 func->GetParameters(fitpar);
2797 for(Int_t i=0; i<3; i++) fitRes(0,i)=fitpar[i];
2798 for(Int_t l=0; l<kfitbins; l++) {
2799 rmean[l] = mean00[l]/RegFunc(&p[l],fitpar);
2800 rsigma[l] = sigma00[l]/RegFunc(&p[l],fitpar);
2802 // create the graph the regularized cov. matrix
2803 TGraphErrors *gr00reg = new TGraphErrors(kfitbins,p,rmean,ep,rsigma);
2804 TString regtitle00("C(y,y)/(A_meas+A_scatt/p^{B})");
2805 regtitle00.Prepend(part);
2806 TH2F *frame00reg = new TH2F("frame00reg",regtitle00.Data(),2,0.1,50,2,0,2);
2807 frame00reg->SetXTitle("p [GeV/c]");
2808 canv00->cd(2); gPad->SetLogx();
2816 // create the canvas
2817 TCanvas *canv11 = new TCanvas("canv11","c11",0,0,700,900);
2818 canv11->Divide(1,2);
2819 // create the graph for cov matrix
2820 TGraphErrors *gr11 = new TGraphErrors(kfitbins,p,mean11,ep,sigma11);
2821 TString title11("C(z,z)"); title11.Prepend(part);
2822 TH2F *frame11 = new TH2F("frame11",title11.Data(),2,0.1,50,2,0,6e-3);
2823 frame11->SetXTitle("p [GeV/c]");
2824 canv11->cd(1); gPad->SetLogx();
2827 // Sets initial values for parameters
2828 func->SetParameters(1.2e-3,8.1e-4,1.);
2829 // Fit points in range defined by function
2830 gr11->Fit("RegFunc","R,Q");
2831 func->GetParameters(fitpar);
2832 for(Int_t i=0; i<3; i++) fitRes(1,i)=fitpar[i];
2833 for(Int_t l=0; l<kfitbins; l++) {
2834 rmean[l] = mean11[l]/RegFunc(&p[l],fitpar);
2835 rsigma[l] = sigma11[l]/RegFunc(&p[l],fitpar);
2837 // create the graph the regularized cov. matrix
2838 TGraphErrors *gr11reg = new TGraphErrors(kfitbins,p,rmean,ep,rsigma);
2839 TString regtitle11("C(z,z)/(A_meas+A_scatt/p^{B})");
2840 regtitle11.Prepend(part);
2841 TH2F *frame11reg = new TH2F("frame11reg",regtitle11.Data(),2,0.1,50,2,0,2);
2842 frame11reg->SetXTitle("p [GeV/c]");
2843 canv11->cd(2); gPad->SetLogx();
2851 // create the canvas
2852 TCanvas *canv20 = new TCanvas("canv20","c20",0,0,700,900);
2853 canv20->Divide(1,2);
2854 // create the graph for cov matrix
2855 TGraphErrors *gr20 = new TGraphErrors(kfitbins,p,mean20,ep,sigma20);
2856 TString title20("C(#eta, y)"); title20.Prepend(part);
2857 TH2F *frame20 = new TH2F("frame20",title20.Data(),2,0.1,50,2,0,2.5e-4);
2858 frame20->SetXTitle("p [GeV/c]");
2859 canv20->cd(1); gPad->SetLogx();
2862 // Sets initial values for parameters
2863 func->SetParameters(7.3e-5,1.2e-5,1.5);
2864 // Fit points in range defined by function
2865 gr20->Fit("RegFunc","R,Q");
2866 func->GetParameters(fitpar);
2867 for(Int_t i=0; i<3; i++) fitRes(2,i)=fitpar[i];
2868 for(Int_t l=0; l<kfitbins; l++) {
2869 rmean[l] = mean20[l]/RegFunc(&p[l],fitpar);
2870 rsigma[l] = sigma20[l]/RegFunc(&p[l],fitpar);
2872 // create the graph the regularized cov. matrix
2873 TGraphErrors *gr20reg = new TGraphErrors(kfitbins,p,rmean,ep,rsigma);
2874 TString regtitle20("C(#eta, y)/(A_meas+A_scatt/p^{B})");
2875 regtitle20.Prepend(part);
2876 TH2F *frame20reg = new TH2F("frame20reg",regtitle20.Data(),2,0.1,50,2,0,2);
2877 frame20reg->SetXTitle("p [GeV/c]");
2878 canv20->cd(2); gPad->SetLogx();
2886 // create the canvas
2887 TCanvas *canv22 = new TCanvas("canv22","c22",0,0,700,900);
2888 canv22->Divide(1,2);
2889 // create the graph for cov matrix
2890 TGraphErrors *gr22 = new TGraphErrors(kfitbins,p,mean22,ep,sigma22);
2891 TString title22("C(#eta, #eta)"); title22.Prepend(part);
2892 TH2F *frame22 = new TH2F("frame22",title22.Data(),2,0.1,50,2,0,3e-5);
2893 frame22->SetXTitle("p [GeV/c]");
2894 canv22->cd(1); gPad->SetLogx();
2897 // Sets initial values for parameters
2898 func->SetParameters(5.2e-6,1.1e-6,2.);
2899 // Fit points in range defined by function
2900 gr22->Fit("RegFunc","R,Q");
2901 func->GetParameters(fitpar);
2902 for(Int_t i=0; i<3; i++) fitRes(3,i)=fitpar[i];
2903 for(Int_t l=0; l<kfitbins; l++) {
2904 rmean[l] = mean22[l]/RegFunc(&p[l],fitpar);
2905 rsigma[l] = sigma22[l]/RegFunc(&p[l],fitpar);
2907 // create the graph the regularized cov. matrix
2908 TGraphErrors *gr22reg = new TGraphErrors(kfitbins,p,rmean,ep,rsigma);
2909 TString regtitle22("C(#eta, #eta)/(A_meas+A_scatt/p^{B})");
2910 regtitle22.Prepend(part);
2911 TH2F *frame22reg = new TH2F("frame22reg",regtitle22.Data(),2,0.1,50,2,0,2);
2912 frame22reg->SetXTitle("p [GeV/c]");
2913 canv22->cd(2); gPad->SetLogx();
2921 // create the canvas
2922 TCanvas *canv31 = new TCanvas("canv31","c31",0,0,700,900);
2923 canv31->Divide(1,2);
2924 // create the graph for cov matrix
2925 TGraphErrors *gr31 = new TGraphErrors(kfitbins,p,mean31,ep,sigma31);
2926 TString title31("C(tg #lambda,z)"); title31.Prepend(part);
2927 TH2F *frame31 = new TH2F("frame31",title31.Data(),2,0.1,50,2,-2e-4,0);
2928 frame31->SetXTitle("p [GeV/c]");
2929 canv31->cd(1); gPad->SetLogx();
2932 // Sets initial values for parameters
2933 func->SetParameters(-1.2e-5,-1.2e-5,1.5);
2934 // Fit points in range defined by function
2935 gr31->Fit("RegFunc","R,Q");
2936 func->GetParameters(fitpar);
2937 for(Int_t i=0; i<3; i++) fitRes(4,i)=fitpar[i];
2938 for(Int_t l=0; l<kfitbins; l++) {
2939 rmean[l] = mean31[l]/RegFunc(&p[l],fitpar);
2940 rsigma[l] = -sigma31[l]/RegFunc(&p[l],fitpar);
2942 // create the graph the regularized cov. matrix
2943 TGraphErrors *gr31reg = new TGraphErrors(kfitbins,p,rmean,ep,rsigma);
2944 TString regtitle31("C(tg #lambda,z)/(A_meas+A_scatt/p^{B})");
2945 regtitle31.Prepend(part);
2946 TH2F *frame31reg = new TH2F("frame31reg",regtitle31.Data(),2,0.1,50,2,0,2);
2947 frame31reg->SetXTitle("p [GeV/c]");
2948 canv31->cd(2); gPad->SetLogx();
2956 // create the canvas
2957 TCanvas *canv33 = new TCanvas("canv33","c33",0,0,700,900);
2958 canv33->Divide(1,2);
2959 // create the graph for cov matrix
2960 TGraphErrors *gr33 = new TGraphErrors(kfitbins,p,mean33,ep,sigma33);
2961 TString title33("C(tg #lambda,tg #lambda)"); title33.Prepend(part);
2962 TH2F *frame33 = new TH2F("frame33",title33.Data(),2,0.1,50,2,0,1e-5);
2963 frame33->SetXTitle("p [GeV/c]");
2964 canv33->cd(1); gPad->SetLogx();
2967 // Sets initial values for parameters
2968 func->SetParameters(1.3e-7,4.6e-7,1.7);
2969 // Fit points in range defined by function
2970 gr33->Fit("RegFunc","R,Q");
2971 func->GetParameters(fitpar);
2972 for(Int_t i=0; i<3; i++) fitRes(5,i)=fitpar[i];
2973 for(Int_t l=0; l<kfitbins; l++) {
2974 rmean[l] = mean33[l]/RegFunc(&p[l],fitpar);
2975 rsigma[l] = sigma33[l]/RegFunc(&p[l],fitpar);
2977 // create the graph the regularized cov. matrix
2978 TGraphErrors *gr33reg = new TGraphErrors(kfitbins,p,rmean,ep,rsigma);
2979 TString regtitle33("C(tg #lambda,tg #lambda)/(A_meas+A_scatt/p^{B})");
2980 regtitle33.Prepend(part);
2981 TH2F *frame33reg = new TH2F("frame33reg",regtitle33.Data(),2,0.1,50,2,0,2);
2982 frame33reg->SetXTitle("p [GeV/c]");
2983 canv33->cd(2); gPad->SetLogx();
2991 // create the canvas
2992 TCanvas *canv40 = new TCanvas("canv40","c40",0,0,700,900);
2993 canv40->Divide(1,2);
2994 // create the graph for cov matrix
2995 TGraphErrors *gr40 = new TGraphErrors(kfitbins,p,mean40,ep,sigma40);
2996 TString title40("C(C,y)"); title40.Prepend(part);
2997 TH2F *frame40 = new TH2F("frame40",title40.Data(),2,0.1,50,2,0,1e-6);
2998 frame40->SetXTitle("p [GeV/c]");
2999 canv40->cd(1); gPad->SetLogx();
3002 // Sets initial values for parameters
3003 func->SetParameters(4.e-7,4.4e-8,1.5);
3004 // Fit points in range defined by function
3005 gr40->Fit("RegFunc","R,Q");
3006 func->GetParameters(fitpar);
3007 for(Int_t i=0; i<3; i++) fitRes(6,i)=fitpar[i];
3008 for(Int_t l=0; l<kfitbins; l++) {
3009 rmean[l] = mean40[l]/RegFunc(&p[l],fitpar);
3010 rsigma[l] = sigma40[l]/RegFunc(&p[l],fitpar);
3012 // create the graph the regularized cov. matrix
3013 TGraphErrors *gr40reg = new TGraphErrors(kfitbins,p,rmean,ep,rsigma);
3014 TString regtitle40("C(C,y)/(A_meas+A_scatt/p^{B})");
3015 regtitle40.Prepend(part);
3016 TH2F *frame40reg = new TH2F("frame40reg",regtitle40.Data(),2,0.1,50,2,0,2);
3017 frame40reg->SetXTitle("p [GeV/c]");
3018 canv40->cd(2); gPad->SetLogx();
3026 // create the canvas
3027 TCanvas *canv42 = new TCanvas("canv42","c42",0,0,700,900);
3028 canv42->Divide(1,2);
3029 // create the graph for cov matrix
3030 TGraphErrors *gr42 = new TGraphErrors(kfitbins,p,mean42,ep,sigma42);
3031 TString title42("C(C, #eta)"); title42.Prepend(part);
3032 TH2F *frame42 = new TH2F("frame42",title42.Data(),2,0.1,50,2,0,2.2e-7);
3033 frame42->SetXTitle("p [GeV/c]");
3034 canv42->cd(1); gPad->SetLogx();
3037 // Sets initial values for parameters
3038 func->SetParameters(3.e-8,8.2e-9,2.);
3039 // Fit points in range defined by function
3040 gr42->Fit("RegFunc","R,Q");
3041 func->GetParameters(fitpar);
3042 for(Int_t i=0; i<3; i++) fitRes(7,i)=fitpar[i];
3043 for(Int_t l=0; l<kfitbins; l++) {
3044 rmean[l] = mean42[l]/RegFunc(&p[l],fitpar);
3045 rsigma[l] = sigma42[l]/RegFunc(&p[l],fitpar);
3047 // create the graph the regularized cov. matrix
3048 TGraphErrors *gr42reg = new TGraphErrors(kfitbins,p,rmean,ep,rsigma);
3049 TString regtitle42("C(C, #eta)/(A_meas+A_scatt/p^{B})");
3050 regtitle42.Prepend(part);
3051 TH2F *frame42reg = new TH2F("frame42reg",regtitle42.Data(),2,0.1,50,2,0,2);
3052 frame42reg->SetXTitle("p [GeV/c]");
3053 canv42->cd(2); gPad->SetLogx();
3061 // create the canvas
3062 TCanvas *canv44 = new TCanvas("canv44","c44",0,0,700,900);
3063 canv44->Divide(1,2);
3064 // create the graph for cov matrix
3065 TGraphErrors *gr44 = new TGraphErrors(kfitbins,p,mean44,ep,sigma44);
3066 TString title44("C(C,C)"); title44.Prepend(part);
3067 TH2F *frame44 = new TH2F("frame44",title44.Data(),2,0.1,50,2,0,2e-9);
3068 frame44->SetXTitle("p [GeV/c]");
3069 canv44->cd(1); gPad->SetLogx();
3072 // Sets initial values for parameters
3073 func->SetParameters(1.8e-10,5.8e-11,2.);
3074 // Fit points in range defined by function
3075 gr44->Fit("RegFunc","R,Q");
3076 func->GetParameters(fitpar);
3077 for(Int_t i=0; i<3; i++) fitRes(8,i)=fitpar[i];
3078 for(Int_t l=0; l<kfitbins; l++) {
3079 rmean[l] = mean44[l]/RegFunc(&p[l],fitpar);
3080 rsigma[l] = sigma44[l]/RegFunc(&p[l],fitpar);
3082 // create the graph the regularized cov. matrix
3083 TGraphErrors *gr44reg = new TGraphErrors(kfitbins,p,rmean,ep,rsigma);
3084 TString regtitle44("C(C,C)/(A_meas+A_scatt/p^{B})");
3085 regtitle44.Prepend(part);
3086 TH2F *frame44reg = new TH2F("frame44reg",regtitle44.Data(),2,0.1,50,2,0,2);
3087 frame44reg->SetXTitle("p [GeV/c]");
3088 canv44->cd(2); gPad->SetLogx();
3098 new(&fRegParPi) TMatrixD(fitRes);
3101 new(&fRegParKa) TMatrixD(fitRes);
3104 new(&fRegParPr) TMatrixD(fitRes);
3107 new(&fRegParEl) TMatrixD(fitRes);
3110 new(&fRegParMu) TMatrixD(fitRes);
3114 // write fit parameters to file
3115 WriteRegParams(outName,pdg);
3152 //-----------------------------------------------------------------------------
3153 Bool_t AliTPCtrackerParam::SelectedTrack(Double_t pt,Double_t eta) const {
3154 //-----------------------------------------------------------------------------
3155 // This function makes a selection according to TPC tracking efficiency
3156 //-----------------------------------------------------------------------------
3160 eff = fEff->GetValueAt(pt,eta);
3162 if(gRandom->Rndm() < eff) return kTRUE;
3166 //-----------------------------------------------------------------------------
3167 void AliTPCtrackerParam::SetParticle(Int_t pdg) {
3168 //-----------------------------------------------------------------------------
3169 // This function set efficiencies, pulls, etc... for the particle
3170 // specie of the current particle
3171 //-----------------------------------------------------------------------------
3175 fDBgrid = &fDBgridPi;
3178 fRegPar = &fRegParPi;
3179 fdEdxMean = &fdEdxMeanPi;
3180 fdEdxRMS = &fdEdxRMSPi;
3183 fDBgrid = &fDBgridKa;
3186 fRegPar = &fRegParKa;
3187 fdEdxMean = &fdEdxMeanKa;
3188 fdEdxRMS = &fdEdxRMSKa;
3191 fDBgrid = &fDBgridPr;
3194 fRegPar = &fRegParPr;
3195 fdEdxMean = &fdEdxMeanPr;
3196 fdEdxRMS = &fdEdxRMSPr;
3199 fDBgrid = &fDBgridEl;
3202 fRegPar = &fRegParEl;
3203 fdEdxMean = &fdEdxMeanEl;
3204 fdEdxRMS = &fdEdxRMSEl;
3207 fDBgrid = &fDBgridMu;
3210 fRegPar = &fRegParMu;
3211 fdEdxMean = &fdEdxMeanMu;
3212 fdEdxRMS = &fdEdxRMSMu;
3218 //-----------------------------------------------------------------------------
3219 void AliTPCtrackerParam::SmearTrack(Double_t *xx,Double_t *xxsm,TMatrixD cov)
3221 //-----------------------------------------------------------------------------
3222 // This function smears track parameters according to streched cov. matrix
3223 //-----------------------------------------------------------------------------
3224 AliGausCorr *corgen = new AliGausCorr(cov,5);
3226 corgen->GetGaussN(corr);
3230 for(Int_t l=0;l<5;l++) {
3231 xxsm[l] = xx[l]+corr[l];
3236 //-----------------------------------------------------------------------------
3237 Int_t AliTPCtrackerParam::WritedEdx(const Char_t *outName,Int_t pdg) {
3238 //-----------------------------------------------------------------------------
3239 // This function writes the dEdx parameters to the DB
3240 //-----------------------------------------------------------------------------
3243 const char *dirName="Pions";
3244 const char *meanName="dEdxMeanPi";
3245 const char *rmsName="dEdxRMSPi";
3249 if(gSystem->AccessPathName(outName,kFileExists)) { opt="recreate";
3250 } else { opt="update"; }
3255 meanName="dEdxMeanPi";
3256 rmsName="dEdxRMSPi";
3260 meanName="dEdxMeanKa";
3261 rmsName="dEdxRMSKa";
3265 meanName="dEdxMeanPr";
3266 rmsName="dEdxRMSPr";
3269 dirName="Electrons";
3270 meanName="dEdxMeanEl";
3271 rmsName="dEdxRMSEl";
3275 meanName="dEdxMeanMu";
3276 rmsName="dEdxRMSMu";
3280 TFile *outFile = new TFile(outName,opt);
3281 if(!gDirectory->cd("/dEdx")) {
3282 outFile->mkdir("dEdx");
3283 gDirectory->cd("/dEdx");
3285 TDirectory *dir2 = gDirectory->mkdir(dirName);
3287 fdEdxMean->SetName(meanName); fdEdxMean->Write();
3288 fdEdxRMS->SetName(rmsName); fdEdxRMS->Write();
3296 //-----------------------------------------------------------------------------
3297 Int_t AliTPCtrackerParam::WriteEffs(const Char_t *outName) {
3298 //-----------------------------------------------------------------------------
3299 // This function writes the TPC efficiencies to the DB
3300 //-----------------------------------------------------------------------------
3305 if(gSystem->AccessPathName(outName,kFileExists)) { opt="recreate";
3306 } else { opt="update"; }
3308 TFile *outFile = new TFile(outName,opt);
3310 outFile->mkdir("Efficiencies");
3311 gDirectory->cd("/Efficiencies");
3312 gDirectory->mkdir("Pions");
3313 gDirectory->mkdir("Kaons");
3314 gDirectory->mkdir("Protons");
3315 gDirectory->mkdir("Electrons");
3316 gDirectory->mkdir("Muons");
3318 gDirectory->cd("/Efficiencies/Pions");
3319 fEffPi.SetName("EffPi");
3321 gDirectory->cd("/Efficiencies/Kaons");
3322 fEffKa.SetName("EffKa");
3324 gDirectory->cd("/Efficiencies/Protons");
3325 fEffPr.SetName("EffPr");
3327 gDirectory->cd("/Efficiencies/Electrons");
3328 fEffEl.SetName("EffEl");
3330 gDirectory->cd("/Efficiencies/Muons");
3331 fEffMu.SetName("EffMu");
3340 //-----------------------------------------------------------------------------
3341 Int_t AliTPCtrackerParam::WritePulls(const Char_t *outName) {
3342 //-----------------------------------------------------------------------------
3343 // This function writes the pulls to the DB
3344 //-----------------------------------------------------------------------------
3348 if(gSystem->AccessPathName(outName,kFileExists)) { opt="recreate";
3349 } else { opt="update"; }
3351 TFile *outFile = new TFile(outName,opt);
3353 outFile->mkdir("Pulls");
3354 gDirectory->cd("/Pulls");
3355 gDirectory->mkdir("Pions");
3356 gDirectory->mkdir("Kaons");
3357 gDirectory->mkdir("Protons");
3358 gDirectory->mkdir("Electrons");
3359 gDirectory->mkdir("Muons");
3361 for(Int_t i=0;i<5;i++) {
3362 TString pi("PullsPi_"); pi+=i;
3363 TString ka("PullsKa_"); ka+=i;
3364 TString pr("PullsPr_"); pr+=i;
3365 TString el("PullsEl_"); el+=i;
3366 TString mu("PullsMu_"); mu+=i;
3367 fPullsPi[i].SetName(pi.Data());
3368 fPullsKa[i].SetName(ka.Data());
3369 fPullsPr[i].SetName(pr.Data());
3370 fPullsEl[i].SetName(el.Data());
3371 fPullsMu[i].SetName(mu.Data());
3372 gDirectory->cd("/Pulls/Pions");
3373 fPullsPi[i].Write();
3374 gDirectory->cd("/Pulls/Kaons");
3375 fPullsKa[i].Write();
3376 gDirectory->cd("/Pulls/Protons");
3377 fPullsPr[i].Write();
3378 gDirectory->cd("/Pulls/Electrons");
3379 fPullsEl[i].Write();
3380 gDirectory->cd("/Pulls/Muons");
3381 fPullsMu[i].Write();
3388 //-----------------------------------------------------------------------------
3389 Int_t AliTPCtrackerParam::WriteRegParams(const Char_t *outName,Int_t pdg) {
3390 //-----------------------------------------------------------------------------
3391 // This function writes the regularization parameters to the DB
3392 //-----------------------------------------------------------------------------
3395 const char *dirName="Pions";
3396 const char *keyName="RegPions";
3400 if(gSystem->AccessPathName(outName,kFileExists)) { opt="recreate";
3401 } else { opt="update"; }
3414 keyName="RegProtons";
3417 dirName="Electrons";
3418 keyName="RegElectrons";
3426 TFile *outFile = new TFile(outName,opt);
3427 if(!gDirectory->cd("/RegParams")) {
3428 outFile->mkdir("RegParams");
3429 gDirectory->cd("/RegParams");
3431 TDirectory *dir2 = gDirectory->mkdir(dirName);
3433 fRegPar->Write(keyName);
3441 //-----------------------------------------------------------------------------
3442 //*****************************************************************************
3443 //-----------------------------------------------------------------------------