9 using namespace RecoBTag;
15 pSet.getParameter<double>(
"etaMin"),
16 pSet.getParameter<double>(
"etaMax"),
17 pSet.getParameter<double>(
"ptRecJetMin"),
18 pSet.getParameter<double>(
"ptRecJetMax"),
20 pSet.getParameter<double>(
"ratioMin"),
21 pSet.getParameter<double>(
"ratioMax"),
22 pSet.getParameter<bool>(
"doJetID" )
24 etaRanges(pSet.getParameter< vector<double> >(
"etaRanges")),
25 ptRanges(pSet.getParameter< vector<double> >(
"ptRanges")),
26 useOldFlavourTool(pSet.getParameter<bool>(
"useOldFlavourTool" )),
27 doJEC(pSet.getParameter<bool>(
"doJEC" )),
28 ptHatWeight(pSet.getParameter< bool >(
"applyPtHatWeight")),
29 moduleConfig(pSet.getParameter< vector<edm::
ParameterSet> >(
"tagConfig")),
30 flavPlots_(pSet.getParameter< std::
string >(
"flavPlots")),
31 jetMatcher(pSet.getParameter<edm::
ParameterSet>(
"recJetMatching")),
32 doPUid(pSet.getParameter< bool >(
"doPUid"))
43 double ptRecJetMin = pSet.
getParameter<
double>(
"ptRecJetMin");
59 for (vector<edm::ParameterSet>::const_iterator iModule =
moduleConfig.begin();
62 const string& dataFormatType = iModule->exists(
"type") ?
63 iModule->getParameter<
string>(
"type") :
65 if (dataFormatType ==
"JetTag") {
69 jetTagToken.push_back(consumes<JetTagCollection>(moduleLabel));
71 else if(dataFormatType ==
"TagCorrelation") {
82 std::vector< edm::EDGetTokenT<edm::View<reco::BaseTagInfo>> > tokens;
83 if(dataFormatType ==
"GenericMVA") {
105 const int iEtaStart = -1 ;
106 const int iEtaEnd =
etaRanges.size() - 1 ;
107 const int iPtStart = -1 ;
108 const int iPtEnd =
ptRanges.size() - 1 ;
112 int iTag = -1;
int iTagCorr = -1;
int iInfoTag = -1;
113 for (vector<edm::ParameterSet>::const_iterator iModule =
moduleConfig.begin();
116 const string& dataFormatType = iModule->exists(
"type") ?
117 iModule->getParameter<
string>(
"type") :
119 if (dataFormatType ==
"JetTag") {
121 const string& folderName = iModule->getParameter<
string>(
"folder");
124 for (
int iEta = iEtaStart ; iEta < iEtaEnd ; iEta++ ) {
126 for (
int iPt = iPtStart ; iPt < iPtEnd ; iPt++ ) {
137 }
else if(dataFormatType ==
"TagCorrelation") {
143 for (
int iEta = iEtaStart ; iEta != iEtaEnd ; ++iEta) {
145 for(
int iPt = iPtStart ; iPt != iPtEnd ; ++iPt) {
158 const string& folderName = iModule->getParameter<
string>(
"folder");
160 for (
int iEta = iEtaStart ; iEta < iEtaEnd ; iEta++ ) {
162 for (
int iPt = iPtStart ; iPt < iPtEnd ; iPt++ ) {
181 bool etaActive_ , ptActive_;
182 double etaMin_, etaMax_, ptMin_, ptMax_ ;
205 return EtaPtBin(etaActive_ , etaMin_ , etaMax_ ,
206 ptActive_ , ptMin_ , ptMax_ );
211 for (vector<vector<JetTagPlotter*> >::iterator iJetLabel =
binJetTagPlotters.begin();
213 for (vector<JetTagPlotter*>::iterator iPlotter = iJetLabel->begin(); iPlotter != iJetLabel->end(); ++iPlotter)
218 for (vector<TagCorrelationPlotter* >::iterator iPlotter = iJetLabel->begin(); iPlotter != iJetLabel->end(); ++iPlotter)
221 for (vector<vector<BaseTagInfoPlotter*> >::iterator iJetLabel =
binTagInfoPlotters.begin();
223 for (vector<BaseTagInfoPlotter*>::iterator iPlotter = iJetLabel->begin(); iPlotter != iJetLabel->end(); ++iPlotter)
241 if( genInfoHandle.
isValid() ) {
242 weight = weight*
static_cast<float>(genInfoHandle->weight());
256 for (JetFlavourInfoMatchingCollection::const_iterator iter = jetMC->begin();
257 iter != jetMC->end(); ++iter) {
258 unsigned int fl =
std::abs(iter->second.getPartonFlavour());
259 flavours.insert(std::make_pair(iter->first, fl));
262 for (
unsigned int i=0;
i<lep.
size();
i++){
267 leptons.insert(std::make_pair(iter->first, lepCount));
273 for (JetFlavourMatchingCollection::const_iterator iter = jetMC->begin();
274 iter != jetMC->end(); ++iter) {
275 unsigned int fl =
std::abs(iter->second.getFlavour());
276 flavours.insert(std::make_pair(iter->first, fl));
278 leptons.insert(std::make_pair(iter->first, lep));
298 corrector = corrHandle.
product();
303 for (
unsigned int iJetLabel = 0; iJetLabel !=
jetTagInputTags.size(); ++iJetLabel) {
311 tagI != tagColl.
end(); ++tagI) {
315 if (flavours[tagI->first] == 5 &&
317 (
muonPlots && !leptons[tagI->first].muon) ||
318 (
tauPlots && !leptons[tagI->first].tau)))
323 if(
doJEC && corrector) {
328 if (!
getJetWithFlavour(iEvent, tagI->first, flavours, jetWithFlavour, corrector, genJetsMatched))
330 if (!
jetSelector(jetWithFlavour.first,
std::abs(jetWithFlavour.second.getPartonFlavour()), infoHandle, jec))
333 for (
int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
335 inBin =
binJetTagPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(jetWithFlavour.first, jec);
338 binJetTagPlotters[iJetLabel][iPlotter]->analyzeTag(jetWithFlavour.first, jec, tagI->second,
std::abs(jetWithFlavour.second.getPartonFlavour()),weight);
341 for (
int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
350 iEvent.
getByToken(inputTokens.first, tagHandle1);
354 iEvent.
getByToken(inputTokens.second, tagHandle2);
360 if (flavours[tagI->first] == 5 &&
362 (
muonPlots && !leptons[tagI->first].muon) ||
363 (
tauPlots && !leptons[tagI->first].tau)))
369 if(
doJEC && corrector) {
374 if (!
getJetWithFlavour(iEvent, tagI->first, flavours, jetWithFlavour, corrector, genJetsMatched))
376 if (!
jetSelector(jetWithFlavour.first,
std::abs(jetWithFlavour.second.getPartonFlavour()), infoHandle, jec))
379 for(
int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
385 double discr2 = tagColl2[tagI->first];
394 for (
unsigned int iJetLabel = 0; iJetLabel !=
tiDataFormatType.size(); ++iJetLabel) {
396 for (
int iPlotter = 0; iPlotter != plotterSize; ++iPlotter)
400 if (inputTags.empty()) {
406 labels.push_back(
"label");
407 for (vector<string>::const_iterator iLabels = labels.begin();
408 iLabels != labels.end(); ++iLabels) {
411 inputTags.push_back(inputTag);
415 unsigned int nInputTags = inputTags.size();
416 vector< edm::Handle< View<BaseTagInfo> > > tagInfoHandles(nInputTags);
418 unsigned int nTagInfos = 0;
419 vector<edm::EDGetTokenT<edm::View<reco::BaseTagInfo>> > & tokens =
tagInfoToken[iJetLabel];
420 if(nInputTags!=tokens.size())
throw cms::Exception(
"Configuration") <<
"Different number of Tag Infos than expected" << endl;
421 for (
unsigned int iInputTags = 0; iInputTags < tokens.size(); ++iInputTags) {
423 iEvent.
getByToken(tokens[iInputTags], tagInfoHandle);
424 unsigned int size = tagInfoHandle->size();
425 LogDebug(
"Info") <<
"Found " << size <<
" B candidates in collection " << inputTags[iInputTags];
428 if (iInputTags == 0) {
429 jetProductID = thisProductID;
431 }
else if (jetProductID != thisProductID)
432 throw cms::Exception(
"Configuration") <<
"TagInfos are referencing a different jet collection." << endl;
433 else if (nTagInfos != size)
434 throw cms::Exception(
"Configuration") <<
"TagInfo collections are having a different size." << endl;
437 for (
unsigned int iTagInfos = 0; iTagInfos < nTagInfos; ++iTagInfos) {
438 vector<const BaseTagInfo*> baseTagInfos(nInputTags);
440 for (
unsigned int iTagInfo = 0; iTagInfo < nInputTags; iTagInfo++) {
441 const BaseTagInfo &baseTagInfo = (*tagInfoHandles[iTagInfo])[iTagInfos];
443 jetRef = baseTagInfo.
jet();
444 else if (baseTagInfo.
jet() != jetRef)
445 throw cms::Exception(
"Configuration") <<
"TagInfos pointing to different jets." << endl;
446 baseTagInfos[iTagInfo] = &baseTagInfo;
452 if (flavours[jetRef] == 5 &&
461 if(
doJEC && corrector) {
466 if (!
getJetWithFlavour(iEvent, jetRef, flavours, jetWithFlavour, corrector, genJetsMatched))
468 if (!
jetSelector(jetWithFlavour.first,
std::abs(jetWithFlavour.second.getPartonFlavour()), infoHandle, jec))
471 for (
int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
476 binTagInfoPlotters[iJetLabel][iPlotter]->analyzeTag(baseTagInfos, jec,
std::abs(jetWithFlavour.second.getPartonFlavour()),weight);
498 : flavours.begin()->first.
id();
502 if (recProdId != refProdId) {
504 for(FlavourMap::const_iterator iter = flavours.begin();
505 iter != flavours.end(); ++iter)
509 for(
unsigned int i = 0;
i < recJetsProd->
size();
i++)
516 if (recProdId != refProdId) {
524 auto itFound = flavours.find(jetRef);
525 unsigned int flavour = itFound != flavours.end()? itFound->second : 0;
529 if(!isNotPU) flavour=20;
534 LogTrace(
"Info") <<
"Found jet with flavour "<<jetWithFlavour.second.getPartonFlavour()<<endl;
535 LogTrace(
"Info") << jetWithFlavour.first.p()<<
" , "<< jetWithFlavour.first.pt()<<
" - "<<endl;
T getParameter(std::string const &) const
BaseTagInfoPlotter * buildPlotter(const std::string &dataFormatType, const std::string &tagName, const EtaPtBin &etaPtBin, const edm::ParameterSet &pSet, const std::string &folderName, const unsigned int &mc, const bool &wf, DQMStore::IBooker &ibook)
bool isNonnull() const
Checks for non-null.
transient_vector_type::const_iterator const_iterator
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
Base class for all types of Jets.
void setThreshold(const double &energy)
const_iterator end() const
double correction(const LorentzVector &fJet) const
get correction using Jet information only
void matchCollections(const edm::RefToBaseVector< reco::Jet > &refJets, const edm::RefToBaseVector< reco::Jet > &recJets, const reco::JetCorrector *corrector)
match the collections
virtual edm::RefToBase< Jet > jet(void) const
returns a polymorphic reference to the tagged jet
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Class storing the jet flavour information.
Abs< T >::type abs(const T &t)
virtual std::vector< std::string > tagInfoRequirements() const
T const * product() const
bool isNull() const
Checks for null.
void setCorrector(const reco::JetCorrector *corrector)
Returns the corrected jet.
RefToBaseProd< T > makeRefToBaseProdFrom(RefToBase< T > const &iRef, Event const &iEvent)
void push_back(const RefToBase< T > &)
size_type size() const
Size of the RefVector.
volatile std::atomic< bool > shutdown_flag false
int flavour(const Candidate &part)
const_iterator begin() const
tuple size
Write out results.