I want to superimpose two graphs
first
TFile *f= new TFile(“f/f01.root”);
hprof = new TProfile(“hprof”,“Profile of e versus a”,20,-100,100,0,100.);
second
vInput.open(Form("%sfile.dat",dir.Data()));
gr2 = new TGraph(vNData,x1,y1);
gr2->Draw(“ACP”)
when I write the script, I have just garph n2 of file.dat gr2
my script ***************************************************
#include <stdio.h>
#include <TROOT.h>
#include <fstream.h>
#include <iostream.h>
TGraph *gr2 ;
void profhit(){
gROOT->Reset();
gROOT->Time();
Float_t x,y,z,alpha;
gStyle->SetTitleFontSize(0.03);
gStyle->SetPalette(1);
TFile *f= new TFile("f01.root");
Hits->SetBranchAddress("x",&x);
Hits->SetBranchAddress("y",&y);
Hits->SetBranchAddress("z",&z);
Hits->SetBranchAddress("alpha",&alpha);
TCanvas* c1= new TCanvas("c1","",600);
hprof = new TProfile("hprof","Profile of alpha versus y",20,-100,100,0,100.);
Int_t nentries=(Int_t)Hits->GetEntries();
for (Int_t i=0;i<nentries;i++)
{
Hits->GetEntry(i);
hprof->Fill(y,alpha);
hprof->Draw();
}
ofstream sortie;/// pb I have not in sortie
sortie.open("alpha.txt",ios::out);
for (y=0;y<200;y++)
{
sortie<<alpha[y]<<" "<<alpha[y]<<endl;
}
sortie.close();
TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName());
dir.ReplaceAll("alpha.C","");
dir.ReplaceAll("/./","/");
Double_t *x1 = new Double_t[400];
Double_t *y1 = new Double_t[400];
Double_t vX1, vY1;
Int_t vNData = 0;
ifstream vInput;
vInput.open(Form("%sfile.dat",dir.Data()));
while (1) {
vInput >> vX1 >> vY1;
if (!vInput.good()) break;
x1[vNData] = vX1;
y1[vNData] = vY1;
vNData++;
}//while
vInput.close();
gr2 = new TGraph(vNData,x1,y1);
gr2->SetMarkerColor(kRed);
gr2->SetMarkerStyle(20);
gr2->Draw("ACP");
}