FairRoot/PandaRoot
anaMvdPid.C
Go to the documentation of this file.
1 {
2 // Analysis for PndMvdAdvancedPidAlgo: run runMvdSim.C and runMvdPidIdeal.C
3 // before running this. An energyloss over momentum plot is drawn as well as
4 // a histo of the generated likelihoods, and a histo of 'fake' likelihoods
5 // that are created with the algo's own parameterisation.
6 // This macro has been tested with rev 2503 so far.
7 
8  // ----- Load libraries ------------------------------------------------
9  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
10  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
11 
12  // ----- Timer --------------------------------------------------------
13  TStopwatch timer;
14  timer.Start();
15  // ------------------------------------------------------------------------
16  //opening tree
17  TFile* inFile = new TFile("MvdPidIdeal.root","READ");
18  TTree* tree = (TTree *)inFile->Get("pndsim");
19  TClonesArray* pointlist=new TClonesArray("PndMvdPidCand");
20  tree->SetBranchAddress("PndMvdPidCand", &pointlist);
21 
22 
23  TH2F* h1=new TH2F("h1", "likelihood count", 100, 0.0, 2.5, 100, 0.0, 1.0);
24  TH2F* h2=new TH2F("h2", "energy loss", 100, 0.0, 2.5, 100, 0.0, 0.05);
25  TH2F* h3=new TH2F("h3", "ideal likelihood count", 100, 0.0, 2.5, 100, 0.0, 1.0);
26 
27  //variable
28 
29  Int_t nEvents = 10000;
30 
31  for(int j=0;j<nEvents && j<tree->GetEntriesFast();j++) {
32  tree->GetEntry(j);
33  for(int i=0;i<pointlist->GetEntriesFast();i++) {
34  PndMvdPidCand* cand=(PndMvdPidCand*)pointlist->At(i);
35  PndMvdPidCand* idealcand=new PndMvdPidCand();
36 
37 
38  double dE=0;
39  double dx=0;
40  double momentum=0;
41 
42  for (int k=0;k<cand->GetMvdHits(); k++) {
43  dE+=cand->GetMvdHitdE(k);
44  dx+=cand->GetMvdHitdx(k);
45  momentum+=cand->GetMvdHitMomentum(k);
46  }
47 
48  if (dx>0)
49  momentum/=cand->GetMvdHits();
50 
51  PndMvdAdvancedPidAlgo::CalcLikelihood(PndMvdAdvancedPidAlgo::proton, momentum, idealcand);
52  h2->Fill(momentum, dE/dx);
53  h1->Fill(momentum, cand->GetLikelihood(2212));
54  h3->Fill(momentum, idealcand->GetLikelihood(2212));
55  }
56  }
57  TCanvas* c;
58  h1->Draw();
59  c=new TCanvas("c2");
60  h2->Draw();
61  c=new TCanvas("c3");
62  h3->Draw();
63 
64  // ----- Finish -------------------------------------------------------
65  timer.Stop();
66  Double_t rtime = timer.RealTime();
67  Double_t ctime = timer.CpuTime();
68  cout << endl << endl;
69  cout << "Macro finished succesfully." << endl;
70  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
71  cout << endl;
72  // ------------------------------------------------------------------------
73 }
TClonesArray * pointlist
Definition: anaMvdPid.C:19
Int_t i
Definition: run_full.C:25
double GetMvdHitdx(int mvdhit) const
double GetLikelihood(int lundId)
TH2F * h2
Definition: anaMvdPid.C:24
double GetMvdHitMomentum(int mvdhit) const
Double_t
Double_t dE
Definition: anasim.C:58
static void CalcLikelihood(PndMvdPidCand *cand)
TFile * inFile
Definition: anaMvdPid.C:17
Double_t rtime
Definition: anaMvdPid.C:66
double dx
Double_t ctime
Definition: anaMvdPid.C:67
TH2F * h3
Definition: anaMvdPid.C:25
TTree * tree
Definition: anaMvdPid.C:18
Int_t nEvents
Definition: anaMvdPid.C:29
double GetMvdHitdE(int mvdhit) const
TCanvas * c
Definition: anaMvdPid.C:57
TH2F * h1
Definition: anaMvdPid.C:23
int GetMvdHits() const
TStopwatch timer
Definition: anaMvdPid.C:13