FairRoot/PandaRoot
piddraw.C
Go to the documentation of this file.
1 {
2  // ---- Load libraries -------------------------------------------------
3  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
4  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
5 
6  // ----- Timer --------------------------------------------------------
7  TStopwatch timer;
8  timer.Start();
9  // ------------------------------------------------------------------------
10 
11  gStyle->SetHistFillColor(9);
12  gStyle->SetCanvasColor(0);
13  gStyle->SetLabelSize(0.025,"X");
14  gStyle->SetLabelSize(0.025,"Y");
15  gStyle->SetTitleSize(0.03,"Y");
16  gStyle->SetBarOffset(10);
17  gStyle->SetTitleOffset(1,"X");
18  gStyle->SetTitleOffset(1.55,"Y");
19  gStyle->SetTitleSize(0.03,"X");
20  gStyle->SetPalette(1,0);
21  gStyle->SetOptFit(1111);
22 
23  //opening tree
24  TFile* inFile = new TFile("../data/MvdMC_Pid_10k.root","READ");
25  TTree* tree = (TTree *)inFile->Get("pndsim");
26  TClonesArray* pointlist=new TClonesArray("PndSdsMCPoint");
27  tree->SetBranchAddress("MVDPoint",&pointlist);
28 
29  //Creating canvas and diagramms
30  TH2D * hist10 = new TH2D("specEnergyLossVsP","dE/dx(p)",200,0.0,1,200,0,0.0005);
31  hist10->SetYTitle("(dE/dx)/(GeV/cm)");
32  hist10->SetXTitle("p/(GeV/c)");
33 
34  //variable
35  TVector3 vecFront,vecBack,vecP;
36  Int_t nEvents = 5000; //1000;
38 
39 
40  for(int j=0;j<nEvents && j<tree->GetEntriesFast();j++)
41  {
42  tree->GetEntry(j);
43  for(int i=0;i<pointlist->GetEntriesFast();i++)
44  {
45  PndSdsMCPoint* point=(PndSdsMCPoint*)pointlist->At(i);
46 
47  vecFront.SetXYZ(point->GetX(),point->GetY(),point->GetZ());
48  vecBack.SetXYZ(point->GetXOut(),point->GetYOut(),point->GetZOut());
49  vecP.SetXYZ(point->GetPxOut(),point->GetPyOut(),point->GetPzOut());
50 
51  dx=(vecBack-vecFront).Mag();
52  dE=point->GetEnergyLoss();
53  p=vecP.Mag();
54 
55  if(dx!=0)
56  {
57  dEdX=(dE/dx);
58  hist10->Fill(p,dE);
59  }
60  }
61  }
62 
63  TCanvas* can1 = new TCanvas("test","Energy in MVD",20,20,800,600);
64 
65  hist10->DrawCopy("col");
66  // ----- Finish -------------------------------------------------------
67  timer.Stop();
68  Double_t rtime = timer.RealTime();
69  Double_t ctime = timer.CpuTime();
70  cout << endl << endl;
71  cout << "Macro finished succesfully." << endl;
72  cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
73  cout << endl;
74  // ------------------------------------------------------------------------
75 }
TCanvas * can1
Definition: piddraw.C:63
Double_t GetXOut() const
Definition: PndSdsMCPoint.h:81
TStopwatch timer
Definition: piddraw.C:7
Int_t i
Definition: run_full.C:25
Double_t GetPyOut() const
Definition: PndSdsMCPoint.h:86
TVector3 vecBack
Definition: piddraw.C:35
Double_t dE
Definition: piddraw.C:37
Double_t GetZOut() const
Definition: PndSdsMCPoint.h:83
Double_t p
Definition: piddraw.C:37
Double_t GetPxOut() const
Definition: PndSdsMCPoint.h:85
TVector3 vecFront
Definition: piddraw.C:35
TClonesArray * pointlist
Definition: piddraw.C:26
Double_t GetPzOut() const
Definition: PndSdsMCPoint.h:87
Double_t
Double_t rtime
Definition: piddraw.C:68
TClonesArray * point
Definition: anaLmdDigi.C:29
Double_t ctime
Definition: piddraw.C:69
Double_t dx
Definition: piddraw.C:37
Int_t nEvents
Definition: piddraw.C:36
TVector3 vecP
Definition: piddraw.C:35
Double_t GetYOut() const
Definition: PndSdsMCPoint.h:82
Double_t dEdX
Definition: piddraw.C:37
TFile * inFile
Definition: piddraw.C:24
TH2D * hist10
Definition: piddraw.C:30
TTree * tree
Definition: piddraw.C:25