Fork me on GitHub

Opened 10 years ago

Last modified 10 years ago

#285 new How to

Problem with b-tagging

Reported by: Diptimoy Ghosh Owned by:
Priority: major Milestone:
Component: Delphes code Version: Delphes 3
Keywords: Cc:

Description

I am facing some problem with b-tagging in Delphes.
I have used the ATLAS detector card provided with the latest Delphes distribution.
I am using the following line to get b-tagging information

if( jet->BTag & (1 << 0) ) { jet is btagged... }

But it seems to me that it does not work. In fact, with the same event file (generated using Delphes-3.1.2) I am getting very different answers when I am analyzing with Delphes-3.1.2 and Delphes-3.0.8.
I am new to Delphes and would really appreciate your help as soon as possible.

Attachments (5)

events.root (13.5 MB ) - added by Diptimoy Ghosh 10 years ago.
delphes_card_ATLAS.tcl (17.5 KB ) - added by Diptimoy Ghosh 10 years ago.
events_new.root (10.7 MB ) - added by Diptimoy Ghosh 10 years ago.
analysis.cpp (1.5 KB ) - added by Diptimoy Ghosh 10 years ago.
Makefile.alt (811 bytes ) - added by Diptimoy Ghosh 10 years ago.

Change History (14)

comment:1 by Alexandre Mertens, 10 years ago

Hello,

The parametrization of the b-tagging in Delphes is described in the card "examples/delphes_card_ATLAS.tcl" after the following lines

###########
# b-tagging
###########

Indeed, as you can check, the parametrization has been different between different releases.
Since the b-tagging efficiency is analysis dependent, it is better to modify those formulas and write efficiencies corresponding to the algorithm that you want to emulate.

comment:2 by Diptimoy Ghosh, 10 years ago

Thanks for the reply.
I now generated a small sample of ttbar events in order to check the b-tagging.
In the ATLAS card I changed the efficiency to 1. But I get only very little b-jets.
The root file and also the detector card are attached.
I will appreciate your help in sorting out the problem.

by Diptimoy Ghosh, 10 years ago

Attachment: events.root added

by Diptimoy Ghosh, 10 years ago

Attachment: delphes_card_ATLAS.tcl added

comment:3 by Michele Selvaggi, 10 years ago

What kind of events are you looking at?
I don't think there is anything wrong with your root file.
Keep in mind that only reconstructed jets that match a produced b-parton within
the acceptance will be tagged as "b".

Michele

comment:4 by Diptimoy Ghosh, 10 years ago

Thanks a lot again for your reply.
A a check, I just wanted to count the number of events with 1, 2 b-tags.

I am using the following piece of code

for(int i=0; i<branchJet->GetEntries(); i++)
{

Jet *jet = (Jet *) branchJet->At(i);
if( jet->BTag & (1 << 0) ) { btag = btag + 1;}

}

As the event file is for ttbar and the b tagging efficiency is set to 1, I expect almost all events to have 1 or 2 b-rags. But this is not happening.

I must say that I am new to Delphes, so I may have done some mistake.
If the above piece of code is not correct then I would request you to provide me with a small piece of code which can be used for my purpose.
Thanks a lot for your time and the help.

comment:5 by Alexandre Mertens, 10 years ago

Hello,

There is a combination of two effects here:

As Michele just said above, a jet might be tagged as a b-jet only if a jet is reconstructed.

Then, there is a pt cut on the jet reconstruction. (no jets with sufficient pt -> no b-jets)

424	############
425	# Jet finder
426	############
427	
428	module FastJetFinder FastJetFinder {
429	  set InputArray Calorimeter/towers
430	
431	  set OutputArray jets
432	
433	  # algorithm: 1 CDFJetClu, 2 MidPoint, 3 SIScone, 4 kt, 5 Cambridge/Aachen, 6 antikt
434	  set JetAlgorithm 6
435	  set ParameterR 0.4
436	
437	  set JetPTMin 20.0
438	}

To validate the procedure, you can access the generated particle in the Delphes output rootfile.
There is an example on how to access the generated particle in the Example3 (examples/Example3.C).

Concerning the code:
Since you're applying only one b-tagging algorithm, you can simply use

if( jet->BTag )

