FairRoot/PandaRoot
reco_apd.C
Go to the documentation of this file.
1 {
2 // Macro loads a file after reconstruction and plots difference between initial direction of particle and angular position of cluster
3 
4 gROOT->LoadMacro("$VMCWORKDIR/gconfig/rootlogon.C");
5 gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
6 rootlogon();
7 basiclibs();
8 
9 TFile* f = new TFile("hit_emc_apd.root"); //file you want to analyse
10 TTree *t=(TTree *) f->Get("pndsim") ;
11 
12 TClonesArray* hit_array=new TClonesArray("PndEmcApdHit");
13 t->SetBranchAddress("EmcApdHit",&hit_array);
14 
15 TFile* fsim = new TFile("sim_emc_apd.root"); //file you want to analyse
16 TTree *tsim=(TTree *) fsim->Get("pndsim") ;
17 TClonesArray* mctrack_array=new TClonesArray("PndMCTrack");
18 tsim->SetBranchAddress("MCTrack",&mctrack_array);
19 
20 Float_t energy = 0;
21 Int_t ntrack = 0;
22 
23 
24 TH1F *hEnergy = new TH1F("hEnergy","Energy Loss",200,0,1); hEnergy->GetXaxis()->SetTitle("Energy Loss [MeV]");
25 TH1F *hMult = new TH1F("hMult","Particle Multiplicity",15,-0.5,14.5);; hMult->GetXaxis()->SetTitle("MCTrack Multiplicity");
26 TH1F *hMom = new TH1F("hMom","Particle Momentum",150,0,1.5); hMom->GetXaxis()->SetTitle("Particle Momentum[GeV/c]");
27 
28 // Loop over hit
29 for (Int_t j=0; j< t->GetEntriesFast(); j++)
30 {
31  t->GetEntry(j);
32  tsim->GetEntry(j);
33 
34  for (Int_t i=0; i<hit_array->GetEntriesFast(); i++)
35  {
36  PndEmcApdHit *apd=(PndEmcApdHit*)hit_array->At(i);
38  ntrack = apd->GetNPoints();
39 
40  hEnergy->Fill(hit_energy*1000.);
41  hMult->Fill(ntrack);
42  cout << "# Particles in APD: " << ntrack << endl;
43  for (Int_t tt=0; tt<ntrack; tt++)
44  {
45  cout << apd->GetMCIndex(tt) << endl;
46  PndMCTrack* mctrack=(PndMCTrack *) mctrack_array->At(apd->GetMCIndex(tt));
47  cout << "Particle ID: " << mctrack->GetPdgCode()<< endl;
48  hMom->Fill(mctrack->GetMomentum().Mag());
49  } // end of MC loop
50  } // end of hit loop
51 }
52 
53 
54 
55 TCanvas* c1 = new TCanvas("c1", "Energy Loss in APDs", 100, 100, 800, 800);
56 hEnergy->Draw();
57 
58 TCanvas* c2 = new TCanvas("c2", "Particles in APDs", 100, 100, 800, 800);
59 hMult->Draw();
60 
61 TCanvas* c3 = new TCanvas("c3", "Particle Momentum in APDs", 100, 100, 800, 800);
62 hMom->Draw();
63 
64 
65 
66 }
67 
PndMCTrack * mctrack
Int_t ntrack
Definition: reco_apd.C:21
basiclibs()
Int_t i
Definition: run_full.C:25
Int_t GetPdgCode() const
Definition: PndMCTrack.h:73
TVector3 GetMomentum() const
Definition: PndMCTrack.h:78
c2
Definition: plot_dirc.C:39
Int_t GetMCIndex(Short_t ind) const
Definition: PndEmcApdHit.h:64
TClonesArray * hit_array
virtual Double_t GetEnergy() const
Definition: PndEmcApdHit.h:51
TH1F * hMom
Definition: reco_apd.C:26
TFile * f
Definition: bump_analys.C:12
Int_t GetNPoints() const
Definition: PndEmcApdHit.h:63
c1
Definition: plot_dirc.C:35
c3
Definition: plot_dirc.C:50
TH1F * hEnergy
Definition: PndDrcReco.cxx:251
TTree * t
Definition: bump_analys.C:13
TClonesArray * mctrack_array
TH1F * hMult
Definition: reco_apd.C:25
double hit_energy
Definition: digi_analys.C:17
Double_t energy
Definition: plot_dirc.C:15