FairRoot/PandaRoot
analysis.C
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 // Author: Mustafa Schmidt (University of Giessen)
3 // E-Mail: mustafa.a.schmidt@physik.uni-giessen.de
4 // Date: 13.09.2015
5 //----------------------------------------------------------------------------
6 
7 
8 int analysis()
9 {
10 
11  TFile *file=TFile::Open("sim.root","read");
12 
13  TTree *tree = (TTree*)file->Get("pndsim");
14 
15  TClonesArray *particle = new TClonesArray("PndDiscParticleMCPoint");
16  TClonesArray *sensor = new TClonesArray("PndDiscSensorMCPoint");
17 
18  tree->SetBranchAddress("DiscParticleMCPoint", &particle);
19  tree->SetBranchAddress("DiscSensorMCPoint", &sensor);
20 
21  int events = tree->GetEntries();
22 
23  //cout << "Number of events: " << events << endl;
24 
25  TH2F *posxy = new TH2F("posxy", "Position on Radiator Disk", 2000,-100,100,2000,-100,100);
26  posxy->GetXaxis()->SetTitle("Position x [mm]");
27  posxy->GetYaxis()->SetTitle("Position y [mm]");
28  posxy->SetStats(0);
29 
30  //Loop charged particles
31 
32  for(int i = 0; i < events; i++)
33  {
34  tree->GetEntry(i);
35 
36  int entries = particle->GetEntries();
37 
38  //cout << "Number of entries in event: " << entries << endl;
39 
40  for(int j = 0; j < entries; j++)
41  {
42  double x = ((PndDiscParticleMCPoint*)particle->At(j))->GetX();
43  double y = ((PndDiscParticleMCPoint*)particle->At(j))->GetY();
44  double z = ((PndDiscParticleMCPoint*)particle->At(j))->GetZ();
45 
46  //cout << "x = " << x << " y = " << y << " z = " << z << endl;
47 
48  if(z == 194 && ((PndDiscParticleMCPoint*)particle->At(j))->is_primary == true)
49  {
50  posxy->Fill(x,y);
51  }
52  }
53  }
54 
55  TCanvas *c1 = new TCanvas();
56  posxy->Draw("colz");
57 
58  //Histogram for photon hits
59 
60  TH2F *possensor = new TH2F("possensor", "Position on PMT", 108,0,108,100,-30,30);
61  possensor->GetXaxis()->SetTitle("Position x [mm]");
62  possensor->GetYaxis()->SetTitle("Position y [mm]");
63  possensor->SetStats(0);
64 
65  for(int i = 0; i < events; i++)
66  {
67  tree->GetEntry(i);
68 
69  int entries = sensor->GetEntries();
70 
71  //cout << "Number of entries in event: " << entries << endl;
72 
73  for(int j = 0; j < entries; j++)
74  {
75  double x = ((PndDiscSensorMCPoint*)sensor->At(j))->GetX();
76  double y = ((PndDiscSensorMCPoint*)sensor->At(j))->GetY();
77  double z = ((PndDiscSensorMCPoint*)sensor->At(j))->GetZ();
78 
79  int vol = ((PndDiscSensorMCPoint*)sensor->At(j))->GetDetectorID();
80 
81  //cout << "x = " << x << " y = " << y << " z = " << z << endl;
82 
83  possensor->Fill(vol,y*10);
84  }
85 
86  }
87 
88  TCanvas *c2 = new TCanvas();
89  possensor->SetMinimum(-1);
90  possensor->Draw("colz");
91 
92  //Reading out digitization file
93  TFile *file2=TFile::Open("digi.root","read");
94  TTree *tree2 = (TTree*)file2->Get("pndsim");
95  TClonesArray *digit = new TClonesArray("PndDiscDigitizedHit");
96  tree2->SetBranchAddress("DiscDigit", &digit);
97 
98  //Reading out reconstruction file
99  TFile *file3=TFile::Open("reco.root","read");
100  TTree *tree3 = (TTree*)file3->Get("pndsim");
101  TClonesArray *recon = new TClonesArray("PndDiscReconResult");
102  tree3->SetBranchAddress("DiscPatternPrediction", &recon);
103 
104  //Reading out PID file
105  TFile *file4=TFile::Open("pid.root","read");
106  TTree *tree4 = (TTree*)file4->Get("pndsim");
107  TClonesArray *pid = new TClonesArray("PndDiscPID");
108  tree4->SetBranchAddress("DiscPID", &pid);
109 
110 
111  //Histogram for pixel hits
112  TH2F *hitpattern = new TH2F("hitpattern", "Simulated Hitpattern", 108,0,108,100,0,100);
113  hitpattern->GetXaxis()->SetTitle("Sensor ID");
114  hitpattern->GetYaxis()->SetTitle("Pixel Number");
115  hitpattern->SetStats(0);
116 
117  for(int i = 0; i < events; i++)
118  {
119  tree2->GetEntry(i);
120 
121  int hits = digit->GetEntries();
122 
123  //cout << "Number of entries in hits: " << hits << endl;
124 
125  for(int j = 0; j < hits; j++)
126  {
127  int pixel = ((PndDiscDigitizedHit*)digit->At(j))->GetPixelNumber();
128  int detector_id = ((PndDiscDigitizedHit*)digit->At(j))->GetDetectorID();
129  int readout_id = ((PndDiscDigitizedHit*)digit->At(j))->GetReadoutID();
130  double tdc = ((PndDiscDigitizedHit*)digit->At(j))->GetTdcTime()*0.05;
131  //cout << "Pixel: " << pixel << " Sensor: " << readout_id << endl;
132 
133  hitpattern->Fill(readout_id+27*detector_id, pixel, tdc);
134  }
135 
136  }
137 
138  //Histogram for predicted hitpattern
139  TH2F *hprediction = new TH2F("hprediction", "Predicted Hitpattern", 108,0,108,100,0,100);
140  hprediction->GetXaxis()->SetTitle("Sensor ID");
141  hprediction->GetYaxis()->SetTitle("Pixel Number");
142  hprediction->SetStats(0);
143 
144  for(int i = 0; i < events; i++)
145  {
146  tree3->GetEntry(i);
147 
148  int entries = recon->GetEntries();
149 
150  //cout << "Number of entries in prediction: " << entries << endl;
151 
152  for(int j = 0; j < entries; j++)
153  {
154  int pixel = ((PndDiscReconResult*)recon->At(j))->pixel;
155  double time = ((PndDiscReconResult*)recon->At(j))->time;
156  int sensor_id = ((PndDiscReconResult*)recon->At(j))->sensor;
157 
158  if(pixel != 1)
159  {
160  hprediction->Fill(sensor_id, pixel, time/events/3);
161  }
162  }
163 
164  }
165 
166  TCanvas *c3 = new TCanvas();
167  int width = c3->GetWw();
168  int height = c3->GetWh();
169  c3->SetWindowSize(1.5*width,height);
170  c3->Divide(2);
171  c3->cd(1);
172  hitpattern->SetMinimum(-1);
173  hitpattern->Draw("colz");
174  c3->cd(2);
175  hprediction->Draw("colz");
176  c3->Update();
177 
178 
179  TH1F *hlikelihood = new TH1F("hlikelihood", "Difference of Likelihood", 100, -100, 100);
180 
181  for(int i = 0; i < events; i++)
182  {
183  tree4->GetEntry(i);
184 
185  int entries = pid->GetEntries();
186 
187  //cout << "Number of entries in PID: " << entries << endl;
188 
189  for(int j = 0; j < entries; j++)
190  {
191  double diff = ((PndDiscPID*)pid->At(j))->loglikepion - ((PndDiscPID*)pid->At(j))->loglikekaon;
192 
193  hlikelihood->Fill(diff);
194  }
195 
196  }
197 
198  TCanvas *c4 = new TCanvas();
199  hlikelihood->Draw();
200  c4->Update();
201 
202  //file2->Close();
203  //file3->Close();
204  return 0;
205 }
c4
Definition: plot_dirc.C:71
Int_t i
Definition: run_full.C:25
TFile * file
TTree * tree
Definition: plot_dirc.C:12
int pid()
c2
Definition: plot_dirc.C:39
TGeoVolume * sensor
const int particle
int analysis()
Definition: analysis.C:8
Double_t z
c1
Definition: plot_dirc.C:35
c3
Definition: plot_dirc.C:50
Double_t x
TTree * tree2
Definition: anaLmdCluster.C:33
CbmHit * hits[nHits]
Definition: RiemannTest.C:19
Double_t y