Dear Experts,
How Can I modify the TH1D and TProfile public member function for variable binning?
Definition of TH1D ::
TH1D (const char *name, const char *title, Int_t nbinsx, const Double_t *xbins)
Here I want to implement two things.
1st: Want to change the fourth argument from “const Double_t” to “Double_t”.
2nd: Want to change the fourth argument from 1D array to 2D vector. Let’s assume,
int bin1 = 4;
const double arr1[bin1+1] = {1, 2, 3, 4, 6};
int bin2 = 7;
const double arr2[bin2+1] = {1, 2, 3.5, 4, 6.2, 7.5, 8.0, 9.1};
TH1D *h1 = new TH1D( “h1”, “h1”, bin1, arr1 )
TH1D *h2 = new TH1D( “h2”, “h2”, bin2, arr2 )
****Here instead of writing two histograms I want to define them in a loop. Like,
int bin [2] = {4, 7};
vector<vector> vect = { {1, 2, 3, 4, 6}, {1, 2, 3.5, 4, 6.2, 7.5, 8.0, 9.1} };
TH1D *h[2];
for(int i = 0; i<vect.size(); i++)
{
h[i] = new TH1D( Form(“h_%d”,i), Form(“h_%d”,i), bin[i], vect[i] );
}
Where
vect[0] = {1, 2, 3, 4, 6};
vect[1] = {1, 2, 3.5, 4, 6.2, 7.5, 8.0, 9.1};
Similarly, I also want to modify the 1D TProfile member function for the same above purposes. But the predefined TH1D and TProfile public member functions are not allowing me to do that.
Could you please tell me how to implement that?
Thanks in advance.
Regards,
Sayan
Please read tips for efficient and successful posting and posting code
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided