Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ParticleShowerSizeGraphMaker.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ParticleShowerSizeGraphMaker.C
2 {
3  float min = -0.5;
4  float max = 0.5;
5  int nchan = 52;
6  const char *file1 = "/sphenix/user/jpinkenburg/ShowerSize/ntuple/neutron_eta0_4GeV.root";
7 
8  TFile *f1 = TFile::Open(file1);
9  if (! f1)
10  {
11  cout << file1 << " not found" << endl;
12  return;
13  }
14  gROOT->cd();
15  TNtuple *de1 = (TNtuple *) f1->Get("de");
16  TCanvas *c1 = new TCanvas();
17  TH2F *h2 = new TH2F("neutron","Particle Shower Sizes",nchan,min,max,nchan,min,max);
18  h2->SetXTitle("dtheta");
19  h2->SetYTitle("dphi");
20  h2->SetZTitle("dE/event");
21  h2->GetXaxis()->SetTitleOffset(2);
22  h2->GetYaxis()->SetTitleOffset(2);
23  h2->GetZaxis()->SetTitleOffset(1.2);
24  if (nevents > 0)
25  {
26  de1->Project("neutron","dphi:dtheta","(ID<=2)*edep/10000.","",nevents);
27  }
28  else
29  {
30  de1->Project("neutron","dphi:dtheta","(ID<=2)*edep/10000.","");
31  }
32  h2->Draw("surf");
33  f1->Close();
34  const char *file2 = "/sphenix/user/jpinkenburg/ShowerSize/ntuple/gamma_eta0_4GeV.root";
35  TFile *f2 = TFile::Open(file2);
36  if (! f2)
37  {
38  cout << file2 << " not found" << endl;
39  return;
40  }
41  gROOT->cd();
42 
43  TNtuple *de2 = (TNtuple *) f2->Get("de");
44  cout << nevents << endl;
45  TH2F *h2a = new TH2F("gamma","Particle Shower Sizes",nchan,min,max,nchan,min,max);
46  h2a->SetXTitle("dtheta");
47  h2a->SetYTitle("dphi");
48  h2a->SetZTitle("dE/event");
49  h2a->GetXaxis()->SetTitleOffset(2);
50  h2a->GetYaxis()->SetTitleOffset(2);
51  h2a->GetZaxis()->SetTitleOffset(1.2);
52  if (nevents > 0)
53  {
54  de2->Project("gamma","dphi:dtheta","(ID<=2)*edep/10000.","",nevents);
55  }
56  else
57  {
58  de2->Project("gamma","dphi:dtheta","(ID<=2)*edep/10000.","");
59  }
60 
61  h2a->SetLineColor(2);
62 h2a->Draw("surf same");
63 // f1->Close();
64  f2->Close();
65  TFile *f3 = TFile::Open("neutron_gamma_edep_4gev.root","UPDATE");
66 
67  h2->Write();
68  h2a->Write();
69  f3->Write();
70  f3->Close();
71  return;
72  de->SetLineColor(2);
73  h2->Draw();
74  /* TImage *img = TImage::Create();
75  img->FromPad(c1);
76  // f2->Close();
77  // TFile *fout = TFile::Open("/direct/phenix+u/jpinkenburg/sPHENIX/analysis/AntiSigma/macros/HistoBaseFiles/PosterFiles/");
78  // h2->Write();
79  //fout->Write();
80  img->WriteImage("Neutron*Gamma_2GeV.png");
81  // //fout->Write();
82  //fout->Close();
83  */
84 }
85 
87 {
88  TCanvas *c1 = new TCanvas();
89  TFile *fin = TFile::Open("neutron_gamma_edep_4gev.root");
90  TH2 *gamma = (TH2F *) fin->Get("gamma");
91  TH2 *neutron = (TH2F *) fin->Get("neutron");
92  c1->SetLogz();
93  gamma->SetStats(0);
94  gamma->SetLineColor(3);
95  gamma->SetTitle("Shower Size");
96  gamma->GetXaxis()->SetTitle("#Delta#Theta [rad]");
97  gamma->GetXaxis()->SetNdivisions(505);
98  gamma->GetYaxis()->SetTitle("#Delta#Phi [rad]");
99  gamma->GetYaxis()->SetNdivisions(505);
100  gamma->GetZaxis()->SetTitle("Deposited Energy [GeV]");
101  gamma->GetZaxis()->SetTitleOffset(1.3);
102  neutron->SetLineColor(2);
103  neutron->SetStats(0);
104  c1->SetTheta(5.);
105  c1->SetPhi(22.);
106 
107  gamma->DrawClone("surf");
108  neutron->DrawClone("surf same");
109 TLegend *legrda = new TLegend(0.54,0.66,0.9,0.79,NULL,"brNDC");
110  legrda->SetLineColor(1);
111  legrda->SetLineStyle(1);
112  legrda->SetLineWidth(1);
113  legrda->SetFillColor(10);
114  legrda->SetFillStyle(1001);
115  legrda->SetBorderSize(0);
116  legrda->SetTextSize(0.039);
117  gamma->SetLineWidth(2);
118  neutron->SetLineWidth(2);
119  legrda->AddEntry(gamma,"4 GeV Photon Shower");
120  legrda->AddEntry(neutron,"4 GeV Neutron Shower");
121  legrda->Draw();
122  c1->Print("showers.png");
123 }