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 --------
66 #include <TGraphErrors.h>
73 //------ AliRoot headers ------
75 #include "AliGausCorr.h"
76 #include "AliKalmanTrack.h"
78 #include "AliMagFCM.h"
79 #include "AliRunLoader.h"
80 #include "AliTPCLoader.h"
81 #include "AliTPCkineGrid.h"
82 #include "AliTPCtrack.h"
83 #include "AliTrackReference.h"
84 #include "AliTPCtrackerParam.h"
86 //-----------------------------
88 Double_t RegFunc(Double_t *x,Double_t *par) {
89 // This is the function used to regularize the covariance matrix
90 Double_t value = par[0]+par[1]/TMath::Power(x[0],par[2]);
94 // structure for DB building
104 Double_t dP0,dP1,dP2,dP3,dP4;
105 Double_t c00,c10,c11,c20,c21,c22,c30,c31,c32,c33,c40,c41,c42,c43,c44;
108 // cov matrix structure
110 Double_t c00,c10,c11,c20,c21,c22,c30,c31,c32,c33,c40,c41,c42,c43,c44;
113 ClassImp(AliTPCtrackerParam)
115 //-----------------------------------------------------------------------------
116 AliTPCtrackerParam::AliTPCtrackerParam(Int_t kcoll, Double_t kBz,
117 Int_t kn, const char* evfoldname):
118 fEvFolderName(evfoldname) {
119 //-----------------------------------------------------------------------------
120 // This is the class conctructor
121 //-----------------------------------------------------------------------------
123 fNevents = kn; // events to be processed
124 fBz = kBz; // value of the z component of L3 field (Tesla)
125 fColl = kcoll; // collision code (0: PbPb6000; 1: pp)
126 fSelAndSmear = kTRUE; // by default selection and smearing are done
129 cerr<<"AliTPCtrackerParam::AliTPCtrackerParam: Invalid field!\n";
130 cerr<<" Available: 0.4"<<endl;
132 if(fColl!=0 && fColl!=1) {
133 cerr<<"AliTPCtrackerParam::AliTPCtrackerParam: Invalid collision!\n";
134 cerr<<" Available: 0 -> PbPb6000"<<endl;
135 cerr<<" 1 -> pp"<<endl;
138 fDBfileName = gSystem->Getenv("ALICE_ROOT");
139 fDBfileName.Append("/TPC/CovMatrixDB_");
140 //fDBfileName = "CovMatrixDB_";
141 if(fColl==0) fDBfileName.Append("PbPb6000");
142 if(fColl==1) fDBfileName.Append("pp");
143 if(fBz==0.4) fDBfileName.Append("_B0.4T.root");
145 //-----------------------------------------------------------------------------
146 AliTPCtrackerParam::~AliTPCtrackerParam() {}
147 //____________________________________________________________________________
148 AliTPCtrackerParam::AliTPCtrackerParam( const AliTPCtrackerParam& p):TObject(p)
150 // dummy copy constructor
152 //----------------------------------------------------------------------------
153 AliTPCtrackerParam::AliTPCseedGeant::AliTPCseedGeant(
154 Double_t x,Double_t y,Double_t z,
155 Double_t px,Double_t py,Double_t pz,
157 //----------------------------------------------------------------------------
158 // Constructor of the geant seeds
159 //----------------------------------------------------------------------------
167 Double_t a = TMath::ATan2(y,x)*180./TMath::Pi();
169 fSector = (Int_t)(a/20.);
170 fAlpha = 10.+20.*fSector;
172 fAlpha *= TMath::Pi();
174 //-----------------------------------------------------------------------------
175 Int_t AliTPCtrackerParam::BuildTPCtracks(const TFile *inp, TFile *out) {
176 //-----------------------------------------------------------------------------
177 // This function creates the TPC parameterized tracks
178 //-----------------------------------------------------------------------------
180 Error("BuildTPCtracks","in and out parameters ignored. new io");
182 /********************************************/
183 AliRunLoader* rl = AliRunLoader::GetRunLoader(fEvFolderName);
186 Error("BuildTPCtracks","Can not get Run Loader from event folder named %s.",
187 fEvFolderName.Data());
190 AliLoader* tpcloader = rl->GetLoader("TPCLoader");
191 if (tpcloader == 0x0)
193 Error("BuildTPCtracks","Can not get TPC Loader from Run Loader.");
197 /********************************************/
200 TTree *covTreePi[50];
201 TTree *covTreeKa[50];
202 TTree *covTreePr[50];
203 TTree *covTreeEl[50];
204 TTree *covTreeMu[50];
207 cerr<<"+++\n+++ Reading DataBase from:\n+++ "<<
208 fDBfileName.Data()<<"\n+++\n";
209 // Read paramters from DB file
210 if(!ReadAllData(fDBfileName.Data())) {
211 cerr<<"AliTPCtrackerParam::BuildTPCtracks: \
212 Could not read data from DB\n\n"; return 1;
215 // Read the trees with regularized cov. matrices from DB
217 fileDB = TFile::Open(fDBfileName.Data());
218 Int_t nBinsPi = fDBgridPi.GetTotBins();
219 for(Int_t l=0; l<nBinsPi; l++) {
220 str = "/CovMatrices/Pions/CovTreePi_bin";
222 covTreePi[l] = (TTree*)fileDB->Get(str.Data());
224 Int_t nBinsKa = fDBgridKa.GetTotBins();
225 for(Int_t l=0; l<nBinsKa; l++) {
226 str = "/CovMatrices/Kaons/CovTreeKa_bin";
228 covTreeKa[l] = (TTree*)fileDB->Get(str.Data());
230 Int_t nBinsPr = fDBgridPr.GetTotBins();
231 for(Int_t l=0; l<nBinsPr; l++) {
233 str = "/CovMatrices/Pions/CovTreePi_bin";
235 str = "/CovMatrices/Protons/CovTreePr_bin";
238 covTreePr[l] = (TTree*)fileDB->Get(str.Data());
240 Int_t nBinsEl = fDBgridEl.GetTotBins();
241 for(Int_t l=0; l<nBinsEl; l++) {
242 str = "/CovMatrices/Electrons/CovTreeEl_bin";
244 covTreeEl[l] = (TTree*)fileDB->Get(str.Data());
246 Int_t nBinsMu = fDBgridMu.GetTotBins();
247 for(Int_t l=0; l<nBinsMu; l++) {
249 str = "/CovMatrices/Pions/CovTreePi_bin";
251 str = "/CovMatrices/Muons/CovTreeMu_bin";
254 covTreeMu[l] = (TTree*)fileDB->Get(str.Data());
257 } else cerr<<"\n ! Creating ALL TRUE tracks at TPC 1st hit !\n\n";
259 TFile *infile=(TFile*)inp;
262 // Get gAlice object from file
266 tpcloader->LoadHits("read");
268 if(!(gAlice=rl->GetAliRun())) {
269 cerr<<"Can not get gAlice from Run Loader !\n";
273 // Check if value in the galice file is equal to selected one (fBz)
274 AliMagF *fiel = (AliMagF*)gAlice->Field();
275 Double_t fieval=(Double_t)fiel->SolenoidField()/10.;
276 printf("Magnetic field is %6.2f Tesla\n",fieval);
278 cerr<<"AliTPCtrackerParam::BuildTPCtracks: Invalid field!"<<endl;
279 cerr<<"Field selected is: "<<fBz<<" T\n";
280 cerr<<"Field found on file is: "<<fieval<<" T\n";
285 AliTPC *tpc=(AliTPC*)gAlice->GetDetector("TPC");
286 Int_t ver = tpc->IsVersion();
287 cerr<<"+++ TPC version "<<ver<<" has been found !\n";
290 AliTPCParam *digp=(AliTPCParam*)infile->Get("75x40_100x60");
293 digp = new AliTPCParamSR();
295 else digp=(AliTPCParam*)infile->Get("75x40_100x60_150x60");
297 if(!digp) { cerr<<"TPC parameters have not been found !\n"; return 1; }
300 // Set the conversion constant between curvature and Pt
301 AliKalmanTrack::SetConvConst(100/0.299792458/fBz);
304 AliTPCseedGeant *seed=0;
305 AliTPCtrack *tpctrack=0;
307 Int_t cl=0,bin,label,pdg,charge;
309 Int_t nParticles,nSeeds,arrentr;
311 //Int_t nSel=0,nAcc=0;
314 // loop over first n events in file
315 for(Int_t evt=0; evt<fNevents; evt++){
316 cerr<<"+++\n+++ Processing event "<<evt<<"\n+++\n";
319 // tree for TPC tracks
320 sprintf(tname,"TreeT_TPC_%d",evt);
321 TTree *tracktree = new TTree(tname,"Tree with TPC tracks");
322 tracktree->Branch("tracks","AliTPCtrack",&tpctrack,20000,0);
324 // array for TPC tracks
325 TObjArray tArray(20000);
327 // array for TPC seeds with geant info
328 TObjArray sArray(20000);
330 // get the particles stack
331 nParticles = (Int_t)gAlice->GetEvent(evt);
333 Bool_t *done = new Bool_t[nParticles];
334 Int_t *pdgCodes = new Int_t[nParticles];
335 Double_t *ptkine = new Double_t[nParticles];
336 Double_t *pzkine = new Double_t[nParticles];
338 // loop on particles and store pdg codes
339 for(Int_t l=0; l<nParticles; l++) {
340 part = (TParticle*)gAlice->GetMCApp()->Particle(l);
341 pdgCodes[l] = part->GetPdgCode();
342 ptkine[l] = part->Pt();
343 pzkine[l] = part->Pz();
346 cerr<<"+++\n+++ Number of particles in event "<<evt<<": "<<nParticles<<
349 cerr<<"\n ********** MAKING SEEDS *****************"<<endl<<endl;
352 // Create the seeds for the TPC tracks at the inner radius of TPC
354 // Get TreeH with hits
355 TTree *th = tpcloader->TreeH();
356 MakeSeedsFromHits(tpc,th,sArray);
358 // Get TreeTR with track references
359 TTree *ttr = rl->TreeTR();
360 MakeSeedsFromRefs(ttr,sArray);
364 nSeeds = sArray.GetEntries();
365 cerr<<"\n\n+++\n+++ Number of seeds: "<<nSeeds<<"\n+++\n";
368 cerr<<"\n ********** BUILDING TRACKS **************"<<endl<<endl;
370 // loop over entries in sArray
371 for(Int_t l=0; l<nSeeds; l++) {
372 //if(l%1000==0) cerr<<" --- Processing seed "
373 // <<l<<" of "<<nSeeds<<" ---\r";
375 seed = (AliTPCseedGeant*)sArray.At(l);
377 // this is TEMPORARY: only for reconstruction of pp production for charm
378 if(fColl==1) cl = CheckLabel(seed,nParticles,ptkine,pzkine);
382 label = seed->GetLabel();
384 // check if this track has already been processed
385 if(done[label]) continue;
386 // PDG code & electric charge
387 pdg = pdgCodes[label];
388 if(pdg>200 || pdg==-11 || pdg==-13) { charge=1; }
389 else if(pdg<-200 || pdg==11 || pdg==13) { charge=-1; }
391 pdg = TMath::Abs(pdg);
392 if(pdg>3000) pdg=211;
394 if(fSelAndSmear) SetParticle(pdg);
398 sEta = seed->GetEta();
400 // Apply selection according to TPC efficiency
401 //if(TMath::Abs(pdg)==211) nAcc++;
402 if(fSelAndSmear && !SelectedTrack(sPt,sEta)) continue;
403 //if(TMath::Abs(pdg)==211) nSel++;
405 // create AliTPCtrack object
406 BuildTrack(seed,charge);
409 bin = fDBgrid->GetBin(sPt,sEta);
412 fCovTree = covTreePi[bin];
415 fCovTree = covTreeKa[bin];
418 fCovTree = covTreePr[bin];
421 fCovTree = covTreeEl[bin];
424 fCovTree = covTreeMu[bin];
427 // deal with covariance matrix and smearing of parameters
430 // assign the track a dE/dx and make a rough PID
434 // put track in array
435 AliTPCtrack *iotrack = new AliTPCtrack(fTrack);
436 iotrack->SetLabel(label);
437 tArray.AddLast(iotrack);
438 // Mark track as "done" and register the pdg code
442 } // loop over entries in sArray
445 // sort array with TPC tracks (decreasing pT)
448 arrentr = tArray.GetEntriesFast();
449 for(Int_t l=0; l<arrentr; l++) {
450 tpctrack=(AliTPCtrack*)tArray.UncheckedAt(l);
455 // write the tree with tracks in the output file
465 printf("\n\n+++\n+++ Number of TPC tracks: %d\n+++\n",tracks);
466 //cerr<<"Average Eff: "<<(Float_t)nSel/nAcc<<endl;
474 if(fileDB) fileDB->Close();
478 //-----------------------------------------------------------------------------
479 void AliTPCtrackerParam::AnalyzedEdx(const Char_t *outName,Int_t pdg) {
480 //-----------------------------------------------------------------------------
481 // This function computes the dE/dx for pions, kaons, protons and electrons,
482 // in the [pT,eta] bins.
483 // Input file is CovMatrix_AllEvts.root.
484 //-----------------------------------------------------------------------------
486 gStyle->SetOptStat(0);
487 gStyle->SetOptFit(10001);
489 const char *part="PIONS";
493 // create a chain with compared tracks
494 TChain *cmptrkchain = new ("cmptrktree");
495 cmptrkchain.Add("CovMatrix_AllEvts.root");
496 //cmptrkchain.Add("CovMatrix_AllEvts_1.root");
497 //cmptrkchain.Add("CovMatrix_AllEvts_2.root");
498 //cmptrkchain.Add("CovMatrix_AllEvts_3.root");
502 TFile *infile = TFile::Open("CovMatrix_AllEvts.root");
503 TTree *cmptrktree = (TTree*)infile->Get("cmptrktree");
506 cmptrktree->SetBranchAddress("comptracks",&cmptrk);
507 Int_t entries = (Int_t)cmptrktree->GetEntries();
508 cerr<<" Number of entries: "<<entries<<endl;
510 InitializeKineGrid("DB");
511 InitializeKineGrid("dEdx");
538 const Int_t knTotBins = fDBgrid->GetTotBins();
540 cerr<<" Fit bins: "<<knTotBins<<endl;
543 Int_t *n = new Int_t[knTotBins];
544 Double_t *p = new Double_t[knTotBins];
545 Double_t *ep = new Double_t[knTotBins];
546 Double_t *mean = new Double_t[knTotBins];
547 Double_t *sigma = new Double_t[knTotBins];
549 for(Int_t l=0; l<knTotBins; l++) {
550 n[l] = 1; // set to 1 to avoid divisions by 0
551 p[l] = mean[l] = sigma[l] = ep[l] = 0.;
554 // loop on chain entries for the mean
555 for(Int_t l=0; l<entries; l++) {
556 cmptrktree->GetEvent(l);
557 if(TMath::Abs(cmptrk.pdg)!=pdg) continue;
558 bin = fDBgrid->GetBin(cmptrk.pt,cmptrk.eta);
560 mean[bin] += cmptrk.dEdx;
562 } // loop on chain entries
564 for(Int_t l=0; l<knTotBins; l++) {
567 n[l] = 1; // set to 1 to avoid divisions by 0
570 // loop on chain entries for the sigma
571 for(Int_t l=0; l<entries; l++) {
572 cmptrktree->GetEvent(l);
573 if(TMath::Abs(cmptrk.pdg)!=pdg) continue;
574 bin = fDBgrid->GetBin(cmptrk.pt,cmptrk.eta);
575 if(cmptrk.p<1. && TMath::Abs(cmptrk.p-p[bin])>0.025) continue;
577 sigma[bin] += (cmptrk.dEdx-mean[bin])*(cmptrk.dEdx-mean[bin]);
578 } // loop on chain entries
580 for(Int_t l=0; l<knTotBins; l++) {
581 sigma[l] = TMath::Sqrt(sigma[l]/n[l]);
585 TCanvas *canv = new TCanvas("canv","dEdx",0,0,900,700);
587 // create the graph for dEdx vs p
588 TGraphErrors *gr = new TGraphErrors(knTotBins,p,mean,ep,sigma);
589 TString title(" : dE/dx vs momentum"); title.Prepend(part);
590 TH2F *frame = new TH2F("frame1",title.Data(),2,0.1,50,2,0,ymax);
591 frame->SetXTitle("p [GeV/c]");
592 frame->SetYTitle("dE/dx [a.u.]");
599 for(Int_t i=0; i<knTotBins; i++) {
600 fdEdxMeanPi.SetParam(i,mean[i]);
601 fdEdxRMSPi.SetParam(i,sigma[i]);
605 for(Int_t i=0; i<knTotBins; i++) {
606 fdEdxMeanKa.SetParam(i,mean[i]);
607 fdEdxRMSKa.SetParam(i,sigma[i]);
611 for(Int_t i=0; i<knTotBins; i++) {
612 fdEdxMeanPr.SetParam(i,mean[i]);
613 fdEdxRMSPr.SetParam(i,sigma[i]);
617 for(Int_t i=0; i<knTotBins; i++) {
618 fdEdxMeanEl.SetParam(i,mean[i]);
619 fdEdxRMSEl.SetParam(i,sigma[i]);
623 for(Int_t i=0; i<knTotBins; i++) {
624 fdEdxMeanMu.SetParam(i,mean[i]);
625 fdEdxRMSMu.SetParam(i,sigma[i]);
630 // write results to file
631 WritedEdx(outName,pdg);
641 //-----------------------------------------------------------------------------
642 void AliTPCtrackerParam::AnalyzePulls(const Char_t *outName) {
643 //-----------------------------------------------------------------------------
644 // This function computes the pulls for pions, kaons and electrons,
645 // in the [pT,eta] bins.
646 // Input file is CovMatrix_AllEvts.root.
647 // Output file is pulls.root.
648 //-----------------------------------------------------------------------------
651 // create a chain with compared tracks
652 TChain *cmptrkchain = new ("cmptrktree");
653 cmptrkchain.Add("CovMatrix_AllEvts.root");
654 //cmptrkchain.Add("CovMatrix_AllEvts_1.root");
655 //cmptrkchain.Add("CovMatrix_AllEvts_2.root");
656 //cmptrkchain.Add("CovMatrix_AllEvts_3.root");
660 TFile *infile = TFile::Open("CovMatrix_AllEvts.root");
661 TTree *cmptrktree = (TTree*)infile->Get("cmptrktree");
664 cmptrktree->SetBranchAddress("comptracks",&cmptrk);
665 Int_t entries = (Int_t)cmptrktree->GetEntries();
666 cerr<<" Number of entries: "<<entries<<endl;
669 Char_t hname[100], htitle[100];
672 AliTPCkineGrid pulls[5];
673 TH1F *hDum = new TH1F("name","title",100,-7.,7.);
674 TF1 *g = new TF1("g","gaus");
676 InitializeKineGrid("pulls");
677 InitializeKineGrid("DB");
681 // loop on the particles Pi,Ka,Pr,El,Mu
682 for(Int_t part=0; part<5; part++) {
687 cerr<<" Processing pions ...\n";
691 cerr<<" Processing kaons ...\n";
695 cerr<<" Processing protons ...\n";
699 cerr<<" Processing electrons ...\n";
703 cerr<<" Processing muons ...\n";
707 SetParticle(thisPdg);
709 for(Int_t i=0;i<5;i++) {
710 pulls[i].~AliTPCkineGrid();
711 new(&pulls[i]) AliTPCkineGrid(*(fPulls+i));
713 nTotBins = fDBgrid->GetTotBins();
714 cerr<<"nTotBins = "<<nTotBins<<endl;
716 // create histograms for the all the bins
723 hPulls0 = new TH1F[nTotBins];
724 hPulls1 = new TH1F[nTotBins];
725 hPulls2 = new TH1F[nTotBins];
726 hPulls3 = new TH1F[nTotBins];
727 hPulls4 = new TH1F[nTotBins];
730 for(Int_t i=0; i<nTotBins; i++) {
731 sprintf(hname,"hPulls0%d",i);
732 sprintf(htitle,"P0 pulls for bin %d",i);
733 hDum->SetName(hname); hDum->SetTitle(htitle);
735 sprintf(hname,"hPulls1%d",i);
736 sprintf(htitle,"P1 pulls for bin %d",i);
737 hDum->SetName(hname); hDum->SetTitle(htitle);
739 sprintf(hname,"hPulls2%d",i);
740 sprintf(htitle,"P2 pulls for bin %d",i);
741 hDum->SetName(hname); hDum->SetTitle(htitle);
743 sprintf(hname,"hPulls3%d",i);
744 sprintf(htitle,"P3 pulls for bin %d",i);
745 hDum->SetName(hname); hDum->SetTitle(htitle);
747 sprintf(hname,"hPulls4%d",i);
748 sprintf(htitle,"P4 pulls for bin %d",i);
749 hDum->SetName(hname); hDum->SetTitle(htitle);
753 // loop on chain entries
754 for(Int_t i=0; i<entries; i++) {
755 cmptrktree->GetEvent(i);
756 if(TMath::Abs(cmptrk.pdg)!=thisPdg) continue;
757 // fill histograms with the pulls
758 bin = fDBgrid->GetBin(cmptrk.pt,cmptrk.eta);
759 //cerr<<" pt "<<cmptrk.pt<<" eta "<<cmptrk.eta<<" bin "<<bin<<endl;
760 hPulls0[bin].Fill(cmptrk.dP0/TMath::Sqrt(cmptrk.c00));
761 hPulls1[bin].Fill(cmptrk.dP1/TMath::Sqrt(cmptrk.c11));
762 hPulls2[bin].Fill(cmptrk.dP2/TMath::Sqrt(cmptrk.c22));
763 hPulls3[bin].Fill(cmptrk.dP3/TMath::Sqrt(cmptrk.c33));
764 hPulls4[bin].Fill(cmptrk.dP4/TMath::Sqrt(cmptrk.c44));
765 } // loop on chain entries
767 // compute the sigma of the distributions
768 for(Int_t i=0; i<nTotBins; i++) {
769 if(hPulls0[i].GetEntries()>10) {
770 g->SetRange(-3.*hPulls0[i].GetRMS(),3.*hPulls0[i].GetRMS());
771 hPulls0[i].Fit("g","R,Q,N");
772 pulls[0].SetParam(i,g->GetParameter(2));
773 } else pulls[0].SetParam(i,-1.);
774 if(hPulls1[i].GetEntries()>10) {
775 g->SetRange(-3.*hPulls1[i].GetRMS(),3.*hPulls1[i].GetRMS());
776 hPulls1[i].Fit("g","R,Q,N");
777 pulls[1].SetParam(i,g->GetParameter(2));
778 } else pulls[1].SetParam(i,-1.);
779 if(hPulls2[i].GetEntries()>10) {
780 g->SetRange(-3.*hPulls2[i].GetRMS(),3.*hPulls2[i].GetRMS());
781 hPulls2[i].Fit("g","R,Q,N");
782 pulls[2].SetParam(i,g->GetParameter(2));
783 } else pulls[2].SetParam(i,-1.);
784 if(hPulls3[i].GetEntries()>10) {
785 g->SetRange(-3.*hPulls3[i].GetRMS(),3.*hPulls3[i].GetRMS());
786 hPulls3[i].Fit("g","R,Q,N");
787 pulls[3].SetParam(i,g->GetParameter(2));
788 } else pulls[3].SetParam(i,-1.);
789 if(hPulls4[i].GetEntries()>10) {
790 g->SetRange(-3.*hPulls4[i].GetRMS(),3.*hPulls4[i].GetRMS());
791 hPulls4[i].Fit("g","R,Q,N");
792 pulls[4].SetParam(i,g->GetParameter(2));
793 } else pulls[4].SetParam(i,-1.);
799 for(Int_t i=0;i<5;i++) {
800 fPullsPi[i].~AliTPCkineGrid();
801 new(&fPullsPi[i]) AliTPCkineGrid(pulls[i]);
805 for(Int_t i=0;i<5;i++) {
806 fPullsKa[i].~AliTPCkineGrid();
807 new(&fPullsKa[i]) AliTPCkineGrid(pulls[i]);
811 for(Int_t i=0;i<5;i++) {
812 fPullsPr[i].~AliTPCkineGrid();
813 new(&fPullsPr[i]) AliTPCkineGrid(pulls[i]);
817 for(Int_t i=0;i<5;i++) {
818 fPullsEl[i].~AliTPCkineGrid();
819 new(&fPullsEl[i]) AliTPCkineGrid(pulls[i]);
823 for(Int_t i=0;i<5;i++) {
824 fPullsMu[i].~AliTPCkineGrid();
825 new(&fPullsMu[i]) AliTPCkineGrid(pulls[i]);
826 //cerr<<" mu pulls "<<i<<" "<<fPullsMu[i].GetParam(0)<<endl;
837 } // loop on particle species
839 // write pulls to file
845 //-----------------------------------------------------------------------------
846 void AliTPCtrackerParam::AnalyzeResolutions(Int_t pdg) {
847 //-----------------------------------------------------------------------------
848 // This function computes the resolutions:
852 // as a function of Pt
853 // Input file is CovMatrix_AllEvts.root.
854 //-----------------------------------------------------------------------------
857 // create a chain with compared tracks
858 TChain *cmptrkchain = new ("cmptrktree");
859 cmptrkchain.Add("CovMatrix_AllEvts.root");
860 //cmptrkchain.Add("CovMatrix_AllEvts_1.root");
861 //cmptrkchain.Add("CovMatrix_AllEvts_2.root");
862 //cmptrkchain.Add("CovMatrix_AllEvts_3.root");
866 TFile *infile = TFile::Open("CovMatrix_AllEvts.root");
867 TTree *cmptrktree = (TTree*)infile->Get("cmptrktree");
870 cmptrktree->SetBranchAddress("comptracks",&cmptrk);
871 Int_t entries = (Int_t)cmptrktree->GetEntries();
872 cerr<<" Number of entries: "<<entries<<endl;
877 InitializeKineGrid("DB");
878 InitializeKineGrid("eff");
882 const Int_t knPtBins = fEff->GetPointsPt();
883 cerr<<"knPtBins = "<<knPtBins<<endl;
884 Double_t *dP0 = new Double_t[knPtBins];
885 Double_t *dP4 = new Double_t[knPtBins];
886 Double_t *dPtToPt = new Double_t[knPtBins];
887 Double_t *pt = new Double_t[knPtBins];
888 fEff->GetArrayPt(pt);
891 TH1F *hDumP0 = new TH1F("nameP0","dy",100,-0.3,0.3);
892 TH1F *hDumP4 = new TH1F("nameP4","dC",100,-0.0005,0.0005);
893 TH1F *hDumPt = new TH1F("namePt","dp_{T}/p_{T}",100,-0.5,0.5);
895 TF1 *g = new TF1("g","gaus");
897 // create histograms for the all the bins
902 hP0 = new TH1F[knPtBins];
903 hP4 = new TH1F[knPtBins];
904 hPt = new TH1F[knPtBins];
906 for(Int_t i=0; i<knPtBins; i++) {
912 // loop on chain entries
913 for(Int_t i=0; i<entries; i++) {
914 cmptrktree->GetEvent(i);
915 if(TMath::Abs(cmptrk.pdg)!=pdg) continue;
916 // fill histograms with the residuals
917 bin = (Int_t)fDBgrid->GetBin(cmptrk.pt,cmptrk.eta)/fDBgrid->GetBinsEta();
918 //cerr<<" pt "<<cmptrk.pt<<" eta "<<cmptrk.eta<<" bin "<<bin<<endl;
919 hP0[bin].Fill(cmptrk.dP0);
920 hP4[bin].Fill(cmptrk.dP4);
921 hPt[bin].Fill(cmptrk.dpt/cmptrk.pt);
922 } // loop on chain entries
925 TCanvas *cP0res = new TCanvas("cP0res","cP0res",0,0,1200,700);
927 TCanvas *cP4res = new TCanvas("cP4res","cP4res",0,0,1200,700);
929 TCanvas *cPtres = new TCanvas("cPtres","cPtres",0,0,1200,700);
933 for(Int_t i=0; i<knPtBins; i++) {
934 cP0res->cd(i+1); hP0[i].Draw();
935 cP4res->cd(i+1); hP4[i].Draw();
936 cPtres->cd(i+1); hPt[i].Draw();
940 // compute the sigma of the distributions
941 for(Int_t i=0; i<knPtBins; i++) {
942 if(hP0[i].GetEntries()>10) {
943 g->SetRange(-3.*hP0[i].GetRMS(),3.*hP0[i].GetRMS());
944 hP0[i].Fit("g","R,Q,N");
945 dP0[i] = g->GetParameter(2);
947 if(hP4[i].GetEntries()>10) {
948 g->SetRange(-3.*hP4[i].GetRMS(),3.*hP4[i].GetRMS());
949 hP4[i].Fit("g","R,Q,N");
950 dP4[i] = g->GetParameter(2);
952 if(hPt[i].GetEntries()>10) {
953 g->SetRange(-3.*hPt[i].GetRMS(),3.*hPt[i].GetRMS());
954 hPt[i].Fit("g","R,Q,N");
955 dPtToPt[i] = 100.*g->GetParameter(2);
956 } else dPtToPt[i] = 0.;
960 TGraph *grdP0 = new TGraph(knPtBins,pt,dP0);
961 TGraph *grdP4 = new TGraph(knPtBins,pt,dP4);
962 TGraph *grdPtToPt = new TGraph(knPtBins,pt,dPtToPt);
964 grdP0->SetMarkerStyle(20); grdP0->SetMarkerColor(2); grdP0->SetMarkerSize(1.5);
965 grdP4->SetMarkerStyle(21); grdP4->SetMarkerColor(3); grdP4->SetMarkerSize(1.5);
966 grdPtToPt->SetMarkerStyle(22); grdPtToPt->SetMarkerColor(4); grdPtToPt->SetMarkerSize(1.5);
969 gStyle->SetOptStat(0);
970 TCanvas *c1 = new TCanvas("c1","dP0",0,0,900,700);
975 TH2F *frame1 = new TH2F("frame1","y resolution VS p_{T} in TPC",2,0.1,30,2,0,0.1);
976 frame1->SetXTitle("p_{T} [GeV/c]");
977 frame1->SetYTitle("#sigma(y) [cm]");
982 TCanvas *c2 = new TCanvas("c2","dP4",0,0,900,700);
987 TH2F *frame2 = new TH2F("frame2","C resolution VS p_{T} in TPC",2,0.1,30,2,0,0.0001);
988 frame2->SetXTitle("p_{T} [GeV/c]");
989 frame2->SetYTitle("#sigma(C) [1/cm]");
993 TCanvas *c3 = new TCanvas("c3","dPtToPt",0,0,900,700);
999 TH2F *frame3 = new TH2F("frame3","Relative p_{T} resolution VS p_{T} in TPC",2,0.1,30,2,0.1,30.);
1000 frame3->SetXTitle("p_{T} [GeV/c]");
1001 frame3->SetYTitle("dp_{T}/p_{T} (%)");
1003 grdPtToPt->Draw("P");
1018 //-----------------------------------------------------------------------------
1019 void AliTPCtrackerParam::BuildTrack(AliTPCseedGeant *s,Int_t ch) {
1020 //-----------------------------------------------------------------------------
1021 // This function uses GEANT info to set true track parameters
1022 //-----------------------------------------------------------------------------
1023 Double_t xref = s->GetXL();
1024 Double_t xx[5],cc[15];
1025 cc[0]=cc[2]=cc[5]=cc[9]=cc[14]=10.;
1026 cc[1]=cc[3]=cc[4]=cc[6]=cc[7]=cc[8]=cc[10]=cc[11]=cc[12]=cc[13]=0.;
1029 TVector3 bfield(0.,0.,fBz);
1032 // radius [cm] of track projection in (x,y)
1033 Double_t rho = s->GetPt()*100./0.299792458/bfield.Z();
1034 // center of track projection in local reference frame
1038 // position (local) and momentum (local) at the seed
1039 // in the bending plane (z=0)
1040 sPos.SetXYZ(s->GetXL(),s->GetYL(),0.);
1041 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.);
1042 TVector3 vrho = sMom.Cross(bfield);
1046 TVector3 vcenter = sPos+vrho;
1048 Double_t x0 = vcenter.X();
1050 // fX = xref X-coordinate of this track (reference plane)
1051 // fAlpha = Alpha Rotation angle the local (TPC sector)
1052 // fP0 = YL Y-coordinate of a track
1053 // fP1 = ZG Z-coordinate of a track
1054 // fP2 = C*x0 x0 is center x in rotated frame
1055 // fP3 = Tgl tangent of the track momentum dip angle
1056 // fP4 = C track curvature
1059 xx[3] = s->GetPz()/s->GetPt();
1063 // create the object AliTPCtrack
1064 AliTPCtrack track(0,xx,cc,xref,s->GetAlpha());
1065 new(&fTrack) AliTPCtrack(track);
1069 //-----------------------------------------------------------------------------
1070 Int_t AliTPCtrackerParam::CheckLabel(AliTPCseedGeant *s,Int_t nPart,
1071 Double_t *ptkine,Double_t *pzkine) const {
1072 //-----------------------------------------------------------------------------
1073 // This function checks if the label of the seed has been correctly
1074 // assigned (to do only for pp charm production with AliRoot v3-08-02)
1075 //-----------------------------------------------------------------------------
1077 Int_t sLabel = s->GetLabel();
1078 Double_t sPt = s->GetPt();
1079 Double_t sPz = s->GetPz();
1081 // check if the label is correct (comparing momentum)
1083 TMath::Abs(sPt-ptkine[sLabel])*
1084 TMath::Abs(sPz-pzkine[sLabel])<0.001) return 0;
1086 if((sLabel-30)>=nPart) return 1;
1088 Double_t diff=0,mindiff=1000.;
1091 for(Int_t i=sLabel-30; i<sLabel; i++) {
1092 if(i<0 || i>=nPart) continue;
1093 diff = TMath::Abs(sPt-ptkine[i])*TMath::Abs(sPz-pzkine[i]);
1094 if(diff<mindiff) { mindiff = diff; bestLabel = i; }
1097 if(mindiff>0.001) return 1;
1098 s->SetLabel(bestLabel);
1102 //-----------------------------------------------------------------------------
1103 void AliTPCtrackerParam::CompareTPCtracks(
1104 const Char_t* galiceName,
1105 const Char_t* trkGeaName,
1106 const Char_t* trkKalName,
1107 const Char_t* covmatName,
1108 const Char_t* tpceffasciiName,
1109 const Char_t* tpceffrootName) {
1110 //-----------------------------------------------------------------------------
1111 // This function compares tracks from TPC Kalman Filter V2 with
1112 // geant tracks at TPC 1st hit. It gives:
1113 // - a tree with Kalman cov. matrix elements, resolutions, dEdx
1114 // - the efficiencies as a function of particle type, pT, eta
1115 //-----------------------------------------------------------------------------
1117 TFile *kalFile = TFile::Open(trkKalName);
1118 TFile *geaFile = TFile::Open(trkGeaName);
1119 TFile *galiceFile = TFile::Open(galiceName);
1121 // get the AliRun object
1122 AliRun *gAlice = (AliRun*)galiceFile->Get("gAlice");
1125 // create the tree for comparison results
1127 TTree *cmptrktree = new TTree("cmptrktree","results of track comparison");
1128 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");
1130 InitializeKineGrid("eff");
1131 InitializeKineGrid("DB");
1132 Int_t effBins = fEffPi.GetTotPoints();
1133 Int_t effBinsPt = fEffPi.GetPointsPt();
1134 Double_t *pt = new Double_t[effBinsPt];
1135 fEffPi.GetArrayPt(pt);
1141 Double_t cc[15],dAlpha;
1142 Int_t pi=0,ka=0,mu=0,el=0,pr=0;
1143 Int_t *geaPi = new Int_t[effBins];
1144 Int_t *geaKa = new Int_t[effBins];
1145 Int_t *geaPr = new Int_t[effBins];
1146 Int_t *geaEl = new Int_t[effBins];
1147 Int_t *geaMu = new Int_t[effBins];
1148 Int_t *kalPi = new Int_t[effBins];
1149 Int_t *kalKa = new Int_t[effBins];
1150 Int_t *kalPr = new Int_t[effBins];
1151 Int_t *kalEl = new Int_t[effBins];
1152 Int_t *kalMu = new Int_t[effBins];
1153 Float_t *effPi = new Float_t[effBins];
1154 Float_t *effKa = new Float_t[effBins];
1155 Float_t *effPr = new Float_t[effBins];
1156 Float_t *effEl = new Float_t[effBins];
1157 Float_t *effMu = new Float_t[effBins];
1159 for(Int_t j=0; j<effBins; j++) {
1160 geaPi[j]=geaKa[j]=geaPr[j]=geaEl[j]=geaMu[j]=0;
1161 kalPi[j]=kalKa[j]=kalPr[j]=kalEl[j]=kalMu[j]=0;
1162 effPi[j]=effKa[j]=effPr[j]=effEl[j]=effMu[j]=-1.;
1167 // loop on events in file
1168 for(Int_t evt=0; evt<fNevents; evt++) {
1169 cerr<<"\n --- Reading tracks for event "<<evt<<" ---\n\n";
1170 sprintf(tname,"TreeT_TPC_%d",evt);
1172 // particles from TreeK
1173 const Int_t knparticles = gAlice->GetEvent(evt);
1175 Int_t *kalLab = new Int_t[knparticles];
1176 for(Int_t i=0; i<knparticles; i++) kalLab[i] = -1;
1179 // tracks from Kalman
1180 TTree *kaltree=(TTree*)kalFile->Get(tname);
1181 if(!kaltree) continue;
1182 AliTPCtrack *kaltrack=new AliTPCtrack;
1183 kaltree->SetBranchAddress("tracks",&kaltrack);
1184 Int_t kalEntries = (Int_t)kaltree->GetEntries();
1186 // tracks from 1st hit
1187 TTree *geatree=(TTree*)geaFile->Get(tname);
1188 if(!geatree) continue;
1189 AliTPCtrack *geatrack=new AliTPCtrack;
1190 geatree->SetBranchAddress("tracks",&geatrack);
1191 Int_t geaEntries = (Int_t)geatree->GetEntries();
1193 cerr<<"+++\n+++ Number of tracks: TPC Kalman = "<<kalEntries<<endl<<"+++ TPC 1st hit = "<<geaEntries<<endl<<"+++\n";
1195 // set pointers for TPC tracks:
1196 // the entry number of the track labelled l is stored in kalLab[l]
1197 Int_t fake=0,mult=0;
1198 for (Int_t j=0; j<kalEntries; j++) {
1199 kaltree->GetEvent(j);
1200 if(kaltrack->GetLabel()>=0) {
1201 if(kalLab[kaltrack->GetLabel()]!=-1) mult++;
1202 kalLab[kaltrack->GetLabel()] = j;
1207 cerr<<"+++ Number of fake tracks in TPC Kalman: "<<fake<<endl;
1208 cerr<<"+++ Number of multiply found tracks in TPC Kalman: "<<mult<<endl;
1211 // Read the labels of the seeds
1214 Bool_t *hasSeed = new Bool_t[knparticles];
1215 for(Int_t i=0; i<knparticles; i++) hasSeed[i] = kFALSE;
1216 sprintf(sname,"seedLabels.%d.dat",evt);
1217 FILE *seedFile = fopen(sname,"r");
1219 ncol = fscanf(seedFile,"%d",&sLabel);
1221 if(sLabel>0) hasSeed[sLabel]=kTRUE;
1226 cerr<<"Doing track comparison...\n";
1227 // loop on tracks at 1st hit
1228 for(Int_t j=0; j<geaEntries; j++) {
1229 geatree->GetEvent(j);
1231 label = geatrack->GetLabel();
1232 part = (TParticle*)gAlice->GetMCApp()->Particle(label);
1234 // use only injected tracks with fixed values of pT
1235 ptgener = part->Pt();
1237 for(Int_t l=0; l<fEffPi.GetPointsPt(); l++) {
1238 if(TMath::Abs(ptgener-pt[l])<0.01) usethis = kTRUE;
1240 if(!usethis) continue;
1242 // check if it has the seed
1243 //if(!hasSeed[label]) continue;
1246 // check if track is entirely contained in a TPC sector
1247 Bool_t out = kFALSE;
1248 for(Int_t l=0; l<10; l++) {
1249 Double_t x = 85. + (250.-85.)*(Double_t)l/9.;
1250 //cerr<<"x "<<x<<" X "<<geatrack->GetX()<<endl;
1251 Double_t y = geatrack->GetY() + (
1252 TMath::Sqrt(1-(geatrack->GetC()*geatrack->GetX()-geatrack->GetEta())*
1253 (geatrack->GetC()*geatrack->GetX()-geatrack->GetEta()))
1254 -TMath::Sqrt(1-(geatrack->GetC()*x-geatrack->GetEta())*
1255 (geatrack->GetC()*x-geatrack->GetEta()))
1258 //cerr<<"y "<<y<<" Y "<<geatrack->GetY()<<endl;
1259 if(y > 0.8*x*TMath::Tan(TMath::Pi()/18)) { out = kTRUE; break; }
1264 cmptrk.pdg = part->GetPdgCode();
1265 cmptrk.eta = part->Eta();
1266 cmptrk.r = TMath::Sqrt(part->Vx()*part->Vx()+part->Vy()*part->Vy());
1268 cmptrk.pt = 1/TMath::Abs(geatrack->Get1Pt());
1269 cmptrk.cosl = TMath::Cos(TMath::ATan(geatrack->GetTgl()));
1270 cmptrk.p = cmptrk.pt/cmptrk.cosl;
1273 bin = fDBgridPi.GetBin(cmptrk.pt,cmptrk.eta);
1275 if(abs(cmptrk.pdg)==211) geaPi[bin]++;
1276 if(abs(cmptrk.pdg)==321) geaKa[bin]++;
1277 if(abs(cmptrk.pdg)==2212) geaPr[bin]++;
1278 if(abs(cmptrk.pdg)==11) geaEl[bin]++;
1279 if(abs(cmptrk.pdg)==13) geaMu[bin]++;
1282 // check if there is the corresponding track in the TPC kalman and get it
1283 if(kalLab[label]==-1) continue;
1284 kaltree->GetEvent(kalLab[label]);
1286 // and go on only if it has xref = 84.57 cm (inner pad row)
1287 if(kaltrack->GetX()>90.) continue;
1289 if(abs(cmptrk.pdg)==211) { kalPi[bin]++; pi++; }
1290 if(abs(cmptrk.pdg)==321) { kalKa[bin]++; ka++; }
1291 if(abs(cmptrk.pdg)==2212) { kalPr[bin]++; pr++; }
1292 if(abs(cmptrk.pdg)==11) { kalEl[bin]++; el++; }
1293 if(abs(cmptrk.pdg)==13) { kalMu[bin]++; mu++; }
1295 kaltrack->PropagateTo(geatrack->GetX(),1.e-9,0.);
1297 cmptrk.dEdx = kaltrack->GetdEdx();
1299 // compute errors on parameters
1300 dAlpha = kaltrack->GetAlpha()-geatrack->GetAlpha();
1301 if(TMath::Abs(dAlpha)>0.1) { cerr<<" ! WRONG SECTOR !\n"; continue; }
1303 cmptrk.dP0 = kaltrack->GetY()-geatrack->GetY();
1304 cmptrk.dP1 = kaltrack->GetZ()-geatrack->GetZ();
1305 cmptrk.dP2 = kaltrack->GetEta()-geatrack->GetEta();
1306 cmptrk.dP3 = kaltrack->GetTgl()-geatrack->GetTgl();
1307 cmptrk.dP4 = kaltrack->GetC()-geatrack->GetC();
1308 cmptrk.dpt = 1/kaltrack->Get1Pt()-1/geatrack->Get1Pt();
1310 // get covariance matrix
1311 // beware: lines 3 and 4 in the matrix are inverted!
1312 kaltrack->GetCovariance(cc);
1320 cmptrk.c30 = cc[10];
1321 cmptrk.c31 = cc[11];
1322 cmptrk.c32 = cc[12];
1323 cmptrk.c33 = cc[14];
1327 cmptrk.c43 = cc[13];
1333 } // loop on tracks at TPC 1st hit
1336 //delete [] hasSeed;
1338 } // end loop on events in file
1341 cerr<<"+++\n+++ Number of compared tracks: "<<pi+ka+el+mu+pr<<endl;
1342 cerr<<"+++ Pions: "<<pi<<", Kaons: "<<ka<<", Protons : "<<pr<<", Electrons: "<<el<<", Muons: "<<mu<<endl;
1345 // Write tree to file
1346 TFile *outfile = new TFile(covmatName,"recreate");
1347 cmptrktree->Write();
1351 // Write efficiencies to ascii file
1352 FILE *effFile = fopen(tpceffasciiName,"w");
1353 //fprintf(effFile,"%d\n",kalEntries);
1354 for(Int_t j=0; j<effBins; j++) {
1355 if(geaPi[j]>=100) effPi[j]=(Float_t)kalPi[j]/geaPi[j];
1356 if(geaKa[j]>=100) effKa[j]=(Float_t)kalKa[j]/geaKa[j];
1357 if(geaPr[j]>=100) effPr[j]=(Float_t)kalPr[j]/geaPr[j];
1358 if(geaEl[j]>=500) effEl[j]=(Float_t)kalEl[j]/geaEl[j];
1359 if(geaMu[j]>=100) effMu[j]=(Float_t)kalMu[j]/geaMu[j];
1360 fprintf(effFile,"%f %f %f %f %f\n",effPi[j],effKa[j],effPr[j],effEl[j],effMu[j]);
1363 for(Int_t j=0; j<effBins; j++) {
1364 fprintf(effFile,"%d %d %d %d %d\n",geaPi[j],geaKa[j],geaPr[j],geaEl[j],geaMu[j]);
1366 for(Int_t j=0; j<effBins; j++) {
1367 fprintf(effFile,"%d %d %d %d %d\n",kalPi[j],kalKa[j],kalPr[j],kalEl[j],kalMu[j]);
1371 // Write efficiencies to root file
1372 for(Int_t j=0; j<effBins; j++) {
1373 fEffPi.SetParam(j,(Double_t)effPi[j]);
1374 fEffKa.SetParam(j,(Double_t)effKa[j]);
1375 fEffPr.SetParam(j,(Double_t)effPr[j]);
1376 fEffEl.SetParam(j,(Double_t)effEl[j]);
1377 fEffMu.SetParam(j,(Double_t)effMu[j]);
1379 WriteEffs(tpceffrootName);
1381 // delete AliRun object
1382 delete gAlice; gAlice=0;
1384 // close all input files
1387 galiceFile->Close();
1408 //-----------------------------------------------------------------------------
1409 void AliTPCtrackerParam::CookdEdx(Double_t pt,Double_t eta) {
1410 //-----------------------------------------------------------------------------
1411 // This function assigns the track a dE/dx and makes a rough PID
1412 //-----------------------------------------------------------------------------
1414 Double_t mean = fdEdxMean->GetValueAt(pt,eta);
1415 Double_t rms = fdEdxRMS->GetValueAt(pt,eta);
1417 Double_t dEdx = gRandom->Gaus(mean,rms);
1419 fTrack.SetdEdx(dEdx);
1421 AliTPCtrackParam t(fTrack);
1424 Double_t p = TMath::Sqrt(1.+t.GetTgl()*t.GetTgl())*pt;
1427 if (dEdx < 39.+ 12./(p+0.25)/(p+0.25)) {
1428 t.AssignMass(0.13957); new(&fTrack) AliTPCtrack(t); return;
1430 if (dEdx < 39.+ 12./p/p) {
1431 t.AssignMass(0.49368); new(&fTrack) AliTPCtrack(t); return;
1433 t.AssignMass(0.93827); new(&fTrack) AliTPCtrack(t); return;
1437 if (dEdx < 39.+ 12./(p+0.25)/(p+0.25)) {
1438 t.AssignMass(0.13957); new(&fTrack) AliTPCtrack(t); return;
1440 t.AssignMass(0.93827); new(&fTrack) AliTPCtrack(t); return;
1443 t.AssignMass(0.13957); new(&fTrack) AliTPCtrack(t); return;
1445 //-----------------------------------------------------------------------------
1446 void AliTPCtrackerParam::CookTrack(Double_t pt,Double_t eta) {
1447 //-----------------------------------------------------------------------------
1448 // This function deals with covariance matrix and smearing
1449 //-----------------------------------------------------------------------------
1453 Double_t trkKine[1],trkRegPar[3];
1454 Double_t xref,alpha,xx[5],xxsm[5],cc[15];
1457 fCovTree->SetBranchAddress("matrix",&covmat);
1459 // get random entry from the tree
1460 treeEntries = (Int_t)fCovTree->GetEntries();
1461 fCovTree->GetEvent(gRandom->Integer(treeEntries));
1463 // get P and Cosl from track
1464 cosl = TMath::Cos(TMath::ATan(fTrack.GetTgl()));
1465 p = 1./TMath::Abs(fTrack.Get1Pt())/cosl;
1469 // get covariance matrix from regularized matrix
1470 for(Int_t l=0;l<3;l++) trkRegPar[l] = (*fRegPar)(0,l);
1471 cc[0] = covmat.c00*RegFunc(trkKine,trkRegPar);
1473 for(Int_t l=0;l<3;l++) trkRegPar[l] = (*fRegPar)(1,l);
1474 cc[2] = covmat.c11*RegFunc(trkKine,trkRegPar);
1475 for(Int_t l=0;l<3;l++) trkRegPar[l] = (*fRegPar)(2,l);
1476 cc[3] = covmat.c20*RegFunc(trkKine,trkRegPar);
1478 for(Int_t l=0;l<3;l++) trkRegPar[l] = (*fRegPar)(3,l);
1479 cc[5] = covmat.c22*RegFunc(trkKine,trkRegPar);
1481 for(Int_t l=0;l<3;l++) trkRegPar[l] = (*fRegPar)(4,l);
1482 cc[7] = covmat.c31*RegFunc(trkKine,trkRegPar);
1484 for(Int_t l=0;l<3;l++) trkRegPar[l] = (*fRegPar)(5,l);
1485 cc[9] = covmat.c33*RegFunc(trkKine,trkRegPar);
1486 for(Int_t l=0;l<3;l++) trkRegPar[l] = (*fRegPar)(6,l);
1487 cc[10]= covmat.c40*RegFunc(trkKine,trkRegPar);
1489 for(Int_t l=0;l<3;l++) trkRegPar[l] = (*fRegPar)(7,l);
1490 cc[12]= covmat.c42*RegFunc(trkKine,trkRegPar);
1492 for(Int_t l=0;l<3;l++) trkRegPar[l] = (*fRegPar)(8,l);
1493 cc[14]= covmat.c44*RegFunc(trkKine,trkRegPar);
1495 TMatrixD covMatSmear(5,5);
1497 covMatSmear = GetSmearingMatrix(cc,pt,eta);
1499 // get track original parameters
1500 xref =fTrack.GetX();
1501 alpha=fTrack.GetAlpha();
1502 xx[0]=fTrack.GetY();
1503 xx[1]=fTrack.GetZ();
1504 xx[2]=fTrack.GetX()*fTrack.GetC()-fTrack.GetSnp();
1505 xx[3]=fTrack.GetTgl();
1506 xx[4]=fTrack.GetC();
1508 // use smearing matrix to smear the original parameters
1509 SmearTrack(xx,xxsm,covMatSmear);
1511 AliTPCtrack track(0,xxsm,cc,xref,alpha);
1512 new(&fTrack) AliTPCtrack(track);
1516 //-----------------------------------------------------------------------------
1517 void AliTPCtrackerParam::DrawEffs(const Char_t* inName,Int_t pdg) {
1518 //-----------------------------------------------------------------------------
1519 // This function draws the TPC efficiencies in the [pT,eta] bins
1520 //-----------------------------------------------------------------------------
1525 const Int_t kn = fEff->GetPointsPt();
1526 Double_t *effsA = new Double_t[kn];
1527 Double_t *effsB = new Double_t[kn];
1528 Double_t *effsC = new Double_t[kn];
1529 Double_t *pt = new Double_t[kn];
1531 fEff->GetArrayPt(pt);
1532 for(Int_t i=0;i<kn;i++) {
1533 effsA[i] = fEff->GetParam(i,0);
1534 effsB[i] = fEff->GetParam(i,1);
1535 effsC[i] = fEff->GetParam(i,2);
1538 TGraph *grA = new TGraph(kn,pt,effsA);
1539 TGraph *grB = new TGraph(kn,pt,effsB);
1540 TGraph *grC = new TGraph(kn,pt,effsC);
1542 grA->SetMarkerStyle(20); grA->SetMarkerColor(2); grA->SetMarkerSize(1.5);
1543 grB->SetMarkerStyle(21); grB->SetMarkerColor(3); grB->SetMarkerSize(1.5);
1544 grC->SetMarkerStyle(22); grC->SetMarkerColor(4); grC->SetMarkerSize(1.5);
1546 TString title("Distribution of the TPC efficiencies");
1549 title.Prepend("PIONS - ");
1552 title.Prepend("KAONS - ");
1555 title.Prepend("PROTONS - ");
1558 title.Prepend("ELECTRONS - ");
1561 title.Prepend("MUONS - ");
1566 gStyle->SetOptStat(0);
1567 TCanvas *c = new TCanvas("c","effs",0,0,900,700);
1572 TH2F *frame = new TH2F("frame",title.Data(),2,0.1,30,2,0,1);
1573 frame->SetXTitle("p_{T} [GeV/c]");
1579 TLegend *leg = new TLegend(0.2,0.2,0.4,0.4);
1580 leg->AddEntry(grA,"|#eta|<0.3","p");
1581 leg->AddEntry(grB,"0.3<|#eta|<0.6","p");
1582 leg->AddEntry(grC,"0.6<|#eta|<0.9","p");
1583 leg->SetFillColor(0);
1593 //-----------------------------------------------------------------------------
1594 void AliTPCtrackerParam::DrawPulls(const Char_t* inName,Int_t pdg,
1596 //-----------------------------------------------------------------------------
1597 // This function draws the pulls in the [pT,eta] bins
1598 //-----------------------------------------------------------------------------
1603 const Int_t kn = (fPulls+par)->GetPointsPt();
1604 Double_t *pullsA = new Double_t[kn];
1605 Double_t *pullsB = new Double_t[kn];
1606 Double_t *pullsC = new Double_t[kn];
1607 Double_t *pt = new Double_t[kn];
1608 (fPulls+par)->GetArrayPt(pt);
1609 for(Int_t i=0;i<kn;i++) {
1610 pullsA[i] = (fPulls+par)->GetParam(i,0);
1611 pullsB[i] = (fPulls+par)->GetParam(i,1);
1612 pullsC[i] = (fPulls+par)->GetParam(i,2);
1615 TGraph *grA = new TGraph(kn,pt,pullsA);
1616 TGraph *grB = new TGraph(kn,pt,pullsB);
1617 TGraph *grC = new TGraph(kn,pt,pullsC);
1619 grA->SetMarkerStyle(20); grA->SetMarkerColor(2); grA->SetMarkerSize(1.5);
1620 grB->SetMarkerStyle(21); grB->SetMarkerColor(3); grB->SetMarkerSize(1.5);
1621 grC->SetMarkerStyle(22); grC->SetMarkerColor(4); grC->SetMarkerSize(1.5);
1623 TString title("Distribution of the pulls: ");
1626 title.Prepend("PIONS - ");
1629 title.Prepend("KAONS - ");
1632 title.Prepend("PROTONS - ");
1635 title.Prepend("ELECTRONS - ");
1638 title.Prepend("MUONS - ");
1649 title.Append(" #eta");
1652 title.Append("tg #lambda");
1659 gStyle->SetOptStat(0);
1660 TCanvas *c = new TCanvas("c","pulls",0,0,900,700);
1665 TH2F *frame = new TH2F("frame",title.Data(),2,0.1,30,2,0,2);
1666 frame->SetXTitle("p_{T} [GeV/c]");
1672 TLegend *leg = new TLegend(0.2,0.2,0.4,0.4);
1673 leg->AddEntry(grA,"|#eta|<0.3","p");
1674 leg->AddEntry(grB,"0.3<|#eta|<0.6","p");
1675 leg->AddEntry(grC,"0.6<|#eta|<0.9","p");
1676 leg->SetFillColor(0);
1686 //-----------------------------------------------------------------------------
1687 TMatrixD AliTPCtrackerParam::GetSmearingMatrix(Double_t* cc,Double_t pt,
1688 Double_t eta) const {
1689 //-----------------------------------------------------------------------------
1690 // This function stretches the covariance matrix according to the pulls
1691 //-----------------------------------------------------------------------------
1693 TMatrixD covMat(5,5);
1696 covMat(1,0)=cc[1]; covMat(0,1)=covMat(1,0);
1698 covMat(2,0)=cc[3]; covMat(0,2)=covMat(2,0);
1699 covMat(2,1)=cc[4]; covMat(1,2)=covMat(2,1);
1701 covMat(3,0)=cc[6]; covMat(0,3)=covMat(3,0);
1702 covMat(3,1)=cc[7]; covMat(1,3)=covMat(3,1);
1703 covMat(3,2)=cc[8]; covMat(2,3)=covMat(3,2);
1705 covMat(4,0)=cc[10]; covMat(0,4)=covMat(4,0);
1706 covMat(4,1)=cc[11]; covMat(1,4)=covMat(4,1);
1707 covMat(4,2)=cc[12]; covMat(2,4)=covMat(4,2);
1708 covMat(4,3)=cc[13]; covMat(3,4)=covMat(4,3);
1712 TMatrixD stretchMat(5,5);
1713 for(Int_t k=0;k<5;k++) {
1714 for(Int_t l=0;l<5;l++) {
1719 for(Int_t i=0;i<5;i++) {
1720 stretchMat(i,i) = (fPulls+i)->GetValueAt(pt,eta);
1721 if(stretchMat(i,i)==0.) stretchMat(i,i) = 1.;
1724 TMatrixD mat(stretchMat,TMatrixD::kMult,covMat);
1725 TMatrixD covMatSmear(mat,TMatrixD::kMult,stretchMat);
1729 //-----------------------------------------------------------------------------
1730 void AliTPCtrackerParam::InitializeKineGrid(Option_t* which) {
1731 //-----------------------------------------------------------------------------
1732 // This function initializes ([pt,eta] points) the data members AliTPCkineGrid
1733 // which = "DB" -> initialize fDBgrid... members
1734 // "eff" -> initialize fEff... members
1735 // "pulls" -> initialize fPulls... members
1736 // "dEdx" -> initialize fdEdx... members
1737 //-----------------------------------------------------------------------------
1739 const char *db = strstr(which,"DB");
1740 const char *eff = strstr(which,"eff");
1741 const char *pulls = strstr(which,"pulls");
1742 const char *dEdx = strstr(which,"dEdx");
1745 Int_t nEta=0, nPt=0;
1747 Double_t etaPoints[2] = {0.3,0.6};
1748 Double_t etaBins[3] = {0.15,0.45,0.75};
1750 Double_t ptPoints[9] = {0.4,0.6,0.8,1.2,1.7,3.,5.,8.,15.};
1751 Double_t ptBins[10] = {0.3,0.5,0.7,1.,1.5,2.,4.,6.,10.,20.};
1754 Double_t *eta=0,*pt=0;
1768 AliTPCkineGrid *dummy=0;
1771 dummy = new AliTPCkineGrid(nPt,nEta,pt,eta);
1772 new(&fDBgridPi) AliTPCkineGrid(*dummy);
1773 new(&fDBgridKa) AliTPCkineGrid(*dummy);
1774 new(&fDBgridPr) AliTPCkineGrid(*dummy);
1775 new(&fDBgridEl) AliTPCkineGrid(*dummy);
1776 new(&fDBgridMu) AliTPCkineGrid(*dummy);
1780 dummy = new AliTPCkineGrid(nPt,nEta,pt,eta);
1781 new(&fEffPi) AliTPCkineGrid(*dummy);
1782 new(&fEffKa) AliTPCkineGrid(*dummy);
1783 new(&fEffPr) AliTPCkineGrid(*dummy);
1784 new(&fEffEl) AliTPCkineGrid(*dummy);
1785 new(&fEffMu) AliTPCkineGrid(*dummy);
1789 dummy = new AliTPCkineGrid(nPt,nEta,pt,eta);
1790 for(Int_t i=0;i<5;i++) new(&fPullsPi[i]) AliTPCkineGrid(*dummy);
1791 for(Int_t i=0;i<5;i++) new(&fPullsKa[i]) AliTPCkineGrid(*dummy);
1792 for(Int_t i=0;i<5;i++) new(&fPullsPr[i]) AliTPCkineGrid(*dummy);
1793 for(Int_t i=0;i<5;i++) new(&fPullsEl[i]) AliTPCkineGrid(*dummy);
1794 for(Int_t i=0;i<5;i++) new(&fPullsMu[i]) AliTPCkineGrid(*dummy);
1798 dummy = new AliTPCkineGrid(nPt,nEta,pt,eta);
1799 new(&fdEdxMeanPi) AliTPCkineGrid(*dummy);
1800 new(&fdEdxRMSPi) AliTPCkineGrid(*dummy);
1801 new(&fdEdxMeanKa) AliTPCkineGrid(*dummy);
1802 new(&fdEdxRMSKa) AliTPCkineGrid(*dummy);
1803 new(&fdEdxMeanPr) AliTPCkineGrid(*dummy);
1804 new(&fdEdxRMSPr) AliTPCkineGrid(*dummy);
1805 new(&fdEdxMeanEl) AliTPCkineGrid(*dummy);
1806 new(&fdEdxRMSEl) AliTPCkineGrid(*dummy);
1807 new(&fdEdxMeanMu) AliTPCkineGrid(*dummy);
1808 new(&fdEdxRMSMu) AliTPCkineGrid(*dummy);
1814 //-----------------------------------------------------------------------------
1815 void AliTPCtrackerParam::MakeDataBase() {
1816 //-----------------------------------------------------------------------------
1817 // This function creates the DB file and store in it:
1818 // - TPC Efficiencies for pi,ka,pr,el,mu (AliTPCkineGrid class)
1819 // - Pulls for pi,ka,el (AliTPCkineGrid class)
1820 // - Regularization parameters for pi,ka,el (TMatrixD class)
1821 // - dE/dx parameterization for pi,ka,pr,el (AliTPCkineGrid class)
1822 // - Regularized cov. matrices for pi,ka,el (COVMATRIX structure)
1823 //-----------------------------------------------------------------------------
1825 // define some file names
1826 const char *effFile ="TPCeff.root";
1827 const char *pullsFile ="pulls.root";
1828 const char *regPiFile ="regPi.root";
1829 const char *regKaFile ="regKa.root";
1830 const char *regPrFile ="regPr.root";
1831 const char *regElFile ="regEl.root";
1832 const char *regMuFile ="regMu.root";
1833 const char *dEdxPiFile="dEdxPi.root";
1834 const char *dEdxKaFile="dEdxKa.root";
1835 const char *dEdxPrFile="dEdxPr.root";
1836 const char *dEdxElFile="dEdxEl.root";
1837 const char *dEdxMuFile="dEdxMu.root";
1838 const char *cmFile ="CovMatrix_AllEvts.root";
1840 Char_t *cmFile1 ="CovMatrix_AllEvts_1.root";
1841 Char_t *cmFile2 ="CovMatrix_AllEvts_2.root";
1842 Char_t *cmFile3 ="CovMatrix_AllEvts_3.root";
1845 // store the effieciencies
1847 WriteEffs(fDBfileName.Data());
1850 ReadPulls(pullsFile);
1851 WritePulls(fDBfileName.Data());
1853 //store the regularization parameters
1854 ReadRegParams(regPiFile,211);
1855 WriteRegParams(fDBfileName.Data(),211);
1856 ReadRegParams(regKaFile,321);
1857 WriteRegParams(fDBfileName.Data(),321);
1858 ReadRegParams(regPrFile,2212);
1859 WriteRegParams(fDBfileName.Data(),2212);
1860 ReadRegParams(regElFile,11);
1861 WriteRegParams(fDBfileName.Data(),11);
1862 ReadRegParams(regMuFile,13);
1863 WriteRegParams(fDBfileName.Data(),13);
1865 // store the dEdx parameters
1866 ReaddEdx(dEdxPiFile,211);
1867 WritedEdx(fDBfileName.Data(),211);
1868 ReaddEdx(dEdxKaFile,321);
1869 WritedEdx(fDBfileName.Data(),321);
1870 ReaddEdx(dEdxPrFile,2212);
1871 WritedEdx(fDBfileName.Data(),2212);
1872 ReaddEdx(dEdxElFile,11);
1873 WritedEdx(fDBfileName.Data(),11);
1874 ReaddEdx(dEdxMuFile,13);
1875 WritedEdx(fDBfileName.Data(),13);
1879 // store the regularized covariance matrices
1881 InitializeKineGrid("DB");
1883 const Int_t knBinsPi = fDBgridPi.GetTotBins();
1884 const Int_t knBinsKa = fDBgridKa.GetTotBins();
1885 const Int_t knBinsPr = fDBgridPr.GetTotBins();
1886 const Int_t knBinsEl = fDBgridEl.GetTotBins();
1887 const Int_t knBinsMu = fDBgridMu.GetTotBins();
1890 // create the trees for cov. matrices
1892 TTree *covTreePi_ = NULL;
1893 covTreePi_ = new TTree[knBinsPi];
1895 TTree *covTreeKa_ = NULL;
1896 covTreeKa_ = new TTree[knBinsKa];
1897 // trees for protons
1898 TTree *covTreePr_ = NULL;
1899 covTreePr_ = new TTree[knBinsPr];
1900 // trees for electrons
1901 TTree *covTreeEl_ = NULL;
1902 covTreeEl_ = new TTree[knBinsEl];
1904 TTree *covTreeMu_ = NULL;
1905 covTreeMu_ = new TTree[knBinsMu];
1907 Char_t hname[100], htitle[100];
1911 for(Int_t i=0; i<knBinsPi; i++) {
1912 sprintf(hname,"CovTreePi_bin%d",i);
1913 sprintf(htitle,"Tree with cov matrix elements for bin %d",i);
1914 covTreePi_[i].SetName(hname); covTreePi_[i].SetTitle(htitle);
1915 covTreePi_[i].Branch("matrix",&covmat,"c00/D:c10:c11:c20:c21:c22:c30:c31:c32:c33:c40:c41:c42:c43:c44",5000000);
1917 for(Int_t i=0; i<knBinsKa; i++) {
1918 sprintf(hname,"CovTreeKa_bin%d",i);
1919 sprintf(htitle,"Tree with cov matrix elements for bin %d",i);
1920 covTreeKa_[i].SetName(hname); covTreeKa_[i].SetTitle(htitle);
1921 covTreeKa_[i].Branch("matrix",&covmat,"c00/D:c10:c11:c20:c21:c22:c30:c31:c32:c33:c40:c41:c42:c43:c44",1000000);
1923 for(Int_t i=0; i<knBinsPr; i++) {
1924 sprintf(hname,"CovTreePr_bin%d",i);
1925 sprintf(htitle,"Tree with cov matrix elements for bin %d",i);
1926 covTreePr_[i].SetName(hname); covTreePr_[i].SetTitle(htitle);
1927 covTreePr_[i].Branch("matrix",&covmat,"c00/D:c10:c11:c20:c21:c22:c30:c31:c32:c33:c40:c41:c42:c43:c44",1000000);
1929 for(Int_t i=0; i<knBinsEl; i++) {
1930 sprintf(hname,"CovTreeEl_bin%d",i);
1931 sprintf(htitle,"Tree with cov matrix elements for bin %d",i);
1932 covTreeEl_[i].SetName(hname); covTreeEl_[i].SetTitle(htitle);
1933 covTreeEl_[i].Branch("matrix",&covmat,"c00/D:c10:c11:c20:c21:c22:c30:c31:c32:c33:c40:c41:c42:c43:c44",1000000);
1935 for(Int_t i=0; i<knBinsMu; i++) {
1936 sprintf(hname,"CovTreeMu_bin%d",i);
1937 sprintf(htitle,"Tree with cov matrix elements for bin %d",i);
1938 covTreeMu_[i].SetName(hname); covTreeMu_[i].SetTitle(htitle);
1939 covTreeMu_[i].Branch("matrix",&covmat,"c00/D:c10:c11:c20:c21:c22:c30:c31:c32:c33:c40:c41:c42:c43:c44",1000000);
1943 // create the chain with the compared tracks
1944 TChain *cmptrktree = new TChain("cmptrktree");
1945 cmptrkchain.Add(cmFile1);
1946 cmptrkchain.Add(cmFile2);
1947 cmptrkchain.Add(cmFile3);
1950 TFile *infile = TFile::Open(cmFile);
1951 TTree *cmptrktree = (TTree*)infile->Get("cmptrktree");
1954 cmptrktree->SetBranchAddress("comptracks",&cmptrk);
1955 Int_t entries = (Int_t)cmptrktree->GetEntries();
1956 cerr<<" Number of entries: "<<entries<<endl;
1958 Int_t trkPdg,trkBin;
1959 Double_t trkKine[1],trkRegPar[3];
1960 Int_t *nPerBinPi = new Int_t[knBinsPi];
1961 for(Int_t k=0;k<knBinsPi;k++) nPerBinPi[k]=0;
1962 Int_t *nPerBinKa = new Int_t[knBinsKa];
1963 for(Int_t k=0;k<knBinsKa;k++) nPerBinKa[k]=0;
1964 Int_t *nPerBinMu = new Int_t[knBinsMu];
1965 for(Int_t k=0;k<knBinsMu;k++) nPerBinMu[k]=0;
1966 Int_t *nPerBinEl = new Int_t[knBinsEl];
1967 for(Int_t k=0;k<knBinsEl;k++) nPerBinEl[k]=0;
1968 Int_t *nPerBinPr = new Int_t[knBinsPr];
1969 for(Int_t k=0;k<knBinsPr;k++) nPerBinPr[k]=0;
1971 // loop on chain entries
1972 for(Int_t l=0; l<entries; l++) {
1973 if(l % 10000 == 0) cerr<<"--- Processing track "<<l<<" of "<<entries<<" ---"<<endl;
1975 cmptrktree->GetEvent(l);
1977 trkPdg = TMath::Abs(cmptrk.pdg);
1978 // use only pions, kaons, protons, electrons, muons
1979 if(trkPdg!=211 && trkPdg!=321 && trkPdg!=2212 && trkPdg!=11 && trkPdg!=13) continue;
1980 SetParticle(trkPdg);
1981 trkBin = fDBgrid->GetBin(cmptrk.pt,cmptrk.eta);
1982 //cerr<<cmptrk.pt<<" "<<cmptrk.eta<<" "<<trkBin<<endl;
1984 if(trkPdg==211 && nPerBinPi[trkBin]>=5000) continue;
1985 if(trkPdg==321 && nPerBinKa[trkBin]>=5000) continue;
1986 if(trkPdg==2212 && nPerBinPr[trkBin]>=5000) continue;
1987 if(trkPdg==11 && nPerBinEl[trkBin]>=5000) continue;
1988 if(trkPdg==13 && nPerBinMu[trkBin]>=5000) continue;
1990 trkKine[0] = cmptrk.p;
1992 // get regularized covariance matrix
1993 for(Int_t k=0;k<3;k++) trkRegPar[k] = (*fRegPar)(0,k);
1994 covmat.c00 = cmptrk.c00/RegFunc(trkKine,trkRegPar);
1995 covmat.c10 = cmptrk.c10;
1996 for(Int_t k=0;k<3;k++) trkRegPar[k] = (*fRegPar)(1,k);
1997 covmat.c11 = cmptrk.c11/RegFunc(trkKine,trkRegPar);
1998 for(Int_t k=0;k<3;k++) trkRegPar[k] = (*fRegPar)(2,k);
1999 covmat.c20 = cmptrk.c20/RegFunc(trkKine,trkRegPar);
2000 covmat.c21 = cmptrk.c21;
2001 for(Int_t k=0;k<3;k++) trkRegPar[k] = (*fRegPar)(3,k);
2002 covmat.c22 = cmptrk.c22/RegFunc(trkKine,trkRegPar);
2003 covmat.c30 = cmptrk.c30;
2004 for(Int_t k=0;k<3;k++) trkRegPar[k] = (*fRegPar)(4,k);
2005 covmat.c31 = cmptrk.c31/RegFunc(trkKine,trkRegPar);
2006 covmat.c32 = cmptrk.c32;
2007 for(Int_t k=0;k<3;k++) trkRegPar[k] = (*fRegPar)(5,k);
2008 covmat.c33 = cmptrk.c33/RegFunc(trkKine,trkRegPar);
2009 for(Int_t k=0;k<3;k++) trkRegPar[k] = (*fRegPar)(6,k);
2010 covmat.c40 = cmptrk.c40/RegFunc(trkKine,trkRegPar);
2011 covmat.c41 = cmptrk.c41;
2012 for(Int_t k=0;k<3;k++) trkRegPar[k] = (*fRegPar)(7,k);
2013 covmat.c42 = cmptrk.c42/RegFunc(trkKine,trkRegPar);
2014 covmat.c43 = cmptrk.c43;
2015 for(Int_t k=0;k<3;k++) trkRegPar[k] = (*fRegPar)(8,k);
2016 covmat.c44 = cmptrk.c44/RegFunc(trkKine,trkRegPar);
2021 covTreePi_[trkBin].Fill();
2022 nPerBinPi[trkBin]++;
2025 covTreeKa_[trkBin].Fill();
2026 nPerBinKa[trkBin]++;
2028 case 2212: // protons
2029 covTreePr_[trkBin].Fill();
2030 nPerBinPr[trkBin]++;
2032 case 11: // electrons
2033 covTreeEl_[trkBin].Fill();
2034 nPerBinEl[trkBin]++;
2037 covTreeMu_[trkBin].Fill();
2038 nPerBinMu[trkBin]++;
2041 } // loop on chain entries
2043 // store all trees the DB file
2044 TFile *dbfile = new TFile(fDBfileName.Data(),"update");
2045 dbfile->mkdir("CovMatrices");
2046 gDirectory->cd("/CovMatrices");
2047 gDirectory->mkdir("Pions");
2048 gDirectory->mkdir("Kaons");
2049 gDirectory->mkdir("Protons");
2050 gDirectory->mkdir("Electrons");
2051 gDirectory->mkdir("Muons");
2053 gDirectory->cd("/CovMatrices/Pions");
2054 fDBgridPi.SetName("DBgridPi"); fDBgridPi.Write();
2055 for(Int_t i=0;i<knBinsPi;i++) covTreePi_[i].Write();
2057 gDirectory->cd("/CovMatrices/Kaons");
2058 fDBgridKa.SetName("DBgridKa"); fDBgridKa.Write();
2059 for(Int_t i=0;i<knBinsKa;i++) covTreeKa_[i].Write();
2061 gDirectory->cd("/CovMatrices/Protons");
2062 fDBgridPr.SetName("DBgridPr"); fDBgridPr.Write();
2063 for(Int_t i=0;i<knBinsPr;i++) covTreePr_[i].Write();
2065 gDirectory->cd("/CovMatrices/Electrons");
2066 fDBgridEl.SetName("DBgridEl"); fDBgridEl.Write();
2067 for(Int_t i=0;i<knBinsEl;i++) covTreeEl_[i].Write();
2069 gDirectory->cd("/CovMatrices/Muons");
2070 fDBgridMu.SetName("DBgridMu"); fDBgridMu.Write();
2071 for(Int_t i=0;i<knBinsMu;i++) covTreeMu_[i].Write();
2074 delete [] nPerBinPi;
2075 delete [] nPerBinKa;
2076 delete [] nPerBinPr;
2077 delete [] nPerBinEl;
2078 delete [] nPerBinMu;
2082 //-----------------------------------------------------------------------------
2083 void AliTPCtrackerParam::MakeSeedsFromHits(AliTPC *tpc,TTree *th,
2084 TObjArray &seedArray) const {
2085 //-----------------------------------------------------------------------------
2086 // This function makes the seeds for tracks from the 1st hits in the TPC
2087 //-----------------------------------------------------------------------------
2089 Double_t xg,yg,zg,px,py,pz,pt;
2091 Int_t nTracks=(Int_t)th->GetEntries();
2093 cerr<<"+++\n+++ Number of \"primary tracks\"(entries in TreeH): "<<nTracks<<
2096 AliTPChit *tpcHit=0;
2098 // loop over entries in TreeH
2099 for(Int_t l=0; l<nTracks; l++) {
2100 if(l%1000==0) cerr<<" --- Processing primary track "
2101 <<l<<" of "<<nTracks<<" ---\r";
2105 tpcHit=(AliTPChit*)tpc->FirstHit(-1);
2106 for( ; tpcHit; tpcHit=(AliTPChit*)tpc->NextHit() ) {
2107 if(tpcHit->fQ !=0.) continue;
2108 // Get particle momentum at hit
2109 px=tpcHit->X(); py=tpcHit->Y(); pz=tpcHit->Z();
2111 pt=TMath::Sqrt(px*px+py*py);
2112 // reject hits with Pt<mag*0.45 GeV/c
2113 if(pt<(fBz*0.45)) continue;
2116 label=tpcHit->Track();
2118 if((tpcHit=(AliTPChit*)tpc->NextHit())==0) break;
2119 if(tpcHit->fQ != 0.) continue;
2120 // Get global coordinates of hit
2121 xg=tpcHit->X(); yg=tpcHit->Y(); zg=tpcHit->Z();
2122 if(TMath::Sqrt(xg*xg+yg*yg)>90.) continue;
2125 AliTPCseedGeant *ioseed = new AliTPCseedGeant(xg,yg,zg,px,py,pz,label);
2127 // reject tracks which are not in the TPC acceptance
2128 if(!ioseed->InTPCAcceptance()) { delete ioseed; continue; }
2130 // put seed in array
2131 seedArray.AddLast(ioseed);
2134 } // loop over entries in TreeH
2138 //-----------------------------------------------------------------------------
2139 void AliTPCtrackerParam::MakeSeedsFromRefs(TTree *ttr,
2140 TObjArray &seedArray) const {
2141 //-----------------------------------------------------------------------------
2142 // This function makes the seeds for tracks from the track references
2143 //-----------------------------------------------------------------------------
2145 Double_t xg,yg,zg,px,py,pz,pt;
2149 TClonesArray *tkRefArray = new TClonesArray("AliTrackReference");
2151 TBranch *b =(TBranch*)ttr->GetBranch("TPC");
2152 if(!b) {cerr<<"TPC branch of TreeTR not found"<<endl; return; }
2153 b->SetAddress(&tkRefArray);
2154 Int_t nTkRef = (Int_t)b->GetEntries();
2155 cerr<<"+++\n+++ Number of entries in TreeTR(TPC): "<<nTkRef<<
2158 // loop on track references
2159 for(Int_t l=0; l<nTkRef; l++){
2160 if(l%1000==0) cerr<<" --- Processing primary track "
2161 <<l<<" of "<<nTkRef<<" ---\r";
2162 if(!b->GetEvent(l)) continue;
2163 nnn = tkRefArray->GetEntriesFast();
2165 if(nnn <= 0) continue;
2166 for(k=0; k<nnn; k++) {
2167 AliTrackReference *tkref = (AliTrackReference*)tkRefArray->UncheckedAt(k);
2175 label = tkref->GetTrack();
2177 pt=TMath::Sqrt(px*px+py*py);
2178 // reject hits with Pt<mag*0.45 GeV/c
2179 if(pt<(fBz*0.45)) continue;
2182 AliTPCseedGeant *ioseed = new AliTPCseedGeant(xg,yg,zg,px,py,pz,label);
2184 // reject if not at the inner part of TPC
2185 if(TMath::Abs(ioseed->GetXL()-82.9701) > 0.1) {
2186 delete ioseed; continue;
2189 // reject tracks which are not in the TPC acceptance
2190 if(!ioseed->InTPCAcceptance()) {
2191 delete ioseed; continue;
2194 // put seed in array
2195 seedArray.AddLast(ioseed);
2200 } // loop on track references
2207 //-----------------------------------------------------------------------------
2208 void AliTPCtrackerParam::MergeEvents(Int_t evFirst,Int_t evLast) {
2209 //-----------------------------------------------------------------------------
2210 // This function: 1) merges the files from track comparison
2211 // (beware: better no more than 100 events per file)
2212 // 2) computes the average TPC efficiencies
2213 //-----------------------------------------------------------------------------
2215 const char *outName="TPCeff.root";
2217 // merge files with tracks
2218 cerr<<" ******** MERGING FILES **********\n\n";
2220 // create the chain for the tree of compared tracks
2221 TChain ch1("cmptrktree");
2222 TChain ch2("cmptrktree");
2223 TChain ch3("cmptrktree");
2225 for(Int_t j=evFirst; j<=evLast; j++) {
2226 cerr<<"Processing event "<<j<<endl;
2228 TString covName("CovMatrix.");
2230 covName.Append(".root");
2232 if(gSystem->AccessPathName(covName.Data(),kFileExists)) continue;
2235 if(j<=100) ch1.Add(covName.Data());
2236 if(j>100 && j<=200) ch2.Add(covName.Data());
2237 if(j>200) ch3.Add(covName.Data());
2241 // merge chain in one file
2243 covOut = new TFile("CovMatrix_AllEvts_1.root","recreate");
2244 ch1.Merge(covOut,1000000000);
2247 covOut = new TFile("CovMatrix_AllEvts_2.root","recreate");
2248 ch2.Merge(covOut,1000000000);
2251 covOut = new TFile("CovMatrix_AllEvts_3.root","recreate");
2252 ch3.Merge(covOut,1000000000);
2258 cerr<<" ***** EFFICIENCIES ******\n\n";
2260 ReadEffs("TPCeff.1.root");
2262 Int_t n = fEffPi.GetTotPoints();
2263 Double_t *avEffPi = new Double_t[n];
2264 Double_t *avEffKa = new Double_t[n];
2265 Double_t *avEffPr = new Double_t[n];
2266 Double_t *avEffEl = new Double_t[n];
2267 Double_t *avEffMu = new Double_t[n];
2268 Int_t *evtsPi = new Int_t[n];
2269 Int_t *evtsKa = new Int_t[n];
2270 Int_t *evtsPr = new Int_t[n];
2271 Int_t *evtsEl = new Int_t[n];
2272 Int_t *evtsMu = new Int_t[n];
2274 for(Int_t j=0; j<n; j++) {
2275 avEffPi[j]=avEffKa[j]=avEffPr[j]=avEffEl[j]=avEffMu[j]=0.;
2276 evtsPi[j]=evtsKa[j]=evtsPr[j]=evtsEl[j]=evtsMu[j]=0;
2279 for(Int_t j=evFirst; j<=evLast; j++) {
2280 cerr<<"Processing event "<<j<<endl;
2282 TString effName("TPCeff.");
2284 effName.Append(".root");
2286 if(gSystem->AccessPathName(effName.Data(),kFileExists)) continue;
2288 ReadEffs(effName.Data());
2290 for(Int_t k=0; k<n; k++) {
2291 if(fEffPi.GetParam(k)>=0.) {avEffPi[k]+=fEffPi.GetParam(k); evtsPi[k]++;}
2292 if(fEffKa.GetParam(k)>=0.) {avEffKa[k]+=fEffKa.GetParam(k); evtsKa[k]++;}
2293 if(fEffPr.GetParam(k)>=0.) {avEffPr[k]+=fEffPr.GetParam(k); evtsPr[k]++;}
2294 if(fEffEl.GetParam(k)>=0.) {avEffEl[k]+=fEffEl.GetParam(k); evtsEl[k]++;}
2295 if(fEffMu.GetParam(k)>=0.) {avEffMu[k]+=fEffMu.GetParam(k); evtsMu[k]++;}
2300 // compute average efficiencies
2301 for(Int_t j=0; j<n; j++) {
2302 if(evtsPi[j]==0) evtsPi[j]++;
2303 fEffPi.SetParam(j,(Double_t)avEffPi[j]/evtsPi[j]);
2304 if(evtsKa[j]==0) evtsKa[j]++;
2305 fEffKa.SetParam(j,(Double_t)avEffKa[j]/evtsKa[j]);
2306 if(evtsPr[j]==0) evtsPr[j]++;
2307 fEffPr.SetParam(j,(Double_t)avEffPr[j]/evtsPr[j]);
2308 if(evtsEl[j]==0) evtsEl[j]++;
2309 fEffEl.SetParam(j,(Double_t)avEffEl[j]/evtsEl[j]);
2310 if(evtsMu[j]==0) evtsMu[j]++;
2311 fEffMu.SetParam(j,(Double_t)avEffMu[j]/evtsMu[j]);
2314 // write efficiencies to a file
2330 //-----------------------------------------------------------------------------
2331 Int_t AliTPCtrackerParam::ReadAllData(const Char_t* inName) {
2332 //-----------------------------------------------------------------------------
2333 // This function reads all parameters from the DB
2334 //-----------------------------------------------------------------------------
2336 if(!ReadEffs(inName)) return 0;
2337 if(!ReadPulls(inName)) return 0;
2338 if(!ReadRegParams(inName,211)) return 0;
2339 if(!ReadRegParams(inName,321)) return 0;
2340 if(!ReadRegParams(inName,2212)) return 0;
2341 if(!ReadRegParams(inName,11)) return 0;
2342 if(!ReadRegParams(inName,13)) return 0;
2343 if(!ReaddEdx(inName,211)) return 0;
2344 if(!ReaddEdx(inName,321)) return 0;
2345 if(!ReaddEdx(inName,2212)) return 0;
2346 if(!ReaddEdx(inName,11)) return 0;
2347 if(!ReaddEdx(inName,13)) return 0;
2348 if(!ReadDBgrid(inName)) return 0;
2352 //-----------------------------------------------------------------------------
2353 Int_t AliTPCtrackerParam::ReaddEdx(const Char_t* inName,Int_t pdg) {
2354 //-----------------------------------------------------------------------------
2355 // This function reads the dEdx parameters from the DB
2356 //-----------------------------------------------------------------------------
2358 if(gSystem->AccessPathName(inName,kFileExists)) {
2359 cerr<<"AliTPCtrackerParam::ReaddEdx: "<<inName<<" not found\n";
2362 TFile *inFile = TFile::Open(inName);
2365 fdEdxMean = (AliTPCkineGrid*)inFile->Get("/dEdx/Pions/dEdxMeanPi");
2366 fdEdxMeanPi.~AliTPCkineGrid();
2367 new(&fdEdxMeanPi) AliTPCkineGrid(*fdEdxMean);
2368 fdEdxRMS = (AliTPCkineGrid*)inFile->Get("/dEdx/Pions/dEdxRMSPi");
2369 fdEdxRMSPi.~AliTPCkineGrid();
2370 new(&fdEdxRMSPi) AliTPCkineGrid(*fdEdxRMS);
2373 fdEdxMean = (AliTPCkineGrid*)inFile->Get("/dEdx/Kaons/dEdxMeanKa");
2374 fdEdxMeanKa.~AliTPCkineGrid();
2375 new(&fdEdxMeanKa) AliTPCkineGrid(*fdEdxMean);
2376 fdEdxRMS = (AliTPCkineGrid*)inFile->Get("/dEdx/Kaons/dEdxRMSKa");
2377 fdEdxRMSKa.~AliTPCkineGrid();
2378 new(&fdEdxRMSKa) AliTPCkineGrid(*fdEdxRMS);
2381 fdEdxMean = (AliTPCkineGrid*)inFile->Get("/dEdx/Protons/dEdxMeanPr");
2382 fdEdxMeanPr.~AliTPCkineGrid();
2383 new(&fdEdxMeanPr) AliTPCkineGrid(*fdEdxMean);
2384 fdEdxRMS = (AliTPCkineGrid*)inFile->Get("/dEdx/Protons/dEdxRMSPr");
2385 fdEdxRMSPr.~AliTPCkineGrid();
2386 new(&fdEdxRMSPr) AliTPCkineGrid(*fdEdxRMS);
2389 fdEdxMean = (AliTPCkineGrid*)inFile->Get("/dEdx/Electrons/dEdxMeanEl");
2390 fdEdxMeanEl.~AliTPCkineGrid();
2391 new(&fdEdxMeanEl) AliTPCkineGrid(*fdEdxMean);
2392 fdEdxRMS = (AliTPCkineGrid*)inFile->Get("/dEdx/Electrons/dEdxRMSEl");
2393 fdEdxRMSEl.~AliTPCkineGrid();
2394 new(&fdEdxRMSEl) AliTPCkineGrid(*fdEdxRMS);
2398 fdEdxMean = (AliTPCkineGrid*)inFile->Get("/dEdx/Pions/dEdxMeanPi");
2399 fdEdxRMS = (AliTPCkineGrid*)inFile->Get("/dEdx/Pions/dEdxRMSPi");
2401 fdEdxMean = (AliTPCkineGrid*)inFile->Get("/dEdx/Muons/dEdxMeanMu");
2402 fdEdxRMS = (AliTPCkineGrid*)inFile->Get("/dEdx/Muons/dEdxRMSMu");
2404 fdEdxMeanMu.~AliTPCkineGrid();
2405 new(&fdEdxMeanMu) AliTPCkineGrid(*fdEdxMean);
2406 fdEdxRMSMu.~AliTPCkineGrid();
2407 new(&fdEdxRMSMu) AliTPCkineGrid(*fdEdxRMS);
2414 //-----------------------------------------------------------------------------
2415 Int_t AliTPCtrackerParam::ReadDBgrid(const Char_t* inName) {
2416 //-----------------------------------------------------------------------------
2417 // This function reads the kine grid from the DB
2418 //-----------------------------------------------------------------------------
2420 if(gSystem->AccessPathName(inName,kFileExists)) {
2421 cerr<<"AliTPCtrackerParam::ReadCovMatrices: "<<inName<<" not found\n";
2424 TFile *inFile = TFile::Open(inName);
2426 // first read the DB grid for the different particles
2427 fDBgrid = (AliTPCkineGrid*)inFile->Get("/CovMatrices/Pions/DBgridPi");
2428 fDBgridPi.~AliTPCkineGrid();
2429 new(&fDBgridPi) AliTPCkineGrid(*fDBgrid);
2430 fDBgrid = (AliTPCkineGrid*)inFile->Get("/CovMatrices/Kaons/DBgridKa");
2431 fDBgridKa.~AliTPCkineGrid();
2432 new(&fDBgridKa) AliTPCkineGrid(*fDBgrid);
2434 fDBgrid = (AliTPCkineGrid*)inFile->Get("/CovMatrices/Pions/DBgridPi");
2436 fDBgrid = (AliTPCkineGrid*)inFile->Get("/CovMatrices/Protons/DBgridPr");
2438 fDBgridPr.~AliTPCkineGrid();
2439 new(&fDBgridPr) AliTPCkineGrid(*fDBgrid);
2440 fDBgrid = (AliTPCkineGrid*)inFile->Get("/CovMatrices/Electrons/DBgridEl");
2441 fDBgridEl.~AliTPCkineGrid();
2442 new(&fDBgridEl) AliTPCkineGrid(*fDBgrid);
2444 fDBgrid = (AliTPCkineGrid*)inFile->Get("/CovMatrices/Pions/DBgridPi");
2446 fDBgrid = (AliTPCkineGrid*)inFile->Get("/CovMatrices/Muons/DBgridMu");
2448 fDBgridMu.~AliTPCkineGrid();
2449 new(&fDBgridMu) AliTPCkineGrid(*fDBgrid);
2455 //-----------------------------------------------------------------------------
2456 Int_t AliTPCtrackerParam::ReadEffs(const Char_t* inName) {
2457 //-----------------------------------------------------------------------------
2458 // This function reads the TPC efficiencies from the DB
2459 //-----------------------------------------------------------------------------
2461 if(gSystem->AccessPathName(inName,kFileExists)) {
2462 cerr<<"AliTPCtrackerParam::ReadEffs: "<<inName<<" not found\n";
2465 TFile *inFile = TFile::Open(inName);
2467 fEff = (AliTPCkineGrid*)inFile->Get("/Efficiencies/Pions/EffPi");
2468 fEffPi.~AliTPCkineGrid();
2469 new(&fEffPi) AliTPCkineGrid(*fEff);
2470 fEff = (AliTPCkineGrid*)inFile->Get("/Efficiencies/Kaons/EffKa");
2471 fEffKa.~AliTPCkineGrid();
2472 new(&fEffKa) AliTPCkineGrid(*fEff);
2473 fEff = (AliTPCkineGrid*)inFile->Get("/Efficiencies/Protons/EffPr");
2474 fEffPr.~AliTPCkineGrid();
2475 new(&fEffPr) AliTPCkineGrid(*fEff);
2476 fEff = (AliTPCkineGrid*)inFile->Get("/Efficiencies/Electrons/EffEl");
2477 fEffEl.~AliTPCkineGrid();
2478 new(&fEffEl) AliTPCkineGrid(*fEff);
2479 fEff = (AliTPCkineGrid*)inFile->Get("/Efficiencies/Muons/EffMu");
2480 fEffMu.~AliTPCkineGrid();
2481 new(&fEffMu) AliTPCkineGrid(*fEff);
2487 //-----------------------------------------------------------------------------
2488 Int_t AliTPCtrackerParam::ReadPulls(const Char_t* inName) {
2489 //-----------------------------------------------------------------------------
2490 // This function reads the pulls from the DB
2491 //-----------------------------------------------------------------------------
2493 if(gSystem->AccessPathName(inName,kFileExists)) {
2494 cerr<<"AliTPCtrackerParam::ReadPulls: "<<inName<<" not found\n";
2497 TFile *inFile = TFile::Open(inName);
2499 for(Int_t i=0; i<5; i++) {
2500 TString pi("/Pulls/Pions/PullsPi_"); pi+=i;
2501 TString ka("/Pulls/Kaons/PullsKa_"); ka+=i;
2502 TString pr("/Pulls/Protons/PullsPr_"); pr+=i;
2503 TString el("/Pulls/Electrons/PullsEl_"); el+=i;
2504 TString mu("/Pulls/Muons/PullsMu_"); mu+=i;
2506 fPulls = (AliTPCkineGrid*)inFile->Get(pi.Data());
2507 fPullsPi[i].~AliTPCkineGrid();
2508 new(&fPullsPi[i]) AliTPCkineGrid(*fPulls);
2510 fPulls = (AliTPCkineGrid*)inFile->Get(ka.Data());
2511 fPullsKa[i].~AliTPCkineGrid();
2512 new(&fPullsKa[i]) AliTPCkineGrid(*fPulls);
2515 fPulls = (AliTPCkineGrid*)inFile->Get(pi.Data());
2517 fPulls = (AliTPCkineGrid*)inFile->Get(pr.Data());
2519 fPullsPr[i].~AliTPCkineGrid();
2520 new(&fPullsPr[i]) AliTPCkineGrid(*fPulls);
2522 fPulls = (AliTPCkineGrid*)inFile->Get(el.Data());
2523 fPullsEl[i].~AliTPCkineGrid();
2524 new(&fPullsEl[i]) AliTPCkineGrid(*fPulls);
2527 fPulls = (AliTPCkineGrid*)inFile->Get(pi.Data());
2529 fPulls = (AliTPCkineGrid*)inFile->Get(mu.Data());
2531 fPullsMu[i].~AliTPCkineGrid();
2532 new(&fPullsMu[i]) AliTPCkineGrid(*fPulls);
2539 //-----------------------------------------------------------------------------
2540 Int_t AliTPCtrackerParam::ReadRegParams(const Char_t* inName,Int_t pdg) {
2541 //-----------------------------------------------------------------------------
2542 // This function reads the regularization parameters from the DB
2543 //-----------------------------------------------------------------------------
2545 if(gSystem->AccessPathName(inName,kFileExists)) {
2546 cerr<<"AliTPCtrackerParam::ReadRegParams: "<<inName<<" not found\n";
2549 TFile *inFile = TFile::Open(inName);
2552 fRegPar = (TMatrixD*)inFile->Get("/RegParams/Pions/RegPions");
2553 new(&fRegParPi) TMatrixD(*fRegPar);
2556 fRegPar = (TMatrixD*)inFile->Get("/RegParams/Kaons/RegKaons");
2557 new(&fRegParKa) TMatrixD(*fRegPar);
2561 fRegPar = (TMatrixD*)inFile->Get("/RegParams/Pions/RegPions");
2563 fRegPar = (TMatrixD*)inFile->Get("/RegParams/Protons/RegProtons");
2565 new(&fRegParPr) TMatrixD(*fRegPar);
2568 fRegPar = (TMatrixD*)inFile->Get("/RegParams/Electrons/RegElectrons");
2569 new(&fRegParEl) TMatrixD(*fRegPar);
2573 fRegPar = (TMatrixD*)inFile->Get("/RegParams/Pions/RegPions");
2575 fRegPar = (TMatrixD*)inFile->Get("/RegParams/Muons/RegMuons");
2577 new(&fRegParMu) TMatrixD(*fRegPar);
2584 //-----------------------------------------------------------------------------
2585 void AliTPCtrackerParam::RegularizeCovMatrix(const Char_t *outName,Int_t pdg) {
2586 //-----------------------------------------------------------------------------
2587 // This function regularizes the elements of the covariance matrix
2588 // that show a momentum depence:
2589 // c00, c11, c22, c33, c44, c20, c24, c40, c31
2590 // The regularization is done separately for pions, kaons, electrons:
2591 // give "Pion","Kaon" or "Electron" as first argument.
2592 //-----------------------------------------------------------------------------
2594 gStyle->SetOptStat(0);
2595 gStyle->SetOptFit(10001);
2598 const char *part="Pions - ";
2600 InitializeKineGrid("DB");
2602 const Int_t kfitbins = fDBgrid->GetBinsPt();
2603 cerr<<" Fit bins: "<<kfitbins<<endl;
2609 cerr<<" Processing pions ...\n";
2614 cerr<<" Processing kaons ...\n";
2616 case 2212: //protons
2619 cerr<<" Processing protons ...\n";
2621 case 11: // electrons
2623 part="Electrons - ";
2624 cerr<<" Processing electrons ...\n";
2629 cerr<<" Processing muons ...\n";
2635 // create a chain with compared tracks
2636 TChain *cmptrkchain = new ("cmptrktree");
2637 cmptrkchain.Add("CovMatrix_AllEvts.root");
2638 //cmptrkchain.Add("CovMatrix_AllEvts_1.root");
2639 //cmptrkchain.Add("CovMatrix_AllEvts_2.root");
2640 //cmptrkchain.Add("CovMatrix_AllEvts_3.root");
2644 TFile *infile = TFile::Open("CovMatrix_AllEvts.root");
2645 TTree *cmptrktree = (TTree*)infile->Get("cmptrktree");
2648 cmptrktree->SetBranchAddress("comptracks",&cmptrk);
2649 Int_t entries = (Int_t)cmptrktree->GetEntries();
2653 Int_t *n = new Int_t[kfitbins];
2654 Int_t *n00 = new Int_t[kfitbins];
2655 Int_t *n11 = new Int_t[kfitbins];
2656 Int_t *n20 = new Int_t[kfitbins];
2657 Int_t *n22 = new Int_t[kfitbins];
2658 Int_t *n31 = new Int_t[kfitbins];
2659 Int_t *n33 = new Int_t[kfitbins];
2660 Int_t *n40 = new Int_t[kfitbins];
2661 Int_t *n42 = new Int_t[kfitbins];
2662 Int_t *n44 = new Int_t[kfitbins];
2663 Double_t *p = new Double_t[kfitbins];
2664 Double_t *ep = new Double_t[kfitbins];
2665 Double_t *mean00 = new Double_t[kfitbins];
2666 Double_t *mean11 = new Double_t[kfitbins];
2667 Double_t *mean20 = new Double_t[kfitbins];
2668 Double_t *mean22 = new Double_t[kfitbins];
2669 Double_t *mean31 = new Double_t[kfitbins];
2670 Double_t *mean33 = new Double_t[kfitbins];
2671 Double_t *mean40 = new Double_t[kfitbins];
2672 Double_t *mean42 = new Double_t[kfitbins];
2673 Double_t *mean44 = new Double_t[kfitbins];
2674 Double_t *sigma00 = new Double_t[kfitbins];
2675 Double_t *sigma11 = new Double_t[kfitbins];
2676 Double_t *sigma20 = new Double_t[kfitbins];
2677 Double_t *sigma22 = new Double_t[kfitbins];
2678 Double_t *sigma31 = new Double_t[kfitbins];
2679 Double_t *sigma33 = new Double_t[kfitbins];
2680 Double_t *sigma40 = new Double_t[kfitbins];
2681 Double_t *sigma42 = new Double_t[kfitbins];
2682 Double_t *sigma44 = new Double_t[kfitbins];
2683 Double_t *rmean = new Double_t[kfitbins];
2684 Double_t *rsigma = new Double_t[kfitbins];
2687 for(Int_t l=0; l<kfitbins; l++) {
2689 n00[l]=n11[l]=n20[l]=n22[l]=n31[l]=n33[l]=n40[l]=n42[l]=n44[l]=1;
2691 mean00[l]=mean11[l]=mean20[l]=mean22[l]=mean31[l]=mean33[l]=mean40[l]=mean42[l]=mean44[l]=0.;
2692 sigma00[l]=sigma11[l]=sigma20[l]=sigma22[l]=sigma31[l]=sigma33[l]=sigma40[l]=sigma42[l]=sigma44[l]=0.;
2695 // loop on chain entries for mean
2696 for(Int_t l=0; l<entries; l++) {
2697 cmptrktree->GetEvent(l);
2698 if(TMath::Abs(cmptrk.pdg)!=thisPdg) continue;
2699 pbin = (Int_t)fDBgrid->GetBin(cmptrk.pt,cmptrk.eta)/fDBgrid->GetBinsEta();
2702 mean00[pbin]+=cmptrk.c00;
2703 mean11[pbin]+=cmptrk.c11;
2704 mean20[pbin]+=cmptrk.c20;
2705 mean22[pbin]+=cmptrk.c22;
2706 mean31[pbin]+=cmptrk.c31;
2707 mean33[pbin]+=cmptrk.c33;
2708 mean40[pbin]+=cmptrk.c40;
2709 mean42[pbin]+=cmptrk.c42;
2710 mean44[pbin]+=cmptrk.c44;
2711 } // loop on chain entries
2713 for(Int_t l=0; l<kfitbins; l++) {
2726 // loop on chain entries for sigma
2727 for(Int_t l=0; l<entries; l++) {
2728 cmptrktree->GetEvent(l);
2729 if(TMath::Abs(cmptrk.pdg)!=thisPdg) continue;
2730 pbin = (Int_t)fDBgrid->GetBin(cmptrk.pt,cmptrk.eta)/fDBgrid->GetBinsEta();
2731 if(TMath::Abs(cmptrk.c00-mean00[pbin])<0.4*mean00[pbin]) { n00[pbin]++;
2732 sigma00[pbin]+=(cmptrk.c00-mean00[pbin])*(cmptrk.c00-mean00[pbin]); }
2733 if(TMath::Abs(cmptrk.c11-mean11[pbin])<0.4*mean11[pbin]) { n11[pbin]++;
2734 sigma11[pbin]+=(cmptrk.c11-mean11[pbin])*(cmptrk.c11-mean11[pbin]); }
2735 if(TMath::Abs(cmptrk.c20-mean20[pbin])<0.4*mean20[pbin]) { n20[pbin]++;
2736 sigma20[pbin]+=(cmptrk.c20-mean20[pbin])*(cmptrk.c20-mean20[pbin]); }
2737 if(TMath::Abs(cmptrk.c22-mean22[pbin])<0.4*mean22[pbin]) { n22[pbin]++;
2738 sigma22[pbin]+=(cmptrk.c22-mean22[pbin])*(cmptrk.c22-mean22[pbin]); }
2739 if(TMath::Abs(cmptrk.c31-mean31[pbin])<-0.4*mean31[pbin]) { n31[pbin]++;
2740 sigma31[pbin]+=(cmptrk.c31-mean31[pbin])*(cmptrk.c31-mean31[pbin]); }
2741 if(TMath::Abs(cmptrk.c33-mean33[pbin])<0.4*mean33[pbin]) { n33[pbin]++;
2742 sigma33[pbin]+=(cmptrk.c33-mean33[pbin])*(cmptrk.c33-mean33[pbin]); }
2743 if(TMath::Abs(cmptrk.c40-mean40[pbin])<0.4*mean40[pbin]) { n40[pbin]++;
2744 sigma40[pbin]+=(cmptrk.c40-mean40[pbin])*(cmptrk.c40-mean40[pbin]); }
2745 if(TMath::Abs(cmptrk.c42-mean42[pbin])<0.4*mean42[pbin]) { n42[pbin]++;
2746 sigma42[pbin]+=(cmptrk.c42-mean42[pbin])*(cmptrk.c42-mean42[pbin]); }
2747 if(TMath::Abs(cmptrk.c44-mean44[pbin])<0.4*mean44[pbin]) { n44[pbin]++;
2748 sigma44[pbin]+=(cmptrk.c44-mean44[pbin])*(cmptrk.c44-mean44[pbin]); }
2749 } // loop on chain entries
2751 for(Int_t l=0; l<kfitbins; l++) {
2752 sigma00[l] = TMath::Sqrt(sigma00[l]/n00[l]);
2753 sigma11[l] = TMath::Sqrt(sigma11[l]/n11[l]);
2754 sigma20[l] = TMath::Sqrt(sigma20[l]/n20[l]);
2755 sigma22[l] = TMath::Sqrt(sigma22[l]/n22[l]);
2756 sigma31[l] = TMath::Sqrt(sigma31[l]/n31[l]);
2757 sigma33[l] = TMath::Sqrt(sigma33[l]/n33[l]);
2758 sigma40[l] = TMath::Sqrt(sigma40[l]/n40[l]);
2759 sigma42[l] = TMath::Sqrt(sigma42[l]/n42[l]);
2760 sigma44[l] = TMath::Sqrt(sigma44[l]/n44[l]);
2765 TF1 *func = new TF1("RegFunc",RegFunc,0.23,50.,3);
2766 func->SetParNames("A_meas","A_scatt","B");
2768 // line to draw on the plots
2769 TLine *lin = new TLine(-1,1,1.69,1);
2770 lin->SetLineStyle(2);
2771 lin->SetLineWidth(2);
2773 // matrix used to store fit results
2774 TMatrixD fitRes(9,3);
2778 // create the canvas
2779 TCanvas *canv00 = new TCanvas("canv00","c00",0,0,700,900);
2780 canv00->Divide(1,2);
2781 // create the graph for cov matrix
2782 TGraphErrors *gr00 = new TGraphErrors(kfitbins,p,mean00,ep,sigma00);
2783 TString title00("C(y,y)"); title00.Prepend(part);
2784 TH2F *frame00 = new TH2F("frame00",title00.Data(),2,0.1,50,2,0,5e-3);
2785 frame00->SetXTitle("p [GeV/c]");
2786 canv00->cd(1); gPad->SetLogx();
2789 // Sets initial values for parameters
2790 func->SetParameters(1.6e-3,1.9e-4,1.5);
2791 // Fit points in range defined by function
2792 gr00->Fit("RegFunc","R,Q");
2793 func->GetParameters(fitpar);
2794 for(Int_t i=0; i<3; i++) fitRes(0,i)=fitpar[i];
2795 for(Int_t l=0; l<kfitbins; l++) {
2796 rmean[l] = mean00[l]/RegFunc(&p[l],fitpar);
2797 rsigma[l] = sigma00[l]/RegFunc(&p[l],fitpar);
2799 // create the graph the regularized cov. matrix
2800 TGraphErrors *gr00reg = new TGraphErrors(kfitbins,p,rmean,ep,rsigma);
2801 TString regtitle00("C(y,y)/(A_meas+A_scatt/p^{B})");
2802 regtitle00.Prepend(part);
2803 TH2F *frame00reg = new TH2F("frame00reg",regtitle00.Data(),2,0.1,50,2,0,2);
2804 frame00reg->SetXTitle("p [GeV/c]");
2805 canv00->cd(2); gPad->SetLogx();
2813 // create the canvas
2814 TCanvas *canv11 = new TCanvas("canv11","c11",0,0,700,900);
2815 canv11->Divide(1,2);
2816 // create the graph for cov matrix
2817 TGraphErrors *gr11 = new TGraphErrors(kfitbins,p,mean11,ep,sigma11);
2818 TString title11("C(z,z)"); title11.Prepend(part);
2819 TH2F *frame11 = new TH2F("frame11",title11.Data(),2,0.1,50,2,0,6e-3);
2820 frame11->SetXTitle("p [GeV/c]");
2821 canv11->cd(1); gPad->SetLogx();
2824 // Sets initial values for parameters
2825 func->SetParameters(1.2e-3,8.1e-4,1.);
2826 // Fit points in range defined by function
2827 gr11->Fit("RegFunc","R,Q");
2828 func->GetParameters(fitpar);
2829 for(Int_t i=0; i<3; i++) fitRes(1,i)=fitpar[i];
2830 for(Int_t l=0; l<kfitbins; l++) {
2831 rmean[l] = mean11[l]/RegFunc(&p[l],fitpar);
2832 rsigma[l] = sigma11[l]/RegFunc(&p[l],fitpar);
2834 // create the graph the regularized cov. matrix
2835 TGraphErrors *gr11reg = new TGraphErrors(kfitbins,p,rmean,ep,rsigma);
2836 TString regtitle11("C(z,z)/(A_meas+A_scatt/p^{B})");
2837 regtitle11.Prepend(part);
2838 TH2F *frame11reg = new TH2F("frame11reg",regtitle11.Data(),2,0.1,50,2,0,2);
2839 frame11reg->SetXTitle("p [GeV/c]");
2840 canv11->cd(2); gPad->SetLogx();
2848 // create the canvas
2849 TCanvas *canv20 = new TCanvas("canv20","c20",0,0,700,900);
2850 canv20->Divide(1,2);
2851 // create the graph for cov matrix
2852 TGraphErrors *gr20 = new TGraphErrors(kfitbins,p,mean20,ep,sigma20);
2853 TString title20("C(#eta, y)"); title20.Prepend(part);
2854 TH2F *frame20 = new TH2F("frame20",title20.Data(),2,0.1,50,2,0,2.5e-4);
2855 frame20->SetXTitle("p [GeV/c]");
2856 canv20->cd(1); gPad->SetLogx();
2859 // Sets initial values for parameters
2860 func->SetParameters(7.3e-5,1.2e-5,1.5);
2861 // Fit points in range defined by function
2862 gr20->Fit("RegFunc","R,Q");
2863 func->GetParameters(fitpar);
2864 for(Int_t i=0; i<3; i++) fitRes(2,i)=fitpar[i];
2865 for(Int_t l=0; l<kfitbins; l++) {
2866 rmean[l] = mean20[l]/RegFunc(&p[l],fitpar);
2867 rsigma[l] = sigma20[l]/RegFunc(&p[l],fitpar);
2869 // create the graph the regularized cov. matrix
2870 TGraphErrors *gr20reg = new TGraphErrors(kfitbins,p,rmean,ep,rsigma);
2871 TString regtitle20("C(#eta, y)/(A_meas+A_scatt/p^{B})");
2872 regtitle20.Prepend(part);
2873 TH2F *frame20reg = new TH2F("frame20reg",regtitle20.Data(),2,0.1,50,2,0,2);
2874 frame20reg->SetXTitle("p [GeV/c]");
2875 canv20->cd(2); gPad->SetLogx();
2883 // create the canvas
2884 TCanvas *canv22 = new TCanvas("canv22","c22",0,0,700,900);
2885 canv22->Divide(1,2);
2886 // create the graph for cov matrix
2887 TGraphErrors *gr22 = new TGraphErrors(kfitbins,p,mean22,ep,sigma22);
2888 TString title22("C(#eta, #eta)"); title22.Prepend(part);
2889 TH2F *frame22 = new TH2F("frame22",title22.Data(),2,0.1,50,2,0,3e-5);
2890 frame22->SetXTitle("p [GeV/c]");
2891 canv22->cd(1); gPad->SetLogx();
2894 // Sets initial values for parameters
2895 func->SetParameters(5.2e-6,1.1e-6,2.);
2896 // Fit points in range defined by function
2897 gr22->Fit("RegFunc","R,Q");
2898 func->GetParameters(fitpar);
2899 for(Int_t i=0; i<3; i++) fitRes(3,i)=fitpar[i];
2900 for(Int_t l=0; l<kfitbins; l++) {
2901 rmean[l] = mean22[l]/RegFunc(&p[l],fitpar);
2902 rsigma[l] = sigma22[l]/RegFunc(&p[l],fitpar);
2904 // create the graph the regularized cov. matrix
2905 TGraphErrors *gr22reg = new TGraphErrors(kfitbins,p,rmean,ep,rsigma);
2906 TString regtitle22("C(#eta, #eta)/(A_meas+A_scatt/p^{B})");
2907 regtitle22.Prepend(part);
2908 TH2F *frame22reg = new TH2F("frame22reg",regtitle22.Data(),2,0.1,50,2,0,2);
2909 frame22reg->SetXTitle("p [GeV/c]");
2910 canv22->cd(2); gPad->SetLogx();
2918 // create the canvas
2919 TCanvas *canv31 = new TCanvas("canv31","c31",0,0,700,900);
2920 canv31->Divide(1,2);
2921 // create the graph for cov matrix
2922 TGraphErrors *gr31 = new TGraphErrors(kfitbins,p,mean31,ep,sigma31);
2923 TString title31("C(tg #lambda,z)"); title31.Prepend(part);
2924 TH2F *frame31 = new TH2F("frame31",title31.Data(),2,0.1,50,2,-2e-4,0);
2925 frame31->SetXTitle("p [GeV/c]");
2926 canv31->cd(1); gPad->SetLogx();
2929 // Sets initial values for parameters
2930 func->SetParameters(-1.2e-5,-1.2e-5,1.5);
2931 // Fit points in range defined by function
2932 gr31->Fit("RegFunc","R,Q");
2933 func->GetParameters(fitpar);
2934 for(Int_t i=0; i<3; i++) fitRes(4,i)=fitpar[i];
2935 for(Int_t l=0; l<kfitbins; l++) {
2936 rmean[l] = mean31[l]/RegFunc(&p[l],fitpar);
2937 rsigma[l] = -sigma31[l]/RegFunc(&p[l],fitpar);
2939 // create the graph the regularized cov. matrix
2940 TGraphErrors *gr31reg = new TGraphErrors(kfitbins,p,rmean,ep,rsigma);
2941 TString regtitle31("C(tg #lambda,z)/(A_meas+A_scatt/p^{B})");
2942 regtitle31.Prepend(part);
2943 TH2F *frame31reg = new TH2F("frame31reg",regtitle31.Data(),2,0.1,50,2,0,2);
2944 frame31reg->SetXTitle("p [GeV/c]");
2945 canv31->cd(2); gPad->SetLogx();
2953 // create the canvas
2954 TCanvas *canv33 = new TCanvas("canv33","c33",0,0,700,900);
2955 canv33->Divide(1,2);
2956 // create the graph for cov matrix
2957 TGraphErrors *gr33 = new TGraphErrors(kfitbins,p,mean33,ep,sigma33);
2958 TString title33("C(tg #lambda,tg #lambda)"); title33.Prepend(part);
2959 TH2F *frame33 = new TH2F("frame33",title33.Data(),2,0.1,50,2,0,1e-5);
2960 frame33->SetXTitle("p [GeV/c]");
2961 canv33->cd(1); gPad->SetLogx();
2964 // Sets initial values for parameters
2965 func->SetParameters(1.3e-7,4.6e-7,1.7);
2966 // Fit points in range defined by function
2967 gr33->Fit("RegFunc","R,Q");
2968 func->GetParameters(fitpar);
2969 for(Int_t i=0; i<3; i++) fitRes(5,i)=fitpar[i];
2970 for(Int_t l=0; l<kfitbins; l++) {
2971 rmean[l] = mean33[l]/RegFunc(&p[l],fitpar);
2972 rsigma[l] = sigma33[l]/RegFunc(&p[l],fitpar);
2974 // create the graph the regularized cov. matrix
2975 TGraphErrors *gr33reg = new TGraphErrors(kfitbins,p,rmean,ep,rsigma);
2976 TString regtitle33("C(tg #lambda,tg #lambda)/(A_meas+A_scatt/p^{B})");
2977 regtitle33.Prepend(part);
2978 TH2F *frame33reg = new TH2F("frame33reg",regtitle33.Data(),2,0.1,50,2,0,2);
2979 frame33reg->SetXTitle("p [GeV/c]");
2980 canv33->cd(2); gPad->SetLogx();
2988 // create the canvas
2989 TCanvas *canv40 = new TCanvas("canv40","c40",0,0,700,900);
2990 canv40->Divide(1,2);
2991 // create the graph for cov matrix
2992 TGraphErrors *gr40 = new TGraphErrors(kfitbins,p,mean40,ep,sigma40);
2993 TString title40("C(C,y)"); title40.Prepend(part);
2994 TH2F *frame40 = new TH2F("frame40",title40.Data(),2,0.1,50,2,0,1e-6);
2995 frame40->SetXTitle("p [GeV/c]");
2996 canv40->cd(1); gPad->SetLogx();
2999 // Sets initial values for parameters
3000 func->SetParameters(4.e-7,4.4e-8,1.5);
3001 // Fit points in range defined by function
3002 gr40->Fit("RegFunc","R,Q");
3003 func->GetParameters(fitpar);
3004 for(Int_t i=0; i<3; i++) fitRes(6,i)=fitpar[i];
3005 for(Int_t l=0; l<kfitbins; l++) {
3006 rmean[l] = mean40[l]/RegFunc(&p[l],fitpar);
3007 rsigma[l] = sigma40[l]/RegFunc(&p[l],fitpar);
3009 // create the graph the regularized cov. matrix
3010 TGraphErrors *gr40reg = new TGraphErrors(kfitbins,p,rmean,ep,rsigma);
3011 TString regtitle40("C(C,y)/(A_meas+A_scatt/p^{B})");
3012 regtitle40.Prepend(part);
3013 TH2F *frame40reg = new TH2F("frame40reg",regtitle40.Data(),2,0.1,50,2,0,2);
3014 frame40reg->SetXTitle("p [GeV/c]");
3015 canv40->cd(2); gPad->SetLogx();
3023 // create the canvas
3024 TCanvas *canv42 = new TCanvas("canv42","c42",0,0,700,900);
3025 canv42->Divide(1,2);
3026 // create the graph for cov matrix
3027 TGraphErrors *gr42 = new TGraphErrors(kfitbins,p,mean42,ep,sigma42);
3028 TString title42("C(C, #eta)"); title42.Prepend(part);
3029 TH2F *frame42 = new TH2F("frame42",title42.Data(),2,0.1,50,2,0,2.2e-7);
3030 frame42->SetXTitle("p [GeV/c]");
3031 canv42->cd(1); gPad->SetLogx();
3034 // Sets initial values for parameters
3035 func->SetParameters(3.e-8,8.2e-9,2.);
3036 // Fit points in range defined by function
3037 gr42->Fit("RegFunc","R,Q");
3038 func->GetParameters(fitpar);
3039 for(Int_t i=0; i<3; i++) fitRes(7,i)=fitpar[i];
3040 for(Int_t l=0; l<kfitbins; l++) {
3041 rmean[l] = mean42[l]/RegFunc(&p[l],fitpar);
3042 rsigma[l] = sigma42[l]/RegFunc(&p[l],fitpar);
3044 // create the graph the regularized cov. matrix
3045 TGraphErrors *gr42reg = new TGraphErrors(kfitbins,p,rmean,ep,rsigma);
3046 TString regtitle42("C(C, #eta)/(A_meas+A_scatt/p^{B})");
3047 regtitle42.Prepend(part);
3048 TH2F *frame42reg = new TH2F("frame42reg",regtitle42.Data(),2,0.1,50,2,0,2);
3049 frame42reg->SetXTitle("p [GeV/c]");
3050 canv42->cd(2); gPad->SetLogx();
3058 // create the canvas
3059 TCanvas *canv44 = new TCanvas("canv44","c44",0,0,700,900);
3060 canv44->Divide(1,2);
3061 // create the graph for cov matrix
3062 TGraphErrors *gr44 = new TGraphErrors(kfitbins,p,mean44,ep,sigma44);
3063 TString title44("C(C,C)"); title44.Prepend(part);
3064 TH2F *frame44 = new TH2F("frame44",title44.Data(),2,0.1,50,2,0,2e-9);
3065 frame44->SetXTitle("p [GeV/c]");
3066 canv44->cd(1); gPad->SetLogx();
3069 // Sets initial values for parameters
3070 func->SetParameters(1.8e-10,5.8e-11,2.);
3071 // Fit points in range defined by function
3072 gr44->Fit("RegFunc","R,Q");
3073 func->GetParameters(fitpar);
3074 for(Int_t i=0; i<3; i++) fitRes(8,i)=fitpar[i];
3075 for(Int_t l=0; l<kfitbins; l++) {
3076 rmean[l] = mean44[l]/RegFunc(&p[l],fitpar);
3077 rsigma[l] = sigma44[l]/RegFunc(&p[l],fitpar);
3079 // create the graph the regularized cov. matrix
3080 TGraphErrors *gr44reg = new TGraphErrors(kfitbins,p,rmean,ep,rsigma);
3081 TString regtitle44("C(C,C)/(A_meas+A_scatt/p^{B})");
3082 regtitle44.Prepend(part);
3083 TH2F *frame44reg = new TH2F("frame44reg",regtitle44.Data(),2,0.1,50,2,0,2);
3084 frame44reg->SetXTitle("p [GeV/c]");
3085 canv44->cd(2); gPad->SetLogx();
3095 new(&fRegParPi) TMatrixD(fitRes);
3098 new(&fRegParKa) TMatrixD(fitRes);
3101 new(&fRegParPr) TMatrixD(fitRes);
3104 new(&fRegParEl) TMatrixD(fitRes);
3107 new(&fRegParMu) TMatrixD(fitRes);
3111 // write fit parameters to file
3112 WriteRegParams(outName,pdg);
3149 //-----------------------------------------------------------------------------
3150 Bool_t AliTPCtrackerParam::SelectedTrack(Double_t pt,Double_t eta) const {
3151 //-----------------------------------------------------------------------------
3152 // This function makes a selection according to TPC tracking efficiency
3153 //-----------------------------------------------------------------------------
3157 eff = fEff->GetValueAt(pt,eta);
3159 if(gRandom->Rndm() < eff) return kTRUE;
3163 //-----------------------------------------------------------------------------
3164 void AliTPCtrackerParam::SetParticle(Int_t pdg) {
3165 //-----------------------------------------------------------------------------
3166 // This function set efficiencies, pulls, etc... for the particle
3167 // specie of the current particle
3168 //-----------------------------------------------------------------------------
3172 fDBgrid = &fDBgridPi;
3175 fRegPar = &fRegParPi;
3176 fdEdxMean = &fdEdxMeanPi;
3177 fdEdxRMS = &fdEdxRMSPi;
3180 fDBgrid = &fDBgridKa;
3183 fRegPar = &fRegParKa;
3184 fdEdxMean = &fdEdxMeanKa;
3185 fdEdxRMS = &fdEdxRMSKa;
3188 fDBgrid = &fDBgridPr;
3191 fRegPar = &fRegParPr;
3192 fdEdxMean = &fdEdxMeanPr;
3193 fdEdxRMS = &fdEdxRMSPr;
3196 fDBgrid = &fDBgridEl;
3199 fRegPar = &fRegParEl;
3200 fdEdxMean = &fdEdxMeanEl;
3201 fdEdxRMS = &fdEdxRMSEl;
3204 fDBgrid = &fDBgridMu;
3207 fRegPar = &fRegParMu;
3208 fdEdxMean = &fdEdxMeanMu;
3209 fdEdxRMS = &fdEdxRMSMu;
3215 //-----------------------------------------------------------------------------
3216 void AliTPCtrackerParam::SmearTrack(Double_t *xx,Double_t *xxsm,TMatrixD cov)
3218 //-----------------------------------------------------------------------------
3219 // This function smears track parameters according to streched cov. matrix
3220 //-----------------------------------------------------------------------------
3221 AliGausCorr *corgen = new AliGausCorr(cov,5);
3223 corgen->GetGaussN(corr);
3227 for(Int_t l=0;l<5;l++) {
3228 xxsm[l] = xx[l]+corr[l];
3233 //-----------------------------------------------------------------------------
3234 Int_t AliTPCtrackerParam::WritedEdx(const Char_t *outName,Int_t pdg) {
3235 //-----------------------------------------------------------------------------
3236 // This function writes the dEdx parameters to the DB
3237 //-----------------------------------------------------------------------------
3240 const char *dirName="Pions";
3241 const char *meanName="dEdxMeanPi";
3242 const char *rmsName="dEdxRMSPi";
3246 if(gSystem->AccessPathName(outName,kFileExists)) { opt="recreate";
3247 } else { opt="update"; }
3252 meanName="dEdxMeanPi";
3253 rmsName="dEdxRMSPi";
3257 meanName="dEdxMeanKa";
3258 rmsName="dEdxRMSKa";
3262 meanName="dEdxMeanPr";
3263 rmsName="dEdxRMSPr";
3266 dirName="Electrons";
3267 meanName="dEdxMeanEl";
3268 rmsName="dEdxRMSEl";
3272 meanName="dEdxMeanMu";
3273 rmsName="dEdxRMSMu";
3277 TFile *outFile = new TFile(outName,opt);
3278 if(!gDirectory->cd("/dEdx")) {
3279 outFile->mkdir("dEdx");
3280 gDirectory->cd("/dEdx");
3282 TDirectory *dir2 = gDirectory->mkdir(dirName);
3284 fdEdxMean->SetName(meanName); fdEdxMean->Write();
3285 fdEdxRMS->SetName(rmsName); fdEdxRMS->Write();
3293 //-----------------------------------------------------------------------------
3294 Int_t AliTPCtrackerParam::WriteEffs(const Char_t *outName) {
3295 //-----------------------------------------------------------------------------
3296 // This function writes the TPC efficiencies to the DB
3297 //-----------------------------------------------------------------------------
3302 if(gSystem->AccessPathName(outName,kFileExists)) { opt="recreate";
3303 } else { opt="update"; }
3305 TFile *outFile = new TFile(outName,opt);
3307 outFile->mkdir("Efficiencies");
3308 gDirectory->cd("/Efficiencies");
3309 gDirectory->mkdir("Pions");
3310 gDirectory->mkdir("Kaons");
3311 gDirectory->mkdir("Protons");
3312 gDirectory->mkdir("Electrons");
3313 gDirectory->mkdir("Muons");
3315 gDirectory->cd("/Efficiencies/Pions");
3316 fEffPi.SetName("EffPi");
3318 gDirectory->cd("/Efficiencies/Kaons");
3319 fEffKa.SetName("EffKa");
3321 gDirectory->cd("/Efficiencies/Protons");
3322 fEffPr.SetName("EffPr");
3324 gDirectory->cd("/Efficiencies/Electrons");
3325 fEffEl.SetName("EffEl");
3327 gDirectory->cd("/Efficiencies/Muons");
3328 fEffMu.SetName("EffMu");
3337 //-----------------------------------------------------------------------------
3338 Int_t AliTPCtrackerParam::WritePulls(const Char_t *outName) {
3339 //-----------------------------------------------------------------------------
3340 // This function writes the pulls to the DB
3341 //-----------------------------------------------------------------------------
3345 if(gSystem->AccessPathName(outName,kFileExists)) { opt="recreate";
3346 } else { opt="update"; }
3348 TFile *outFile = new TFile(outName,opt);
3350 outFile->mkdir("Pulls");
3351 gDirectory->cd("/Pulls");
3352 gDirectory->mkdir("Pions");
3353 gDirectory->mkdir("Kaons");
3354 gDirectory->mkdir("Protons");
3355 gDirectory->mkdir("Electrons");
3356 gDirectory->mkdir("Muons");
3358 for(Int_t i=0;i<5;i++) {
3359 TString pi("PullsPi_"); pi+=i;
3360 TString ka("PullsKa_"); ka+=i;
3361 TString pr("PullsPr_"); pr+=i;
3362 TString el("PullsEl_"); el+=i;
3363 TString mu("PullsMu_"); mu+=i;
3364 fPullsPi[i].SetName(pi.Data());
3365 fPullsKa[i].SetName(ka.Data());
3366 fPullsPr[i].SetName(pr.Data());
3367 fPullsEl[i].SetName(el.Data());
3368 fPullsMu[i].SetName(mu.Data());
3369 gDirectory->cd("/Pulls/Pions");
3370 fPullsPi[i].Write();
3371 gDirectory->cd("/Pulls/Kaons");
3372 fPullsKa[i].Write();
3373 gDirectory->cd("/Pulls/Protons");
3374 fPullsPr[i].Write();
3375 gDirectory->cd("/Pulls/Electrons");
3376 fPullsEl[i].Write();
3377 gDirectory->cd("/Pulls/Muons");
3378 fPullsMu[i].Write();
3385 //-----------------------------------------------------------------------------
3386 Int_t AliTPCtrackerParam::WriteRegParams(const Char_t *outName,Int_t pdg) {
3387 //-----------------------------------------------------------------------------
3388 // This function writes the regularization parameters to the DB
3389 //-----------------------------------------------------------------------------
3392 const char *dirName="Pions";
3393 const char *keyName="RegPions";
3397 if(gSystem->AccessPathName(outName,kFileExists)) { opt="recreate";
3398 } else { opt="update"; }
3411 keyName="RegProtons";
3414 dirName="Electrons";
3415 keyName="RegElectrons";
3423 TFile *outFile = new TFile(outName,opt);
3424 if(!gDirectory->cd("/RegParams")) {
3425 outFile->mkdir("RegParams");
3426 gDirectory->cd("/RegParams");
3428 TDirectory *dir2 = gDirectory->mkdir(dirName);
3430 fRegPar->Write(keyName);
3438 //-----------------------------------------------------------------------------
3439 //*****************************************************************************
3440 //-----------------------------------------------------------------------------