C++ 这个错误意味着什么?警告:传递给需要非null参数[-Wnonnull]的被调用方的null

C++ 这个错误意味着什么?警告:传递给需要非null参数[-Wnonnull]的被调用方的null,c++,root,C++,Root,我不知道为什么会出现这个错误,或者它意味着什么?我正在尝试运行HistPlotter.C文件来创建直方图。然而,我得到一个错误,使它无法工作?我的绘图目录中有所有需要工作的.root文件,我的其他同学可以让它们工作 Error in <TFile::TFile>: file hist-WenuNoJetsBVeto.root does not exist [/Users/andrewbarajas/root/root_v6.22.08/lib/libCling.so]cling_ru

我不知道为什么会出现这个错误,或者它意味着什么?我正在尝试运行HistPlotter.C文件来创建直方图。然而,我得到一个错误,使它无法工作?我的绘图目录中有所有需要工作的.root文件,我的其他同学可以让它们工作

Error in <TFile::TFile>: file hist-WenuNoJetsBVeto.root does not exist
[/Users/andrewbarajas/root/root_v6.22.08/lib/libCling.so]cling_runtime_internal_throwIfInvalidPointer (no debug info)
[<unknown binary>] (no debug info)
[<unknown binary>] (no debug info)
[<unknown binary>] (no debug info)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libCling.so] cling::IncrementalExecutor::executeWrapper(llvm::StringRef, cling::Value*) const (no debug info)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libCling.so] cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) (no debug info)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libCling.so] cling::Interpreter::EvaluateInternal(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) (no debug info)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libCling.so] cling::MetaSema::actOnxCommand(llvm::StringRef, llvm::StringRef, cling::Value*) (no debug info)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libCling.so] cling::MetaParser::isXCommand(cling::MetaSema::ActionResult&, cling::Value*) (no debug info)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libCling.so] cling::MetaParser::isCommand(cling::MetaSema::ActionResult&, cling::Value*) (no debug info)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libCling.so] cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) (no debug info)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libCling.so] HandleInterpreterException(cling::MetaProcessor*, char const*, cling::Interpreter::CompilationResult&, cling::Value*) (no debug info)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libCling.so] TCling::ProcessLine(char const*, TInterpreter::EErrorCode*) (no debug info)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libCling.so] TCling::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) (no debug info)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libCore.6.22.so] TApplication::ExecuteFile(char const*, int*, bool) (no debug info)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libRint.6.22.so] TRint::ProcessLineNr(char const*, char const*, int*) (no debug info)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libRint.6.22.so] TRint::Run(bool) (no debug info)
[/Users/andrewbarajas/root/root_v6.22.08/bin/root.exe] main (no debug info)
[/usr/lib/system/libdyld.dylib] start (no debug info)
Error in <HandleInterpreterException>: Trying to dereference null pointer or trying to call  routine taking non-null arguments.
Execution of your code was aborted.
In file included from input_line_11:1:
/Users/andrewbarajas/root/Plotting/HistPlotter.C:252:23: warning: null passed to a callee that requires a non-null argument [-Wnonnull]
TH1F *h = (TH1F*) f->Get(histname.c_str());    
                  ^
错误:文件hist-WenuNoJetsBVeto.root不存在
[/Users/andrewbarajas/root/root\u v6.22.08/lib/libCling.so]cling\u runtime\u internal\u throwIfInvalidPointer(无调试信息)
[](无调试信息)
[](无调试信息)
[](无调试信息)
[/Users/andrewbarajas/root/root\u v6.22.08/lib/libCling.so]cling::IncrementalExecutor::executeWrapper(llvm::StringRef,cling::Value*)常量(无调试信息)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libCling.so]cling::解释器::运行函数(clang::FunctionDecl const*,cling::Value*)(无调试信息)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libCling.so]cling::解释器::EvaluateInternal(std::_1::basic_string const&,cling::compileationoptions,cling::Value*,cling::Transaction**,unsigned long)(无调试信息)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libCling.so]cling::MetaSema::actOnxCommand(llvm::StringRef,llvm::StringRef,cling::Value*)(无调试信息)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libCling.so]cling::MetaParser::isXCommand(cling::MetaSema::ActionResult&,cling::Value*)(无调试信息)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libCling.so]cling::MetaParser::isCommand(cling::MetaSema::ActionResult&,cling::Value*)(无调试信息)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libCling.so]cling::MetaProcessor::process(llvm::StringRef,cling::解释器::compilementresult&,cling::Value*,bool)(无调试信息)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libCling.so]HandleInterpreterException(CLANG::MetaProcessor*,char const*,CLANG::解释器::编译结果&,CLANG::Value*)(无调试信息)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libCling.so]TCling::ProcessLine(char const*,TInterpreter::EErrorCode*)(无调试信息)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libCling.so]TCling::ProcessLineSynch(char const*,TInterpreter::EErrorCode*)(无调试信息)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libCore.6.22.so]TApplication::ExecuteFile(char const*,int*,bool)(无调试信息)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libRint.6.22.so]TRint::ProcessLineNr(char const*,char const*,int*)(无调试信息)
[/Users/andrewbarajas/root/root_v6.22.08/lib/libRint.6.22.so]TRint::Run(bool)(无调试信息)
[/Users/andrewbarajas/root/root_v6.22.08/bin/root.exe]main(无调试信息)
[/usr/lib/system/libdyld.dylib]启动(无调试信息)
错误:尝试取消引用空指针或尝试调用采用非空参数的例程。
代码的执行被中止。
在输入_行_11:1中包含的文件中:
/Users/andrewbarajas/root/Plotting/HistPlotter.C:252:23:警告:传递给需要非null参数[-Wnonnull]的被调用方的null
TH1F*h=(TH1F*)f->Get(histname.c_str());
^
这是我的代码,它是hist plot.C。我不知道我把代码哪里弄糟了

