Dear rooters,
I am a begginner in root and will be grateful if anyone could
show me how to superimpose two or more histograms from
different C++ macros, example: tb_9GeV_elec.C and tb_9GeV_pion.C all in
the same directory. I have been able to execute these macros without any
error, and display the histograms on a TCanvas which all came out nicely
but now my problem is how to superimpose the two named histograms: h10 in
tb_9GeV_elec.C and another h10 in tb_9GeV_pion.C.
However, below is my key parts of my macro. Thank you all in advance for
your assistance.
I am working with root 4.02/02 on Linux machine.
Regards,
Addy.
macro:tb_9GeV_elec.C, looks this
#include tb_elec2.C
#include "tb_9GeV_elec.h"
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>
void tb_9GeV_elec()
{
gStyle->SetCanvasBorderMode(0);
gStyle->SetPadBorderMode(0);
char name0[80],
//Get Branches needed
tree->SetBranchesAddress("trk_nTrtHits", trk_nTrthits")
//Defining the Canvas
TCanvas *c1 = new TCanvas("c1", "electron track selection @9GeV,
50,50,600,800);
//Histograms
TH1F *h10 =new TH1F("HL electron per track", "nHL per electron
track",30,0.,30.);
//Loop over hits
for (int hit=0;hit<trk_nTrrtHits[track];hit++) {
if (sADC_C2>650){
h10->Fill(nhigh);
}
c1-cd();
h10-Draw(); h10->SetFillColor(7) h10->SetXaxis()->SetTitle("nHL hit per track with cut")c1->Update();
macro2 tb_9GeV_pion.C
I used the same macro but pion beam energy.
macro:tb_9GeV_elec.C, looks this
#include tb_9GeV_pion.C
#include "tb_9GeV_pion.h"
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>
void tb_9GeV_pion()
{
gStyle->SetCanvasBorderMode(0);
gStyle->SetPadBorderMode(0);
char name0[80],
//Get Branches needed
tree->SetBranchesAddress("trk_nTrtHits", trk_nTrthits")
//Defining the Canvas
TCanvas *c1 = new TCanvas("c1", "electron track selection @9GeV,
50,50,600,800);
//Histograms
TH1F *h10 =new TH1F("HL electron per track", "nHL per electron
track",30,0.,30.);
//Loop over hits
for (int hit=0;hit<trk_nTrrtHits[track];hit++) {
if (sADC_C2>650){
h10->Fill(nhigh);
}
c1-cd();
h10-Draw(); h10->SetFillColor(7) h10->SetXaxis()->SetTitle("nHL hit per track with cut")c1->Update();
This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:13 MET