How to surimpose histograms from GEANT4 on an acquision histogram

Hello ,
I simulated energy deposits in a scintillator with a gamma source on GEANT4. Now I would like to superimpose by Root my histogram obtained in manipulation which is in number of charges. I am looking for a method to normalize my acquisition histogram and to superimpose it on my simulation in order to compare them.
Would someone have an idea of how to do it please?

Thanks to all !
_

TH1::Scale
TH1::DrawNormalized

I think we would need some code example showing what you are doing. With “Scale” you should be able to normalised by some factor one of the histogram. Then you should Draw the first histogram of the 2nd histogram on top using option SAME. If the axis do not really match ou can use THStack which will compute for you the axis containing all the histograms you put in.

Thank you for your replay !

Here is a example of my code :

TString fileName = GEANT4File.root
	TFile *f = new TFile(fileName);
	TTree *Tree = (TTree*)f->Get("Tree");
	nbEntries = Tree->GetEntries();
	cout << "entries : " << nbEntries << endl;

	Float_t Energy;
  
	Tree->SetBranchAddress("Energy",&Energy);


	TString fileName = "MANIPULATIONFILE.root";
	
	TFile * file1 = TFile::Open(fileName);
      histo = (TH1F*)file1->Get("histo");

	TH1F *histo_GEANT4   = new TH1F("Signal","",500,0,1500);
histo_Geant4->Fill(energy)

TCanvas *C_superposition = new TCanvas();
	histo_GEANT4->Draw();
 	histo->Draw("same");

//NORMALIZATION 

histo_GEANT4->Scale(1/histo_GEANT4->Integral());
histo->Scale(histo->Integral()/histo_GEANT4->Integral());

you should normalise before doing the drawing

I put the normalization before the Draw, but it doesn’t change the problem unfortunately.

Yu create the “histo_GEANT4” but you do not fill it (so, it’s empty, hence its integral is zero).

@Wile_E_Coyote is right. You do:

TH1F *histo_GEANT4   = new TH1F("Signal","",500,0,1500);
TCanvas *C_superposition = new TCanvas();
histo_GEANT4->Draw();

So histo_GEANT4 is empty

Yes you are right, when I copied my code I forgot the part about filling the histogram. Otherwise in my code I did fill as I just modified in my code above. I would like to try DrawNormalized, being a beginner I don’t know how to use it correctly.

The help is here. You only need to do:

H->DrawNormalized("",0.5)

To normalise H to 0.5 and produce the corresponding plot.

Maybe:

histo_GEANT4->DrawNormalized("", histo->Integral());
histo->Draw("SAME");

or:

histo_GEANT4->Draw("");
histo->DrawNormalized("SAME", histo_GEANT4->Integral());

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.