#include "include/AtlasStyle.C"
#include "include/AtlasLabels.C"
#include "include/AtlasUtils.C"


  void groupSamples();
  void makeGroupHist();

  std::map<TString, float> db;
  std::map<TString, float> dy;
  std::map<TString, float> w;
  std::map<TString, float> z;
  std::map<TString, float> stop;
  std::map<TString, float> tt;
  std::map<TString, float> signalmap;

  TH1F *h_db;
  TH1F *h_drellyan;
  TH1F *h_wjets;
  TH1F *h_zjets;
  TH1F *h_singletop;
  TH1F *h_ttbar;

  std::string histname = "h_event_selection";
  float lumi = 1000.;
  int rebin = 1; //20 - ZmInv //4 - wmt //1 - event selection                                                                                                                                                                                   
  bool logy = true;
  std::string signalmass = "400";

  void HistPlotter(std::string mass = ""){

 if(mass!= "") signalmass = mass;

 SetAtlasStyle();
 TH1::SetDefaultSumw2(true);
 gROOT->Reset();

 groupSamples();
 makeGroupHist();

 THStack *h_stack = new THStack("h_stack","");

 h_db->SetFillColor(kRed);
 h_drellyan->SetFillColor(kGreen);
 h_wjets->SetFillColor(kMagenta);
 h_zjets->SetFillColor(kBlue);
 h_singletop->SetFillColor(kOrange);
 h_ttbar->SetFillColor(kCyan);

 h_stack->Add(h_db);
 h_stack->Add(h_drellyan);
 h_stack->Add(h_wjets);
 h_stack->Add(h_zjets);
 h_stack->Add(h_singletop);
 h_stack->Add(h_ttbar);

 TH1F *h_err = (TH1F*) h_db->Clone();
 h_err->Add(h_drellyan);
 h_err->Add(h_wjets);
 h_err->Add(h_zjets);
 h_err->Add(h_singletop);
 h_err->Add(h_ttbar);
 h_err->SetFillStyle(3004);
 h_err->SetFillColor(kBlack);
 h_err->SetLineColor(0);
 h_err->SetMarkerStyle(1);


 TFile *f_sig = TFile::Open(("hist-ZPrime" + signalmass + ".root").c_str());
 TH1F* h_signal = (TH1F*) f_sig->Get(histname.c_str());
  h_signal->Rebin(rebin);
 TH1F* h_signal_clone = (TH1F*) h_signal->Clone();
 //Rescale signal                                                                                                                                                                                  
    h_signal->Scale(1e5*lumi*signalmap[("ZPrime" + signalmass).c_str()]);
 h_signal->SetLineStyle(7);
 h_signal->SetLineWidth(3);
 h_signal->SetLineColor(kPink-8);


 TFile *f_egamma = TFile::Open("hist-DataEgamma.root");
 TFile *f_muon = TFile::Open("hist-DataMuons.root");
 TH1F *h_data_egamma = (TH1F*) f_egamma->Get(histname.c_str());
 TH1F *h_data_muon = (TH1F*) f_muon->Get(histname.c_str());
 h_data_egamma->Rebin(rebin);
 h_data_muon->Rebin(rebin);

 TH1F *h_data = (TH1F*) h_data_egamma->Clone();
 h_data->Add(h_data_muon);
 h_data->SetMarkerSize(1);
 h_data->SetMarkerStyle(20);
 h_data->SetMarkerColor(kBlack);

 /// Chi2                                                                                                                                                                                          
 //double chi2_test = h_data->Chi2Test(h_err, "UW,P");                                                                                                                                             
 //cout<<"chi2_test  "<<chi2_test<<endl;                                                                                                                                                           

 // I will print some numbers here based on the h_signal, h_data and h_err (sum of all backgrounds) histograms  
  float cut = 0;

 if(signalmass == "400") cut = 0.;
 if(signalmass == "500") cut = 0.;
 if(signalmass == "750") cut = 400.;
 if(signalmass == "1000") cut = 500.;
 if(signalmass == "1250") cut = 800.;
 if(signalmass == "1500") cut = 1000.;
 if(signalmass == "1750") cut = 1250.;
 if(signalmass == "2000") cut = 1500.;
 if(signalmass == "2250") cut = 1500.;
 if(signalmass == "2500") cut = 1500.;
 if(signalmass == "3000") cut = 1500.;


 cout<<"#####\t Event yields"<<endl;
 cout<<"#####\t Data   \t:\t"<< h_data->Integral(h_data->GetXaxis()->FindBin(cut), h_data->GetNbinsX()+1)<<endl;
 cout<<"#####\t MC     \t:\t"<< h_err->Integral(h_err->GetXaxis()->FindBin(cut), h_err->GetNbinsX()+1)<<endl;
 cout<<"#####\t Signal "<<signalmass<<" :\t"<< h_signal_clone->Integral(h_signal_clone->GetXaxis()->FindBin(cut), h_signal_clone->GetNbinsX()+1)<<endl;

  //calculate event selection efficiency                                                                                                                                                            
    if(  histname== "h_event_selection"){
      for(int bin = 2; bin < h_data->GetNbinsX(); bin++){
       double eff_rel = h_err->GetBinContent(bin-1) != 0 ? h_err->GetBinContent(bin)/h_err->GetBinContent(bin-1) : 0;
       double eff_abs = h_err->GetBinContent(1) != 0 ? h_err->GetBinContent(bin)/h_err->GetBinContent(1) : 0;

    double eff_rel_err =  h_err->GetBinContent(bin-1) != 0 ? sqrt( eff_rel*(1- eff_rel)/ h_err->GetBinContent(bin)/h_err->GetBinContent(bin-1)) : 0;
    double eff_abs_err = h_err->GetBinContent(1) != 0 ?  sqrt( eff_abs*(1- eff_abs)/ h_err->GetBinContent(bin)/h_err->GetBinContent(bin-1)) : 0;
  cout<<h_err->GetXaxis()->GetBinLabel(bin)<<endl;
  std::cout<< eff_rel<<" "<<eff_rel_err<<std::endl;
  std::cout<< eff_abs<<" "<<eff_abs_err<<std::endl;
   }
 }
  ///// Plotting                                                                                                                                                                                    
    TCanvas *can = new TCanvas("can","", 600, 600);
 can->cd();
    if(logy) can->SetLogy();

h_stack->Draw("hist");
h_err->Draw("e2same");
h_data->Draw("epsame");
h_signal->Draw("histsame");
h_stack->SetMaximum(1.15*h_stack->GetMaximum());
if (logy && histname.find("event_selection") != std::string::npos) h_stack->SetMaximum(1e8*h_stack->GetMaximum());
if (logy && histname.find("event_selection") != std::string::npos) h_stack->SetMinimum(10);

 //else if(logy) h_stack->SetMinimum(0.5);                                                                                                                                                         

h_stack->GetXaxis()->SetTitle(h_data_egamma->GetXaxis()->GetTitle());
h_stack->GetYaxis()->SetTitle("Events");
h_stack->GetYaxis()->SetTitleOffset(1.60);
if(histname.find("wmt") != std::string::npos)h_stack->GetXaxis()->SetRangeUser(0, 775);
else if(histname.find("ZmInv") != std::string::npos)h_stack->GetXaxis()->SetRangeUser(0, 3775);
else if(histname.find("ZmT") != std::string::npos)h_stack->GetXaxis()->SetRangeUser(0, 3575);
else if(histname.find("lep_pt") != std::string::npos)h_stack->GetXaxis()->SetRangeUser(0, 1575);
else if(histname.find("h_ZpInvM") != std::string::npos) h_stack->GetXaxis()->SetRangeUser(0, 3350);


TLegend *leg = new TLegend(0.55, 0.55, 0.75, 0.9);
leg->SetBorderSize(0);
leg->SetTextFont(42);
leg->SetTextSize(0.035);
leg->SetLineColor(1);
leg->SetLineStyle(1);
leg->SetLineWidth(1);
leg->SetFillColor(0);
leg->SetFillStyle(1001);
leg->SetHeader("     #sqrt{s} = 8 TeV, 1 fb^{-1}");
leg->AddEntry(h_data,"Data","p");
leg->AddEntry(h_ttbar,"t#bar{t}","f");
leg->AddEntry(h_singletop,"Single top","f");
leg->AddEntry(h_zjets,"Z","f");
leg->AddEntry(h_wjets,"W","f");
leg->AddEntry(h_drellyan,"Drell-Yan","f");
leg->AddEntry(h_db,"Diboson","f");
leg->AddEntry(h_err,"MC stat. uncertainty","f");
leg->AddEntry(h_signal,("Z'(" + signalmass + " GeV)#rightarrow t#bar{t} x 10^{5}").c_str(),"l");
leg->Draw();

 std::string outfile = histname.substr(2, std::string::npos);
 if(logy) can->SaveAs((outfile+"_log.pdf").c_str());
 else can->SaveAs((outfile+".pdf").c_str());
}

  void groupSamples(){

 std::ifstream samples;
 samples.open("samples.txt");


  while(!samples.eof()){
    TString sample;
    float xsec;
   float red_eff;
   float sumw;
   float nevt;

   samples >> sample >> xsec >> red_eff >> sumw >> nevt;

nevt=1;
   //sumw=1;                                                                                                                                                                                       
   if(sample.Contains("WW")  || sample.Contains("WZ")  || sample.Contains("ZZ")  ) db[sample] = xsec*nevt/(red_eff*sumw);

   if(sample.Contains("DY")  ) dy[sample] = xsec*nevt/(red_eff*sumw);

   if(sample.Contains("Wenu")  || sample.Contains("Wmunu")  || sample.Contains("Wtaunu")  ) w[sample] = xsec*nevt/(red_eff*sumw);

   if(sample.Contains("Zee")  || sample.Contains("Zmumu")  || sample.Contains("Ztautau")  ) z[sample] = xsec*nevt/(red_eff*sumw);

   if(sample.Contains("stop")  ) stop[sample] = xsec*nevt/(red_eff*sumw);

   if(sample.Contains("ttbar")  ) tt[sample] = xsec*nevt/(red_eff*sumw);

   if(sample.Contains("ZPrime")  ) signalmap[sample] = xsec*nevt/(red_eff*sumw);


 }


 return;
  }

  void makeGroupHist(){

 //for(unsigned int i = 0; i < db.size(); i++){                                                                                                                                                    
 int i = 0;
 for(std::map<TString, float>::iterator it = db.begin(); it != db.end(); ++it){
   TFile *f = TFile::Open(Form("hist-%s.root",(it->first).Data()));
   TH1F *h = (TH1F*) f->Get(histname.c_str());
   h->Rebin(rebin);
  h->Scale(it->second*lumi);
  //h->Scale(it->second*lumi/h->Integral(0, h->GetNbinsX()+1));                                                                                                                                   
  if(i==0) h_db = (TH1F*) h->Clone();
  else h_db->Add(h);
   i++;
 }

  i = 0;
    for(std::map<TString, float>::iterator it = dy.begin(); it != dy.end(); ++it){
      TFile *f = TFile::Open(Form("hist-%s.root",(it->first).Data()));
      TH1F *h = (TH1F*) f->Get(histname.c_str());
      h->Rebin(rebin);
     h->Scale(it->second*lumi);
     //h->Scale(it->second*lumi/h->Integral(0, h->GetNbinsX()+1));                                                                                                                                   
     if(i==0) h_drellyan = (TH1F*) h->Clone();
     else h_drellyan->Add(h);
     i++;
    }

 i = 0;
 for(std::map<TString, float>::iterator it = w.begin(); it != w.end(); ++it){
   TFile *f = TFile::Open(Form("hist-%s.root",(it->first).Data()));
  TH1F *h = (TH1F*) f->Get(histname.c_str());
  h->Rebin(rebin);
  h->Scale(it->second*lumi);
   //h->Scale(it->second*lumi/h->Integral(0, h->GetNbinsX()+1));                                                                                                                                   
  if(i==0) h_wjets = (TH1F*) h->Clone();
  else h_wjets->Add(h);
  i++;
}

i = 0;
 for(std::map<TString, float>::iterator it = z.begin(); it != z.end(); ++it){
   TFile *f = TFile::Open(Form("hist-%s.root",(it->first).Data()));
   TH1F *h = (TH1F*) f->Get(histname.c_str());
  h->Rebin(rebin);
  h->Scale(it->second*lumi);
  //h->Scale(it->second*lumi/h->Integral(0, h->GetNbinsX()+1));                                                                                                                                   
  if(i==0) h_zjets = (TH1F*) h->Clone();
  else h_zjets->Add(h);
  i++;
}

i = 0;
for(std::map<TString, float>::iterator it = stop.begin(); it != stop.end(); ++it){
  TFile *f = TFile::Open(Form("hist-%s.root",(it->first).Data()));
  TH1F *h = (TH1F*) f->Get(histname.c_str());
  h->Rebin(rebin);
  h->Scale(it->second*lumi);
  //h->Scale(it->second*lumi/h->Integral(0, h->GetNbinsX()+1));                                                                                                                                   
  if(i==0) h_singletop = (TH1F*) h->Clone();
  else h_singletop->Add(h);
  i++;
 }

i = 0;
for(std::map<TString, float>::iterator it = tt.begin(); it != tt.end(); ++it){
  TFile *f = TFile::Open(Form("hist-%s.root",(it->first).Data()));
   TH1F *h = (TH1F*) f->Get(histname.c_str());
  h->Rebin(rebin);
  h->Scale(it->second*lumi);
  //h->Scale(it->second*lumi/h->Integral(0, h->GetNbinsX()+1));                                                                                                                                   
  if(i==0) h_ttbar = (TH1F*) h->Clone();
  else h_ttbar->Add(h);
  i++;
}
  }
