2 // This macro draws time resolution for true hypothesis and fits it with gausian
3 // on a given reference plane in a given momentum range.
4 // The results is then printed to a PostScript file.
5 // The filename is composed out of input parameters.
8 // nRefPlane - indicate the reference plane.
13 // minP, maxP - total momentum cuts. momentum from gAlice are used for cuts
15 // The macro is using SORTED reference points in a file "trackRef.root".
16 // Track references can be sorted using CopyReferences.C
18 // Before using check filenames and names of trees invlolved
20 // ITS tracks (nRefPlane == 1) are compared at inner TPC ref Plane
21 // make shure they are properly propagated to this plane
23 // Sylwester Radomski, e-mail: S.Radomski@gsi.de
28 CompareTime (Int_t nRefPlane, Double_t minP, Double_t maxP)
31 // Check input data Consistancy
32 if (nRefPlane < 1 || nRefPlane > 3) {
33 cout << "Wrong Reference Plane Id ( " << nRefPalne << ") [1-3] " << endl;
38 cout << "MaxP lesser than MinP" << endl;
44 gROOT->SetStyle("Plain");
45 gStyle->SetOptStat(1110);
46 gStyle->SetOptFit(11);
48 Double_t cc = 0.299792458;
49 AliKalmanTrack::SetConvConst(100/cc/0.4);
51 const char* gFileName = "galice.root";
52 const char* refFileName = "trackRef.root";
54 const char* trackFileName[] = {"AliTPCtracks.root", "AliTPCBackTracks.root", "AliTRDtracks.root"};
55 const char *treeName[] = {"TreeT_ITSb_0", "seedsTPCtoTRD_0", "TRDb_0"};
56 const char *refTreeName[] = {"TPC", "TPC", "TRD"};
60 const Int_t nTypes = 5;
61 Int_t codes[] = {11, 13, 211, 321, 2212};
63 //Double_t cutoff[] = {20, 20, 20, 100, 100};
64 Double_t cutoff[] = {30, 30, 30, 100, 200};
66 const char *names[nTypes] = {"Electrons", "Muons", "Pions", "Kaons", "Protons"};
68 TH1D *hDiffSame[nTypes];;
70 for(Int_t i=0; i<nTypes; i++)
71 hDiffSame[i] = new TH1D(names[i], names[i], 50, -cutoff[i], cutoff[i]);
73 TH1D *hLength = new TH1D("length", "Length Resolution", 100, -0.5, 0.5);
77 TFile *refFile = new TFile(gFileName, "READ");
78 gAlice = (AliRun*)refFile->Get("gAlice");
84 refFile = new TFile(refFileName, "READ");
85 TTree *treeRef = (TTree*)refFile->Get("TreeTR0_Sorted");
86 TBranch *trkRef = treeRef->GetBranch( refTreeName[nRefPlane-1] );
87 TClonesArray *trkRefs = new TClonesArray("AliTrackReference", 100);
88 trkRef->SetAddress(&trkRefs);
90 Int_t ntracks = trkRef->GetEntries();
91 cout << ntracks << endl;
95 TFile *trackFile = new TFile(trackFileName[nRefPlane-1]);
97 TTree *tracks = (TTree*)trackFile->Get(treeName[nRefPlane-1]);
98 TBranch *recTracks = tracks->GetBranch("tracks");
99 AliTPCtrack *track = 0;
100 recTracks->SetAddress(&track);
102 for(Int_t t=0; t<tracks->GetEntries(); t++) {
106 recTracks->GetEvent(t);
108 Int_t lab = track->GetLabel();
109 if (lab < 0 || lab > 100000) continue;
111 Int_t pdg = gAlice->Particle(lab)->GetPdgCode();
112 treeRef->GetEvent(lab);
114 Int_t nEntrRef = trkRefs->GetEntries();
116 if (gAlice->Particle(lab)->P() < minP ) continue;
117 if (gAlice->Particle(lab)->P() > maxP ) continue;
118 if (gAlice->Particle(lab)->GetFirstMother() != -1) continue;
120 if (!(nEntrRef)) continue;
122 Double_t timeTrue, timeTrack;
125 Int_t index = nEntrRef-1;
126 if (nRefPlane == 1) index = 0;
128 timeTrue = ((AliTrackReference*)(*trkRefs)[index])->GetTime() * 1e12;
129 trueLength = ((AliTrackReference*)(*trkRefs)[index])->GetLength();
131 hLength->Fill(trueLength - track->GetIntegratedLength());
133 for(Int_t i=0; i<nTypes; i++) {
134 timeTrack = track->GetIntegratedTime(codes[i]);
135 if (abs(pdg) == codes[i]) hDiffSame[i]->Fill(timeTrue - timeTrack);
139 TCanvas *c = new TCanvas();
140 c->SetCanvasSize(640, 800);
141 c->SetWindowSize(650, 830);
146 hLength->SetXTitle("True Length - Measured Length [cm]");
148 for(Int_t i=0; i<nTypes; i++) {
152 hDiffSame[i]->Draw();
153 hDiffSame[i]->SetXTitle("time true - measured [ps]");
154 hDiffSame[i]->Fit("gaus");
157 char outFileName[80];
158 const char *refPlaneNames[] = {"inTPC", "outTPC","outTRD"};
163 sprintf(outFileName, "time_%s_%3.2f-%3.2f.ps", refPlaneNames[nRefPlane-1], minP, maxP);
164 c->Print(outFileName);
166 if (treeRef) delete treeRef;
167 if (tracks) delete tracks;