Index: modules/BTagging.cc
===================================================================
--- modules/BTagging.cc	(revision 1d9974ea88eb58af9439d181a19287dce50b0fa4)
+++ modules/BTagging.cc	(revision 28027d5512f2b684a80502d8951effa581f70cd0)
@@ -22,5 +22,5 @@
  *  Determines origin of jet,
  *  applies b-tagging efficiency (miss identification rate) formulas
- *  and sets b-tagging flags 
+ *  and sets b-tagging flags
  *
  *  \author P. Demin - UCL, Louvain-la-Neuve
@@ -46,5 +46,5 @@
 #include "TLorentzVector.h"
 
-#include <algorithm> 
+#include <algorithm>
 #include <stdexcept>
 #include <iostream>
@@ -62,5 +62,5 @@
 
   Int_t GetCategory(TObject *object);
-  
+
   Double_t fEtaMax, fPTMin;
 };
@@ -75,5 +75,5 @@
 
   if(momentum.Pt() <= fPTMin || TMath::Abs(momentum.Eta()) > fEtaMax) return -1;
-  
+
   pdgCode = TMath::Abs(parton->PID);
   if(pdgCode != 21 && pdgCode > 5) return -1;
@@ -117,5 +117,5 @@
   param = GetParam("EfficiencyFormula");
   size = param.GetSize();
-  
+
   fEfficiencyMap.clear();
   for(i = 0; i < size/2; ++i)
@@ -143,5 +143,5 @@
 
   fFilter = new ExRootFilter(fPartonInputArray);
-  
+
   fJetInputArray = ImportArray(GetString("JetInputArray", "FastJetFinder/jets"));
   fItJetInputArray = fJetInputArray->MakeIterator();