#包括“include/AtlasStyle.C”
#包括“include/AtlasLabels.C”
#包括“include/AtlasUtils.C”
void groupSamples();
void makeGroupHist();
地图数据库;
std::mapdy;
std::map w;
std::mapz;
地图站;
std::map-tt;
std::map信号图;
TH1F*h_db;
TH1F*h_drellyan;
TH1F*h_wjets;
TH1F*Hzjets;
TH1F*h_单顶;
TH1F*h_ttbar;
std::string histname=“h\u事件\u选择”;
浮动lumi=1000。;
int-rebin=1//20-ZmInv//4-wmt//1-事件选择
布尔逻辑=真;
std::string signalmass=“400”;
无效HistPlotter(标准::字符串质量=){
如果(质量!=“”)信号质量=质量;
SetAtlasStyle();
TH1::SetDefaultSumw2(真);
格罗特->重置();
组样本();
makeGroupHist();
THStack*h_stack=新的THStack(“h_stack”,即“”);
h_db->SetFillColor(kRed);
h_drellyan->SetFillColor(绿色);
h_wjets->SetFillColor(kMagenta);
h_zjets->SetFillColor(kBlue);
h_singletop->SetFillColor(kOrange);
h_ttbar->SetFillColor(kCyan);
h_堆栈->添加(h_db);
h_stack->Add(h_drellyan);
h_堆栈->添加(h_wjets);
h_堆栈->添加(h_zjets);
h_stack->Add(h_singletop);
h_堆栈->添加(h_ttbar);
TH1F*h_err=(TH1F*)h_db->Clone();
h_err->Add(h_drellyan);
h_err->Add(h_wjets);
h_err->Add(h_zjets);
h_err->Add(h_singletop);
h_err->Add(h_ttbar);
h_err->SetFillStyle(3004);
h_err->SetFillColor(kBlack);
h_err->SetLineColor(0);
h_err->SetMarkerStyle(1);
TFile*f_sig=TFile::Open(((“hist ZPrime”+signalmass+“.root”).c_str());
TH1F*h_信号=(TH1F*)f_信号->获取(histname.c_str());
h_信号->重新输入(重新输入);
TH1F*h_信号\u克隆=(TH1F*)h_信号->克隆();
//重缩放信号
h_信号->比例(1e5*lumi*signalmap[((“ZPrime”+signalmass.c_str()]);
h_信号->设置线型(7);
h_信号->设置线宽(3);
h_信号->设置线颜色(kPink-8);
TFile*f_egama=TFile::Open(“hist dataegama.root”);
TFile*f_μon=TFile::Open(“hist-DataMuons.root”);
TH1F*h_data_egama=(TH1F*)f_egama->Get(histname.c_str());
TH1F*h_-data_-muon=(TH1F*)f_-muon->Get(histname.c_-str());
h_data_egamma->Rebin(Rebin);
h_数据μon->Rebin(Rebin);
TH1F*h_data=(TH1F*)h_data_egama->Clone();
h_数据->添加(h_数据μon);
h_数据->设置标记化(1);
h_数据->设置标记样式(20);
h_数据->设置标记颜色(kBlack);
///Chi2