File indexing completed on 2025-08-06 08:13:24
0001 #pragma once
0002 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,0)
0003
0004 #include "sPhenixStyle.C"
0005 #include "sPhenixStyle.h"
0006
0007
0008 #include <TH1.h>
0009 #include <TH2.h>
0010 #include <TFile.h>
0011 #include <TCanvas.h>
0012 #include <TLegend.h>
0013 #include <TLatex.h>
0014 #include <TPad.h>
0015 #include <TDirectory.h>
0016 #include <TFitResult.h>
0017
0018
0019 #include <string>
0020 #include <vector>
0021 #include <array>
0022 #include <algorithm>
0023 #include <sstream>
0024 #include <math.h>
0025 #include <map>
0026 std::vector<TDirectory*> file_dir_top;
0027 std::vector<std::array<TDirectory*,4>> lower_dirs;
0028 void LoadInRegionPlots(TDirectory* botdir, std::vector<std::vector<TH1F*>*>* RegionPlots)
0029 {
0030 int Calo=0;
0031 for(auto b:*botdir->GetListOfKeys()){
0032 TKey* k=(TKey*)b;
0033 std::string hist_name = k->GetName();
0034 if(hist_name.find("EMCAL")!=std::string::npos) Calo=0;
0035 else if(hist_name.find("IHCAL")!=std::string::npos) Calo=1;
0036 else if(hist_name.find("OHCAL")!=std::string::npos) Calo=2;
0037 else continue;
0038 if(hist_name.find("e_")!=std::string::npos) RegionPlots->at(0)->at(Calo)=(TH1F*)botdir->Get(hist_name.c_str());
0039 if(hist_name.find("E2C_")!=std::string::npos) RegionPlots->at(1)->at(Calo)=(TH1F*)botdir->Get(hist_name.c_str());
0040 if(hist_name.find("E3C_")!=std::string::npos) RegionPlots->at(2)->at(Calo)=(TH1F*)botdir->Get(hist_name.c_str());
0041 if(hist_name.find("R_")!=std::string::npos) RegionPlots->at(3)->at(Calo)=(TH1F*)botdir->Get(hist_name.c_str());
0042 if(hist_name.find("n_")!=std::string::npos) RegionPlots->at(4)->at(Calo)=(TH1F*)botdir->Get(hist_name.c_str());
0043 }
0044 std::array<int, 3> n_evts;
0045 n_evts[0]=RegionPlots->at(0)->at(0)->GetEntries();
0046 n_evts[1]=RegionPlots->at(0)->at(1)->GetEntries();
0047 n_evts[2]=RegionPlots->at(0)->at(2)->GetEntries();
0048
0049 for(auto R:*RegionPlots)
0050 {
0051 for(int i=0; i<(int)R->size(); i++)
0052 {
0053 auto p=R->at(i);
0054 if(!p) continue;
0055 if(n_evts[i]==0) n_evts[i]=1;
0056 p->Scale(1/((float) n_evts[i]));
0057 std::string ptitle = p->GetYaxis()->GetTitle();
0058 if(ptitle.find("Total Ev") == std::string::npos)
0059 p->SetYTitle(Form("#frac{1}{Total Events} %s", p->GetYaxis()->GetTitle()));
0060 }
0061 }
0062 return;
0063 }
0064 std::array<std::vector<std::vector<std::string>>,4> GetPlotLabels(std::array<std::vector<std::vector<TH1F*>*>*, 4> RegPlts)
0065 {
0066 std::array<std::vector<std::vector<std::string>>, 4> plt_lbs;
0067 for(int k=0; k<(int)RegPlts.size(); k++){
0068 auto a=RegPlts[k];
0069 std::vector<std::vector<std::string>> a1;
0070 for(int i=0; i< (int)a->size(); i++)
0071 {
0072 std::vector<std::string> a2;
0073 for(int j=0; j <(int) a->at(i)->size(); j++)
0074 {
0075 std::string lb="";
0076 std::string plt_name, thr, cal;
0077 if(! a->at(i)->at(j)) continue;
0078 plt_name=a->at(i)->at(j)->GetName();
0079 std::stringstream str_plt (plt_name);
0080 std::string subparts;
0081 bool get_name=false;
0082 while(std::getline(str_plt, subparts, '_')){
0083 if( get_name){
0084 thr=subparts;
0085 break;
0086 }
0087 else if(subparts.find("CAL") != std::string::npos){
0088 get_name=true;
0089 cal=subparts;
0090 continue;
0091 }
0092 else continue;
0093 }
0094 lb=cal+", E_{tower} #geq "+thr+" MeV";
0095 a2.push_back(lb);
0096 }
0097 a1.push_back(a2);
0098 }
0099 plt_lbs[k]=a1;
0100 }
0101 return plt_lbs;
0102 }
0103 void LoadInPlots(int threshold_index, std::array<std::vector<std::vector<TH1F*>*>*, 4>* RegPlts){
0104
0105 TH1F* CEMC_FullEnergy=NULL, *CEMC_FullE2C=NULL, *CEMC_FullE3C=NULL, *CEMC_FullR=NULL, *CEMC_FullN=NULL;
0106 TH1F* CEMC_TowardsEnergy=NULL, *CEMC_TowardsE2C=NULL, *CEMC_TowardsE3C=NULL, *CEMC_TowardsR=NULL, *CEMC_TowardsN=NULL;
0107 TH1F* CEMC_AwayEnergy=NULL, *CEMC_AwayE2C=NULL, *CEMC_AwayE3C=NULL, *CEMC_AwayR=NULL, *CEMC_AwayN=NULL;
0108 TH1F* CEMC_TransEnergy=NULL, *CEMC_TransE2C=NULL, *CEMC_TransE3C=NULL, *CEMC_TransR=NULL, *CEMC_TransN=NULL;
0109
0110 TH1F* OHCAL_FullEnergy=NULL, *OHCAL_FullE2C=NULL, *OHCAL_FullE3C=NULL, *OHCAL_FullR=NULL, *OHCAL_FullN=NULL;
0111 TH1F* OHCAL_TowardsEnergy=NULL, *OHCAL_TowardsE2C=NULL, *OHCAL_TowardsE3C=NULL, *OHCAL_TowardsR=NULL, *OHCAL_TowardsN=NULL;
0112 TH1F* OHCAL_AwayEnergy=NULL, *OHCAL_AwayE2C=NULL, *OHCAL_AwayE3C=NULL, *OHCAL_AwayR=NULL, *OHCAL_AwayN=NULL;
0113 TH1F* OHCAL_TransEnergy=NULL, *OHCAL_TransE2C=NULL, *OHCAL_TransE3C=NULL, *OHCAL_TransR=NULL, *OHCAL_TransN=NULL;
0114
0115 TH1F* IHCAL_FullEnergy=NULL, *IHCAL_FullE2C=NULL, *IHCAL_FullE3C=NULL, *IHCAL_FullR=NULL, *IHCAL_FullN=NULL;
0116 TH1F* IHCAL_TowardsEnergy=NULL, *IHCAL_TowardsE2C=NULL, *IHCAL_TowardsE3C=NULL, *IHCAL_TowardsR=NULL, *IHCAL_TowardsN=NULL;
0117 TH1F* IHCAL_AwayEnergy=NULL, *IHCAL_AwayE2C=NULL, *IHCAL_AwayE3C=NULL, *IHCAL_AwayR=NULL, *IHCAL_AwayN=NULL;
0118 TH1F* IHCAL_TransEnergy=NULL, *IHCAL_TransE2C=NULL, *IHCAL_TransE3C=NULL, *IHCAL_TransR=NULL, *IHCAL_TransN=NULL;
0119
0120 std::vector<TH1F*>* FullEnergy=new std::vector<TH1F*>{}, *FullE2C=new std::vector<TH1F*>{}, *FullE3C=new std::vector<TH1F*>{}, *FullR=new std::vector<TH1F*>{}, *FullN=new std::vector<TH1F*>{};
0121 std::vector<TH1F*>* TowardsEnergy=new std::vector<TH1F*>{}, *TowardsE2C=new std::vector<TH1F*>{}, *TowardsE3C=new std::vector<TH1F*>{}, *TowardsR=new std::vector<TH1F*>{}, *TowardsN=new std::vector<TH1F*>{};
0122 std::vector<TH1F*>* AwayEnergy=new std::vector<TH1F*>{}, *AwayE2C=new std::vector<TH1F*>{}, *AwayE3C=new std::vector<TH1F*>{}, *AwayR=new std::vector<TH1F*>{}, *AwayN=new std::vector<TH1F*>{};
0123 std::vector<TH1F*>* TransEnergy=new std::vector<TH1F*>{}, *TransE2C=new std::vector<TH1F*>{}, *TransE3C=new std::vector<TH1F*>{}, *TransR=new std::vector<TH1F*>{}, *TransN=new std::vector<TH1F*>{};
0124
0125
0126 std::vector<std::vector<TH1F*>*>* Full, *Away, *Towards, *Trans;
0127
0128 FullEnergy->push_back(CEMC_FullEnergy);
0129 FullEnergy->push_back(IHCAL_FullEnergy);
0130 FullEnergy->push_back(OHCAL_FullEnergy);
0131
0132 FullE2C->push_back(CEMC_FullE2C);
0133 FullE2C->push_back(IHCAL_FullE2C);
0134 FullE2C->push_back(OHCAL_FullE2C);
0135
0136 FullE3C->push_back(CEMC_FullE3C);
0137 FullE3C->push_back(IHCAL_FullE3C);
0138 FullE3C->push_back(OHCAL_FullE3C);
0139
0140 FullR->push_back(CEMC_FullR);
0141 FullR->push_back(IHCAL_FullR);
0142 FullR->push_back(OHCAL_FullR);
0143
0144 FullN->push_back(CEMC_FullN);
0145 FullN->push_back(IHCAL_FullN);
0146 FullN->push_back(OHCAL_FullN);
0147
0148
0149 Full=new std::vector<std::vector<TH1F*>*> {FullEnergy, FullE2C, FullE3C, FullR, FullN};
0150
0151 TowardsEnergy->push_back(CEMC_TowardsEnergy);
0152 TowardsEnergy->push_back(IHCAL_TowardsEnergy);
0153 TowardsEnergy->push_back(OHCAL_TowardsEnergy);
0154
0155 TowardsE2C->push_back(CEMC_TowardsE2C);
0156 TowardsE2C->push_back(IHCAL_TowardsE2C);
0157 TowardsE2C->push_back(OHCAL_TowardsE2C);
0158
0159 TowardsE3C->push_back(CEMC_TowardsE3C);
0160 TowardsE3C->push_back(IHCAL_TowardsE3C);
0161 TowardsE3C->push_back(OHCAL_TowardsE3C);
0162
0163 TowardsR->push_back(CEMC_TowardsR);
0164 TowardsR->push_back(IHCAL_TowardsR);
0165 TowardsR->push_back(OHCAL_TowardsR);
0166
0167 TowardsN->push_back(CEMC_TowardsN);
0168 TowardsN->push_back(IHCAL_TowardsN);
0169 TowardsN->push_back(OHCAL_TowardsN);
0170
0171
0172 Towards=new std::vector<std::vector<TH1F*>*> {TowardsEnergy, TowardsE2C, TowardsE3C, TowardsR, TowardsN};
0173
0174 AwayEnergy->push_back(CEMC_AwayEnergy);
0175 AwayEnergy->push_back(IHCAL_AwayEnergy);
0176 AwayEnergy->push_back(OHCAL_AwayEnergy);
0177
0178 AwayE2C->push_back(CEMC_AwayE2C);
0179 AwayE2C->push_back(IHCAL_AwayE2C);
0180 AwayE2C->push_back(OHCAL_AwayE2C);
0181
0182 AwayE3C->push_back(CEMC_AwayE3C);
0183 AwayE3C->push_back(IHCAL_AwayE3C);
0184 AwayE3C->push_back(OHCAL_AwayE3C);
0185
0186 AwayR->push_back(CEMC_AwayR);
0187 AwayR->push_back(IHCAL_AwayR);
0188 AwayR->push_back(OHCAL_AwayR);
0189
0190 AwayN->push_back(CEMC_AwayN);
0191 AwayN->push_back(IHCAL_AwayN);
0192 AwayN->push_back(OHCAL_AwayN);
0193
0194
0195 Away=new std::vector<std::vector<TH1F*>*> {AwayEnergy, AwayE2C, AwayE3C, AwayR, AwayN};
0196
0197 TransEnergy->push_back(CEMC_TransEnergy);
0198 TransEnergy->push_back(IHCAL_TransEnergy);
0199 TransEnergy->push_back(OHCAL_TransEnergy);
0200
0201 TransE2C->push_back(CEMC_TransE2C);
0202 TransE2C->push_back(IHCAL_TransE2C);
0203 TransE2C->push_back(OHCAL_TransE2C);
0204
0205 TransE3C->push_back(CEMC_TransE3C);
0206 TransE3C->push_back(IHCAL_TransE3C);
0207 TransE3C->push_back(OHCAL_TransE3C);
0208
0209 TransR->push_back(CEMC_TransR);
0210 TransR->push_back(IHCAL_TransR);
0211 TransR->push_back(OHCAL_TransR);
0212
0213 TransN->push_back(CEMC_TransN);
0214 TransN->push_back(IHCAL_TransN);
0215 TransN->push_back(OHCAL_TransN);
0216
0217 Trans=new std::vector<std::vector<TH1F*>*> {TransEnergy, TransE2C, TransE3C, TransR, TransN};
0218
0219
0220 TDirectory* topdir=file_dir_top[threshold_index];
0221 topdir->cd();
0222 for(int i=0; i<(int)lower_dirs[threshold_index].size(); i++){
0223
0224 TDirectory* botdir=lower_dirs[threshold_index][i];
0225 botdir->cd();
0226
0227 std::string dir_name=botdir->GetName();
0228
0229 std::vector<std::vector<TH1F*>*>* rp;
0230
0231 if(dir_name.find("Full") != std::string::npos) rp=Full;
0232 else if(dir_name.find("Towards") != std::string::npos ) rp=Towards;
0233 else if(dir_name.find("Trans") != std::string::npos ) rp=Trans;
0234 else if(dir_name.find("Away") != std::string::npos ) rp=Away;
0235
0236 LoadInRegionPlots(botdir, rp);
0237
0238 }
0239 RegPlts->at(0)=Full;
0240 RegPlts->at(1)=Towards;
0241 RegPlts->at(2)=Away;
0242 RegPlts->at(3)=Trans;
0243
0244 return;
0245 }
0246
0247 std::array<std::vector<std::vector<TH1F*>*>*, 4> DrawOneThreshold(TFile* datafile, std::array<std::vector<TPad*>*, 4>* p1, std::array<std::vector<TLegend*>*, 4>* l1, int threshold_index, int style)
0248 {
0249
0250
0251 std::array<std::vector<std::vector<TH1F*>*>*, 4> RegPlts {};
0252 LoadInPlots(threshold_index, &RegPlts);
0253
0254
0255 int offset=0;
0256 std::string run_type="";
0257 if(style==0) run_type="Pedestal";
0258 if(style==1) run_type="Pulser";
0259 if(style==2) run_type="LED";
0260 std::array<std::vector<std::vector<std::string>>, 4> plot_label;
0261
0262 plot_label=GetPlotLabels(RegPlts);
0263
0264 if(threshold_index == 3 ) offset = 6;
0265 else if (threshold_index > 3) offset = 9;
0266 else if (threshold_index > 5) offset= 17;
0267
0268 for(int i=0; i<(int) p1->size(); i++){
0269 std::cout<<p1->size() <<std::endl;
0270 for(int j=0; j<(int)p1->at(i)->size(); j++)
0271 {
0272 if(!p1->at(i)->at(j)) continue;
0273 p1->at(i)->at(j)->cd();
0274 if(! RegPlts[i]->at(j)) continue;
0275 bool need_to_cont=false;
0276 for(int k=0; k<(int) RegPlts[i]->at(j)->size(); k++)
0277 if(!RegPlts[i]->at(j)->at(k))
0278 need_to_cont=true;
0279 if(need_to_cont) continue;
0280 if(style== 0){
0281 RegPlts[i]->at(j)->at(0)->SetLineColor(kGreen);
0282 RegPlts[i]->at(j)->at(0)->SetMarkerColor(kGreen);
0283 }
0284 if(style== 1){
0285 RegPlts[i]->at(j)->at(0)->SetLineColor(kTeal+3);
0286 RegPlts[i]->at(j)->at(0)->SetMarkerColor(kTeal+3);
0287 }
0288 if(style== 2){
0289 RegPlts[i]->at(j)->at(0)->SetLineColor(kBlack);
0290 RegPlts[i]->at(j)->at(0)->SetMarkerColor(kBlack);
0291 }
0292 RegPlts[i]->at(j)->at(0)->SetMarkerStyle(20+threshold_index+offset);
0293 RegPlts[i]->at(j)->at(0)->SetMarkerSize(1.5f);
0294 RegPlts[i]->at(j)->at(0)->Draw("same");
0295 l1->at(i)->at(j)->AddEntry(RegPlts[i]->at(j)->at(0), Form("%s %s ", run_type.c_str(), plot_label[i][j][0].c_str()));
0296
0297 if(style== 0 ) {
0298 RegPlts[i]->at(j)->at(1)->SetLineColor(kPink+9);
0299 RegPlts[i]->at(j)->at(1)->SetMarkerColor(kPink+9);
0300 }
0301 if(style== 1 ) {
0302 RegPlts[i]->at(j)->at(1)->SetLineColor(kOrange+7);
0303 RegPlts[i]->at(j)->at(1)->SetMarkerColor(kOrange+7);
0304 }
0305 if(style== 2 ) {
0306 RegPlts[i]->at(j)->at(1)->SetLineColor(kRed);
0307 RegPlts[i]->at(j)->at(1)->SetMarkerColor(kRed);
0308 }
0309
0310 RegPlts[i]->at(j)->at(1)->SetMarkerStyle(20+threshold_index+offset);
0311 RegPlts[i]->at(j)->at(2)->SetMarkerSize(1.5f);
0312 RegPlts[i]->at(j)->at(1)->Draw("same");
0313 l1->at(i)->at(j)->AddEntry(RegPlts[i]->at(j)->at(0), Form("%s %s", run_type.c_str(), plot_label[i][j][0].c_str()));
0314 if(style == 0){
0315 RegPlts[i]->at(j)->at(2)->SetLineColor(kCyan);
0316 RegPlts[i]->at(j)->at(2)->SetMarkerColor(kCyan);
0317 }
0318 if(style == 1){
0319 RegPlts[i]->at(j)->at(2)->SetLineColor(kBlue);
0320 RegPlts[i]->at(j)->at(2)->SetMarkerColor(kBlue);
0321 }
0322 if(style == 2){
0323 RegPlts[i]->at(j)->at(2)->SetLineColor(kViolet+1);
0324 RegPlts[i]->at(j)->at(2)->SetMarkerColor(kViolet+1);
0325 }
0326 RegPlts[i]->at(j)->at(2)->SetMarkerStyle(20+threshold_index+offset);
0327 RegPlts[i]->at(j)->at(2)->SetMarkerSize(1.5f);
0328 RegPlts[i]->at(j)->at(2)->Draw("same");
0329 l1->at(i)->at(j)->AddEntry(RegPlts[i]->at(j)->at(0), Form("%s %s", run_type.c_str(), plot_label[i][j][0].c_str()));
0330 }
0331 }
0332
0333
0334 return RegPlts;
0335 }
0336
0337
0338
0339
0340 void PlotRatios(std::vector<std::map<std::string, std::array<std::vector<std::vector<TH1F*>*>*, 4>>> Thrs, std::array<std::vector<TPad*>*,4>* prat, std::array<std::vector<TLegend*>*, 4>* Lt)
0341 {
0342
0343 int t=0;
0344 for(auto th:Thrs)
0345 {
0346 std::array<std::vector<std::vector<TH1F*>*>*, 4> Ped, Pul, LED;
0347 Ped=th["Pedestal"];
0348 Pul=th["Pulser"];
0349 bool has_led=false;
0350 if(th.find("LED") != th.end()){
0351 has_led=true;
0352 LED=th["LED"];
0353 }
0354 for(int i=0; i<4; i++)
0355 {
0356 std::vector<std::vector<TH1F*>*>* pd_r=new std::vector<std::vector<TH1F*>*>{}, *pl_r=new std::vector<std::vector<TH1F*>*>{}, *ld_r=new std::vector<std::vector<TH1F*>*>{};
0357 pd_r=Ped[i];
0358 pl_r=Pul[i];
0359 if(has_led) ld_r=LED[i];
0360 std::vector<TPad*>* rps=prat->at(i);
0361 std::vector<TLegend*>* lts=Lt->at(i);
0362 for(int j=0; j<(int) pd_r->size(); j++)
0363 {
0364 TPad* p=rps->at(j);
0365 TLegend* l=lts->at(j);
0366 p->cd();
0367 if(j==0 || j==4 ) continue;
0368 for(int k=0; k<(int) pd_r->at(j)->size(); k++)
0369 {
0370 if(!pd_r->at(j)->at(k)) continue;
0371 TH1F* ped_hist=(TH1F*)pd_r->at(j)->at(k)->Clone();
0372 if(pl_r->at(j)->at(k)->GetEntries() == 0 ) continue;
0373 ped_hist->Divide(pl_r->at(j)->at(k));
0374 ped_hist->SetYTitle(" Pedestal / (Pulser, LED) ");
0375 ped_hist->GetYaxis()->SetTitleOffset(1);
0376 ped_hist->GetYaxis()->SetTitleSize(0.05f);
0377 int offset=0;
0378 if(t== 5) offset=1;
0379 if(t==6 ) offset=9;
0380 ped_hist->SetMarkerStyle(24+t+offset);
0381 std::string lb="";
0382 std::string plt_name, thr, cal;
0383 plt_name=ped_hist->GetName();
0384 std::stringstream str_plt (plt_name);
0385 std::string subparts;
0386 bool get_name=false;
0387 while(std::getline(str_plt, subparts, '_')){
0388 if( get_name){
0389 thr=subparts;
0390 break;
0391 }
0392 else if(subparts.find("CAL") != std::string::npos){
0393 get_name=true;
0394 cal=subparts;
0395 continue;
0396 }
0397 else continue;
0398 }
0399 lb=cal+", E_{tower} #geq "+thr+" MeV";
0400 std::string lbp=" Pedestal / Pulser : "+lb;
0401 l->AddEntry(ped_hist, lbp.c_str());
0402 ped_hist->Draw("same");
0403 if(has_led ){
0404 TH1F* ped_hist_l=(TH1F*)pd_r->at(j)->at(k)->Clone();
0405 if(ld_r->at(j)->at(k)->GetEntries() == 0 ) continue;
0406 ped_hist_l->Divide(ld_r->at(j)->at(k));
0407 ped_hist_l->SetMarkerColor(ld_r->at(j)->at(k)->GetMarkerColor());
0408 ped_hist_l->SetLineColor(ld_r->at(j)->at(k)->GetLineColor());
0409 ped_hist_l->SetYTitle(" Pedestal / (Pulser, LED) ");
0410 ped_hist_l->GetYaxis()->SetTitleOffset(1);
0411 ped_hist_l->GetYaxis()->SetTitleSize(0.05f);
0412 ped_hist_l->SetMarkerStyle(24+t+offset);
0413 std::string lbl=" Pedestal / LED : "+lb;
0414 l->AddEntry(ped_hist_l, lbl.c_str());
0415 ped_hist_l->Draw("same");
0416 }
0417 }
0418 }
0419 }
0420 t++;
0421 }
0422 return;
0423 }
0424
0425
0426
0427
0428 int LocalRunThresholdScan(TFile* Pedestal_data, int ped_run, TFile* Pulser_data, int pulse_run, TFile* LED_data=NULL, int led_run = 0, bool include_led=false)
0429 {
0430 SetsPhenixStyle();
0431 Pedestal_data->cd();
0432 for(int i=0; i< 7; i++){
0433 TDirectory* t=(TDirectory*)Pedestal_data->Get(Form("Threshold_Index_%d", i));
0434 file_dir_top.push_back(t);
0435 t->cd();
0436 TDirectory* ft=(TDirectory*)t->Get(Form("Full_Calorimeter_Threshold_index_%d", i));
0437 TDirectory* tw=(TDirectory*)t->Get(Form("Towards_Region_Threshold_index_%d", i));
0438 TDirectory* aw=(TDirectory*)t->Get(Form("Away_Region_Threshold_index_%d", i));
0439 TDirectory* trans=(TDirectory*)t->Get(Form("Transverse_Region_Threshold_index_%d", i));
0440 std::array<TDirectory*, 4> sub {ft, tw, aw, trans};
0441 lower_dirs.push_back(sub);
0442 }
0443 std::cout<<"Got the directory Names"<<std::endl;
0444 std::array<std::vector<TLegend*>*, 4> LegendTitles, PlotLeg;
0445 std::array<std::vector<TPad*>*, 4> p_main, p_ratio;
0446 std::array<std::vector<TCanvas*>*, 4> Canvases;
0447 for(int i= 0; i<4; i++)
0448 {
0449 std::string region;
0450 std::vector<TLegend*> *LT=new std::vector<TLegend*>{}, *PL=new std::vector<TLegend*>{};
0451 std::vector<TPad*> *P1=new std::vector<TPad*>{}, *P2=new std::vector<TPad*>{};
0452 std::vector<TCanvas*> *cs=new std::vector<TCanvas*>{};
0453 if(i==0) region="Full Calorimeter";
0454 if(i==1) region="Lead Region";
0455 if(i==2) region="Away Region";
0456 if(i==3) region="Transverse Regions";
0457
0458 for(int j=0; j < 5; j++)
0459 {
0460 TCanvas* c1=new TCanvas(Form("c_%d_%d", i, j), Form("c_%d_%d", i, j));
0461 c1->cd();
0462 float ymin=0.33;
0463 if( j == 0 || j == 4) ymin=0;
0464 TPad* p1=new TPad(Form("p_1_%d_%d", i, j), Form("p_1_%d_%d", i, j), 0, ymin, 1, 1);
0465 TPad* p2=new TPad(Form("p_2_%d_%d", i, j), Form("p_2_%d_%d", i, j), 0, 0, 1, 0.3);
0466
0467 TLegend* l1=new TLegend(0.7, 0.5, 0.9, 0.95);
0468 l1->SetFillStyle(0);
0469 l1->SetFillColor(0);
0470 l1->SetBorderSize(0);
0471 l1->SetTextSize(0.1f);
0472 l1->AddEntry("", "#bf{#it{sPHENIX}} Internal", "");
0473 l1->AddEntry("", "Calorimeter Calibration Running", "");
0474 l1->AddEntry("", Form("Pedestal Run %d", ped_run), "");
0475 l1->AddEntry("", Form("Pulser Run %d", pulse_run), "");
0476 if(include_led) l1->AddEntry("", Form("LED Run %d", led_run), "");
0477 l1->AddEntry("", region.c_str(), "");
0478 std::string var;
0479 if(j==0) var="#sum_{Towers} Energy";
0480 if(j==1) var="2 Point Energy Correlator";
0481 if(j==2) var="3 Point Energy Correlator";
0482 if(j==3) var="Geometric Seperation of Non-zero Energy Towers";
0483 if(j==4) var="Number of non-zero energy towers";
0484 l1->AddEntry("", var.c_str(), "");
0485 LT->push_back(l1);
0486
0487 TLegend* l2=new TLegend(0.1, 0.6, 0.5, 0.85);
0488 l2->SetFillStyle(0);
0489 l2->SetFillColor(0);
0490 l2->SetBorderSize(0);
0491 l2->SetTextSize(0.01f);
0492 l2->SetNColumns(3);
0493 PL->push_back(l2);
0494
0495 P1->push_back(p1);
0496 P2->push_back(p2);
0497 cs->push_back(c1);
0498 }
0499 LegendTitles[i]=LT;
0500 PlotLeg[i]=PL;
0501 p_main[i]=P1;
0502 p_ratio[i]=P2;
0503 Canvases[i]=cs;
0504
0505 }
0506 std::vector<std::map<std::string, std::array<std::vector<std::vector<TH1F*>*>*, 4>> > threshold_maps {};
0507 for(int i=0; i<7; i++)
0508 {
0509
0510 std::map<std::string, std::array<std::vector<std::vector<TH1F*>*>*, 4>> tm;
0511 std::cout<<p_main[0]->size()<<std::endl;
0512 std::array<std::vector<std::vector<TH1F*>*>*, 4> rg_1=DrawOneThreshold( Pedestal_data, &p_main, &PlotLeg, i, 0);
0513 tm["Pedestal"]=rg_1;
0514
0515 std::array<std::vector<std::vector<TH1F*>*>*, 4> rg_2=DrawOneThreshold( Pulser_data, &p_main, &PlotLeg, i, 0);
0516 tm["Pulser"]=rg_2;
0517
0518 if(include_led){
0519 std::array<std::vector<std::vector<TH1F*>*>*, 4> rg_3=DrawOneThreshold( LED_data, &p_main, &PlotLeg, i, 0);
0520 tm["LED"]=rg_3;
0521 }
0522 threshold_maps.push_back(tm);
0523
0524 }
0525
0526 PlotRatios(threshold_maps, &p_ratio, &PlotLeg);
0527
0528 for(int i=0; i<(int)Canvases.size(); i++)
0529 {
0530 std::string region="";
0531 if(i==0) region="Full";
0532 if(i==1) region="Lead";
0533 if(i==2) region="Away";
0534 if(i==3) region="Transverse";
0535
0536 for(int j=0; j<(int)Canvases[i]->size(); j++)
0537 {
0538 Canvases[i]->at(j)->cd();
0539 p_main[i]->at(j)->Draw();
0540 if(j >= 1 && j <=3 ) p_ratio[i]->at(j)->Draw();
0541 p_main[i]->at(j)->cd();
0542 LegendTitles[i]->at(j)->Draw();
0543 PlotLeg[i]->at(j)->Draw();
0544 std::string var;
0545 if(j==0) var="E";
0546 if(j==1) var="E2C";
0547 if(j==2) var="E3C";
0548 if(j==3) var="RL";
0549 if(j==4) var="N";
0550 Canvases[i]->at(j)->Print(Form("~/local_run/thresh_scan_%s_var_%s.pdf", region.c_str(), var.c_str()));
0551 Canvases[i]->at(j)->Print(Form("~/local_run/thresh_scan_%s_var_%s.ps", region.c_str(), var.c_str()));
0552 }
0553 }
0554 return 0;
0555 }
0556 int EnergyDistr(TFile* f1, int run_num, std::string type)
0557 {
0558 SetsPhenixStyle();
0559 TCanvas* c1=new TCanvas(Form("EMC_%d_%s", run_num, type.c_str()), Form("EMC_%d_%s", run_num, type.c_str()));
0560 TCanvas* c2=new TCanvas(Form("IHC_%d_%s", run_num, type.c_str()), Form("IHC_%d_%s", run_num, type.c_str()));
0561 TCanvas* c3=new TCanvas(Form("OHC_%d_%s", run_num, type.c_str()), Form("OHC_%d_%s", run_num, type.c_str()));
0562 std::vector<TCanvas*> cs {c1, c2, c3};
0563 for(int i=0; i<(int)cs.size(); i++)
0564 {
0565 cs[i]->cd();
0566 TPad* p1=new TPad("p1", "p1", 0, 0.51, 0.49, 0.75);
0567 TPad* p2=new TPad("p2", "p2", 0.51, 0.51, 0.9, 0.75);
0568 TPad* p3=new TPad("p3", "p3", 0, 0.25, 0.49, 0.5);
0569 TPad* p4=new TPad("p4", "p4", 0.51, 0.25, 0.9, 0.5);
0570 TPad* p5=new TPad("p5", "p5", 0, 0, 0.49, 0.24);
0571 TPad* p6=new TPad("p6", "p6", 0.51, 0, 0.9, 0.24);
0572 TPad* p7=new TPad("p7", "p7", 0, 0.76, 0.49, 0.95);
0573 p7->cd();
0574 TH2F* h1, *h2, *h3, *h4, *h5, *h6, *h7;
0575 float z_max=0.;
0576 if(i==0)
0577 {
0578 h1=(TH2F*)f1->Get("emcal_energy_10_MeV");
0579 h2=(TH2F*)f1->Get("emcal_energy_21_MeV");
0580 h3=(TH2F*)f1->Get("emcal_energy_33_MeV");
0581 h4=(TH2F*)f1->Get("emcal_energy_44_MeV");
0582 h5=(TH2F*)f1->Get("emcal_energy_56_MeV");
0583 h6=(TH2F*)f1->Get("emcal_energy_68_MeV");
0584 h7=(TH2F*)f1->Get("emcal_energy_80_MeV");
0585 }
0586 if(i==1)
0587 {
0588 h1=(TH2F*)f1->Get("ihcal_energy_5_MeV");
0589 h2=(TH2F*)f1->Get("ihcal_energy_6_MeV");
0590 h3=(TH2F*)f1->Get("ihcal_energy_8_MeV");
0591 h4=(TH2F*)f1->Get("ihcal_energy_10_MeV");
0592 h5=(TH2F*)f1->Get("ihcal_energy_11_MeV");
0593 h6=(TH2F*)f1->Get("ihcal_energy_13_MeV");
0594 h7=(TH2F*)f1->Get("ihcal_energy_15_MeV");
0595
0596 }
0597 if(i==2)
0598 {
0599 h1=(TH2F*)f1->Get("ohcal_energy_10_MeV");
0600 h2=(TH2F*)f1->Get("ohcal_energy_21_MeV");
0601 h3=(TH2F*)f1->Get("ohcal_energy_33_MeV");
0602 h4=(TH2F*)f1->Get("ohcal_energy_44_MeV");
0603 h5=(TH2F*)f1->Get("ohcal_energy_56_MeV");
0604 h6=(TH2F*)f1->Get("ohcal_energy_68_MeV");
0605 h7=(TH2F*)f1->Get("ohcal_energy_80_MeV");
0606 }
0607 z_max=h1->GetMaximum();
0608 h2->GetZaxis()->SetRangeUser(0, z_max);
0609 h3->GetZaxis()->SetRangeUser(0, z_max);
0610 h4->GetZaxis()->SetRangeUser(0, z_max);
0611 h5->GetZaxis()->SetRangeUser(0, z_max);
0612 h6->GetZaxis()->SetRangeUser(0, z_max);
0613 h7->GetZaxis()->SetRangeUser(0, z_max);
0614 h1->Draw("colz");
0615 TLegend* l1=new TLegend(0.2, 0.9, 0.2, 1);
0616 l1->SetTextSize(0.1f);
0617 l1->SetFillStyle(0);
0618 l1->SetFillColor(0);
0619 l1->SetBorderSize(0);
0620 l1->AddEntry("", h1->GetTitle(), "");
0621 l1->Draw();
0622 cs[i]->cd();
0623 p7->Draw();
0624 TLegend* l=new TLegend(0.4, 0.8, 1, 1);
0625 l->SetFillStyle(0);
0626 l->SetFillColor(0);
0627 l->SetBorderSize(0);
0628 cs[i]->cd();
0629 std::string Calo="Electromagnetic";
0630 if(i==1) Calo="Inner Hadronic";
0631 else if (i==2) Calo="Outer Hadronic";
0632 l->AddEntry("", "#bf{#it{sPHENIX}} Internal", "");
0633 l->AddEntry("", Form("%s Calorimeter", Calo.c_str()), "");
0634 l->AddEntry("", Form("%s Run %d", type.c_str(), run_num), "");
0635 l->Draw();
0636 p1->cd();
0637 h2->Draw("colz");
0638 TLegend* l2=new TLegend(0, 0.9, 0.2, 1);
0639 l2->SetTextSize(0.1f);
0640 l2->SetFillStyle(0);
0641 l2->SetFillColor(0);
0642 l2->SetBorderSize(0);
0643 l2->AddEntry("", h2->GetTitle(), "");
0644 l2->Draw();
0645 cs[i]->cd();
0646 p1->Draw();
0647
0648 p3->cd();
0649 h2->Draw("colz");
0650 TLegend* l3=new TLegend(0, 0.9, 0.2, 1);
0651 l3->SetTextSize(0.1f);
0652 l3->SetFillStyle(0);
0653 l3->SetFillColor(0);
0654 l3->SetBorderSize(0);
0655 l3->AddEntry("", h3->GetTitle(), "");
0656 l3->Draw();
0657 cs[i]->cd();
0658 p3->Draw();
0659
0660 p5->cd();
0661 h4->Draw("colz");
0662 TLegend* l4=new TLegend(0, 0.9, 0.2, 1);
0663 l4->SetTextSize(0.1f);
0664 l4->SetFillStyle(0);
0665 l4->SetFillColor(0);
0666 l4->SetBorderSize(0);
0667 l4->AddEntry("", h4->GetTitle(), "");
0668 l4->Draw();
0669 cs[i]->cd();
0670 p5->Draw();
0671
0672 p2->cd();
0673 h5->Draw("colz");
0674 TLegend* l5=new TLegend(0, 0.9, 0.2, 1);
0675 l5->SetTextSize(0.1f);
0676 l5->SetFillStyle(0);
0677 l5->SetFillColor(0);
0678 l5->SetBorderSize(0);
0679 l5->AddEntry("", h5->GetTitle(), "");
0680 l5->Draw();
0681 cs[i]->cd();
0682 p2->Draw();
0683
0684 p4->cd();
0685 h6->Draw("colz");
0686 TLegend* l6=new TLegend(0, 0.9, 0.2, 1);
0687 l6->SetTextSize(0.1f);
0688 l6->SetFillStyle(0);
0689 l6->SetFillColor(0);
0690 l6->SetBorderSize(0);
0691 l6->AddEntry("", h6->GetTitle(), "");
0692 l6->Draw();
0693 cs[i]->cd();
0694 p4->Draw();
0695
0696 p6->cd();
0697 h7->Draw("colz");
0698 TLegend* l7=new TLegend(0, 0.9, 0.2, 1);
0699 l7->SetTextSize(0.1f);
0700 l7->SetFillStyle(0);
0701 l7->SetFillColor(0);
0702 l7->SetBorderSize(0);
0703 l7->AddEntry("", h7->GetTitle(), "");
0704 l7->Draw();
0705 cs[i]->cd();
0706 p6->Draw();
0707 }
0708 cs[0]->Print(Form("~/EMCAL_run_%d_type_%s.pdf", run_num, type.c_str()));
0709 cs[1]->Print(Form("~/IHCAL_run_%d_type_%s.pdf", run_num, type.c_str()));
0710 cs[2]->Print(Form("~/OHCAL_run_%d_type_%s.pdf", run_num, type.c_str()));
0711 return 0;
0712 }
0713 TH1F* getReflected(TH1F* norm)
0714 {
0715 TH1F* rf = (TH1F*) norm->Clone();
0716 rf->SetName(Form("%s_reflected", norm->GetName()));
0717 rf->SetTitle(Form("%s |E|", norm->GetTitle()));
0718 for(int i=0; i<rf->GetNbinsX(); i++)
0719 {
0720 rf->SetBinContent(i, 0);
0721 }
0722 for(int i= 0; i<norm->GetNbinsX(); i++)
0723 {
0724 float bin_center = norm->GetBinCenter(i);
0725 if( bin_center > 0 ) break;
0726 float bin_val = norm->GetBinContent(i);
0727 rf->Fill(abs(bin_center), bin_val);
0728 }
0729 return rf;
0730 }
0731 TH1F* regeneratePlot(TH1F* energies)
0732 {
0733 TH1F* thres=(TH1F*) energies->Clone();
0734 std::vector<int> freq {};
0735 float max_val = 0;
0736 for(int i = 0; i<energies->GetNbinsX(); i++)
0737 {
0738 float bin_center = energies->GetBinCenter(i);
0739 if(bin_center < 0 ) continue;
0740 freq.push_back(0);
0741 if(energies->GetBinContent(i) > 0 ) max_val = bin_center;
0742 }
0743 for(int i = 0; i < energies->GetNbinsX(); i++)
0744 {
0745 float bin_center = energies->GetBinCenter(i);
0746 if(bin_center < 0 ) continue;
0747 if((int)bin_center >= (int)max_val) break;
0748 for(int j=(int) bin_center; j < max_val; j++)
0749 {
0750 freq[j]+=energies->GetBinContent(i);
0751 }
0752 }
0753 for(int i = 0; i<(int)freq.size(); i++){
0754 thres->Fill(i, freq.at(i));
0755 }
0756 return thres;
0757 }
0758 double fitTheNegSide(TH1F* data_energy, TCanvas* c, TLegend* l, TLegend* ll, float n_evt, int cal)
0759 {
0760 c->cd();
0761 c->SetLogy();
0762 TH1F* negative_side=new TH1F(Form("neg_data_%s", data_energy->GetName()), Form("Negative Energy Side %s", data_energy->GetTitle()), data_energy->GetNbinsX(), data_energy->GetBinLowEdge(1), data_energy->GetBinLowEdge(data_energy->GetNbinsX()));
0763 if(cal==2) data_energy->Rebin(4);
0764 for(int i=0; i<data_energy->GetNbinsX(); i++)
0765 {
0766 float E=data_energy->GetBinCenter(i);
0767 if(E > 0 ) break;
0768 int N=data_energy->GetBinContent(i);
0769 for(int j=0; j<N; j++){
0770 negative_side->Fill(E);
0771 negative_side->Fill(std::abs(E));
0772 }
0773 }
0774 data_energy->Scale(1/(float)n_evt);
0775 negative_side->Scale(1/(float)n_evt);
0776 if(cal==2){
0777 data_energy->Scale(1/4.0);
0778 negative_side->Scale(1/4.0);
0779 }
0780 TF1* f_fit=new TF1("fit","gaus",data_energy->GetBinLowEdge(1), data_energy->GetBinLowEdge(data_energy->GetNbinsX()));
0781 TFitResultPtr p=negative_side->Fit(f_fit, "S");
0782 double sigma = p->Parameter(2);
0783 data_energy->Draw();
0784 if(cal==0){
0785 data_energy->GetXaxis()->SetRangeUser(-300, 999);
0786 data_energy->GetYaxis()->SetRangeUser(0.01, 1100);
0787 }
0788 else if(cal==1){
0789 data_energy->GetXaxis()->SetRangeUser(-50, 600);
0790 data_energy->GetYaxis()->SetRangeUser(0.01, 500);
0791 }
0792 else{
0793 data_energy->GetXaxis()->SetRangeUser(-100, 600);
0794 data_energy->GetYaxis()->SetRangeUser(0.01, 500);
0795 }
0796
0797 negative_side->SetMarkerColor(kPink+1);
0798 negative_side->SetLineColor(kPink+1);
0799
0800 negative_side->Draw("same");
0801 f_fit->SetLineColor(kBlack);
0802 f_fit->Draw("same");
0803 l->AddEntry(negative_side, "E_{tow} < 0, Reflected");
0804 l->AddEntry(f_fit, Form("#splitline{Gaussian Fit to Negative Side noise}{ #splitline{#mu = %.3g #pm %.2g MeV}{ #sigma = %3.3g #pm %.1g MeV }}", p->Parameter(1),p->ParError(1), sigma, p->ParError(2)), "l");
0805 l->Draw();
0806 ll->Draw();
0807 return sigma;
0808 }
0809
0810 int OneDEnergyPlots(TFile* fpedestal, int run_ph, int run_pe, TFile* fdata, int run_d, TFile* fsim10, TFile* fsim30, TFile* fsimMB)
0811 {
0812 SetsPhenixStyle();
0813 TCanvas* c1=new TCanvas("OHE", "Outer HCal Energy");
0814 TCanvas* c2=new TCanvas("IHE", "Inner HCal Energy");
0815 TCanvas* c3=new TCanvas("EME", "EM Cal Energy");
0816 TCanvas* c4=new TCanvas("OHH", "Outer HCal Hits");
0817 TCanvas* c5=new TCanvas("IHH", "Inner HCal Hits");
0818 TCanvas* c6=new TCanvas("EMH", "EM Cal Hits");
0819 TCanvas* c7=new TCanvas("AE", "AllCal Energy");
0820 TCanvas* c8=new TCanvas("AH", "All Cal Hits");
0821
0822
0823
0824
0825
0826
0827
0828
0829 std::vector<TFile*> files {fpedestal, fdata, fsim10, fsim30, fsimMB};
0830 std::vector<TLegend*> lt {}, ll {};
0831 std::vector<TCanvas*> Canvases {c1, c4, c2, c5, c3, c6, c7, c8};
0832
0833 std::vector<TPad*> pad_val, pad_rats;
0834 for(int i=0; i<8; i++)
0835 {
0836 Canvases[i]->cd();
0837 TPad* p1=new TPad("p1", "p1", 0, 0.35, 1, 1);
0838 TPad* p2=new TPad("p2", "p2", 0, 0, 1, 0.33);
0839 p1->cd();
0840 p1->SetLogy();
0841 Canvases[i]->SetLogy();
0842 if(i%2 == 1) Canvases[i]->SetLogx();
0843 float xmin=0.5;
0844 float xmax=0.85;
0845 if(i%2 == 1 ){
0846 xmin=0.2;
0847 xmax=0.35;
0848 }
0849 TLegend* l1=new TLegend(0.5, 0.7, 0.85, 1);
0850 TLegend* l=new TLegend(xmin, 0.2, xmax, 0.45);
0851 TLegend* l2=new TLegend(xmin, 0.2, xmax, 0.45);
0852 l1->SetFillStyle(0);
0853 l1->SetFillColor(0);
0854 l1->SetBorderSize(0);
0855 l->SetFillStyle(0);
0856 l->SetFillColor(0);
0857 l->SetBorderSize(0);
0858 l2->SetFillColor(0);
0859 l2->SetBorderSize(0);
0860 l->SetTextSize(0.04f);
0861 l1->SetTextSize(0.04f);
0862 l2->SetTextSize(0.04f);
0863 l1->AddEntry("", "#it{#bf{sPHENIX}} Preliminary", "");
0864 l1->AddEntry("", "p+p #sqrt{s} = 200 GeV", "");
0865
0866
0867
0868 if(i==0){
0869 l1->AddEntry("", "Outer Hadronic Calorimeter", "");
0870
0871 }
0872 if(i==1){
0873 l1->AddEntry("", "Outer Hadronic Calorimeter", "");
0874
0875 }
0876 if(i==2){
0877 l1->AddEntry("", "Inner Hadronic Calorimeter", "");
0878
0879 }
0880 if(i==3){
0881 l1->AddEntry("", "Inner Hadronic Calorimeter", "");
0882
0883 }
0884 if(i==4){
0885 l1->AddEntry("", "Electromagnetic Calorimeter", "");
0886
0887 }
0888 if(i==5){
0889 l1->AddEntry("", "Electromagnetic Calorimeter", "");
0890
0891 }
0892 if(i==6){
0893 l1->AddEntry("", "All Calorimeters binned to HCAL", "");
0894
0895 }
0896 if(i==7){
0897 l1->AddEntry("", "All Calorimeters binned to HCAL", "");
0898
0899 }
0900 lt.push_back(l);
0901 ll.push_back(l1);
0902 pad_val.push_back(p1);
0903 pad_rats.push_back(p2);
0904 }
0905 std::vector <std::string> label {"Pedestal", "p+p, 10 GeV #leq Lead jet p_{T} #leq 30 GeV ", "Pythia8 + GEANT4 + Noise, Lead jet p_{T} #geq 10 GeV","Pythia8 + GEANT4 + Noise, Lead jet p_{T} #geq 30 GeV", "Pythia, Minimum bias Detroit Tune"};
0906
0907 std::array<float, 6> maxes {0.,0.,0.,0.,0.,0.};
0908 std::vector<std::array<TH1F*,6>> rats{};
0909
0910
0911
0912
0913
0914
0915
0916
0917
0918
0919
0920
0921
0922
0923
0924
0925
0926
0927
0928
0929
0930
0931
0932
0933
0934
0935
0936
0937
0938
0939
0940
0941
0942
0943
0944
0945
0946
0947
0948
0949
0950
0951
0952
0953
0954
0955
0956
0957
0958
0959
0960
0961
0962
0963
0964
0965
0966
0967
0968
0969
0970
0971
0972
0973
0974
0975
0976
0977
0978
0979
0980
0981
0982
0983
0984
0985
0986
0987
0988
0989
0990
0991
0992
0993
0994
0995
0996
0997
0998
0999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102 for(int i=0; i<(int)files.size(); i++)
1103 {
1104 if(i==0 || i== 4) continue;
1105 TFile* f=files[i];
1106 TH1F* oh_e = (TH1F*) f->Get("ohcal_energy");
1107 TH1F* oh_h = (TH1F*) f->Get("ohc_hit");
1108 TH1F* ih_e = (TH1F*) f->Get("ihcal_energy");
1109 TH1F* ih_h = (TH1F*) f->Get("ihc_hit");
1110 TH1F* em_e = (TH1F*) f->Get("emcal_energy");
1111 TH1F* em_h = (TH1F*) f->Get("emc_hit");
1112 TH1F* a_e = (TH1F*) f->Get("allcal_energy");
1113 TH1F* a_h = (TH1F*) f->Get("amc_hit");
1114 TH1F* oh_Et = (TH1F*) f->Get("ohcal_total_E");
1115 TH1F* ih_Et = (TH1F*) f->Get("ihcal_total_E");
1116 TH1F* em_Et = (TH1F*) f->Get("emcal_total_E");
1117 TH1F* a_Et = (TH1F*) f->Get("allcal_total_E");
1118 int n_evt_oh=oh_Et->GetEntries();
1119 int n_evt_ih=ih_Et->GetEntries();
1120 int n_evt_em=em_Et->GetEntries();
1121 int n_evt_a=a_Et->GetEntries();
1122
1123
1124
1125 oh_e->SetYTitle(Form("#frac{1}{N_{events}} %s ", oh_e->GetYaxis()->GetTitle()));
1126 oh_h->SetYTitle(Form("#frac{1}{N_{events}} %s) ", oh_h->GetYaxis()->GetTitle()));
1127 ih_e->SetYTitle(Form("#frac{1}{N_{events}} %s ", ih_e->GetYaxis()->GetTitle()));
1128 ih_h->SetYTitle(Form("#frac{1}{N_{events}} %s) ", ih_h->GetYaxis()->GetTitle()));
1129 em_e->SetYTitle(Form("#frac{1}{N_{events}} %s ", em_e->GetYaxis()->GetTitle()));
1130 em_h->SetYTitle(Form("#frac{1}{N_{events}} %s) ", em_h->GetYaxis()->GetTitle()));
1131 a_e->SetYTitle(Form("#frac{1}{N_{events}} %s ", a_e->GetYaxis()->GetTitle()));
1132 a_h->SetYTitle(Form("#frac{1}{N_{events}} %s) ", a_h->GetYaxis()->GetTitle()));
1133
1134 oh_e->GetYaxis()->SetRangeUser(0.08, 500);
1135 em_e->GetYaxis()->SetRangeUser(0.08, 25000);
1136 ih_e->GetYaxis()->SetRangeUser(0.08, 500);
1137 a_e->GetYaxis()->SetRangeUser(0.08, 1600);
1138 a_h->GetYaxis()->SetRangeUser(0.08, 1600);
1139 oh_h->GetYaxis()->SetRangeUser(0.08, 1600);
1140 em_h->GetYaxis()->SetRangeUser(0.08, 25000);
1141 ih_h->GetYaxis()->SetRangeUser(0.08, 1600);
1142 oh_h->GetXaxis()->SetRangeUser(0.01, 500);
1143 ih_h->GetXaxis()->SetRangeUser(0.01, 500);
1144 oh_e->GetXaxis()->SetRangeUser(-100, 600);
1145 ih_e->GetXaxis()->SetRangeUser(-100, 600);
1146 em_e->GetXaxis()->SetRangeUser(-300, 1000);
1147 if(i==0){
1148 oh_e->SetLineColor(kGreen);
1149 oh_e->SetMarkerColor(kGreen);
1150 oh_h->SetLineColor(kGreen);
1151 oh_h->SetMarkerColor(kGreen);
1152 ih_e->SetLineColor(kGreen);
1153 ih_e->SetMarkerColor(kGreen);
1154 ih_h->SetLineColor(kGreen);
1155 ih_h->SetMarkerColor(kGreen);
1156 em_e->SetLineColor(kGreen);
1157 em_e->SetMarkerColor(kGreen);
1158 em_h->SetLineColor(kGreen);
1159 em_h->SetMarkerColor(kGreen);
1160 a_h->SetLineColor(kGreen);
1161 a_h->SetMarkerColor(kGreen);
1162 a_h->SetLineColor(kGreen);
1163 a_h->SetMarkerColor(kGreen);
1164
1165 }
1166
1167 if(i==4){
1168 oh_e->SetLineColor(kBlack);
1169 oh_e->SetMarkerColor(kBlack);
1170 oh_h->SetLineColor(kBlack);
1171 oh_h->SetMarkerColor(kBlack);
1172 ih_e->SetLineColor(kBlack);
1173 ih_e->SetMarkerColor(kBlack);
1174 ih_h->SetLineColor(kBlack);
1175 ih_h->SetMarkerColor(kBlack);
1176 em_e->SetLineColor(kBlack);
1177 em_e->SetMarkerColor(kBlack);
1178 em_h->SetLineColor(kBlack);
1179 em_h->SetMarkerColor(kBlack);
1180 a_h->SetLineColor(kBlack);
1181 a_h->SetMarkerColor(kBlack);
1182 a_h->SetLineColor(kBlack);
1183 a_h->SetMarkerColor(kBlack);
1184 }
1185 if(i==2){
1186 oh_e->SetLineColor(kBlue);
1187 oh_e->SetMarkerColor(kBlue);
1188 oh_h->SetLineColor(kBlue);
1189 oh_h->SetMarkerColor(kBlue);
1190 ih_e->SetLineColor(kBlue);
1191 ih_e->SetMarkerColor(kBlue);
1192 ih_h->SetLineColor(kBlue);
1193 ih_h->SetMarkerColor(kBlue);
1194 em_e->SetLineColor(kBlue);
1195 em_e->SetMarkerColor(kBlue);
1196 em_h->SetLineColor(kBlue);
1197 em_h->SetMarkerColor(kBlue);
1198 a_e->SetLineColor(kBlue);
1199 a_e->SetMarkerColor(kBlue);
1200 a_h->SetLineColor(kBlue);
1201 a_h->SetMarkerColor(kBlue);
1202 }
1203 if(i==3){
1204 oh_e->SetLineColor(kRed);
1205 oh_e->SetMarkerColor(kRed);
1206 oh_h->SetLineColor(kRed);
1207 oh_h->SetMarkerColor(kRed);
1208 ih_e->SetLineColor(kRed);
1209 ih_e->SetMarkerColor(kRed);
1210 ih_h->SetLineColor(kRed);
1211 ih_h->SetMarkerColor(kRed);
1212 em_e->SetLineColor(kRed);
1213 em_e->SetMarkerColor(kRed);
1214 em_h->SetLineColor(kRed);
1215 em_h->SetMarkerColor(kRed);
1216 a_e->SetLineColor(kRed);
1217 a_e->SetMarkerColor(kRed);
1218 a_h->SetLineColor(kRed);
1219 a_h->SetMarkerColor(kRed);
1220 }
1221 if(i==1){
1222 oh_e->SetLineColor(kViolet+1);
1223 oh_e->SetMarkerColor(kViolet+1);
1224 oh_h->SetLineColor(kViolet+1);
1225 oh_h->SetMarkerColor(kViolet+1);
1226 ih_e->SetLineColor(kViolet+1);
1227 ih_e->SetMarkerColor(kViolet+1);
1228 ih_h->SetLineColor(kViolet+1);
1229 ih_h->SetMarkerColor(kViolet+1);
1230 em_e->SetLineColor(kViolet+1);
1231 em_e->SetMarkerColor(kViolet+1);
1232 em_h->SetLineColor(kViolet+1);
1233 em_h->SetMarkerColor(kViolet+1);
1234 a_e->SetLineColor(kViolet+1);
1235 a_e->SetMarkerColor(kViolet+1);
1236 a_h->SetLineColor(kViolet+1);
1237 a_h->SetMarkerColor(kViolet+1);
1238 }
1239
1240
1241
1242 lt[0]->AddEntry(oh_e, Form("%s", label[i].c_str()));
1243
1244
1245 lt[1]->AddEntry(oh_h, Form("%s", label[i].c_str()));
1246
1247
1248 lt[2]->AddEntry(ih_e, Form("%s", label[i].c_str()));
1249
1250
1251 lt[3]->AddEntry(ih_h, Form("%s", label[i].c_str()));
1252
1253
1254 lt[4]->AddEntry(em_e, Form("%s", label[i].c_str()));
1255
1256
1257 lt[5]->AddEntry(em_h, Form("%s", label[i].c_str()));
1258
1259
1260 lt[6]->AddEntry(a_e, Form("%s", label[i].c_str()));
1261
1262
1263 lt[7]->AddEntry(a_h, Form("%s", label[i].c_str()));
1264
1265
1266
1267 if(i==1){
1268 TCanvas* co=new TCanvas("c_ohcal", "data_ohcal");
1269 TCanvas* ci=new TCanvas("c_ihcal", "data_ihcal");
1270 TCanvas* ce=new TCanvas("c_emcal", "data_emcal");;
1271 co->cd();
1272 TLegend* lb1=(TLegend*)ll[0]->Clone();
1273 lb1->Draw();
1274 ci->cd();
1275 TLegend* lb2=(TLegend*)ll[2]->Clone();
1276 lb2->Draw();
1277 ce->cd();
1278 TLegend* lb3=(TLegend*)ll[4]->Clone();
1279 lb3->Draw();
1280
1281 TLegend* lo=(TLegend*)lt[0]->Clone();
1282 TLegend* li=(TLegend*)lt[2]->Clone();
1283 TLegend* le=(TLegend*)lt[4]->Clone();
1284 TH1F* oh_e2=(TH1F*)oh_e->Clone();
1285 TH1F* ih_e2=(TH1F*)ih_e->Clone();
1286 TH1F* em_e2=(TH1F*)em_e->Clone();
1287 double sigma_o=fitTheNegSide(oh_e2, co, lo, lb1, n_evt_oh, 2);
1288 double sigma_i=fitTheNegSide(ih_e2, ci, li, lb2, n_evt_ih, 1);
1289 double sigma_e=fitTheNegSide(em_e2, ce, le, lb3, n_evt_em, 0);
1290 }
1291 oh_e->Rebin(4);
1292 oh_e->Scale(1/((float)n_evt_oh*4.0));
1293 oh_h->Scale(1/(float)n_evt_oh);
1294
1295 ih_e->Scale(1/(float)n_evt_ih);
1296 ih_h->Scale(1/(float)n_evt_ih);
1297
1298 em_e->Scale(1/(float)n_evt_em);
1299 em_h->Scale(1/(float)n_evt_em);
1300
1301 a_e->Scale(1/(float)n_evt_a);
1302 a_h->Scale(1/(float)n_evt_a);
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346 Canvases[0]->cd();
1347
1348 oh_e->Draw("same");
1349
1350
1351
1352
1353
1354
1355
1356 Canvases[1]->cd();
1357 oh_h->Draw("same");
1358
1359
1360
1361
1362
1363
1364
1365
1366 Canvases[2]->cd();
1367 ih_e->Draw("same");
1368
1369
1370
1371
1372
1373
1374
1375 Canvases[3]->cd();
1376 ih_h->Draw("same");
1377
1378
1379
1380
1381
1382
1383
1384 Canvases[4]->cd();
1385 em_e->Draw("same");
1386
1387
1388
1389
1390
1391
1392
1393 Canvases[5]->cd();
1394 em_h->Draw("same");
1395
1396
1397
1398
1399
1400
1401 Canvases[6]->cd();
1402 a_e->Draw("same");
1403
1404
1405
1406
1407
1408
1409 Canvases[7]->cd();
1410 a_h->Draw("same");
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436 }
1437 for(int i=0; i<(int)Canvases.size(); i++)
1438 {
1439 Canvases[i]->cd();
1440 lt[i]->Draw();
1441 ll[i]->Draw();
1442
1443 }
1444
1445
1446
1447
1448
1449
1450
1451 return 0;
1452 }
1453 #endif