I hope this can help.

Alexandre

Version 0, edited 10 years ago by Alexandre Mertens (next)

comment:6 by Diptimoy Ghosh, 10 years ago

Thanks a lot again for your time and help.
I have now generated
p p > b bbar with all the b's having pT > 50 GeV and |Eta| < 2.5.
The parton level distributions generated by Madgraph are also consistent with this.

So I guess that the jets should pass the selection cuts easily.
The root file attached has 250 events. Even then I am only finally getting a few events with b-tag.
Somewhere I must be doing a mistake.

I am attaching the new root file again.
I request you to please help me with this, may you can check how many events with b-tags you are getting. This will confirm the confusion.

I again thank you for the help.


Last edited 10 years ago by Diptimoy Ghosh (previous) (diff)

by Diptimoy Ghosh, 10 years ago

Attachment: events_new.root added

comment:7 by Alexandre Mertens, 10 years ago

Hello,

If you look in the rootfile and check the number of b-tagged jet:

root -l events_new.root
root [1] TBrowser 
root [2] Delphes->Draw("Jet.BTag")

You can see that you have more than 450 jets which are b-tagged in your sample.

here is an example of macro that you can try :

root -l examples/btag.C\(\"delphes_output.root\"\)

after having copied the following line into a file "examples/btag.C"

//------------------------------------------------------------------------------

void btag(const char *inputFile)
{
  gSystem->Load("libDelphes");

  // Create chain of root trees
  TChain chain("Delphes");
  chain.Add(inputFile);

  // Create object of class ExRootTreeReader
  ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);
  Long64_t numberOfEntries = treeReader->GetEntries();

  // Get pointers to branches used in this analysis
  TClonesArray *branchJet = treeReader->UseBranch("Jet");

  // define the number of B-jets in the event
  int NofBs = 0;

  // Loop over all events
  for(Int_t entry = 0; entry < numberOfEntries; ++entry)
  {
    // Load selected branches with data from specified event
    treeReader->ReadEntry(entry);

    // set the number of B-jets in the event to 0
    NofBs = 0;

    // If event contains at least 1 jet
    for(unsigned int i = 0; i < branchJet->GetEntries(); i++)
    {
      // Take first jet
      Jet *jet = (Jet*) branchJet->At(i);

      if (jet->BTag == 1) NofBs++;
    }
    cout << NofBs << endl;
  }
}

comment:8 by Diptimoy Ghosh, 10 years ago

Hi,

Million thanks for the help.
I could use your code without any problem.

Now I think that it was probably some stupid problem in my code, although I do not know what.
I am attaching a small piece of code (basically adapted from yours) and a Makefile which I use.
With this code I do not get the correct answer. The code compiles and runs and gives some warnings.
I do not get these warnings in Delphes 3.0.9 but they do appear in the latest version.

As I do not get any linking or other error I am unable to spot the problem.

I will really grateful if you could help.
I am again sorry for my ignorance.
The analysis code and Makefile are attached.

Thanks again.

In case you want to see the warnings


Warning in <TStreamerInfo::BuildCheck>:

The StreamerInfo of class Tower read from file events_new.root
has the same version (=1) as the active class but a different checksum.
You should update the version to ClassDef(Tower,2).
Do not try to write objects with the current class definition,
the files will not be readable.

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 1 of class 'Tower' is missing from
the on-file layout version 1:

Float_t T;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 1 of class 'Tower' is missing from
the on-file layout version 1:

Float_t Eem;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 1 of class 'Tower' is missing from
the on-file layout version 1:

Float_t Ehad;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 1 of class 'Tower' is missing from
the on-file layout version 1:

Float_t Edges;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 1 of class 'Tower' is missing from
the on-file layout version 1:

TRefArray Particles;

Warning in <TStreamerInfo::BuildCheck>:

The StreamerInfo of class Jet read from file events_new.root
has the same version (=2) as the active class but a different checksum.
You should update the version to ClassDef(Jet,3).
Do not try to write objects with the current class definition,
the files will not be readable.

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Jet' is missing from
the on-file layout version 2:

Float_t T;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Jet' is missing from
the on-file layout version 2:

Float_t Mass;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Jet' is missing from
the on-file layout version 2:

