Hello all and thanks for your answers,
Doing what you say :
HangingTree->Draw(raw+">>histo");
TH1D *h = (TH1D*) gROOT->FindObject("histo");
std::cout << raw << " " << h->GetMean() << std::endl;
I get :
QCDnorm_corr_mu -0.157223
QCDnorm_corr_mu_btag 0.106851
is the same problem I found doing directly the histo->GetMean()
while in the root file: (http://personal.ifae.es/jnadal/sumRootFile.root)
root [2] HangingTree->Draw("QCDnorm_corr_mu_btag>>histo")
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
root [3] histo->GetMean()
(const Double_t)1.69030729412928876e-01
root [4]
So the second value is failing. Maybe is not related to this issue of the histogram… maybe is because I do not erase the histogram be in each iteration...
Thanks all again!
Cheers,
Jordi
PS: I put here the macro
{
int N = 2;
TString parnames[N] = {
//"k_ttbar", //"k_Wjets", //"Rb", "QCDnorm_corr_mu", "QCDnorm_corr_mu_btag", //"LarHole",
// "BCtag",
// "Ltag",
// "Wjets_HFQQ",
// "Wjets_HFC",
// "Wjets_Berends",
// "ttbar_ISR",
// "ttbar_FSR",
// //"JER",
// "Xsect_singleTop",
// "Xsect_DB",
// //"bJES",
// "Wjets_HFQQ_3ex",
// "Wjets_HFQQ_4ex",
// "Wjets_HFQQ_5in",
// "Wjets_HFC_3ex",
// "Wjets_HFC_4ex",
// "Wjets_HFC_5in",
// "JES_Calo",
// "JES_Noise",
// "JES_Perugia",
// "JES_Herwig",
// "JES_EtaInterCali",
// "JES_Pileup",
// "JES_Closure"
//TFile *file = TFile::Open("ELE/Data/sumRootFile.root"); TFile *file = TFile::Open("PSE/JO_muon_PSE_RbFree/sumRootFile.root"); TTree* HangingTree = (TTree*) file->Get("HangingTree");
std::cout << "\\begin{table}[htb] " << std::endl; std::cout << "\\begin{center} " << std::endl; std::cout << "\\begin{tabular}{l | r | r r } " << std::endl; std::cout << "\\hline " << std::endl; std::cout << "\\hline" << std::endl; std::cout << " Nuisance parameters & $\\alpha$ & \\multicolumn{2}{c}{$\\Delta\\alpha$} \\\\ " << std::endl; std::cout << "\\hline " << std::endl; std::cout << "\\hline " << std::endl; std::cout << "\\multicolumn{4}{l}{Object selection} \\\\" << std::endl; std::cout << "\\hline " << std::endl; //int binN= 100; //int minB = -1; //int maxB = 1; //TH1F* histo = new TH1F("histo", "histo", binN, minB, maxB); //TH1F* histo1 = new TH1F("histo1", "histo1", binN, minB, maxB); //TH1F* histo2 = new TH1F("histo2", "histo2", binN, minB, maxB);
for(int i=0; i<N;i++){
TString raw = parnames[i]; HangingTree->Draw(raw+">>histo"); // HangingTree->Draw(raw+"_upErr>>histo1"); // HangingTree->Draw(raw+"_downErr>>histo2"); TH1D *h = (TH1D*) gROOT->FindObject("histo"); std::cout << raw << " " << h->GetMean() << std::endl;
//std::cout << raw << " & " << printf("%.3f",histo->GetMean()) << " & " << printf("%.3f",histo1->GetMean()) << "& "<< printf("%.3f",histo2->GetMean()) << "\\\\" << std::endl; //std::cout << raw << " & " << histo->GetMean() << " & " << histo1->GetMean() << " & " << histo2->GetMean() << "\\\\" << std::endl;
}
std::cout << "\\hline " << std::endl; std::cout << "\\hline" << std::endl; std::cout << "\\end{tabular} " << std::endl; std::cout << "\\end{center}" << std::endl; std::cout << "\\end{table} " << std::endl;
}
On Sep 8, 2011, at 12:10 AM, suvayu ali wrote:
> Hi Jordi, > > On Wed, Sep 7, 2011 at 6:02 PM, Jordi Nadal <jnadal_at_ifae.es> wrote: >> root [1] gROOT->FindObject("Wjets_HFC_4ex") >> (const class TObject*)0x0 > ^^^^^ > As you can see here, there is no object "named" Wjets_HFC_4ex so it > returns a null pointer (as indicated above). You have to first create the > histogram before you can retrieve it with FindObject(). > >> root [2] .ls >> TFile** PSE/JO_muon_PSE_RbFree/sumRootFile.root >> TFile* PSE/JO_muon_PSE_RbFree/sumRootFile.root >> KEY: TTree HangingTree;1 no lemons at that tree >> root [3] TH1F *Wjets_HFC = (TH1F*) gROOT->FindObject("Wjets_HFC_4ex") >> root [4] Wjets_HFC->GetMean >> GetMean >> GetMeanError >> root [4] Wjets_HFC->GetMean() >> Error: illegal pointer to class object Wjets_HFC 0x0 550 (tmpfile):1: >> *** Interpreter error recovered *** > > So if you try the above _after_ you have plotted the histogram as in > your first post, the above should give you the expected results. > > HTH > > -- > Suvayu > > Open source is the future. It sets us free.Received on Thu Sep 08 2011 - 09:33:06 CEST
This archive was generated by hypermail 2.2.0 : Thu Sep 08 2011 - 17:50:01 CEST