【问题标题】:How to Properly Add a Branch to An Already Existing Tree如何正确地将分支添加到已经存在的树
【发布时间】:2020-06-03 05:05:02
【问题描述】:

我正在计算来自 dimuon 通道的不变质量。

我正在使用 RDataFrame 进行此计算。 我的一个sn-p代码如下:

// Enable multi-threading
   ROOT::EnableImplicitMT();
   // Create dataframe from NanoAOD files
   ROOT::RDataFrame df("Delphes;6",
                      "tag_1_delphes_events.root");
   //auto mu_mass = df.Define("muon_mass", "0.1");
   // For simplicity, select only events with exactly two muons and require opposite charge
   //auto df_2mu = df.Filter("nMuon == 2", "Events with exactly two muons");
   auto df_os = df.Filter("Muon.Charge[0] != Muon.Charge[1]", "Muons with opposite charge");
   // Compute invariant mass of the dimuon system
   auto df_mu_mass = df_os.Define("muon_mass", "0.1");
   auto df_mass = df_mu_mass.Define("Dimuon_mass", InvariantMass<float>, {"Muon.PT", "Muon.Eta", "Muon.Phi", "muon_mass"});
   // Make histogram of dimuon mass spectrum
   auto h = df_mass.Histo1D({"Dimuon_mass", "Dimuon_mass", 30000, 0.25, 300}, "Dimuon_mass");
   // Request cut-flow report
   auto report = df_mass.Report();
   // Produce plot

我的 PT、eta、Phi 值是浮点值。我得到的错误是:

terminate called after throwing an instance of 'std::runtime_error'
  what():  RColumnValue: type specified for column "muon_mass" is ROOT::VecOps::RVec<float> but temporary column has type double

我尝试在我的定义中将 RVec 插入到 0.1 的前面,但这不起作用。 如何解决此问题以使其正常工作?

【问题讨论】:

    标签: c++ floating-point stdvector root-framework


    【解决方案1】:

    我发现解决此问题的最简单方法是在我的树中手动添加分支值

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-10
      • 2021-06-09
      • 2021-12-07
      • 2011-03-04
      • 1970-01-01
      • 2015-05-22
      • 2022-01-03
      • 1970-01-01
      相关资源
      最近更新 更多