File indexing completed on 2025-08-03 08:22:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <TFile.h>
0012 #include <TPad.h>
0013 #include <TString.h>
0014 #include <TSystem.h>
0015 #include <TTree.h>
0016 #include <cassert>
0017 #include <cmath>
0018
0019
0020
0021 #include <calobase/RawTower.h>
0022 #include <calobase/RawTowerv1.h>
0023 #include <g4main/PHG4HitEval.h>
0024 #include <g4main/PHG4Particlev1.h>
0025 #include <g4main/PHG4Particlev2.h>
0026 #include <g4main/PHG4VtxPointv1.h>
0027 using namespace std;
0028
0029
0030 TFile *_file0 = NULL;
0031 TTree *T = NULL;
0032
0033
0034 void CheckItOut()
0035 {
0036
0037
0038
0039
0040
0041
0042 T->Show(0);
0043
0044
0045 new TCanvas("CheckItOut", "CheckItOut");
0046 T->Draw(
0047 "Sum$(G4HIT_HCALOUT.edep) + Sum$(G4HIT_ABSORBER_HCALOUT.edep)>>hSum_CEMC(30,0,30)");
0048 TH1 *hSum_CEMC = static_cast<TH1 *>(gDirectory->GetObjectChecked("hSum_CEMC", "TH1"));
0049 hSum_CEMC->SetTitle(
0050 "Total energy deposition in Outer HCal;Energy deposition (GeV)");
0051 }
0052
0053
0054 void AcessGeant4Particles()
0055 {
0056
0057
0058 T->SetAlias("PHG4Particle_p",
0059 "1*sqrt(PHG4Particle[].fpx**2+PHG4Particle[].fpy**2+PHG4Particle[].fpz**2)");
0060 T->SetAlias("PHG4Particle_eta",
0061 "0.5*log((PHG4Particle_p+PHG4Particle[].fpz)/(PHG4Particle_p-PHG4Particle[].fpz))");
0062 T->SetAlias("PHG4Particle_pT",
0063 "1*sqrt(PHG4Particle[].fpx**2+PHG4Particle[].fpy**2)");
0064
0065 new TCanvas("AcessGeant4Particles", "AcessGeant4Particles");
0066 T->Draw("PHG4Particle_pT>>hPHG4Particle_pT(30,0,50)",
0067 "PHG4Particle[].trkid>0"
0068 );
0069 TH1 *hPHG4Particle_pT = static_cast<TH1 *>(gDirectory->GetObjectChecked("hPHG4Particle_pT", "TH1"));
0070 hPHG4Particle_pT->SetTitle("pT for the first Geant4 particle;pT (GeV/c)");
0071 }
0072
0073
0074
0075
0076 void WhereIsTheHits()
0077 {
0078 new TCanvas("WhereIsTheHits", "WhereIsTheHits");
0079 gPad->DrawFrame(-250, -250, 250, 250,
0080 "Geant4 Hit distribution;X (cm);Y (cm)");
0081
0082 T->Draw("G4HIT_SVTX.get_avg_y():G4HIT_SVTX.get_avg_x()", "", "* same");
0083 T->Draw(
0084 "G4HIT_ABSORBER_CEMC.get_avg_y():G4HIT_ABSORBER_CEMC.get_avg_x()>>hG4HIT_ABSORBER_CEMC(500,-250,250,500,-250,250)",
0085 "", "scat same");
0086 T->Draw(
0087 "G4HIT_ABSORBER_HCALIN.get_avg_y():G4HIT_ABSORBER_HCALIN.get_avg_x()>>hG4HIT_ABSORBER_HCALIN(500,-250,250,500,-250,250)",
0088 "", "scat same");
0089 T->Draw(
0090 "G4HIT_ABSORBER_HCALOUT.get_avg_y():G4HIT_ABSORBER_HCALOUT.get_avg_x()>>hG4HIT_ABSORBER_HCALOUT(500,-250,250,500,-250,250)",
0091 "", "scat same");
0092 }
0093
0094 void PlotCalorimeterSamplingFraction()
0095 {
0096
0097 T->SetAlias("CEMC_Sample",
0098 "Sum$(G4HIT_CEMC.edep)/(Sum$(G4HIT_CEMC.edep) + Sum$(G4HIT_ABSORBER_CEMC.edep))");
0099 T->SetAlias("HCALIN_Sample",
0100 "Sum$(G4HIT_HCALIN.edep)/(Sum$(G4HIT_HCALIN.edep) + Sum$(G4HIT_ABSORBER_HCALIN.edep))");
0101 T->SetAlias("HCALOUT_Sample",
0102 "Sum$(G4HIT_HCALOUT.edep)/(Sum$(G4HIT_HCALOUT.edep) + Sum$(G4HIT_ABSORBER_HCALOUT.edep))");
0103
0104 new TCanvas("PlotCalorimeterSamplingFraction", "PlotCalorimeterSamplingFraction");
0105
0106 T->Draw("CEMC_Sample>>CEMC_Sample(30,0,.15)");
0107 TH1 *CEMC_Sample = static_cast<TH1 *>(gDirectory->GetObjectChecked("CEMC_Sample", "TH1"));
0108 CEMC_Sample->SetLineColor(kRed);
0109 T->Draw("HCALIN_Sample>>HCALIN_Sample(30,0,.15)", "", "same");
0110 TH1 *HCALIN_Sample = static_cast<TH1 *>(gDirectory->GetObjectChecked("HCALIN_Sample", "TH1"));
0111 HCALIN_Sample->SetLineColor(kMagenta);
0112 T->Draw("HCALOUT_Sample>>HCALOUT_Sample(30,0,.15)", "", "same");
0113 TH1 *HCALOUT_Sample = static_cast<TH1 *>(gDirectory->GetObjectChecked("HCALOUT_Sample", "TH1"));
0114 HCALOUT_Sample->SetLineColor(kBlue);
0115 CEMC_Sample->SetTitle("Sampling fraction for three calorimeters; E_{Scint}/(E_{Scint} + E_{Absorber})");
0116 }
0117
0118 void AccessCalorimeterTowers()
0119 {
0120 new TCanvas("AccessCalorimeterTowers", "AccessCalorimeterTowers");
0121
0122 T->Draw("TOWER_CALIB_HCALOUT.get_bineta()>>hTowerBin(22,-0.5,21.5)", "TOWER_CALIB_HCALOUT.get_energy()");
0123 TH1 *hTowerBin = static_cast<TH1 *>(gDirectory->GetObjectChecked("hTowerBin", "TH1"));
0124 hTowerBin->SetTitle("HCal tower eta bin distribution; Eta Bin # ; Sum energy in scintillator (GeV)");
0125 }
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148 void Example(
0149 const TString infile =
0150 "https://www.phenix.bnl.gov/phenix/WWW/sPHENIX/tutorial/G4sPHENIX.root_DSTReader.root"
0151 )
0152 {
0153 gSystem->Load("libg4dst.so");
0154
0155
0156 _file0 = TFile::Open(infile);
0157 assert(_file0);
0158 T = (TTree *) _file0->GetObjectChecked("T", "TTree");
0159 assert(T);
0160
0161
0162
0163
0164 CheckItOut();
0165 AcessGeant4Particles();
0166 WhereIsTheHits();
0167 PlotCalorimeterSamplingFraction();
0168 AccessCalorimeterTowers();
0169 }