@@ -170,19 +170,18 @@
 void BTagging::Process()
 {
-  Candidate *jet, *parton;
+  Candidate *jet;
   Double_t pt, eta, phi, e;
   TObjArray *partonArray;
   map< Int_t, DelphesFormula * >::iterator itEfficiencyMap;
   DelphesFormula *formula;
-  Int_t pdgCode, pdgCodeMax;
 
   // select quark and gluons
   fFilter->Reset();
   partonArray = fFilter->GetSubArray(fClassifier, 0);
-  
+
   if(partonArray == 0) return;
 
   TIter itPartonArray(partonArray);
-  
+
   // loop over all input jets
   fItJetInputArray->Reset();
@@ -190,26 +189,11 @@
   {
     const TLorentzVector &jetMomentum = jet->Momentum;
-    pdgCodeMax = -1;
     eta = jetMomentum.Eta();
     phi = jetMomentum.Phi();
     pt = jetMomentum.Pt();
     e = jetMomentum.E();
-    
-    // loop over all input partons
-    itPartonArray.Reset();
-    while((parton = static_cast<Candidate*>(itPartonArray.Next())))
-    {
-      pdgCode = TMath::Abs(parton->PID);
-      if(pdgCode == 21) pdgCode = 0;
-      if(jetMomentum.DeltaR(parton->Momentum) <= fDeltaR)
-      {
-        if(pdgCodeMax < pdgCode) pdgCodeMax = pdgCode;
-      }
-    }
-    if(pdgCodeMax == 0) pdgCodeMax = 21;
-    if(pdgCodeMax == -1) pdgCodeMax = 0;
 
     // find an efficency formula
-    itEfficiencyMap = fEfficiencyMap.find(pdgCodeMax);
+    itEfficiencyMap = fEfficiencyMap.find(jet->Flavor);
     if(itEfficiencyMap == fEfficiencyMap.end())
     {
@@ -220,6 +204,28 @@
     // apply an efficency formula
     jet->BTag |= (gRandom->Uniform() <= formula->Eval(pt, eta, phi, e)) << fBitNumber;
-  }
-}
-
-//------------------------------------------------------------------------------
+
+    // find an efficency formula for algo flavor definition
+    itEfficiencyMap = fEfficiencyMap.find(jet->FlavorAlgo);
+    if(itEfficiencyMap == fEfficiencyMap.end())
+    {
+      itEfficiencyMap = fEfficiencyMap.find(0);
+    }
+    formula = itEfficiencyMap->second;
+
+    // apply an efficency formula
+    jet->BTagAlgo |= (gRandom->Uniform() <= formula->Eval(pt, eta, phi, e)) << fBitNumber;
+
+    // find an efficency formula for phys flavor definition
+    itEfficiencyMap = fEfficiencyMap.find(jet->FlavorPhys);
+    if(itEfficiencyMap == fEfficiencyMap.end())
+    {
+      itEfficiencyMap = fEfficiencyMap.find(0);
+    }
+    formula = itEfficiencyMap->second;
+
+    // apply an efficency formula
+    jet->BTagPhys |= (gRandom->Uniform() <= formula->Eval(pt, eta, phi, e)) << fBitNumber;
+  }
+}
+
+//------------------------------------------------------------------------------
Index: modules/BTaggingCMS.cc
===================================================================
--- modules/BTaggingCMS.cc	(revision 1d9974ea88eb58af9439d181a19287dce50b0fa4)
+++ 	(revision )
@@ -1,421 +1,0 @@
-/*
- *  Delphes: a framework for fast simulation of a generic collider experiment
- *  Copyright (C) 2012-2014  Universite catholique de Louvain (UCL), Belgium
- *
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-/** \class BTaggingCMS
- *
- *  Applies b-tagging efficiency (miss identification rate) formulas
- *  and sets b-tagging flags
- *
- *  \author P. Demin - UCL, Louvain-la-Neuve
- *
- */
-
-#include "modules/BTaggingCMS.h"
-
-#include "classes/DelphesClasses.h"
-#include "classes/DelphesFactory.h"
-#include "classes/DelphesFormula.h"
-
-#include "ExRootAnalysis/ExRootResult.h"
-#include "ExRootAnalysis/ExRootFilter.h"
-#include "ExRootAnalysis/ExRootClassifier.h"
-
-#include "TMath.h"
-#include "TString.h"
-#include "TFormula.h"
-#include "TRandom3.h"
-#include "TObjArray.h"
-#include "TDatabasePDG.h"
-#include "TLorentzVector.h"
-
-#include <algorithm>
-#include <stdexcept>
-#include <iostream>
-#include <sstream>
-
-using namespace std;
-
-//------------------------------------------------------------------------------
-
-BTaggingCMS::BTaggingCMS() :
-  fItJetInputArray(0)
-{
-}
-
-//------------------------------------------------------------------------------
-
-BTaggingCMS::~BTaggingCMS()
-{
-}
-
-//------------------------------------------------------------------------------
-
-void BTaggingCMS::Init()
-{
-  map< Int_t, DelphesFormula * >::iterator itEfficiencyMap;
-  ExRootConfParam param;
-  DelphesFormula *formula;
-  Int_t i, size;
-
-  // read efficiency formulas
-  param = GetParam("EfficiencyFormulaLoose");
-  size = param.GetSize();
-
-  fEfficiencyMapLoose.clear();
-  for(i = 0; i < size/2; ++i)
-  {
-    formula = new DelphesFormula;
-    formula->Compile(param[i*2 + 1].GetString());
-    fEfficiencyMapLoose[param[i*2].GetInt()] = formula;
-  }
-
-  // set default efficiency formula
-  itEfficiencyMap = fEfficiencyMapLoose.find(0);
-  if(itEfficiencyMap == fEfficiencyMapLoose.end())
-  {
-    formula = new DelphesFormula;
-    formula->Compile("0.0");
-    fEfficiencyMapLoose[0] = formula;
-  }
-
-  // read efficiency formulas
-  param = GetParam("EfficiencyFormulaMedium");
-  size = param.GetSize();
-
-  fEfficiencyMapMedium.clear();
-  for(i = 0; i < size/2; ++i)
-  {
-    formula = new DelphesFormula;
-    formula->Compile(param[i*2 + 1].GetString());
-    fEfficiencyMapMedium[param[i*2].GetInt()] = formula;
-  }
-
-  // set default efficiency formula
-  itEfficiencyMap = fEfficiencyMapMedium.find(0);
-  if(itEfficiencyMap == fEfficiencyMapMedium.end())
-  {
-    formula = new DelphesFormula;
-    formula->Compile("0.0");
-    fEfficiencyMapMedium[0] = formula;
-  }
-
-  // read efficiency formulas
-  param = GetParam("EfficiencyFormulaTight");
-  size = param.GetSize();
-
-  fEfficiencyMapTight.clear();
-  for(i = 0; i < size/2; ++i)
-  {
-    formula = new DelphesFormula;
-    formula->Compile(param[i*2 + 1].GetString());
-    fEfficiencyMapTight[param[i*2].GetInt()] = formula;
-  }
-
-  // set default efficiency formula
-  itEfficiencyMap = fEfficiencyMapTight.find(0);
-  if(itEfficiencyMap == fEfficiencyMapTight.end())
-  {
-    formula = new DelphesFormula;
-    formula->Compile("0.0");
-    fEfficiencyMapTight[0] = formula;
-  }
-
-  // import input array(s)
-  fJetInputArray = ImportArray(GetString("JetInputArray", "FastJetFinder/jets"));
-  fItJetInputArray = fJetInputArray->MakeIterator();
-}
-
-//------------------------------------------------------------------------------
-
-void BTaggingCMS::Finish()
-{
-  map< Int_t, DelphesFormula * >::iterator itEfficiencyMap;
-  DelphesFormula *formula;
-
-  if(fItJetInputArray) delete fItJetInputArray;
-
-  for(itEfficiencyMap = fEfficiencyMapLoose.begin(); itEfficiencyMap != fEfficiencyMapLoose.end(); ++itEfficiencyMap)
-  {
-    formula = itEfficiencyMap->second;
-    if(formula) delete formula;
-  }
-
-  for(itEfficiencyMap = fEfficiencyMapMedium.begin(); itEfficiencyMap != fEfficiencyMapMedium.end(); ++itEfficiencyMap)
-  {
-    formula = itEfficiencyMap->second;
-    if(formula) delete formula;
-  }
-
-  for(itEfficiencyMap = fEfficiencyMapTight.begin(); itEfficiencyMap != fEfficiencyMapTight.end(); ++itEfficiencyMap)
-  {
-    formula = itEfficiencyMap->second;
-    if(formula) delete formula;
-  }
-}
-
-//------------------------------------------------------------------------------
-
-void BTaggingCMS::Process()
-{
-  Candidate *jet;
-  map< Int_t, DelphesFormula * >::iterator itEfficiencyMap;
-  DelphesFormula *formula;
-  float randomNumber;
-
-  // loop over all input jets
-  fItJetInputArray->Reset();
-
-  while((jet = static_cast<Candidate*>(fItJetInputArray->Next())))
-  {
-    const TLorentzVector &jetMomentum = jet->Momentum;
-
-    randomNumber = gRandom->Uniform();
-
-    // --------------------------
-    // Loose b-tagging
-    // --------------------------
-
-    // find heaviest flavor and b-tag
-    if(fEfficiencyMapLoose.size() != 0)
-    {
-      itEfficiencyMap = fEfficiencyMapLoose.find(jet->FlavorHeaviest);
-      if(itEfficiencyMap == fEfficiencyMapLoose.end())
-      {
-        itEfficiencyMap = fEfficiencyMapLoose.find(0);
-      }
-      formula = itEfficiencyMap->second;
-
-      if(randomNumber <= formula->Eval(jetMomentum.Pt(), jetMomentum.Eta())) jet->BTagHeaviest = 1;
-
-      // find hisghestpt flavor and b-tag
-      itEfficiencyMap = fEfficiencyMapLoose.find(jet->FlavorHighestPt);
-      if(itEfficiencyMap == fEfficiencyMapLoose.end())
-      {
-        itEfficiencyMap = fEfficiencyMapLoose.find(0);
-      }
-      formula = itEfficiencyMap->second;
-
-      if(randomNumber <= formula->Eval(jetMomentum.Pt(), jetMomentum.Eta())) jet->BTagHighestPt = 1;
-
-      // find nearest2 flavor and b-tag
-      itEfficiencyMap = fEfficiencyMapLoose.find(jet->FlavorNearest2);
-      if(itEfficiencyMap == fEfficiencyMapLoose.end())
-      {
-        itEfficiencyMap = fEfficiencyMapLoose.find(0);
-      }
-      formula = itEfficiencyMap->second;
-
-      if(randomNumber <= formula->Eval(jetMomentum.Pt(), jetMomentum.Eta())) jet->BTagNearest2 = 1;
-
-      // find nearest3 flavor and b-tag
-      itEfficiencyMap = fEfficiencyMapLoose.find(jet->FlavorNearest3);
-      if(itEfficiencyMap == fEfficiencyMapLoose.end())
-      {
-        itEfficiencyMap = fEfficiencyMapLoose.find(0);
-      }
-      formula = itEfficiencyMap->second;
-
-      if(randomNumber <= formula->Eval(jetMomentum.Pt(), jetMomentum.Eta())) jet->BTagNearest3 = 1;
-
-      // find nearest3 flavor and b-tag
-      itEfficiencyMap = fEfficiencyMapLoose.find(jet->FlavorAlgo);
-      if(itEfficiencyMap == fEfficiencyMapLoose.end())
-      {
-        itEfficiencyMap = fEfficiencyMapLoose.find(0);
-      }
-      formula = itEfficiencyMap->second;
-
-      if(randomNumber <= formula->Eval(jetMomentum.Pt(), jetMomentum.Eta())) jet->BTagAlgo = 1;
-
-      // find nearest3 flavor and b-tag
-      itEfficiencyMap = fEfficiencyMapLoose.find(jet->FlavorPhysics);
-      if(itEfficiencyMap == fEfficiencyMapLoose.end())
-      {
-        itEfficiencyMap = fEfficiencyMapLoose.find(0);
-      }
-      formula = itEfficiencyMap->second;
-
-      if(randomNumber <= formula->Eval(jetMomentum.Pt(), jetMomentum.Eta())) jet->BTagPhysics = 1;
-
-      // default
-      itEfficiencyMap = fEfficiencyMapLoose.find(jet->FlavorDefault);
-      if(itEfficiencyMap == fEfficiencyMapLoose.end())
-      {
-        itEfficiencyMap = fEfficiencyMapLoose.find(0);
-      }
-      formula = itEfficiencyMap->second;
-
-      if(randomNumber <= formula->Eval(jetMomentum.Pt(), jetMomentum.Eta())) jet->BTagDefault = 1;
-    }
-
-    // --------------------------
-    // Medium b-tagging
-    // --------------------------
-
-    // find heaviest flavor and b-tag
-    if(fEfficiencyMapMedium.size() != 0)
-    {
-      itEfficiencyMap = fEfficiencyMapMedium.find(jet->FlavorHeaviest);
-      if(itEfficiencyMap == fEfficiencyMapMedium.end())
-      {
-        itEfficiencyMap = fEfficiencyMapMedium.find(0);
-      }
-      formula = itEfficiencyMap->second;
-
-      if(randomNumber <= formula->Eval(jetMomentum.Pt(), jetMomentum.Eta())) jet->BTagHeaviest = 2;
-
-      // find hisghestpt flavor and b-tag
-      itEfficiencyMap = fEfficiencyMapMedium.find(jet->FlavorHighestPt);
-      if(itEfficiencyMap == fEfficiencyMapMedium.end())
-      {
-        itEfficiencyMap = fEfficiencyMapMedium.find(0);
-      }
-      formula = itEfficiencyMap->second;
-
-      if(randomNumber <= formula->Eval(jetMomentum.Pt(), jetMomentum.Eta())) jet->BTagHighestPt = 2;
-
-      // find nearest2 flavor and b-tag
-      itEfficiencyMap = fEfficiencyMapMedium.find(jet->FlavorNearest2);
-      if(itEfficiencyMap == fEfficiencyMapMedium.end())
-      {
-        itEfficiencyMap = fEfficiencyMapMedium.find(0);
-      }
-      formula = itEfficiencyMap->second;
-
-      if(randomNumber <= formula->Eval(jetMomentum.Pt(), jetMomentum.Eta())) jet->BTagNearest2 = 2;
-
-      // find nearest3 flavor and b-tag
-      itEfficiencyMap = fEfficiencyMapMedium.find(jet->FlavorNearest3);
-      if(itEfficiencyMap == fEfficiencyMapMedium.end())
-      {
-        itEfficiencyMap = fEfficiencyMapMedium.find(0);
-      }
-      formula = itEfficiencyMap->second;
-
-      if(randomNumber <= formula->Eval(jetMomentum.Pt(), jetMomentum.Eta())) jet->BTagNearest3 = 2;
-
-      // find nearest3 flavor and b-tag
-      itEfficiencyMap = fEfficiencyMapMedium.find(jet->FlavorAlgo);
-      if(itEfficiencyMap == fEfficiencyMapMedium.end())
-      {
-        itEfficiencyMap = fEfficiencyMapMedium.find(0);
-      }
-      formula = itEfficiencyMap->second;
-
-      if(randomNumber <= formula->Eval(jetMomentum.Pt(), jetMomentum.Eta())) jet->BTagAlgo = 2;
-
-      // find nearest3 flavor and b-tag
-      itEfficiencyMap = fEfficiencyMapMedium.find(jet->FlavorPhysics);
-      if(itEfficiencyMap == fEfficiencyMapMedium.end())
-      {
-        itEfficiencyMap = fEfficiencyMapMedium.find(0);
-      }
-      formula = itEfficiencyMap->second;
-
-      if(randomNumber <= formula->Eval(jetMomentum.Pt(), jetMomentum.Eta())) jet->BTagPhysics = 2;
-
-      // default
-      itEfficiencyMap = fEfficiencyMapMedium.find(jet->FlavorDefault);
-      if(itEfficiencyMap == fEfficiencyMapMedium.end())
-      {
-        itEfficiencyMap = fEfficiencyMapMedium.find(0);
-      }
-      formula = itEfficiencyMap->second;
-
-      if(randomNumber <= formula->Eval(jetMomentum.Pt(), jetMomentum.Eta())) jet->BTagDefault = 2;
-    }
-
-    // --------------------------
-    // Tight b-tagging
-    // --------------------------
-
-    // find heaviest flavor and b-tag
-    if(fEfficiencyMapTight.size() != 0)
-    {
-      itEfficiencyMap = fEfficiencyMapTight.find(jet->FlavorHeaviest);
-      if(itEfficiencyMap == fEfficiencyMapTight.end())
-      {
-        itEfficiencyMap = fEfficiencyMapTight.find(0);
-      }
-      formula = itEfficiencyMap->second;
-
-      if(randomNumber <= formula->Eval(jetMomentum.Pt(), jetMomentum.Eta())) jet->BTagHeaviest = 3;
-
-      // find hisghestpt flavor and b-tag
-      itEfficiencyMap = fEfficiencyMapTight.find(jet->FlavorHighestPt);
-      if(itEfficiencyMap == fEfficiencyMapTight.end())
-      {
-        itEfficiencyMap = fEfficiencyMapTight.find(0);
-      }
-      formula = itEfficiencyMap->second;
-
-      if(randomNumber <= formula->Eval(jetMomentum.Pt(), jetMomentum.Eta())) jet->BTagHighestPt = 3;
-
-      // find nearest2 flavor and b-tag
-      itEfficiencyMap = fEfficiencyMapTight.find(jet->FlavorNearest2);
-      if(itEfficiencyMap == fEfficiencyMapTight.end())
-      {
-        itEfficiencyMap = fEfficiencyMapTight.find(0);
-      }
-      formula = itEfficiencyMap->second;
-
-      if(randomNumber <= formula->Eval(jetMomentum.Pt(), jetMomentum.Eta())) jet->BTagNearest2 = 3;
-
-      // find nearest3 flavor and b-tag
-      itEfficiencyMap = fEfficiencyMapTight.find(jet->FlavorNearest3);
-      if(itEfficiencyMap == fEfficiencyMapTight.end())
-      {
-        itEfficiencyMap = fEfficiencyMapTight.find(0);
-      }
-      formula = itEfficiencyMap->second;
-
-      if(randomNumber <= formula->Eval(jetMomentum.Pt(), jetMomentum.Eta())) jet->BTagNearest3 = 3;
-
-      // find nearest3 flavor and b-tag
-      itEfficiencyMap = fEfficiencyMapTight.find(jet->FlavorAlgo);
-      if(itEfficiencyMap == fEfficiencyMapTight.end())
-      {
-        itEfficiencyMap = fEfficiencyMapTight.find(0);
-      }
-      formula = itEfficiencyMap->second;
-
-      if(randomNumber <= formula->Eval(jetMomentum.Pt(), jetMomentum.Eta())) jet->BTagAlgo = 3;
-
-      // find nearest3 flavor and b-tag
-      itEfficiencyMap = fEfficiencyMapTight.find(jet->FlavorPhysics);
-      if(itEfficiencyMap == fEfficiencyMapTight.end())
-      {
-        itEfficiencyMap = fEfficiencyMapTight.find(0);
-      }
-      formula = itEfficiencyMap->second;
-
-      if(randomNumber <= formula->Eval(jetMomentum.Pt(), jetMomentum.Eta())) jet->BTagPhysics = 3;
-
-      // default
-      itEfficiencyMap = fEfficiencyMapTight.find(jet->FlavorDefault);
-      if(itEfficiencyMap == fEfficiencyMapTight.end())
-      {
-        itEfficiencyMap = fEfficiencyMapTight.find(0);
-      }
-      formula = itEfficiencyMap->second;
-
-      if(randomNumber <= formula->Eval(jetMomentum.Pt(), jetMomentum.Eta())) jet->BTagDefault = 3;
-    }
-  }
-}
Index: modules/BTaggingCMS.h
===================================================================
--- modules/BTaggingCMS.h	(revision 1d9974ea88eb58af9439d181a19287dce50b0fa4)
+++ 	(revision )
@@ -1,68 +1,0 @@
-/*
- *  Delphes: a framework for fast simulation of a generic collider experiment
- *  Copyright (C) 2012-2014  Universite catholique de Louvain (UCL), Belgium
- *
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef BTaggingCMS_h
-#define BTaggingCMS_h
-
-/** \class BTaggingCMS
- *
- *  Applies b-tagging efficiency (miss identification rate) formulas
- *  and sets b-tagging flags
- *
- *  \author P. Demin - UCL, Louvain-la-Neuve
- *
- */
-
-#include "classes/DelphesModule.h"
-#include "classes/DelphesClasses.h"
-
-#include <map>
-
-class TObjArray;
-class DelphesFormula;
-
-class ExRootFilter;
-
-class BTaggingCMS: public DelphesModule
-{
-
-public:
-
-  BTaggingCMS();
-  ~BTaggingCMS();
-
-  void Init();
-  void Process();
-  void Finish();
-
-private:
-
-#if !defined(__CINT__) && !defined(__CLING__)
-  std::map< Int_t, DelphesFormula * > fEfficiencyMapLoose; //!
-  std::map< Int_t, DelphesFormula * > fEfficiencyMapMedium; //!
-  std::map< Int_t, DelphesFormula * > fEfficiencyMapTight; //!
-#endif
-
-  TIterator *fItJetInputArray; //!
-
-  const TObjArray *fJetInputArray; //!
-
-  ClassDef(BTaggingCMS, 1)
-};
-
-#endif
Index: modules/JetFlavorAssociation.cc
===================================================================
--- modules/JetFlavorAssociation.cc	(revision 1d9974ea88eb58af9439d181a19287dce50b0fa4)
+++ modules/JetFlavorAssociation.cc	(revision 28027d5512f2b684a80502d8951effa581f70cd0)
@@ -216,9 +216,8 @@
 {
   float maxPt = 0;
-  float minDr = 1000;
   bool isGoodParton = true;
   int daughterCounter = 0;
   Candidate *parton, *partonLHEF;
-  Candidate *tempParton = 0, *tempPartonNearest = 0, *tempPartonHighestPt = 0;
+  Candidate *tempParton = 0, *tempPartonHighestPt = 0;
   int pdgCode, pdgCodeMax = -1;
 
@@ -263,10 +262,4 @@
       if(jet->Momentum.DeltaR(parton->Momentum) <= fDeltaR)
       {
-        if(jet->Momentum.DeltaR(parton->Momentum) < minDr)
-        {
-          minDr = jet->Momentum.DeltaR(parton->Momentum);
-          tempPartonNearest = parton;
-        }
-
         // if not yet found && pdgId is a c, take as c
         if(TMath::Abs(parton->PID) == 4) tempParton = parton;
@@ -281,7 +274,4 @@
   }
 
-  jet->FlavorHeaviest = tempParton ? TMath::Abs(tempParton->PID) : 0;
-  jet->FlavorHighestPt = tempPartonHighestPt ? TMath::Abs(tempPartonHighestPt->PID) : 0;
-  jet->FlavorNearest2 = tempPartonNearest ? TMath::Abs(tempPartonNearest->PID) : 0;
   if(!tempParton) tempParton = tempPartonHighestPt;
   jet->FlavorAlgo = tempParton ? TMath::Abs(tempParton->PID) : 0;
@@ -290,5 +280,5 @@
   if(pdgCodeMax == -1) pdgCodeMax = 0;
 
-  jet->FlavorDefault = pdgCodeMax;
+  jet->Flavor = pdgCodeMax;
 }
 
