FairRoot/PandaRoot
macro/detectors/emc/dedicated/reco_analys.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  TFile* f = new TFile("cluster_emc.root"); //file you want to analyse
4  TTree *t=(TTree *) f->Get("pndsim") ;
5  TClonesArray* cluster_array=new TClonesArray("PndEmcCluster");
6  t->SetBranchAddress("EmcCluster",&cluster_array);
7 
8  t->AddFriend("pndsim", "digi_emc.root");
9  TClonesArray* digi_array=new TClonesArray("PndEmcDigi");
10  t->SetBranchAddress("EmcDigi",&digi_array);
11 
12  TFile* fsim = new TFile("sim_emc.root"); //file you want to analyse
13  TTree *tsim=(TTree *) fsim->Get("pndsim") ;
14 
16 
17  TClonesArray* mctrack_array=new TClonesArray("PndMCTrack");
18  tsim->SetBranchAddress("MCTrack",&mctrack_array);
19 
20  TVector3 photon_momentum;
21 
23  double cluster_theta, cluster_phi; //position of the cluster
24  double theta, phi; // angular position of the initial particle
26  int ndigi, npoint;
27  double max_energy=0;
28 
29  TH1F *h1= new TH1F("h1","Theta difference",200,-5.,5.);
30  TH1F *h2= new TH1F("h2","Phi difference",200,-5.,5.);
31  TH1F *h3= new TH1F("h3","Cluster energy",100,0.85,1.05);
32  TH2F *h2theta= new TH2F("h2theta","Theta difference",200,0.,180.,200,-5.,5.);
33  TH2F *h2phi= new TH2F("h2phi","Phi difference",200,0.,180.,200,-5.,5.);
34  TH1F *hE1= new TH1F("hE1","E1",200,0.,1.05);
35  TH1F *hE1E9= new TH1F("hE1E9","E1 / E9",200,0.,1.05);
36  TH1F *hE9E25= new TH1F("hE9E25","E9 / E25",200,0.,1.05);
37 
38  // Cluster angular position
39  // Entrance point is determined by minimal time
40 
41  // Cluster energy
42  for (Int_t j=0; j< t->GetEntriesFast(); j++)
43  {
44  t->GetEntry(j);
45  for (Int_t i=0; i<cluster_array->GetEntriesFast(); i++)
46  {
47  PndEmcCluster *cluster=(PndEmcCluster*)cluster_array->At(i);
48  cluster_energy=cluster->energy();
49  if ((cluster->NumberOfDigis()>1)&&(cluster_energy>0.02))
50  h3->Fill(cluster_energy);
51  PndEmcClusterEnergySums esum(*cluster, digi_array);
52  hE1->Fill(esum.E1());
53  hE1E9->Fill(esum.E1E9());
54  hE9E25->Fill(esum.E9E25());
55 
56  }
57  }
58 
59  for (Int_t j=0; j< t->GetEntriesFast(); j++)//t->GetEntriesFast()
60  {
61  t->GetEntry(j);
62  tsim->GetEntry(j);
63 
64  PndMCTrack *mctrack=(PndMCTrack *) mctrack_array->At(0);
65  photon_momentum=mctrack->GetMomentum();
66  theta=photon_momentum.Theta();
67  phi=photon_momentum.Phi();
68 
69 
70  // Loop over clusters
71  // If we have 1 initial particle and several cluster
72  // we can separate cluster from the first interaction by maximum energy
73 
74  max_energy=0;
75 
76  for (Int_t i=0; i<cluster_array->GetEntriesFast(); i++)
77  {
78  PndEmcCluster *cluster=(PndEmcCluster*)cluster_array->At(i);
79  cluster_energy=cluster->energy();
80  if (cluster_energy>max_energy)
81  {
82  max_energy=cluster_energy;
83  TVector3 cluster_pos=cluster->where();
84  cluster_theta=cluster_pos.Theta();
85  cluster_phi=cluster_pos.Phi();
86  }
87 
88  }
89 
90  if (max_energy>0.6)
91  {
92  theta_diff=(cluster_theta-theta)*180./TMath::Pi();
93  h1->Fill(theta_diff);
94  h2theta->Fill(theta*TMath::RadToDeg(),theta_diff);
95 
96  phi_diff=(cluster_phi-phi)*180./TMath::Pi();
97  h2->Fill(phi_diff);
98  h2phi->Fill(phi*TMath::RadToDeg(),phi_diff);
99  }
100 
101  }
102 
103  TCanvas* c1 = new TCanvas("c1", "Cluster Energy", 100, 100, 800, 800);
104  h3->SetTitle("Cluster energy of 1 GeV photon");
105  h3->GetXaxis()->SetTitle("Energy, GeV");
106  h3->Draw();
107 
108 
109  TCanvas* c2 = new TCanvas("c2", "#theta_{reco} - #theta_{truth}", 100, 100, 800, 800);
110  h1->SetTitle("Difference between cluster and initial photon theta angle");
111  h1->GetXaxis()->SetTitle("#theta_{reco} - #theta_{truth}, degree");
112  h1->Draw();
113 
114 // TF1 *f1 = new TF1("f1","gaus(0)",-2.,2.);
115 // Double_t par1[3]={60,0,0.5};
116 // f1->SetParameters(par1);
117 // f1->SetLineColor(2);
118  //
119 // h1->Fit("f1","RB");
120 // double mu1=f1->GetParameter(1);
121 // double sigma1=f1->GetParameter(2);
122 
123  TCanvas* c3 = new TCanvas("c3", "#phi_{reco} - #phi_{truth}", 100, 100, 800, 800);
124  h2->SetTitle("Difference between cluster and initial photon phi angle");
125  h2->GetXaxis()->SetTitle("#phi_{reco} - #phi_{truth}, degree");
126  h2->Draw();
127 
128  TCanvas* c4 = new TCanvas("c4", "#theta_{reco} - #theta_{truth} vs #theta_{truth}", 100, 100, 800, 800);
129  h2theta->SetTitle("Difference between cluster and initial photon theta angle");
130  h2theta->GetXaxis()->SetTitle("#theta_{truth}, degree");
131  h2theta->GetYaxis()->SetTitle("#theta_{reco} - #theta_{truth}, degree");
132  h2theta->Draw();
133 
134  TCanvas* c5 = new TCanvas("c5", "#phi_{reco} - #phi_{truth} vs #phi_{truth}", 100, 100, 800, 800);
135  h2phi->SetTitle("Difference between cluster and initial photon phi angle");
136  h2phi->GetXaxis()->SetTitle("#phi_{truth}, degree");
137  h2phi->GetYaxis()->SetTitle("#phi_{reco} - #phi_{truth}, degree");
138  h2phi->Draw();
139 
140  TCanvas* c6 = new TCanvas("c6", "Cluster Properties", 100, 100, 800, 800);
141  c6->Divide(2,2);
142  c6->cd(1); hE1->Draw();
143  c6->cd(2); hE1E9->Draw();
144  c6->cd(3); hE9E25->Draw();
145 
146 
147 }
148 
PndMCTrack * mctrack
TVector3 where() const
Int_t i
Definition: run_full.C:25
TVector3 GetMomentum() const
Definition: PndMCTrack.h:78
TClonesArray * cluster_array
TClonesArray * digi_array
virtual Double_t E1() const
TClonesArray * mctrack_array
static void Init(Int_t MapVersion)
TFile * f
Definition: bump_analys.C:12
a cluster (group of neighboring crystals) of hit emc crystals
Definition: PndEmcCluster.h:29
Int_t NumberOfDigis() const
virtual Double_t E1E9() const
virtual Double_t energy() const
virtual Double_t E9E25() const
Double_t Pi