Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:11:56

0001 void ParticleShowerSizeHistoMaker(const int nevents)
0002 {
0003   float min = -0.5;
0004   float max = 0.5;
0005   int nchan = 52;
0006    const char *file1 = "/sphenix/user/jpinkenburg/ShowerSize/ntuple/neutron_eta0_4GeV.root";
0007 
0008   TFile *f1 = TFile::Open(file1);
0009   if (! f1)
0010     {
0011       cout << file1 << " not found" << endl;
0012       return;
0013     }
0014     gROOT->cd();
0015  TNtuple *de1 = (TNtuple *) f1->Get("de");
0016  TCanvas *c1 = new TCanvas();
0017  TH2F *h2 = new TH2F("neutron","Particle Shower Sizes",nchan,min,max,nchan,min,max);
0018   h2->SetXTitle("dtheta");
0019   h2->SetYTitle("dphi");
0020   h2->SetZTitle("dE/event");
0021   h2->GetXaxis()->SetTitleOffset(2);
0022   h2->GetYaxis()->SetTitleOffset(2);
0023   h2->GetZaxis()->SetTitleOffset(1.2);
0024   if (nevents > 0)
0025   {
0026  de1->Project("neutron","dphi:dtheta","(ID<=2)*edep/10000.","",nevents);
0027   }
0028   else
0029   {
0030  de1->Project("neutron","dphi:dtheta","(ID<=2)*edep/10000.","");
0031   }
0032   h2->Draw("surf");
0033   f1->Close();
0034   const char *file2 = "/sphenix/user/jpinkenburg/ShowerSize/ntuple/gamma_eta0_4GeV.root";
0035   TFile *f2 = TFile::Open(file2);
0036   if (! f2)
0037     {
0038       cout << file2 << " not found" << endl;
0039       return;
0040     }
0041   gROOT->cd();
0042  
0043   TNtuple *de2 = (TNtuple *) f2->Get("de");
0044   cout << nevents << endl;
0045   TH2F *h2a = new TH2F("gamma","Particle Shower Sizes",nchan,min,max,nchan,min,max);
0046   h2a->SetXTitle("dtheta");
0047   h2a->SetYTitle("dphi");
0048   h2a->SetZTitle("dE/event");
0049   h2a->GetXaxis()->SetTitleOffset(2);
0050   h2a->GetYaxis()->SetTitleOffset(2);
0051   h2a->GetZaxis()->SetTitleOffset(1.2);
0052   if (nevents > 0)
0053   {
0054   de2->Project("gamma","dphi:dtheta","(ID<=2)*edep/10000.","",nevents);
0055   }
0056   else
0057   {
0058   de2->Project("gamma","dphi:dtheta","(ID<=2)*edep/10000.","");
0059   }
0060 
0061  h2a->SetLineColor(2);
0062 h2a->Draw("surf same");
0063 // f1->Close();
0064   f2->Close();
0065   TFile *f3 = TFile::Open("neutron_gamma_edep_4gev.root","UPDATE");
0066 
0067   h2->Write();
0068   h2a->Write();
0069   f3->Write();
0070   f3->Close();
0071   return;
0072   de->SetLineColor(2);
0073   h2->Draw();
0074   /* TImage *img = TImage::Create();
0075   img->FromPad(c1);
0076   //  f2->Close();
0077   // TFile *fout = TFile::Open("/direct/phenix+u/jpinkenburg/sPHENIX/analysis/AntiSigma/macros/HistoBaseFiles/PosterFiles/");
0078   // h2->Write();
0079   //fout->Write();
0080   img->WriteImage("Neutron*Gamma_2GeV.png");
0081   // //fout->Write();
0082   //fout->Close();
0083   */
0084 }
0085 
0086 void DrawShowers()
0087 {
0088   TCanvas *c1 = new TCanvas();
0089   TFile *fin = TFile::Open("neutron_gamma_edep_4gev.root");
0090   TH2 *gamma = (TH2F *) fin->Get("gamma");
0091   TH2 *neutron = (TH2F *) fin->Get("neutron");
0092   c1->SetLogz();
0093   gamma->SetStats(0);
0094   gamma->SetLineColor(3);
0095   gamma->SetTitle("Shower Size");
0096   gamma->GetXaxis()->SetTitle("#Delta#Theta [rad]");
0097   gamma->GetXaxis()->SetNdivisions(505);
0098   gamma->GetYaxis()->SetTitle("#Delta#Phi [rad]");
0099   gamma->GetYaxis()->SetNdivisions(505);
0100   gamma->GetZaxis()->SetTitle("Deposited Energy [GeV]");
0101   gamma->GetZaxis()->SetTitleOffset(1.3);
0102   neutron->SetLineColor(2);
0103   neutron->SetStats(0);
0104   c1->SetTheta(5.);
0105   c1->SetPhi(22.);
0106 
0107   gamma->DrawClone("surf");
0108   neutron->DrawClone("surf same");
0109 TLegend *legrda = new TLegend(0.54,0.66,0.9,0.79,NULL,"brNDC");
0110   legrda->SetLineColor(1);
0111   legrda->SetLineStyle(1);
0112   legrda->SetLineWidth(1);
0113   legrda->SetFillColor(10);
0114   legrda->SetFillStyle(1001);
0115   legrda->SetBorderSize(0);
0116   legrda->SetTextSize(0.039);
0117   gamma->SetLineWidth(2);
0118   neutron->SetLineWidth(2);
0119   legrda->AddEntry(gamma,"4 GeV Photon Shower");
0120   legrda->AddEntry(neutron,"4 GeV Neutron Shower");
0121   legrda->Draw();
0122   c1->Print("showers.png");
0123 }