Two histogram in one plain


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


i am trying to plot two histogram in common axis so i write the program

TFile f("charm02.root");

TCut cut1 = "(sqrt((e1+e2)*(e1+e2)-(px1+px2)*(px1+px2)-(py1+py2)*(py1+py2)-(pz1+pz2)*(pz1+pz2)))>1.5";
TCut cut2 = "(sqrt((e1+e2)*(e1+e2)-(px1+px2)*(px1+px2)-(py1+py2)*(py1+py2)-(pz1+pz2)*(pz1+pz2)))<2.5";
TCut cut3 = "(px1*px1+py1*py1+pz1*pz1)>3 && (px2*px2+py2*py2+pz2*pz2)>3";
TCut cut4 = "abs(eta2)>1.2 && abs(eta2)<2.2";

T->Draw("abs(phi1 - phi2)", cut1 && cut2 && cut3 && cut4 );



TCut cut5 = "(sqrt((pe1+pe2)*(pe1+pe2)-(ppx1+ppx2)*(ppx1+ppx2)-(ppy1+ppy2)*(ppy1+ppy2)-(ppz1+ppz2)*(ppz1+ppz2)))>1.5";
TCut cut6 = "(sqrt((pe1+pe2)*(pe1+pe2)-(ppx1+ppx2)*(ppx1+ppx2)-(ppy1+ppy2)*(ppy1+ppy2)-(ppz1+ppz2)*(ppz1+ppz2)))<2.5";
TCut cut7 = "(ppx1*ppx1+ppy1*ppy1+ppz1*ppz1)>3 && (ppx2*ppx2+ppy2*ppy2+ppz2*ppz2)>3";
TCut cut8 = "abs(peta2)>1.2 && abs(peta2)<2.2";

PC->Draw("abs(pphi1 - pphi2)","","SAME", cut5 && cut6 && cut7 && cut8 );
}

and the eroor comes

Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1
input_line_40:2:7: error: no matching member function for call to 'Draw'
 (PC->Draw("abs(pphi1 - pphi2)", "", "SAME", ((*(class TCut*)0x7f7586e98...
  ~~~~^~~~
/home/tarun/software/root/include/TTree.h:357:28: note: candidate function not viable: no known conversion from 'TCut' to 'Long64_t'
      (aka 'long long') for 4th argument
   virtual Long64_t        Draw(const char* varexp, const char* selectio...
                           ^
/home/tarun/software/root/include/TTree.h:356:28: note: candidate function not viable: no known conversion from 'TCut' to 'Long64_t'
      (aka 'long long') for 4th argument
   virtual Long64_t        Draw(const char* varexp, const TCut& selectio...
                           ^
/home/tarun/software/root/include/TTree.h:355:28: note: candidate function not viable: requires single argument 'opt', but 4 arguments
      were provided
   virtual void            Draw(Option_t* opt) { Draw(opt, "", "", kMaxE...
                           ^
Error in <TRint::HandleTermInput()>: cling::CompilationException caught: Error evaluating expression (PC->Draw("abs(pphi1 - pphi2)", "", "SAME", ((*(class TCut*)0x7f7586e98458)) && ((*(class TCut*)0x7f7586e98498)) && ((*(class TCut*)0x7f7586e984d8)) && ((*(class TCut*)0x7f7586e98518))))

please help me

PC->Draw("abs(pphi1 - pphi2)", cut5 && cut6 && cut7 && cut8, "same");

1 Like

You may have a look at the TTree::Draw documentation.

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