Hi experts,
I am a beginner in root. when I try to project my output root tree named events to two histograms named test2 and test3,in a single canvas. However, in output only test2 is working. I hereby give my code. can anyone help me ?
#include <iostream>
#include <vector>
void DrawTrack(const char* file_name){
//fle_name="gun_g4sim.root"
TCanvas *c1 = new TCanvas("c1","PionTrack",600,600);
TDirectory *where = gDirectory;
TH2D *test2 = new TH2D("test2","Track of pions",300,-300,300,300,-300,300);
TH2F *test3 = new TH2F("pion decay","Decay_of_primary_pion2",300,-300,300,300,-300,300);
TFile *_file0 = TFile::Open(file_name);
TTree *events = (TTree*)_file0->Get("events");
where->cd();
test2->SetMarkerStyle(8);
test2->SetMarkerSize(1);
test2->SetMarkerColor(4);
test2->GetXaxis()->SetTitle("X [mm]");
test2->GetYaxis()->SetTitle("Y [mm");
events->Project("test3","tpc_positionedHits.position.y:tpc_positionedHits.position.x","tpc_positionedHits.core.bits==1","");
test2->Draw();
events->Project("test2","tpc_positionedHits.position.y:tpc_positionedHits.position.x","tpc_positionedHits.core.bits==1","same");
test3->SetMarkerStyle(2);
test3->SetMarkerSize(1);
test3->SetMarkerColor(3);
test3->Draw("same");
TEllipse *el1 = new TEllipse(0.,40.,41.005,41.005,365.0,0.0);
el1->SetFillStyle(0);
el1->SetLineColor(2);
el1->SetLineWidth(3);
//el1->SetFillColorAlpha(kWhite, 1.0);
el1->Draw("same");
TEllipse *beampipe = new TEllipse(0, 40, 13.6, 0.0, 0.0, 365.0, 0.0);
beampipe->SetFillStyle(0);
beampipe->SetLineColor(4);
beampipe->SetLineWidth(5);
beampipe->Draw("same");
TLatex *lsolid = new TLatex(-278, 250, "Pions with momentus 75MeV");
lsolid->SetTextSize(0.022);
lsolid->Draw("same");
TEllipse *el2 = new TEllipse(0.,20.,199.5,199.5,365.0,0.0);
el2->SetFillStyle(0);
el2->SetLineColor(3);
el2->SetLineWidth(3);
el2->Draw("same");
}
ROOT Version: 6.13
Platform: Ubuntu 16.04
Compiler: Not Provided