@@ -54,39 +54,37 @@ EntryConfig::EntryConfig(const Axis& x, Cuts* cuts_x, const Axis& y, Cuts* cuts_
5454 InitPlot ();
5555}
5656
57-
58-
5957TH1* EntryConfig::CreateHisto1D () const {
60- auto * ret = new TH1F (name_.c_str (), title_.c_str (),
61- axes_.at (0 ).GetNbins (), axes_.at (0 ).GetXmin (), axes_.at (0 ).GetXmax ());
62- ret->SetXTitle (axes_.at (0 ).GetTitle ());
58+ auto x = axes_.at (0 );
59+ TH1* ret = x.IsVariableBinSize () ?
60+ new TH1F (name_.c_str (), title_.c_str (), x.GetNbins (), x.GetXbins ()->GetArray ()) :
61+ new TH1F (name_.c_str (), title_.c_str (), x.GetNbins (), x.GetXmin (), x.GetXmax ());
62+ ret->SetXTitle (x.GetTitle ());
6363 ret->SetYTitle (" Entries" );
6464 return ret;
6565}
66- // TODO fix axes
66+
6767TProfile* EntryConfig::CreateProfile () const {
68+ auto x{axes_.at (0 )}, y{axes_.at (1 )};
69+ auto ret = x.IsVariableBinSize () ?
70+ new TProfile (name_.c_str (), title_.c_str (), x.GetNbins (), x.GetXbins ()->GetArray ()) :
71+ new TProfile (name_.c_str (), title_.c_str (), x.GetNbins (), x.GetXmin (), x.GetXmax ());
6872
69- TProfile* ret{nullptr };
70- if (axes_[1 ].GetNbins () == 1 && axes_[1 ].GetXmax () == 1 . && axes_[1 ].GetXmin () == 0 .) {// Not init by user
71- ret = new TProfile (name_.c_str (), title_.c_str (),
72- axes_.at (0 ).GetNbins (), axes_.at (0 ).GetXmin (), axes_.at (0 ).GetXmax ());
73- } else if (axes_.size () == 2 ) {
74- ret = new TProfile (name_.c_str (), title_.c_str (),
75- axes_.at (0 ).GetNbins (), axes_.at (0 ).GetXmin (), axes_.at (0 ).GetXmax (),
76- axes_.at (1 ).GetXmin (), axes_.at (1 ).GetXmax ());
77- }
78- ret->SetYTitle (axes_.at (1 ).GetTitle ());
79- ret->SetXTitle (axes_.at (0 ).GetTitle ());
73+ ret->SetXTitle (x.GetTitle ());
74+ ret->SetYTitle (y.GetTitle ());
8075 return ret;
8176}
8277
8378TH2* EntryConfig::CreateHisto2D () const {
79+ auto x{axes_.at (0 )}, y{axes_.at (1 )};
80+ assert (x.IsVariableBinSize () && y.IsVariableBinSize () || !x.IsVariableBinSize () && !y.IsVariableBinSize ());
81+
82+ auto * ret = x.IsVariableBinSize () ?
83+ new TH2F (name_.c_str (), title_.c_str (), x.GetNbins (), x.GetXbins ()->GetArray (), y.GetNbins (), y.GetXbins ()->GetArray ()) :
84+ new TH2F (name_.c_str (), title_.c_str (), x.GetNbins (), x.GetXmin (), x.GetXmax (), y.GetNbins (), y.GetXmin (), y.GetXmax ());
8485
85- auto * ret = new TH2F (name_.c_str (), title_.c_str (),
86- axes_.at (0 ).GetNbins (), axes_.at (0 ).GetXmin (), axes_.at (0 ).GetXmax (),
87- axes_.at (1 ).GetNbins (), axes_.at (1 ).GetXmin (), axes_.at (1 ).GetXmax ());
88- ret->SetXTitle (axes_.at (0 ).GetTitle ());
89- ret->SetYTitle (axes_.at (1 ).GetTitle ());
86+ ret->SetXTitle (x.GetTitle ());
87+ ret->SetYTitle (y.GetTitle ());
9088 ret->SetZTitle (" Entries" );
9189 ret->SetMinimum (1 );
9290 return ret;
0 commit comments