Float_t DeltaEta;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Jet' is missing from
the on-file layout version 2:

Float_t DeltaPhi;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Jet' is missing from
the on-file layout version 2:

UInt_t BTag;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Jet' is missing from
the on-file layout version 2:

UInt_t TauTag;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Jet' is missing from
the on-file layout version 2:

Int_t Charge;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Jet' is missing from
the on-file layout version 2:

Float_t EhadOverEem;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Jet' is missing from
the on-file layout version 2:

Int_t NCharged;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Jet' is missing from
the on-file layout version 2:

Int_t NNeutrals;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Jet' is missing from
the on-file layout version 2:

Float_t Beta;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Jet' is missing from
the on-file layout version 2:

Float_t BetaStar;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Jet' is missing from
the on-file layout version 2:

Float_t MeanSqDeltaR;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Jet' is missing from
the on-file layout version 2:

Float_t PTD;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Jet' is missing from
the on-file layout version 2:

Float_t FracPt;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Jet' is missing from
the on-file layout version 2:

Float_t Tau1;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Jet' is missing from
the on-file layout version 2:

Float_t Tau2;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Jet' is missing from
the on-file layout version 2:

Float_t Tau3;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Jet' is missing from
the on-file layout version 2:

Float_t Tau4;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Jet' is missing from
the on-file layout version 2:

Float_t Tau5;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Jet' is missing from
the on-file layout version 2:

TRefArray Constituents;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Jet' is missing from
the on-file layout version 2:

TRefArray Particles;

Warning in <TStreamerInfo::BuildCheck>:

The StreamerInfo of class Electron read from file events_new.root
has the same version (=2) as the active class but a different checksum.
You should update the version to ClassDef(Electron,3).
Do not try to write objects with the current class definition,
the files will not be readable.

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Electron' is missing from
the on-file layout version 2:

Float_t T;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Electron' is missing from
the on-file layout version 2:

Int_t Charge;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Electron' is missing from
the on-file layout version 2:

Float_t EhadOverEem;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Electron' is missing from
the on-file layout version 2:

TRef Particle;

Warning in <TStreamerInfo::BuildCheck>:

The StreamerInfo of class Photon read from file events_new.root
has the same version (=2) as the active class but a different checksum.
You should update the version to ClassDef(Photon,3).
Do not try to write objects with the current class definition,
the files will not be readable.

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Photon' is missing from
the on-file layout version 2:

Float_t T;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Photon' is missing from
the on-file layout version 2:

Float_t EhadOverEem;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Photon' is missing from
the on-file layout version 2:

TRefArray Particles;

Warning in <TStreamerInfo::BuildCheck>:

The StreamerInfo of class Muon read from file events_new.root
has the same version (=2) as the active class but a different checksum.
You should update the version to ClassDef(Muon,3).
Do not try to write objects with the current class definition,
the files will not be readable.

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Muon' is missing from
the on-file layout version 2:

Float_t T;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Muon' is missing from
the on-file layout version 2:

Int_t Charge;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 2 of class 'Muon' is missing from
the on-file layout version 2:

TRef Particle;

Warning in <TStreamerInfo::BuildCheck>:

The StreamerInfo of class MissingET read from file events_new.root
has the same version (=1) as the active class but a different checksum.
You should update the version to ClassDef(MissingET,2).
Do not try to write objects with the current class definition,
the files will not be readable.

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 1 of class 'MissingET' is missing from
the on-file layout version 1:

Float_t Eta;

Warning in <TStreamerInfo::CompareContent>: The following data member of
the in-memory layout version 1 of class 'MissingET' is missing from
the on-file layout version 1:

Float_t Phi;




Last edited 10 years ago by Diptimoy Ghosh (previous) (diff)

by Diptimoy Ghosh, 10 years ago

Attachment: analysis.cpp added

by Diptimoy Ghosh, 10 years ago

Attachment: Makefile.alt added

comment:9 by Diptimoy Ghosh, 10 years ago

This is just to add that I get the same answer with my analysis.cpp program as your code with delphes 3.0.8 but completely different result with delphes 3.1.2 (as I explained in my previous post).
Although I get the same warnings.

Note: See TracTickets for help on using tickets.