38 TH1D* bg_proj =
nullptr;
48 xlow =
GetTH2()->GetXaxis()->GetBinLowEdge(firstbin);
49 xhigh =
GetTH2()->GetXaxis()->GetBinUpEdge(lastbin);
50 bg_xlow =
GetTH2()->GetXaxis()->GetBinLowEdge(first_bg_bin);
51 bg_xhigh =
GetTH2()->GetXaxis()->GetBinUpEdge(last_bg_bin);
53 proj =
GetTH2()->ProjectionX(
"temp1", firstbin, lastbin);
54 bg_proj =
GetTH2()->ProjectionX(
"temp2", first_bg_bin, last_bg_bin);
55 }
else if(axis == 1) {
56 xlow =
GetTH2()->GetYaxis()->GetBinLowEdge(firstbin);
57 xhigh =
GetTH2()->GetYaxis()->GetBinUpEdge(lastbin);
58 bg_xlow =
GetTH2()->GetYaxis()->GetBinLowEdge(first_bg_bin);
59 bg_xhigh =
GetTH2()->GetYaxis()->GetBinUpEdge(last_bg_bin);
61 proj =
GetTH2()->ProjectionY(
"temp1", firstbin, lastbin);
62 bg_proj =
GetTH2()->ProjectionY(
"temp2", first_bg_bin, last_bg_bin);
67 Form(
"%s_%s_%d_%d_bg_%d_%d",
GetTH2()->GetName(), sproj.c_str(), firstbin, lastbin, first_bg_bin, last_bg_bin);
68 title = Form(
"%s_%s_%d[%.02f]_%d[%.02f]_bg_%d[%.02f]_%d[%.02f]",
GetTH2()->GetName(), sproj.c_str(), firstbin, xlow,
69 lastbin, xhigh, first_bg_bin, bg_xlow, last_bg_bin, bg_xhigh);
71 double bg_scaling =
static_cast<double>(lastbin - firstbin) /
static_cast<double>(last_bg_bin - first_bg_bin);
76 proj->Add(bg_proj, -bg_scaling);
77 auto* output =
new GH1D(*proj);
81 output->SetName(name.c_str());
82 output->SetTitle(title.c_str());
83 output->SetParent(
GetTH2());
84 output->SetProjectionAxis(axis);
85 output->SetDirectory(
nullptr);
93 double xlow =
GetTH2()->GetYaxis()->GetBinLowEdge(firstbin);
94 double xhigh =
GetTH2()->GetYaxis()->GetBinUpEdge(lastbin);
96 if(firstbin == 0 && lastbin == -1) {
98 title = Form(
"%s_totalx",
GetTH2()->GetName());
100 title = Form(
"%s_projx_%d[%.02f]_%d[%.02f]",
GetTH2()->GetName(), firstbin, xlow, lastbin, xhigh);
103 std::string actual_name = name;
104 if(actual_name ==
"_px") {
108 actual_name = Form(
"%s_projx_%d_%d",
GetTH2()->GetName(), firstbin, lastbin);
112 GH1D* output =
nullptr;
115 TH1D* proj =
GetTH2()->ProjectionX(
"temp", firstbin, lastbin, option);
116 output =
new GH1D(*proj);
120 output->SetName(actual_name.c_str());
121 output->SetTitle(title.c_str());
124 output->SetDirectory(
nullptr);
127 if(KeepEmpty || output->Integral() > 0) {
131 if(KeepEmpty || output->Integral() > 0) {
147 double ylow =
GetTH2()->GetXaxis()->GetBinLowEdge(firstbin);
148 double yhigh =
GetTH2()->GetXaxis()->GetBinUpEdge(lastbin);
150 if(firstbin == 0 && lastbin == -1) {
152 title = Form(
"%s_totaly",
GetTH2()->GetName());
154 title = Form(
"%s_projy_%d[%.02f]_%d[%.02f]",
GetTH2()->GetName(), firstbin, ylow, lastbin, yhigh);
157 std::string actual_name = name;
158 if(actual_name ==
"_py") {
162 actual_name = Form(
"%s_projy_%d_%d",
GetTH2()->GetName(), firstbin, lastbin);
166 GH1D* output =
nullptr;
169 TH1D* proj =
GetTH2()->ProjectionY(
"temp", firstbin, lastbin, option);
170 output =
new GH1D(*proj);
174 output->SetName(actual_name.c_str());
175 output->SetTitle(title.c_str());
178 output->SetDirectory(
nullptr);
181 if(KeepEmpty || output->Integral() > 0) {
185 if(KeepEmpty || output->Integral() > 0) {
248 if(curr !=
nullptr) {
249 name = curr->GetName();
250 size_t underscore_pos = name.rfind(
'_');
251 binnum = std::atoi(name.c_str() + underscore_pos + 1);
257 max_binnum =
GetTH2()->GetXaxis()->GetNbins();
259 max_binnum =
GetTH2()->GetYaxis()->GetNbins();
262 if(binnum > max_binnum) {
266 int start_bin = binnum;
268 std::string hist_name = Form(
"%s_%d",
GetTH2()->GetName(), binnum);
270 if((
hist !=
nullptr) &&
hist->Integral() > 0) {
282 if((
hist !=
nullptr) &&
hist->Integral() > 0) {
286 if(binnum == start_bin) {
298 if(curr !=
nullptr) {
299 name = curr->GetName();
300 size_t underscore_pos = name.rfind(
'_');
301 binnum = std::atoi(name.c_str() + underscore_pos + 1);
307 max_binnum =
GetTH2()->GetXaxis()->GetNbins();
309 max_binnum =
GetTH2()->GetYaxis()->GetNbins();
316 std::string hist_name = Form(
"%s_%d",
GetTH2()->GetName(), binnum);
319 return static_cast<GH1D*
>(obj);
323 int start_bin = binnum;
325 std::string hist_name2 = Form(
"%s_%d",
GetTH2()->GetName(), binnum);
334 if((
hist !=
nullptr) &&
hist->Integral() > 0) {
338 if(binnum == start_bin) {
GH1D * ProjectionY_Background(int firstbin=0, int lastbin=-1, int first_bg_bin=0, int last_bg_bin=-1, EBackgroundSubtraction mode=EBackgroundSubtraction::kRegionBackground)
GH1D * ProjectionX_Background(int firstbin=0, int lastbin=-1, int first_bg_bin=0, int last_bg_bin=-1, EBackgroundSubtraction mode=EBackgroundSubtraction::kRegionBackground)
GH1D * Projection_Background(int axis=0, int firstbin=0, int lastbin=-1, int first_bg_bin=0, int last_bg_bin=-1, EBackgroundSubtraction mode=EBackgroundSubtraction::kRegionBackground)