1 //------------------------------------------------------------------------------
2 // Implementation of AliComparisonRes class. It keeps information from
3 // comparison of reconstructed and MC particle tracks. In addtion,
4 // it keeps selection cuts used during comparison. The comparison
5 // information is stored in the ROOT histograms. Analysis of these
6 // histograms can be done by using Analyse() class function. The result of
7 // the analysis (histograms) are stored in the output picture_res.root file.
9 // Author: J.Otwinowski 04/02/2008
10 //------------------------------------------------------------------------------
13 //after running analysis, read the file, and get component
14 gSystem->Load("libPWG1.so");
15 TFile f("Output.root");
16 AliComparisonRes * comp = (AliComparisonRes*)f.Get("AliComparisonRes");
18 // analyse comparison data (output stored in pictures_res.root)
21 // paramtetrisation of the TPC track length (for information only)
22 TF1 fl("fl","((min(250./(abs(x+0.000001)),250)-90))",0,2); // TPC track length function
23 TF1 fl2("fl2","[0]/((min(250./(abs(x+0.000001)),250)-90))^[1]",0,2);
24 fl2.SetParameter(1,1);
25 fl2.SetParameter(0,1);
36 #include "TProfile2D.h"
41 #include "AliESDEvent.h"
43 #include "AliESDfriend.h"
44 #include "AliESDfriendTrack.h"
45 #include "AliRecInfoCuts.h"
46 #include "AliMCInfoCuts.h"
49 #include "AliMathBase.h"
50 #include "AliTreeDraw.h"
52 #include "AliMCInfo.h"
53 #include "AliESDRecInfo.h"
54 #include "AliComparisonRes.h"
58 ClassImp(AliComparisonRes)
60 //_____________________________________________________________________________
61 AliComparisonRes::AliComparisonRes():
62 TNamed("AliComparisonRes","AliComparisonRes"),
65 fPtResolLPT(0), // pt resolution - low pt
66 fPtResolHPT(0), // pt resolution - high pt
67 fPtPullLPT(0), // pt resolution - low pt
68 fPtPullHPT(0), // pt resolution - high pt
70 // Resolution constrained param
72 fCPhiResolTan(0), // angular resolution - constrained
73 fCTanResolTan(0), // angular resolution - constrained
74 fCPtResolTan(0), // pt resolution - constrained
75 fCPhiPullTan(0), // angular resolution - constrained
76 fCTanPullTan(0), // angular resolution - constrained
77 fCPtPullTan(0), // pt resolution - constrained
87 //_____________________________________________________________________________
88 AliComparisonRes::~AliComparisonRes(){
90 // Resolution histograms
91 if(fPtResolLPT) delete fPtResolLPT; fPtResolLPT=0;
92 if(fPtResolHPT) delete fPtResolHPT; fPtResolHPT=0;
93 if(fPtPullLPT) delete fPtPullLPT; fPtPullLPT=0;
94 if(fPtPullHPT) delete fPtPullHPT; fPtPullHPT=0;
96 // Resolution histograms (constrained param)
97 if(fCPhiResolTan) delete fCPhiResolTan; fCPhiResolTan=0;
98 if(fCTanResolTan) delete fCTanResolTan; fCTanResolTan=0;
99 if(fCPtResolTan) delete fCPtResolTan; fCPtResolTan=0;
100 if(fCPhiPullTan) delete fCPhiPullTan; fCPhiPullTan=0;
101 if(fCTanPullTan) delete fCTanPullTan; fCTanPullTan=0;
102 if(fCPtPullTan) delete fCPtPullTan; fCPtPullTan=0;
105 //_____________________________________________________________________________
106 void AliComparisonRes::InitHisto(){
109 fCPhiResolTan = new TH2F("CPhiResolTan","CPhiResolTan",50, -2,2,200,-0.025,0.025);
110 fCPhiResolTan->SetXTitle("tan(#theta)");
111 fCPhiResolTan->SetYTitle("#Delta#phi");
113 fCTanResolTan = new TH2F("CTanResolTan","CTanResolTan",50, -2,2,200,-0.025,0.025);
114 fCTanResolTan->SetXTitle("tan(#theta)");
115 fCTanResolTan->SetYTitle("#Delta#theta");
117 fCPtResolTan=new TH2F("CPtResol","CPtResol",50, -2,2,200,-0.2,0.2);
118 fCPtResolTan->SetXTitle("Tan(#theta)");
119 fCPtResolTan->SetYTitle("#Deltap_{t}/p_{t}");
121 fCPhiPullTan = new TH2F("CPhiPullTan","CPhiPullTan",50, -2,2,200,-5,5);
122 fCPhiPullTan->SetXTitle("Tan(#theta)");
123 fCPhiPullTan->SetYTitle("#Delta#phi/#Sigma");
125 fCTanPullTan = new TH2F("CTanPullTan","CTanPullTan",50, -2,2,200,-5,5);
126 fCTanPullTan->SetXTitle("Tan(#theta)");
127 fCTanPullTan->SetYTitle("#Delta#theta/#Sigma");
129 fCPtPullTan=new TH2F("CPtPull","CPtPull",50, -2,2,200,-5,5);
130 fCPtPullTan->SetXTitle("Tan(#theta)");
131 fCPtPullTan->SetYTitle("(1/mcp_{t}-1/p_{t})/#Sigma");
133 fPtResolLPT = new TH2F("Pt_resol_lpt","pt resol",10, 0.1,3,200,-0.2,0.2);
134 fPtResolLPT->SetXTitle("p_{t}");
135 fPtResolLPT->SetYTitle("#Deltap_{t}/p_{t}");
137 fPtResolHPT = new TH2F("Pt_resol_hpt","pt resol",10, 2,100,200,-0.3,0.3);
138 fPtResolHPT->SetXTitle("p_{t}");
139 fPtResolHPT->SetYTitle("#Deltap_{t}/p_{t}");
141 fPtPullLPT = new TH2F("Pt_pull_lpt","pt pool",10, 0.1,3,200,-6,6);
142 fPtPullLPT->SetXTitle("p_{t}");
143 fPtPullLPT->SetYTitle("#Deltap_{t}/#Sigma");
145 fPtPullHPT = new TH2F("Pt_pull_hpt","pt pool",10, 2,100,200,-6,6);
146 fPtPullHPT->SetXTitle("p_{t}");
147 fPtPullHPT->SetYTitle("#Deltap_{t}/#Sigma");
150 //_____________________________________________________________________________
151 void AliComparisonRes::InitCuts()
155 fCutsRC = new AliRecInfoCuts();
157 fCutsRC->SetPtRange(0.15,200.0);
158 fCutsRC->SetMaxAbsTanTheta(1.0);
159 fCutsRC->SetMinNClustersTPC(10);
160 fCutsRC->SetMinTPCsignalN(50);
162 AliDebug(AliLog::kError, "ERROR: Cannot create AliRecInfoCuts object");
166 fCutsMC = new AliMCInfoCuts();
168 fCutsMC->SetMinRowsWithDigits(50);
169 fCutsMC->SetMaxR(0.1);
170 fCutsMC->SetMaxVz(10.);
171 fCutsMC->SetRangeTPCSignal(0.5,1.4);
173 AliDebug(AliLog::kError, "ERROR: Cannot AliMCInfoCuts object");
179 AliDebug(AliLog::kError, "ERROR: Cannot find AliMCInfoCuts object");
181 AliDebug(AliLog::kError, "ERROR: Cannot find AliRecInfoCuts object");
184 //_____________________________________________________________________________
185 void AliComparisonRes::Process(AliMCInfo* infoMC, AliESDRecInfo *infoRC)
187 // Fill resolution comparison information
189 Float_t mcpt = infoMC->GetParticle().Pt();
190 Bool_t isPrim = infoMC->GetParticle().R() < fCutsMC->GetMaxR() &&
191 TMath::Abs(infoMC->GetParticle().Vz()) < fCutsMC->GetMaxVz() ;
193 // Check selection cuts
194 if (fCutsMC->IsPdgParticle(TMath::Abs(infoMC->GetParticle().GetPdgCode())) == kFALSE) return;
196 if (infoRC->GetStatus(1)==0) return;
197 if (!infoRC->GetESDtrack()) return;
198 if (infoRC->GetESDtrack()->GetTPCNcls()<fCutsRC->GetMinNClustersTPC()) return;
200 Float_t deltaPt= (mcpt-infoRC->GetESDtrack()->Pt())/mcpt;
201 Float_t pullPt= (1/mcpt-infoRC->GetESDtrack()->OneOverPt())/TMath::Sqrt(infoRC->GetESDtrack()->GetSigma1Pt2());
204 fPtResolLPT->Fill(mcpt,deltaPt);
205 fPtResolHPT->Fill(mcpt,deltaPt);
206 fPtPullLPT->Fill(mcpt,pullPt);
207 fPtPullHPT->Fill(mcpt,pullPt);
210 Long64_t AliComparisonRes::Merge(TCollection* list)
212 // Merge list of objects (needed by PROOF)
220 TIterator* iter = list->MakeIterator();
223 // collection of generated histograms
225 while((obj = iter->Next()) != 0)
227 AliComparisonRes* entry = dynamic_cast<AliComparisonRes*>(obj);
229 Error("Add","Attempt to add object of class: %s to a %s",
230 obj->ClassName(),this->ClassName());
234 fPtResolLPT->Add(entry->fPtResolLPT);
235 fPtResolHPT->Add(entry->fPtResolHPT);
236 fPtPullLPT->Add(entry->fPtPullLPT);
237 fPtPullHPT->Add(entry->fPtPullHPT);
239 // Resolution histograms (constrained param)
240 fCPhiResolTan->Add(entry->fCPhiResolTan);
241 fCTanResolTan->Add(entry->fCTanResolTan);
242 fCPtResolTan->Add(entry->fCPtResolTan);
243 fCPhiPullTan->Add(entry->fCPhiPullTan);
244 fCTanPullTan->Add(entry->fCTanPullTan);
245 fCPtPullTan->Add(entry->fCPtPullTan);
257 //_____________________________________________________________________________
258 void AliComparisonRes::ProcessConstrained(AliMCInfo* infoMC, AliESDRecInfo *infoRC)
260 // Fill resolution comparison information (constarained parameters)
262 Float_t mcpt = infoMC->GetParticle().Pt();
263 Float_t tantheta = TMath::Tan(infoMC->GetParticle().Theta()-TMath::Pi()*0.5);
264 Bool_t isPrim = infoMC->GetParticle().R()<fCutsMC->GetMaxR() && TMath::Abs(infoMC->GetParticle().Vz())<fCutsMC->GetMaxVz();
266 // Check selection cuts
267 if (fCutsMC->IsPdgParticle(TMath::Abs(infoMC->GetParticle().GetPdgCode())) == kFALSE) return;
269 if (infoRC->GetStatus(1)!=3) return;
270 if (!infoRC->GetESDtrack()) return;
271 if (infoRC->GetESDtrack()->GetTPCNcls()<fCutsRC->GetMinNClustersTPC()) return;
272 if (!infoRC->GetESDtrack()->GetConstrainedParam()) return;
274 // constrained parameters resolution
275 const AliExternalTrackParam * cparam = infoRC->GetESDtrack()->GetConstrainedParam();
276 Float_t deltaCPt= (mcpt-cparam->Pt())/mcpt;
277 Float_t pullCPt= (1/mcpt-cparam->OneOverPt())/
278 TMath::Sqrt(cparam->GetSigma1Pt2());
279 Float_t deltaPhi = TMath::ATan2(cparam->Py(),cparam->Px())-
280 TMath::ATan2(infoMC->GetParticle().Py(),infoMC->GetParticle().Px());
281 Float_t pullPhi = deltaPhi/TMath::Sqrt(cparam->GetSigmaSnp2());
283 Float_t deltaTan = TMath::ATan2(cparam->Pz(),cparam->Pt())-TMath::ATan2(infoMC->GetParticle().Pz(),infoMC->GetParticle().Pt());
284 Float_t pullTan = deltaPhi/TMath::Sqrt(cparam->GetSigmaSnp2());
287 fCPtResolTan->Fill(tantheta,deltaCPt);
288 fCPtPullTan->Fill(tantheta,pullCPt);
289 fCPhiResolTan->Fill(tantheta,deltaPhi);
290 fCPhiPullTan->Fill(tantheta,pullPhi);
291 fCTanResolTan->Fill(tantheta,deltaTan);
292 fCTanPullTan->Fill(tantheta,pullTan);
295 //_____________________________________________________________________________
296 void AliComparisonRes::Exec(AliMCInfo* infoMC, AliESDRecInfo *infoRC){
298 // Process comparison information
299 Process(infoMC,infoRC);
300 ProcessConstrained(infoMC,infoRC);
304 //_____________________________________________________________________________
305 TH1F* AliComparisonRes::MakeResol(TH2F * his, Int_t integ, Bool_t type){
306 // Create resolution histograms
309 if (!gPad) new TCanvas;
310 hisr = AliTreeDraw::CreateResHistoI(his,&hism,integ);
311 if (type) return hism;
316 //_____________________________________________________________________________
317 void AliComparisonRes::Analyse(){
318 // Analyse comparison information and store output histograms
319 // in the "pictures_res.root" file
321 AliComparisonRes * comp=this;
324 TFile *fp = new TFile("pictures_res.root","recreate");
327 TCanvas * c = new TCanvas("Phi resol Tan","Phi resol Tan");
330 hiss = comp->MakeResol(comp->fCPtResolTan,1,0);
331 hiss->SetXTitle("Tan(#theta)");
332 hiss->SetYTitle("#sigmap_{t}/p_{t}");
334 hiss->Write("CptResolTan");
336 hiss = comp->MakeResol(comp->fCPhiResolTan,1,0);
337 hiss->SetXTitle("Tan(#theta)");
338 hiss->SetYTitle("#sigma#phi (rad)");
340 hiss->Write("PhiResolTan");
342 hiss = comp->MakeResol(comp->fCTanResolTan,1,0);
343 hiss->SetXTitle("Tan(#theta)");
344 hiss->SetYTitle("#sigma#theta (rad)");
346 hiss->Write("ThetaResolTan");
348 hiss = comp->MakeResol(comp->fCPtPullTan,1,0);
349 hiss->SetXTitle("Tan(#theta)");
350 hiss->SetYTitle("1/mcp_{t}-1/p_{t}/#Sigma(1/p_{t})");
352 hiss->Write("CptPullTan");