CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
TtFullHadKinFitProducer Class Reference
Inheritance diagram for TtFullHadKinFitProducer:
edm::stream::EDProducer<>

Public Member Functions

 TtFullHadKinFitProducer (const edm::ParameterSet &cfg)
 default constructor More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Public Attributes

std::unique_ptr< TtFullHadKinFitter::KinFitkinFitter
 kinematic fit interface More...
 

Private Member Functions

void produce (edm::Event &event, const edm::EventSetup &setup) override
 produce fitted object collections and meta data describing fit quality More...
 

Private Attributes

std::vector< edm::ParameterSetbResolutions_
 
std::string bTagAlgo_
 input tag for b-tagging algorithm More...
 
unsigned int bTags_
 minimal number of b-jets More...
 
std::vector< unsigned > constraints_
 numbering of different possible kinematic constraints More...
 
std::string jetCorrectionLevel_
 correction level for jets More...
 
std::vector< double > jetEnergyResolutionEtaBinning_
 
std::vector< double > jetEnergyResolutionScaleFactors_
 scale factors for jet energy resolution More...
 
unsigned int jetParam_
 numbering of different possible jet parametrizations More...
 
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
 input tag for jets More...
 
edm::EDGetTokenT< std::vector< std::vector< int > > > matchToken_
 input tag for matches (in case the fit should be performed on certain matches) More...
 
double maxBTagValueNonBJet_
 max value of bTag for a non-b-jet More...
 
double maxDeltaS_
 maximal chi2 equivalent More...
 
double maxF_
 maximal deviation for contstraints More...
 
int maxNComb_
 maximal number of combinations to be written to the event More...
 
int maxNJets_
 maximal number of jets (-1 possible to indicate 'all') More...
 
unsigned int maxNrIter_
 maximal number of iterations to be performed for the fit More...
 
double minBTagValueBJet_
 min value of bTag for a b-jet More...
 
double mTop_
 top mass value used for constraints More...
 
double mW_
 W mass value used for constraints. More...
 
std::vector< edm::ParameterSetudscResolutions_
 store the resolutions for the jets More...
 
bool useBTagging_
 switch to tell whether to use b-tagging or not More...
 
bool useOnlyMatch_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 19 of file TtFullHadKinFitProducer.cc.

Constructor & Destructor Documentation

◆ TtFullHadKinFitProducer()

TtFullHadKinFitProducer::TtFullHadKinFitProducer ( const edm::ParameterSet cfg)
explicit

default constructor

Definition at line 80 of file TtFullHadKinFitProducer.cc.

References bResolutions_, bTagAlgo_, bTags_, looper::cfg, constraints_, Exception, jetCorrectionLevel_, jetEnergyResolutionEtaBinning_, jetEnergyResolutionScaleFactors_, jetParam_, kinFitter, maxBTagValueNonBJet_, maxDeltaS_, maxF_, maxNComb_, maxNJets_, maxNrIter_, minBTagValueBJet_, mTop_, mW_, udscResolutions_, and useBTagging_.

