2 // This macro draws time resolution for true and false particle hypothesis
3 // on a given reference plane in a given momentum range.
4 // True hypothesis is painted in BLUE while false in RED
7 // nRefPlane - indicate the reference plane.
12 // minP, maxP - total momentum cuts. momentum from gAlice are used for cuts
14 // The macro is using SORTED reference points in a file "trackRef.root".
15 // Track references can be sorted using CopyReferences.C
17 // Before using check filenames and names of trees invlolved
19 // ITS tracks (nRefPlane == 1) are compared at inner TPC ref Plane
20 // make shure they are properly propagated to this plane.
22 // Sylwester Radomski, e-mail: S.Radomski@gsi.de
26 CompareTimeHypothesis (Int_t nRefPlane, Double_t minP, Double_t maxP) {
28 // Check input data Consistancy
30 if (nRefPlane < 1 || nRefPlane > 3) {
31 cout << "Wrong Reference Plane Id ( " << nRefPalne << ") [1-3] " << endl;
36 cout << "MaxP lesser than MinP" << endl;
41 gROOT->SetStyle("Plain");
42 gStyle->SetOptStat(1111);
43 gStyle->SetStatH(0.2);
44 gStyle->SetStatW(0.3);
46 // magnetic field 0.4 T
47 Double_t cc = 0.299792458;
48 AliKalmanTrack::SetConvConst(100/cc/0.4);
50 const char* gFileName = "galice.root";
51 const char* refFileName = "trackRef.root";
53 const char* trackFileName[] = {"AliTPCtracks.root", "AliTPCBackTracks.root", "AliTRDtracks.root"};
54 const char *treeName[] = {"TreeT_ITSb_0", "seedsTPCtoTRD_0", "TRDb_0"};
55 const char *refTreeName[] = {"TPC", "TPC", "TRD"};
59 const Int_t nTypes = 5;
60 Int_t codes[] = {11, 13, 211, 321, 2212};
62 //Double_t cutoff[] = {20, 20, 20, 100, 100};
63 Double_t cutoff[] = {30, 30, 30, 100, 200};
65 const char *names[3*nTypes] = {
66 "Electrons", "Muons", "Pions", "Kaons", "Protons",
67 "11s", "13s", "211s", "321s", "2212s",
68 "11o", "13o", "211o", "321o", "2212o"
71 THStack *stack[nTypes];
72 TH1D *hDiffSame[nTypes], *hDiffOdd[nTypes];
74 for(Int_t i=0; i<nTypes; i++) {
76 stack[i] = new THStack(names[i], names[i]);
77 hDiffSame[i] = new TH1D(names[nTypes+i], names[nTypes+i], 50, -cutoff[i], cutoff[i]);
78 hDiffOdd[i] = new TH1D(names[2*nTypes+i], names[2*nTypes+i], 50, -cutoff[i], cutoff[i]);
80 hDiffSame[i]->SetFillColor(kBlue);
81 hDiffOdd[i]->SetFillColor(kRed);
83 //hDiffSame[i]->SetFillStyle(3003);
84 //hDiffOdd[i]->SetFillStyle(3008);
86 stack[i]->Add(hDiffOdd[i]);
87 stack[i]->Add(hDiffSame[i]);
90 TH1D *hLength = new TH1D("length", "Length Resolution", 100, -0.5, 0.5);
94 TFile *refFile = new TFile(gFileName, "READ");
95 gAlice = (AliRun*)refFile->Get("gAlice");
101 refFile = new TFile(refFileName, "READ");
102 TTree *treeRef = (TTree*)refFile->Get("TreeTR0_Sorted");
103 TBranch *trkRef = treeRef->GetBranch(refTreeName[nRefPlane-1]);
104 TClonesArray *trkRefs = new TClonesArray("AliTrackReference", 100);
105 trkRef->SetAddress(&trkRefs);
107 Int_t ntracks = trkRef->GetEntries();
108 cout << ntracks << endl;
112 TFile *trackFile = new TFile(trackFileName[nRefPlane-1]);
113 TTree *tracks = (TTree*)trackFile->Get(treeName[nRefPlane-1]);
114 TBranch *trkTracks = tracks->GetBranch("tracks");
115 AliTPCtrack *track = 0;
116 trkTracks->SetAddress(&track);
118 for(Int_t t=0; t<tracks->GetEntries(); t++) {
122 trkTracks->GetEvent(t);
124 Int_t lab = track->GetLabel();
125 if (lab < 0 || lab > 100000) continue;
127 Int_t pdg = gAlice->Particle(lab)->GetPdgCode();
128 treeRef->GetEvent(lab);
130 Int_t nEntrTRK = trkRefs->GetEntries();
132 // Primaries within momentum range
133 if (gAlice->Particle(lab)->P() < minP ) continue;
134 if (gAlice->Particle(lab)->P() > maxP ) continue;
135 if (gAlice->Particle(lab)->GetFirstMother() != -1) continue;
136 if (!(nEntrTRK)) continue;
138 Double_t timeTrue, timeTrack;
141 Int_t index = nEntrTRK-1;
142 if (nRefPlane == 1) index = 0;
144 timeTrue = ((AliTrackReference*)(*trkRefs)[index])->GetTime() * 1e12;
146 //timeTrue = gRandom->Gaus(timeTrue, 10);
148 trueLength = ((AliTrackReference*)(*trkRefs)[index])->GetLength();
149 hLength->Fill(trueLength - track->GetIntegratedLength());
151 for(Int_t i=0; i<nTypes; i++) {
153 timeTrack = track->GetIntegratedTime(codes[i]);
154 if (abs(pdg) == codes[i]) hDiffSame[i]->Fill(timeTrue - timeTrack);
155 else hDiffOdd[i]->Fill(timeTrue - timeTrack);
159 TCanvas *c = new TCanvas();
160 c->SetWindowSize(640, 800);
165 hLength->SetXTitle("True Length - Measured Length [cm]");
167 for(Int_t i=0; i<nTypes; i++) {
172 stack[i]->GetXaxis()->SetTitle("time true - measured [ps]");
175 if (treeRef) delete treeRef;
176 if (tracks) delete tracks;