46 string cal_name[] = {
"iHCal",
"oHCal",
"EMCal" };
47 string cal_tag[] = {
"_in",
"_out",
"_emc" };
64 double dPhi = phi1 - phi2;
65 while (dPhi>=M_PI) { dPhi -= 2.*M_PI; }
66 while (dPhi<=-M_PI) { dPhi += 2.*M_PI; }
71 while (phi>=M_PI) { phi -= 2.*M_PI; }
72 while (phi<=-M_PI) { phi += 2.*M_PI; }
77 double min_eta = eta - 0.024*N - 0.012;
78 double max_eta = eta + 0.024*N + 0.012;
79 if ( calo_eta<min_eta || calo_eta>max_eta ) {
return false; }
80 double min_phi = phi - (M_PI/128.)*N - (M_PI/256.);
81 double max_phi = phi + (M_PI/128.)*N + (M_PI/256.);
82 if ( calo_phi<min_phi || calo_phi>max_phi ) {
return false; }
83 if ( calo_eta>=min_eta && calo_eta<=max_eta && calo_phi>=min_phi && calo_phi<=max_phi ) {
return true; }
88 double n_rings = (
double) N;
89 double eta_lo = eta - 0.024*n_rings;
90 double eta_hi = eta + 0.024*n_rings;
96 if ( calo_eta>eta_lo-0.012 && calo_eta<eta_hi+0.012 ) {
return true; }
98 if ( fabs(eta_lo-calo_eta)<=0.012 || fabs(eta_hi-calo_eta)<=0.012 ) {
99 if ( calo_phi>phi_lo-(M_PI/256.) && calo_phi<phi_hi+(M_PI/256.) ) {
return true; }
112 TH3D *hEsum_per_nRings =
new TH3D(
"hEsum_per_nRings",
";pion p_{T} [GeV/c];E sum in tower square [GeV];n_{rings}",30,0.,30.,100,0.,100.,30,0.,30.);
113 TH3D *hEsum_in_ringN =
new TH3D(
"hEsum_in_ringN",
";pion p_{T} [GeV/c];E sum in tower ring [GeV];n_{rings}",30,0.,30.,200,0.,40.,30,0.,30.);
114 TH3D *hEMCalE_over_pionE =
new TH3D(
"hEMCalE_over_pionE",
";pion p_{T} [GeV/c];E_{EMCal}/E_{pion};n_{rings}",30,0.,30.,115,0.,1.15,30,0.,30.);
116 TH3D *hTotalCaloSum_per_nRings =
new TH3D(
"hTotalCaloSum_per_nRings",
";pion p_{T} [GeV/c];E sum in all calos [GeV];",30,0.,30.,200,0.,100.,30,0.,30.);
117 TH3D *hTotalCaloEfrac_per_nRings =
new TH3D(
"hTotalCaloEfrac_per_nRings",
";pion p_{T} [GeV/c];total calo E / pion E;",30,0.,30.,70,0.,7.,30,0.,30.);
119 for (
int i=0;
i<30; ++
i){ hTotalCaloSum_per_nRings->GetXaxis()->SetBinLabel(
i+1,Form(
"%ix%i",2*
i+1,2*
i+1)); }
120 hTotalCaloSum_per_nRings->GetXaxis()->SetAlphanumeric();
123 TTree *
fChain = (TTree*)f->Get(
"T");
125 fChain->SetBranchAddress(
"event", &
event);
126 fChain->SetBranchAddress(
"eta", &
eta);
127 fChain->SetBranchAddress(
"phi", &
phi);
128 fChain->SetBranchAddress(
"e", &
e);
129 fChain->SetBranchAddress(
"pt", &
pt);
130 fChain->SetBranchAddress(
"vx", &
vx);
131 fChain->SetBranchAddress(
"vy", &
vy);
132 fChain->SetBranchAddress(
"vz", &
vz);
134 for (
int ical=0; ical<
ncal; ++ical) {
135 fChain->SetBranchAddress(Form(
"nTow%s",
cal_tag[ical].c_str()), &
nTowers[ical]);
136 fChain->SetBranchAddress(Form(
"eta%s",
cal_tag[ical].c_str()), &
calo_eta[ical]);
137 fChain->SetBranchAddress(Form(
"phi%s",
cal_tag[ical].c_str()), &
calo_phi[ical]);
138 fChain->SetBranchAddress(Form(
"e%s",
cal_tag[ical].c_str()), &
calo_e[ical]);
139 fChain->SetBranchAddress(Form(
"ieta%s",
cal_tag[ical].c_str()), &
calo_ieta[ical]);
140 fChain->SetBranchAddress(Form(
"iphi%s",
cal_tag[ical].c_str()), &
calo_iphi[ical]);
144 Long64_t nentries = fChain->GetEntriesFast();
146 for (Long64_t jentry=0; jentry<nentries;jentry++) {
147 Long64_t ientry = fChain->GetTreeNumber();
148 if (ientry < 0)
break;
150 fChain->GetEntry(jentry);
152 double total_calo_E[
ncal] = {0.,0.,0.};
176 else { cerr<<
"ope"<<endl; }
179 for (
int itow=0; itow<
calo_e[
index]->size(); ++itow) {
184 int n_towers_in_square = 0;
185 double square_e_sum = 0.;
186 for (
int n_rings = 0; n_rings<30; ++n_rings) {
188 double ring_e_sum = 0.;
189 int n_towers_in_ring = 0;
190 for (
int itow=0; itow<
calo_e[
i_cal]->size(); ++itow) {
196 n_towers_in_square += 1;
197 n_towers_in_ring += 1;
200 hEsum_per_nRings->Fill(
pt,square_e_sum,n_rings);
201 hEsum_in_ringN->Fill(
pt,ring_e_sum,n_rings);
202 hEMCalE_over_pionE->Fill(
pt,ring_e_sum/
e,n_rings);
204 hTotalCaloSum_per_nRings->Fill(
e,square_e_sum+total_calo_E[0]+total_calo_E[1],n_rings);
205 hTotalCaloEfrac_per_nRings->Fill(
e,(square_e_sum+total_calo_E[0]+total_calo_E[1])/
e,n_rings);
215 string remove_this =
".root";
216 size_t pos = outputroot.find(remove_this);
217 if (pos != string::npos) { outputroot.erase(pos, remove_this.length()); }
221 TString
outFileName = outputroot +
"_EMCalRings.root";
223 TFile *outFile =
new TFile(outFileName,
"RECREATE");
224 hEsum_per_nRings->Write();
225 hEsum_in_ringN->Write();
226 hTotalCaloSum_per_nRings->Write();
227 hTotalCaloEfrac_per_nRings->Write();
228 hEMCalE_over_pionE->Write();
232 vector<TH3D *>
histos = {hEsum_per_nRings, hEsum_in_ringN, hTotalCaloSum_per_nRings, hTotalCaloEfrac_per_nRings, hEMCalE_over_pionE};
233 auto fa1 =
new TF1(
"fa1",
"0.",0,1);
235 TCanvas * can =
new TCanvas(
"can" ,
"" ,700 ,500 );
237 const char us[] =
"_";
239 for (
int i=0;
i<histos.size(); ++
i ) {
240 histos[
i]->Project3D(
"YZ")->Draw(
"COLZ");
241 can->SaveAs(Form(
"plots/EMCalTowerRingStudy/%s.pdf",histos[
i]->GetName()),
"PDF");
242 for (
int j=0;
j<3; ++
j) {
244 double pthi = (
double)10.*(
j+1);
245 histos[
i]->GetXaxis()->SetRangeUser(ptlo,pthi);
246 histos[
i]->Project3D(
"YZ")->Draw(
"COLZ");
247 can->SaveAs(Form(
"plots/EMCalTowerRingStudy/%s%s%i%s%i.pdf",histos[
i]->GetName(),us,(
int)ptlo,us,(
int)pthi),
"PDF");
250 histos[
i]->GetXaxis()->SetRangeUser(1.,2.);
251 TH2D *hDenom2D = (TH2D*)histos[
i]->Project3D(
"YZ");
252 TH1D *hDenom = (TH1D*)hDenom2D->ProfileX();
253 hDenom->SetName(
"hDenom");
255 for (
int j=1;
j<10; ++
j) {
257 double pthi = (
double)1.*(
j+1);
258 histos[
i]->GetXaxis()->SetRangeUser(ptlo,pthi);
259 histos[
i]->Project3D(
"YZ")->Draw(
"COLZ");
260 TH2D *hTemp = (TH2D*)histos[
i]->Project3D(
"YZ");
261 hTemp->SetLineColor(kRed);
262 hTemp->SetMarkerColor(kRed);
263 TH1D *hNum = (TH1D*)hTemp->ProfileX();
265 can->SaveAs(Form(
"plots/EMCalTowerRingStudy/%s_FINE_%s%i%s%i.pdf",histos[
i]->GetName(),us,(
int)ptlo,us,(
int)pthi),
"PDF");
266 hNum->Divide(hDenom);
267 hNum->GetYaxis()->SetRangeUser(0.1,2.2);
270 can->SaveAs(Form(
"plots/EMCalTowerRingStudy/%s_FINE_%s%i%s%i__ratioTo1_2.pdf",histos[
i]->GetName(),us,(
int)ptlo,us,(
int)pthi),
"PDF");
274 histos[
i]->GetXaxis()->SetRangeUser(0.,30.);