Hello experts, I have a 2D histos of different particle species and i want to plot its projections in one histo. i’m doing it by TStack class but it just showed me the last histo that i added in it. I didn’t get what i"m doing wrong please tell me how can i do it is there anyother way to show it. this is the code:
THStack *hs=new THStack("hs"," ");
TFile *f = TFile::Open ("Input.root");
TList *l =(TList*) f ->Get("Input1");
TH2F *h =(TH2F*) l ->FindObject("hDeuteron");
TH2F *hP=(TH2F*) l ->FindObject("hProtons")
TH1F *histo1= (TH1F*)h ->ProjectionY("2.2-2.6 GeV",110,130,"");
histo1 ->SetLineColor(kRed);
histo1 -> SetLineWidth(1);
histo1 ->SetMarkerStyle(7);
hs ->Add(histo1);
TH1F *histo2= (TH1F*)hP ->ProjectionY("2.2-2.6 GeV",110,130,"");
histo2 ->SetLineColor(kBlue);
histo2 -> SetLineWidth(1);
hs->Add(histo2);
hs->Add(histo2);
TCanvas *c1 =new TCanvas ("c1","",900,900);
c1 ->SetLogy();
hs->Draw("nostack");
it shows me just one last histo.although i used the same class for the histos that filled with data, it worked but not with projections. please tell me what shoild i do. thank you.
Regards,
Sana Shahid