@@ -297,5 +287,4 @@
 void JetFlavorAssociation::GetPhysicsFlavor(Candidate *jet, TIter &itPartonArray, TIter &itPartonLHEFArray)
 {
-  float minDr = 1000;
   int partonCounter = 0;
   float biggerConeSize = 0.7;
@@ -305,5 +294,5 @@
   int motherCounter = 0;
   Candidate *parton, *partonLHEF, *mother1, *mother2;
-  Candidate *tempParton = 0, *tempPartonNearest = 0;
+  Candidate *tempParton = 0;
   vector<Candidate *> contaminations;
   vector<Candidate *>::iterator itContaminations;
@@ -315,9 +304,4 @@
   {
     dist = jet->Momentum.DeltaR(partonLHEF->Momentum); // take the DR
-    if(partonLHEF->Status == 1 && dist < minDr)
-    {
-      tempPartonNearest = partonLHEF;
-      minDr = dist;
-    }
 
     if(partonLHEF->Status == 1 && dist <= fDeltaR)
@@ -354,17 +338,15 @@
   }
 
-  jet->FlavorNearest3 = tempPartonNearest ? TMath::Abs(tempPartonNearest->PID) : 0;
-
   if(partonCounter != 1)
   {
-    jet->FlavorPhysics = 0;
+    jet->FlavorPhys = 0;
   }
   else if(contaminations.size() == 0)
   {
-    jet->FlavorPhysics = TMath::Abs(tempParton->PID);
+    jet->FlavorPhys = TMath::Abs(tempParton->PID);
   }
   else if(contaminations.size() > 0)
   {
-    jet->FlavorPhysics = TMath::Abs(tempParton->PID);
+    jet->FlavorPhys = TMath::Abs(tempParton->PID);
 
     for(itContaminations = contaminations.begin(); itContaminations != contaminations.end(); ++itContaminations)
@@ -391,5 +373,5 @@
         // keep association --> the initialParton is a c --> the contaminated parton is a c
         if(contaminatingFlavor == 4) continue;
-        jet->FlavorPhysics = 0; // all the other cases reject!
+        jet->FlavorPhys = 0; // all the other cases reject!
         break;
       }
Index: modules/ModulesLinkDef.h
===================================================================
--- modules/ModulesLinkDef.h	(revision 1d9974ea88eb58af9439d181a19287dce50b0fa4)
+++ modules/ModulesLinkDef.h	(revision 28027d5512f2b684a80502d8951effa581f70cd0)
@@ -42,5 +42,4 @@
 #include "modules/UniqueObjectFinder.h"
 #include "modules/TrackCountingBTagging.h"
-#include "modules/BTaggingCMS.h"
 #include "modules/BTagging.h"
 #include "modules/TauTagging.h"
@@ -85,5 +84,4 @@
 #pragma link C++ class UniqueObjectFinder+;
 #pragma link C++ class TrackCountingBTagging+;
-#pragma link C++ class BTaggingCMS+;
 #pragma link C++ class BTagging+;
 #pragma link C++ class TauTagging+;
Index: modules/TreeWriter.cc
===================================================================
--- modules/TreeWriter.cc	(revision 1d9974ea88eb58af9439d181a19287dce50b0fa4)
+++ modules/TreeWriter.cc	(revision 28027d5512f2b684a80502d8951effa581f70cd0)
@@ -490,5 +490,4 @@
     const TLorentzVector &position = candidate->Position;
 
-
     pt = momentum.Pt();
     cosTheta = TMath::Abs(momentum.CosTheta());
@@ -567,21 +566,12 @@
     entry->DeltaPhi = candidate->DeltaPhi;
 
+    entry->Flavor = candidate->Flavor;
+    entry->FlavorAlgo = candidate->FlavorAlgo;
+    entry->FlavorPhys = candidate->FlavorPhys;
+
     entry->BTag = candidate->BTag;
 
     entry->BTagAlgo = candidate->BTagAlgo;
-    entry->BTagDefault = candidate->BTagDefault;
-    entry->BTagPhysics = candidate->BTagPhysics;
-    entry->BTagNearest2 = candidate->BTagNearest2;
-    entry->BTagNearest3 = candidate->BTagNearest3;
-    entry->BTagHeaviest = candidate->BTagHeaviest;
-    entry->BTagHighestPt = candidate->BTagHighestPt;
-
-    entry->FlavorAlgo = candidate->FlavorAlgo;
-    entry->FlavorDefault = candidate->FlavorDefault;
-    entry->FlavorPhysics = candidate->FlavorPhysics;
-    entry->FlavorNearest2 = candidate->FlavorNearest2;
-    entry->FlavorNearest3 = candidate->FlavorNearest3;
-    entry->FlavorHeaviest = candidate->FlavorHeaviest;
-    entry->FlavorHighestPt = candidate->FlavorHighestPt;
+    entry->BTagPhys = candidate->BTagPhys;
 
     entry->TauTag = candidate->TauTag;
