How to do b (Jet.BTag) cut form .root file

Please read tips for efficient and successful posting and posting code

_ROOT Version:_6.18.04
Platform: ubuntu 20
Compiler: g++

I am working with MadGraph5_aMC@NLO for a SM process simulation. After launch I got a .root file named tag_1_delphes_events.root.Then I analysis this file by using ROOT to set some cuts,for example I need at least three b quark in final states.
Here is my code :

#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <TH1F.h>
#include <iostream>
#include "TClonesArray.h"
#include "TObject.h"
#include "TLorentzVector.h"
using namespace std;

void c00004(){ 
TFile *file   = new TFile("tag_1_delphes_events.root");
TTree *tree   = (TTree*)file->Get("Delphes");
// int nEntries = tree->GetEntries();
// cout <<  nEntries << endl; 
 TTree          *fChain;   //!pointer to the analyzed TTree or TChain
 Int_t           fCurrent; //!current Tree number in a TChain
  Int_t kMaxJet = 13;
  Int_t kMaxElectron = 3;
  Int_t kMaxMuon = 2; 
  UInt_t          Jet_BTag[kMaxJet];
  Int_t           Electron_size;
  Int_t           Muon_size;
 TBranch        *b_Jet_BTag;
 TBranch        *b_Electron_size;
 TBranch        *b_Muon_size;
 fChain->SetBranchAddress("Jet.BTag", Jet_BTag, &b_Jet_BTag);
 fChain->SetBranchAddress("Electron_size", &Electron_size, &b_Electron_size);
 fChain->SetBranchAddress("Muon_size", &Muon_size, &b_Muon_size);
double numcut1=0;
double effcut1=0;  
for(int k=0;k<10000;k++){
  if (!fChain) return;       
//   fChain->Show(k);    
int lnum = Electron_size+Muon_size;
int bnum = Jet_BTag[0]+Jet_BTag[1]+Jet_BTag[2]+Jet_BTag[3]
if ( bnum>=3 /*lnum>=2*/){
cout<< numcut1 << "**"<< "effcut1:" << effcut1 <<"**"<< k <<endl;

Here I was useing Tree->MakeClass(“myclass”),and most of code I was copied form myclass.h.
When I execute my code 6660 events passed the select, so the efficiency is 0.666.
But when I use MadAnalysis5 to execute the same cut by using the same file,the efficiency is 0.475.
Then I have tried lepton cut by changing above code to

if ( /*bnum>=3*/lnum>=2){

2588 events passed the select,so the efficiency is 0.2588. then using MadAnalysis5 I do the same cut using the same file,the efficiency is 0.259.that’s works fine.
So I wonder is there something wrong with my code by doing b cuts.
PS: the SM process is

pp → ttt~b~ → (bW+ )(bW− )(bW+ )b → l+ l+ 4b2j
pp → tt~t~b → (bW+ )(bW− )(bW− )b → l− l− 4b2j

PPS: my whole code is too long to post and the above code is not executable
If you need anymore information, ask me freely.
Best Regards.

Hi @masterluke,
and welcome to the ROOT forum!
Unfortunately it’s really hard to tell what the difference between the MadAnalysis5 and your code might be.

It looks like something that needs to be debugged on your side, e.g. are you sure Jet_BTag has at least 13 elements for each event?
You can check whether variables have the same distributions in MadAnalysis5 and your code e.g. by filling a histogram with them and comparing the resulting histogram plots.

We can help in case there is something unclear about what ROOT is doing or whether you can pin down the problem to some ROOT code that you expect to behave in a certain way but behaves in another.

Best regards,

Thanks for your reply.
Follow your advise I plot the distributions of leptons and Jet_BTag,by using ROOT and MadAnalysis5
The leptons distributions fits well,but Jet_BTag are not. Then I have cout Jet_BTag, but can’t find anything wrong. Here is my whole code. most were copied from Delphes.h generate by using MakeClassc00004.c (71.6 KB) Delphes.h (73.0 KB)
PS: is there some another way(not too complex) for I can used to add cuts.
Thanks again.
Best regards.

I just find there do have something wrong with my code.
Thanks again for your advise.
Best regards.

1 Like