Как найти количество мюонов в ветви в TTree: ROOT - PullRequest
0 голосов
/ 17 февраля 2020

Я пытаюсь найти количество мюонов внутри моего TTree, которое называется Delphes. У меня есть мюонная ветвь внутри дерева Дельф, которая дает разные переменные мюонов, такие как поперечный импульс; однако, это не говорит о количестве сгенерированных мюонов.

Просмотрев некоторые учебные пособия, я попытался выполнить следующее:

//#ifdef __CLING__
//R__LOAD_LIBRARY(libDelphes)
#include "classes/DelphesClasses.h"
#include "external/ExRootAnalysis/ExRootTreeReader.h"
#include "external/ExRootAnalysis/ExRootResult.h"
//#else
class ExRootTreeReader;
class ExRootResult;
//#endif

#include "ROOT/RDataFrame.hxx"
#include "ROOT/RVec.hxx"
#include "TCanvas.h"
#include "TH1D.h"
#include "TLatex.h"
#include "Math/Vector4D.h"
#include "TStyle.h"
using namespace ROOT::VecOps;
void invariantmass()
{
  //gSystem->Load("libDelphes");
  // Create chain of root trees
  //TChain chain("Delphes;2");
  //chain.Add(inputFile);

  // Create object of class ExRootTreeReader
  ExRootTreeReader *treeReader = new ExRootTreeReader();
    Int_t numberOfMuons = branchMuon->GetEntries();
    cout << "There are "  << numberOfMuons << " muons in run" << endl;

    TClonesArray *branchMuon     = treeReader->UseBranch("Muon");

   // Enable multi-threading
   ROOT::EnableImplicitMT();
   // Create dataframe from NanoAOD files
   ROOT::RDataFrame df("Delphes;2",
                      "tag_1_delphes_events.root");
   // 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_mass = df_os.Define("Dimuon_mass", InvariantMass<float>, {"Muon.PT", "Muon.Eta", "Muon.Phi", "m"});
   // 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();

}

Я полагаю, что раньше у меня был код. Но теперь я получаю эту ошибку:

root [0]
Processing invariantmass.C...
In file included from input_line_8:1:
/mnt/c/1/MG5_aMC_v2_6_6/trisignal/Events/run_01/invariantmass.C:3:10: fatal error: 'classes/DelphesClasses.h' file not found
#include "classes/DelphesClasses.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/c/1/MG5_aMC_v2_6_6/trisignal/Events/run_01/invariantmass.C:27:38: error: allocation of incomplete type 'ExRootTreeReader'
  ExRootTreeReader *treeReader = new ExRootTreeReader();
                                     ^~~~~~~~~~~~~~~~
/mnt/c/1/MG5_aMC_v2_6_6/trisignal/Events/run_01/invariantmass.C:7:7: note: forward declaration of 'ExRootTreeReader'
class ExRootTreeReader;
      ^
/mnt/c/1/MG5_aMC_v2_6_6/trisignal/Events/run_01/invariantmass.C:28:27: error: use of undeclared identifier 'branchMuon'
    Int_t numberOfMuons = branchMuon->GetEntries();
                          ^
/mnt/c/1/MG5_aMC_v2_6_6/trisignal/Events/run_01/invariantmass.C:31:46: error: member access into incomplete type 'ExRootTreeReader'
    TClonesArray *branchMuon     = treeReader->UseBranch("Muon");
                                             ^
/mnt/c/1/MG5_aMC_v2_6_6/trisignal/Events/run_01/invariantmass.C:7:7: note: forward declaration of 'ExRootTreeReader'
class ExRootTreeReader;
      ^

с нарушением сегментации.

Как я могу это исправить? Есть ли более простой способ сделать это?

РЕДАКТИРОВАТЬ: Я обнаружил, что Дельфес может сказать вам количество мюонов по ветви Muon_size.

...