81  : jetsToken_(consumes<std::vector<pat::Jet> >(cfg.getParameter<edm::InputTag>("jets"))),
82  matchToken_(mayConsume<std::vector<std::vector<int> > >(cfg.getParameter<edm::InputTag>("match"))),
83  useOnlyMatch_(cfg.getParameter<bool>("useOnlyMatch")),
84  bTagAlgo_(cfg.getParameter<std::string>("bTagAlgo")),
85  minBTagValueBJet_(cfg.getParameter<double>("minBTagValueBJet")),
86  maxBTagValueNonBJet_(cfg.getParameter<double>("maxBTagValueNonBJet")),
87  useBTagging_(cfg.getParameter<bool>("useBTagging")),
88  bTags_(cfg.getParameter<unsigned int>("bTags")),
89  jetCorrectionLevel_(cfg.getParameter<std::string>("jetCorrectionLevel")),
90  maxNJets_(cfg.getParameter<int>("maxNJets")),
91  maxNComb_(cfg.getParameter<int>("maxNComb")),
92  maxNrIter_(cfg.getParameter<unsigned int>("maxNrIter")),
93  maxDeltaS_(cfg.getParameter<double>("maxDeltaS")),
94  maxF_(cfg.getParameter<double>("maxF")),
95  jetParam_(cfg.getParameter<unsigned>("jetParametrisation")),
96  constraints_(cfg.getParameter<std::vector<unsigned> >("constraints")),
97  mW_(cfg.getParameter<double>("mW")),
98  mTop_(cfg.getParameter<double>("mTop")),
99  jetEnergyResolutionScaleFactors_(cfg.getParameter<std::vector<double> >("jetEnergyResolutionScaleFactors")),
100  jetEnergyResolutionEtaBinning_(cfg.getParameter<std::vector<double> >("jetEnergyResolutionEtaBinning")) {
101  if (cfg.exists("udscResolutions") && cfg.exists("bResolutions")) {
102  udscResolutions_ = cfg.getParameter<std::vector<edm::ParameterSet> >("udscResolutions");
103  bResolutions_ = cfg.getParameter<std::vector<edm::ParameterSet> >("bResolutions");
104  } else if (cfg.exists("udscResolutions") || cfg.exists("bResolutions")) {
105  if (cfg.exists("udscResolutions"))
106  throw cms::Exception("Configuration")
107  << "Parameter 'bResolutions' is needed if parameter 'udscResolutions' is defined!\n";
108  else
109  throw cms::Exception("Configuration")
110  << "Parameter 'udscResolutions' is needed if parameter 'bResolutions' is defined!\n";
111  }
112 
113  // define kinematic fit interface
114  kinFitter = std::make_unique<TtFullHadKinFitter::KinFit>(useBTagging_,
115  bTags_,
116  bTagAlgo_,
124  maxNJets_,
125  maxNComb_,
126  maxNrIter_,
127  maxDeltaS_,
128  maxF_,
129  jetParam_,
130  constraints_,
131  mW_,
132  mTop_);
133 
134  // produces the following collections
135  produces<std::vector<pat::Particle> >("PartonsB");
136  produces<std::vector<pat::Particle> >("PartonsBBar");
137  produces<std::vector<pat::Particle> >("PartonsLightQ");
138  produces<std::vector<pat::Particle> >("PartonsLightQBar");
139  produces<std::vector<pat::Particle> >("PartonsLightP");
140  produces<std::vector<pat::Particle> >("PartonsLightPBar");
141 
142  produces<std::vector<std::vector<int> > >();
143  produces<std::vector<double> >("Chi2");
144  produces<std::vector<double> >("Prob");
145  produces<std::vector<int> >("Status");
146 }
edm::EDGetTokenT< std::vector< std::vector< int > > > matchToken_
input tag for matches (in case the fit should be performed on certain matches)
unsigned int jetParam_
numbering of different possible jet parametrizations
double mTop_
top mass value used for constraints
std::vector< unsigned > constraints_
numbering of different possible kinematic constraints
double mW_
W mass value used for constraints.
std::vector< edm::ParameterSet > udscResolutions_
store the resolutions for the jets
bool useBTagging_
switch to tell whether to use b-tagging or not
std::unique_ptr< TtFullHadKinFitter::KinFit > kinFitter
kinematic fit interface
std::vector< edm::ParameterSet > bResolutions_
int maxNComb_
maximal number of combinations to be written to the event
std::string jetCorrectionLevel_
correction level for jets
double maxF_
maximal deviation for contstraints
double maxDeltaS_
maximal chi2 equivalent
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
input tag for jets
unsigned int maxNrIter_
maximal number of iterations to be performed for the fit
std::string bTagAlgo_
input tag for b-tagging algorithm
std::vector< double > jetEnergyResolutionScaleFactors_
scale factors for jet energy resolution
int maxNJets_
maximal number of jets (-1 possible to indicate &#39;all&#39;)
double maxBTagValueNonBJet_
max value of bTag for a non-b-jet
unsigned int bTags_
minimal number of b-jets
std::vector< double > jetEnergyResolutionEtaBinning_
double minBTagValueBJet_
min value of bTag for a b-jet

Member Function Documentation

◆ produce()

void TtFullHadKinFitProducer::produce ( edm::Event event,
const edm::EventSetup setup 
)
overrideprivate

produce fitted object collections and meta data describing fit quality

set match to be used

set the validity of a match

Definition at line 149 of file TtFullHadKinFitProducer.cc.

References heavyIonCSV_trainingSettings::idx, PDWG_EXODelayedJetMET_cff::jets, jetsToken_, kinFitter, match(), oniaPATMuonsWithTrigger_cff::matches, matchToken_, maxNComb_, eostools::move(), nPartons, useOnlyMatch_, and trackerHitRTTI::vector.

149  {
150  // get jet collection
151  const edm::Handle<std::vector<pat::Jet> >& jets = event.getHandle(jetsToken_);
152 
153  // get match in case that useOnlyMatch_ is true
154  std::vector<int> match;
155  bool invalidMatch = false;
156  if (useOnlyMatch_) {
157  kinFitter->setUseOnlyMatch(true);
158  // in case that only a ceratin match should be used, get match here
159  const edm::Handle<std::vector<std::vector<int> > >& matches = event.getHandle(matchToken_);
160  match = *(matches->begin());
161  // check if match is valid
162  if (match.size() != nPartons) {
163  invalidMatch = true;
164  } else {
165  for (unsigned int idx = 0; idx < match.size(); ++idx) {
166  if (match[idx] < 0 || match[idx] >= (int)jets->size()) {
167  invalidMatch = true;
168  break;
169  }
170  }
171  }
173  kinFitter->setMatch(match);
174  }
175 
177  kinFitter->setMatchInvalidity(invalidMatch);
178 
179  std::list<TtFullHadKinFitter::KinFitResult> fitResults = kinFitter->fit(*jets);
180 
181  // pointer for output collections
182  std::unique_ptr<std::vector<pat::Particle> > pPartonsB(new std::vector<pat::Particle>);
183  std::unique_ptr<std::vector<pat::Particle> > pPartonsBBar(new std::vector<pat::Particle>);
184  std::unique_ptr<std::vector<pat::Particle> > pPartonsLightQ(new std::vector<pat::Particle>);
185  std::unique_ptr<std::vector<pat::Particle> > pPartonsLightQBar(new std::vector<pat::Particle>);
186  std::unique_ptr<std::vector<pat::Particle> > pPartonsLightP(new std::vector<pat::Particle>);
187  std::unique_ptr<std::vector<pat::Particle> > pPartonsLightPBar(new std::vector<pat::Particle>);
188  // pointer for meta information
189  std::unique_ptr<std::vector<std::vector<int> > > pCombi(new std::vector<std::vector<int> >);
190  std::unique_ptr<std::vector<double> > pChi2(new std::vector<double>);
191  std::unique_ptr<std::vector<double> > pProb(new std::vector<double>);
192  std::unique_ptr<std::vector<int> > pStatus(new std::vector<int>);
193 
194  unsigned int iComb = 0;
195  for (std::list<TtFullHadKinFitter::KinFitResult>::const_iterator res = fitResults.begin(); res != fitResults.end();
196  ++res) {
197  if (maxNComb_ >= 1 && iComb == (unsigned int)maxNComb_) {
198  break;
199  }
200  ++iComb;
201 
202  pPartonsB->push_back(res->B);
203  pPartonsBBar->push_back(res->BBar);
204  pPartonsLightQ->push_back(res->LightQ);
205  pPartonsLightQBar->push_back(res->LightQBar);
206  pPartonsLightP->push_back(res->LightP);
207  pPartonsLightPBar->push_back(res->LightPBar);
208 
209  pCombi->push_back(res->JetCombi);
210  pChi2->push_back(res->Chi2);
211  pProb->push_back(res->Prob);
212  pStatus->push_back(res->Status);
213  }
214 
215  event.put(std::move(pCombi));
216  event.put(std::move(pPartonsB), "PartonsB");
217  event.put(std::move(pPartonsBBar), "PartonsBBar");
218  event.put(std::move(pPartonsLightQ), "PartonsLightQ");
219  event.put(std::move(pPartonsLightQBar), "PartonsLightQBar");
220  event.put(std::move(pPartonsLightP), "PartonsLightP");
221  event.put(std::move(pPartonsLightPBar), "PartonsLightPBar");
222  event.put(std::move(pChi2), "Chi2");
223  event.put(std::move(pProb), "Prob");
224  event.put(std::move(pStatus), "Status");
225 }
static const unsigned int nPartons
edm::EDGetTokenT< std::vector< std::vector< int > > > matchToken_
input tag for matches (in case the fit should be performed on certain matches)
Definition: Electron.h:6
std::unique_ptr< TtFullHadKinFitter::KinFit > kinFitter
kinematic fit interface
int maxNComb_
maximal number of combinations to be written to the event
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
input tag for jets
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ bResolutions_

std::vector<edm::ParameterSet> TtFullHadKinFitProducer::bResolutions_
private

Definition at line 67 of file TtFullHadKinFitProducer.cc.

Referenced by TtFullHadKinFitProducer().

◆ bTagAlgo_

std::string TtFullHadKinFitProducer::bTagAlgo_
private

input tag for b-tagging algorithm

Definition at line 37 of file TtFullHadKinFitProducer.cc.

Referenced by TtFullHadKinFitProducer().

◆ bTags_

unsigned int TtFullHadKinFitProducer::bTags_
private

minimal number of b-jets

Definition at line 45 of file TtFullHadKinFitProducer.cc.

Referenced by TtFullHadKinFitProducer().

◆ constraints_

std::vector<unsigned> TtFullHadKinFitProducer::constraints_
private

numbering of different possible kinematic constraints

Definition at line 61 of file TtFullHadKinFitProducer.cc.

Referenced by TtFullHadKinFitProducer().

◆ jetCorrectionLevel_

std::string TtFullHadKinFitProducer::jetCorrectionLevel_
private

correction level for jets

Definition at line 47 of file TtFullHadKinFitProducer.cc.

Referenced by TtFullHadKinFitProducer().

◆ jetEnergyResolutionEtaBinning_

std::vector<double> TtFullHadKinFitProducer::jetEnergyResolutionEtaBinning_
private

Definition at line 70 of file TtFullHadKinFitProducer.cc.

Referenced by TtFullHadKinFitProducer().

◆ jetEnergyResolutionScaleFactors_

std::vector<double> TtFullHadKinFitProducer::jetEnergyResolutionScaleFactors_
private

scale factors for jet energy resolution

Definition at line 69 of file TtFullHadKinFitProducer.cc.

Referenced by TtFullHadKinFitProducer().

◆ jetParam_

unsigned int TtFullHadKinFitProducer::jetParam_
private

numbering of different possible jet parametrizations

Definition at line 59 of file TtFullHadKinFitProducer.cc.

Referenced by TtFullHadKinFitProducer().

◆ jetsToken_

edm::EDGetTokenT<std::vector<pat::Jet> > TtFullHadKinFitProducer::jetsToken_
private

input tag for jets

Definition at line 30 of file TtFullHadKinFitProducer.cc.

Referenced by produce().

◆ kinFitter

std::unique_ptr<TtFullHadKinFitter::KinFit> TtFullHadKinFitProducer::kinFitter

kinematic fit interface

Definition at line 74 of file TtFullHadKinFitProducer.cc.

Referenced by produce(), and TtFullHadKinFitProducer().

◆ matchToken_

edm::EDGetTokenT<std::vector<std::vector<int> > > TtFullHadKinFitProducer::matchToken_
private

input tag for matches (in case the fit should be performed on certain matches)

Definition at line 32 of file TtFullHadKinFitProducer.cc.

Referenced by produce().

◆ maxBTagValueNonBJet_

double TtFullHadKinFitProducer::maxBTagValueNonBJet_
private

max value of bTag for a non-b-jet

Definition at line 41 of file TtFullHadKinFitProducer.cc.

Referenced by TtFullHadKinFitProducer().

◆ maxDeltaS_

double TtFullHadKinFitProducer::maxDeltaS_
private

maximal chi2 equivalent

Definition at line 55 of file TtFullHadKinFitProducer.cc.

Referenced by TtFullHadKinFitProducer().

◆ maxF_

double TtFullHadKinFitProducer::maxF_
private

maximal deviation for contstraints

Definition at line 57 of file TtFullHadKinFitProducer.cc.

Referenced by TtFullHadKinFitProducer().

◆ maxNComb_

int TtFullHadKinFitProducer::maxNComb_
private

maximal number of combinations to be written to the event

Definition at line 51 of file TtFullHadKinFitProducer.cc.

Referenced by produce(), and TtFullHadKinFitProducer().

◆ maxNJets_

int TtFullHadKinFitProducer::maxNJets_
private

maximal number of jets (-1 possible to indicate 'all')

Definition at line 49 of file TtFullHadKinFitProducer.cc.

Referenced by TtFullHadKinFitProducer().

◆ maxNrIter_

unsigned int TtFullHadKinFitProducer::maxNrIter_
private

maximal number of iterations to be performed for the fit

Definition at line 53 of file TtFullHadKinFitProducer.cc.

Referenced by TtFullHadKinFitProducer().

◆ minBTagValueBJet_

double TtFullHadKinFitProducer::minBTagValueBJet_
private

min value of bTag for a b-jet

Definition at line 39 of file TtFullHadKinFitProducer.cc.

Referenced by TtFullHadKinFitProducer().

◆ mTop_

double TtFullHadKinFitProducer::mTop_
private

top mass value used for constraints

Definition at line 65 of file TtFullHadKinFitProducer.cc.

Referenced by TtFullHadKinFitProducer().

◆ mW_

double TtFullHadKinFitProducer::mW_
private

W mass value used for constraints.

Definition at line 63 of file TtFullHadKinFitProducer.cc.

Referenced by TtFullHadKinFitProducer().

◆ udscResolutions_

std::vector<edm::ParameterSet> TtFullHadKinFitProducer::udscResolutions_
private

store the resolutions for the jets

Definition at line 67 of file TtFullHadKinFitProducer.cc.

Referenced by TtFullHadKinFitProducer().

◆ useBTagging_

bool TtFullHadKinFitProducer::useBTagging_
private

switch to tell whether to use b-tagging or not

Definition at line 43 of file TtFullHadKinFitProducer.cc.

Referenced by TtFullHadKinFitProducer().

◆ useOnlyMatch_

bool TtFullHadKinFitProducer::useOnlyMatch_
private

switch to tell whether all possible combinations should be used for the fit or only a certain combination

Definition at line 35 of file TtFullHadKinFitProducer.cc.

Referenced by produce().