So I have this code that helps extract two plots and divide them however how would I vary the histograms bin sizes I have extracted individually and the histogram that is created by dividing the other two ? I want to know how to have different bin sizes. I know how to create the number of bins and there width but they are all usually the same size bins and right now they are not ?
This is the code I use to extract and draw out the plots.
Can you post here any of those examples? Typically, you need the original data to rebuild the histograms (I am currently not sure whether that is serialized by the I/O layer when the histograms are written to a ROOT file).
Let me put a more simple example where I would want to have a varied width size and maybe through this example I can apply it to my main code
void getrandomh() {
TH1F *source = new TH1F("source","source hist",100,-3,3);
source->FillRandom("gaus",1000);
// Fill Random is a funciton or feature with in the TH1F class we access it through our pointer called source
//FillRandom("the type of function that will I guess determine how the data distributed, so in this case we have a gaussian with the "gaus"
// the parameter 1000 indicates how many random numbers are generated and also how many are filled in the histogram called source
TH1F *final = new TH1F("final","final hist",100,-3,3);
// continued...
for (Int_t i=0;i<10000;i++) {
// Int_t is a signed integer which can be both postive and negative
// i = 0, as long as i is less then 1000 the for look will continue
// i++ is basically increasing the variable i by one so i = i+1
final->Fill(source->GetRandom());
// Aslong as the loop is going we we continue filling the final histogoram with values represented by i
// Here the get randmom operator is used to get random number distributed according tp the contents of a histogram which is the source histogram
// Fill a histogram following the distribution of a existing histogram we can use as a second signature, we like intgerate and normalize the values i believe
}
Double_t xbins[3];
TH1F *J = (TH1F*) final->Rebin(2,"hnew",xbins);
// We are using for loop for the final plot to fill in the values
TCanvas *c2 = new TCanvas ("c2","c2",800,100);
J->Draw();
TCanvas *c1 = new TCanvas("c1","c1",800,1000);
// The lst two values are like width and length of the image will come out as
// A canvas is an area mapped to a window directly under the control of the display manager
c1->Divide(1,2);
//(main pad, divided by 2 so we have 2 pads now)
// this command is what allows us to print the plots on the same canvaas but divided evenly one on top the other on bottom
c1->cd(1);
// the first pad is active now so now we use the source->draw() to visually show us the plot in pad one
source->Draw();
c1->cd(2);
// Now pad 2 is active so now we have to insert the plot into that pad
// basically draws plot two in pad two
final->Draw();
c1->cd();
// My attempt in trying to have different width size you can ignore
Float_t Lower[5];
Lower[0] = -3;
Lower[1] = -1;
Lower[2] = 2;
Lower[3] = 2.5;
Lower[4] = 3;
TH1F* hist =new TH1F (*final,"hist", 4, Lower);
hist->SetBinContent(1, 1);
hist->SetBinContent(2, 2);
hist->SetBinContent(3, 3);
hist->SetBinContent(4, 4);
hist->SetMinimum(0);
hist->Draw();
}
So here to reproduce the final or source signal in new bins how would we change the bins but also how to have different bin sizes.
@Abaraj48 did you get the values right for each element of the Lower[] array? Could you please provide an excerpt of the relevant fragments of the code that you have?