14 : jetSelector(pSet.getParameter<double>(
"etaMin"),
15 pSet.getParameter<double>(
"etaMax"),
16 pSet.getParameter<double>(
"ptRecJetMin"),
17 pSet.getParameter<double>(
"ptRecJetMax"),
20 pSet.getParameter<double>(
"ratioMin"),
21 pSet.getParameter<double>(
"ratioMax"),
22 pSet.getParameter<
bool>(
"doJetID")),
23 etaRanges(pSet.getParameter<vector<double>>(
"etaRanges")),
24 ptRanges(pSet.getParameter<vector<double>>(
"ptRanges")),
25 useOldFlavourTool(pSet.getParameter<
bool>(
"useOldFlavourTool")),
26 doJEC(pSet.getParameter<
bool>(
"doJEC")),
27 ptHatWeight(pSet.getParameter<
bool>(
"applyPtHatWeight")),
28 moduleConfig(pSet.getParameter<vector<
edm::
ParameterSet>>(
"tagConfig")),
29 flavPlots_(pSet.getParameter<
std::
string>(
"flavPlots")),
45 double ptRecJetMin = pSet.
getParameter<
double>(
"ptRecJetMin");
47 switch (pSet.
getParameter<
unsigned int>(
"leptonPlots")) {
76 mayConsume<edm::Association<reco::GenJetCollection>>(pSet.
getParameter<
InputTag>(
"genJetsMatched"));
85 const string &dataFormatType = iModule->exists(
"type") ? iModule->getParameter<
string>(
"type") :
"JetTag";
86 if (dataFormatType ==
"JetTag") {
90 jetTagToken.push_back(consumes<JetTagCollection>(moduleLabel));
91 }
else if (dataFormatType ==
"TagCorrelation") {
98 consumes<JetTagCollection>(label1), consumes<JetTagCollection>(label2)));
100 vector<edm::InputTag> vIP;
103 std::vector<edm::EDGetTokenT<edm::View<reco::BaseTagInfo>>> tokens;
104 if (dataFormatType ==
"GenericMVA") {
105 const std::vector<InputTag> listInfo = iModule->getParameter<vector<InputTag>>(
"listTagInfos");
106 for (
unsigned int ITi = 0; ITi < listInfo.size(); ITi++) {
108 vIP.push_back(listInfo[ITi]);
113 vIP.push_back(moduleLabel);
129 const int iEtaStart = -1;
132 const int iPtStart = -1;
144 const string &dataFormatType = iModule->exists(
"type") ? iModule->getParameter<
string>(
"type") :
"JetTag";
145 if (dataFormatType ==
"JetTag") {
147 const string &folderName = iModule->getParameter<
string>(
"folder");
149 bool doDifferentialPlots =
false;
150 double discrCut = -999.;
151 if (iModule->exists(
"differentialPlots") && iModule->getParameter<
bool>(
"differentialPlots") ==
true) {
152 doDifferentialPlots =
true;
153 discrCut = iModule->getParameter<
double>(
"discrCut");
157 for (
int iEta = iEtaStart; iEta < iEtaEnd; iEta++) {
159 for (
int iPt = iPtStart; iPt < iPtEnd; iPt++) {
164 std::make_unique<JetTagPlotter>(folderName,
175 }
else if (dataFormatType ==
"TagCorrelation") {
181 for (
int iEta = iEtaStart; iEta != iEtaEnd; ++iEta) {
183 for (
int iPt = iPtStart; iPt != iPtEnd; ++iPt) {
187 std::make_unique<TagCorrelationPlotter>(label1.
label(),
201 const string &folderName = iModule->getParameter<
string>(
"folder");
203 for (
int iEta = iEtaStart; iEta < iEtaEnd; iEta++) {
205 for (
int iPt = iPtStart; iPt < iPtEnd; iPt++) {
226 bool etaActive_, ptActive_;
227 double etaMin_, etaMax_, ptMin_, ptMax_;
248 return EtaPtBin(etaActive_, etaMin_, etaMax_, ptActive_, ptMin_, ptMax_);
265 weight = weight *
static_cast<float>(genInfoHandle->
weight());
277 for (JetFlavourInfoMatchingCollection::const_iterator iter = jetMC->
begin(); iter != jetMC->
end(); ++iter) {
278 unsigned int fl =
std::abs(iter->second.getPartonFlavour());
279 flavours.insert(std::make_pair(iter->first, fl));
282 for (
unsigned int i = 0;
i < lep.
size();
i++) {
290 leptons.insert(std::make_pair(iter->first, lepCount));
295 for (JetFlavourMatchingCollection::const_iterator iter = jetMC->
begin(); iter != jetMC->
end(); ++iter) {
296 unsigned int fl =
std::abs(iter->second.getFlavour());
297 flavours.insert(std::make_pair(iter->first, fl));
299 leptons.insert(std::make_pair(iter->first, lep));
321 corrector = corrHandle.
product();
326 for (
unsigned int iJetLabel = 0; iJetLabel !=
jetTagInputTags.size(); ++iJetLabel) {
337 if (flavours[tagI->first] == 5 &&
339 (
tauPlots && !leptons[tagI->first].tau)))
350 if (!
getJetWithFlavour(iEvent, tagI->first, flavours, jetWithFlavour, corrector, genJetsMatched))
352 if (!
jetSelector(jetWithFlavour.first,
std::abs(jetWithFlavour.second.getPartonFlavour()), infoHandle, jec))
355 for (
int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
357 inBin =
binJetTagPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(jetWithFlavour.first, jec);
361 jetWithFlavour.first, jec, tagI->second,
std::abs(jetWithFlavour.second.getPartonFlavour()), weight);
364 for (
int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
374 iEvent.
getByToken(inputTokens.first, tagHandle1);
378 iEvent.
getByToken(inputTokens.second, tagHandle2);
383 if (flavours[tagI->first] == 5 &&
385 (
tauPlots && !leptons[tagI->first].tau)))
397 if (!
getJetWithFlavour(iEvent, tagI->first, flavours, jetWithFlavour, corrector, genJetsMatched))
399 if (!
jetSelector(jetWithFlavour.first,
std::abs(jetWithFlavour.second.getPartonFlavour()), infoHandle, jec))
402 for (
int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
407 double discr2 = tagColl2[tagI->first];
409 tagI->second, discr2,
std::abs(jetWithFlavour.second.getPartonFlavour()), weight);
417 for (
unsigned int iJetLabel = 0; iJetLabel !=
tiDataFormatType.size(); ++iJetLabel) {
419 for (
int iPlotter = 0; iPlotter != plotterSize; ++iPlotter)
422 vector<edm::EDGetTokenT<edm::View<reco::BaseTagInfo>>> &tokens =
tagInfoToken[iJetLabel];
426 labels.push_back(
"label");
427 if (labels.size() != tokens.size())
429 <<
"Different number of Tag Infos than expected" << labels.size() << tokens.size() << endl;
431 unsigned int nInputTags = tokens.size();
432 vector<edm::Handle<View<BaseTagInfo>>> tagInfoHandles(nInputTags);
434 unsigned int nTagInfos = 0;
435 for (
unsigned int iInputTags = 0; iInputTags < tokens.size(); ++iInputTags) {
437 iEvent.
getByToken(tokens[iInputTags], tagInfoHandle);
438 if (tagInfoHandle.
isValid() ==
false) {
440 <<
" Collection " <<
tagInfoInputTags[iJetLabel][iInputTags] <<
" not present. Skipping it for this event.";
444 unsigned int size = tagInfoHandle->size();
447 if (iInputTags == 0) {
448 jetProductID = thisProductID;
450 }
else if (jetProductID != thisProductID)
451 throw cms::Exception(
"Configuration") <<
"TagInfos are referencing a different jet collection." << endl;
452 else if (nTagInfos != size)
453 throw cms::Exception(
"Configuration") <<
"TagInfo collections are having a different size." << endl;
456 for (
unsigned int iTagInfos = 0; iTagInfos < nTagInfos; ++iTagInfos) {
457 vector<const BaseTagInfo *> baseTagInfos(nInputTags);
459 for (
unsigned int iTagInfo = 0; iTagInfo < nInputTags; iTagInfo++) {
460 const BaseTagInfo &baseTagInfo = (*tagInfoHandles[iTagInfo])[iTagInfos];
462 jetRef = baseTagInfo.
jet();
463 else if (baseTagInfo.
jet() != jetRef)
464 throw cms::Exception(
"Configuration") <<
"TagInfos pointing to different jets." << endl;
465 baseTagInfos[iTagInfo] = &baseTagInfo;
484 if (!
getJetWithFlavour(iEvent, jetRef, flavours, jetWithFlavour, corrector, genJetsMatched))
486 if (!
jetSelector(jetWithFlavour.first,
std::abs(jetWithFlavour.second.getPartonFlavour()), infoHandle, jec))
489 for (
int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
495 baseTagInfos, jec,
std::abs(jetWithFlavour.second.getPartonFlavour()), weight);
518 edm::ProductID refProdId = (flavours.begin() == flavours.end()) ? recProdId : flavours.begin()->first.
id();
522 if (recProdId != refProdId) {
524 for (FlavourMap::const_iterator iter = flavours.begin(); iter != flavours.end(); ++iter)
528 for (
unsigned int i = 0;
i < recJetsProd->
size();
i++)
535 if (recProdId != refProdId) {
544 auto itFound = flavours.find(jetRef);
545 unsigned int flavour = itFound != flavours.end() ? itFound->second : 0;
555 LogTrace(
"Info") <<
"Found jet with flavour " << jetWithFlavour.second.getPartonFlavour() << endl;
556 LogTrace(
"Info") << jetWithFlavour.first.p() <<
" , " << jetWithFlavour.first.pt() <<
" - " << endl;
T getParameter(std::string const &) const
bool isNonnull() const
Checks for non-null.
transient_vector_type::const_iterator const_iterator
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void setThreshold(const double &energy)
const_iterator end() const
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
#define DEFINE_FWK_MODULE(type)
Class storing the jet flavour information.
Abs< T >::type abs(const T &t)
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.
std::unique_ptr< BaseTagInfoPlotter > buildPlotter(const std::string &dataFormatType, const std::string &tagName, const EtaPtBin &etaPtBin, const edm::ParameterSet &pSet, const std::string &folderName, unsigned int mc, bool wf, DQMStore::IBooker &ibook)
const_iterator begin() const