13 pSet.getParameter<double>(
"etaMin"),
14 pSet.getParameter<double>(
"etaMax"),
15 pSet.getParameter<double>(
"ptRecJetMin"),
16 pSet.getParameter<double>(
"ptRecJetMax"),
18 pSet.getParameter<double>(
"ratioMin"),
19 pSet.getParameter<double>(
"ratioMax"),
20 pSet.getParameter<
bool>(
"doJetID" )
22 etaRanges(pSet.getParameter< vector<double> >(
"etaRanges")),
23 ptRanges(pSet.getParameter< vector<double> >(
"ptRanges")),
24 doJEC(pSet.getParameter<
bool>(
"doJEC" )),
25 moduleConfig(pSet.getParameter< vector<
edm::
ParameterSet> >(
"tagConfig"))
37 for (vector<edm::ParameterSet>::const_iterator iModule =
moduleConfig.begin();
40 const string& dataFormatType = iModule->exists(
"type") ?
41 iModule->getParameter<
string>(
"type") :
43 if (dataFormatType ==
"JetTag") {
47 jetTagToken.push_back(consumes<JetTagCollection>(moduleLabel));
49 else if(dataFormatType ==
"TagCorrelation") {
57 vector<edm::InputTag> vIP;
60 std::vector< edm::EDGetTokenT<edm::View<reco::BaseTagInfo>> > tokens;
61 if(dataFormatType ==
"GenericMVA") {
62 const std::vector<InputTag> listInfo = iModule->getParameter<vector<InputTag>>(
"listTagInfos");
63 for(
unsigned int ITi=0; ITi<listInfo.size(); ITi++) {
65 vIP.push_back(listInfo[ITi]);
71 vIP.push_back(moduleLabel);
84 const int iEtaStart = -1 ;
86 const int iPtStart = -1 ;
91 int iTag = -1;
int iTagCorr = -1;
int iInfoTag = -1;
92 for (vector<edm::ParameterSet>::const_iterator iModule =
moduleConfig.begin();
95 const string& dataFormatType = iModule->exists(
"type") ?
96 iModule->getParameter<
string>(
"type") :
98 if (dataFormatType ==
"JetTag") {
100 const string& folderName = iModule->getParameter<
string>(
"folder");
102 bool doDifferentialPlots =
false;
103 double discrCut = -999.;
104 if (iModule->exists(
"differentialPlots") && iModule->getParameter<
bool>(
"differentialPlots") ==
true) {
105 doDifferentialPlots =
true;
106 discrCut = iModule->getParameter<
double>(
"discrCut");
110 for (
int iEta = iEtaStart ; iEta < iEtaEnd ; ++iEta) {
112 for (
int iPt = iPtStart ; iPt < iPtEnd ; ++iPt) {
117 binJetTagPlotters.at(iTag).push_back(std::make_unique<JetTagPlotter>(folderName, etaPtBin, iModule->getParameter<
edm::ParameterSet>(
"parameters"), 0,
false, ibook,
false, doDifferentialPlots, discrCut));
122 }
else if (dataFormatType ==
"TagCorrelation") {
128 for (
int iEta = iEtaStart ; iEta != iEtaEnd ; ++iEta) {
130 for(
int iPt = iPtStart ; iPt != iPtEnd ; ++iPt) {
134 std::make_unique<TagCorrelationPlotter>(label1.
label(), label2.label(), etaPtBin,
136 0,
false,
false, ibook)
144 const string& folderName = iModule->getParameter<
string>(
"folder");
147 for (
int iEta = iEtaStart ; iEta < iEtaEnd ; ++iEta) {
149 for (
int iPt = iPtStart ; iPt < iPtEnd ; ++iPt) {
166 bool etaActive_ , ptActive_;
167 double etaMin_, etaMax_, ptMin_, ptMax_;
190 return EtaPtBin(etaActive_, etaMin_, etaMax_, ptActive_, ptMin_ , ptMax_);
229 corrector = corrHandle.
product();
234 for (
unsigned int iJetLabel = 0; iJetLabel !=
jetTagInputTags.size(); ++iJetLabel) {
254 if(
doJEC && corrector) {
258 if (!
jetSelector(*(tagI->first), -1, infoHandle, jec))
261 for (
int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
262 bool inBin =
binJetTagPlotters[iJetLabel][iPlotter]->etaPtBin().inBin(*tagI->first, jec);
268 for (
int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
277 iEvent.
getByToken(inputTokens.first, tagHandle1);
281 iEvent.
getByToken(inputTokens.second, tagHandle2);
288 if(
doJEC && corrector) {
292 if (!
jetSelector(*(tagI->first), -1, infoHandle, jec))
295 for(
int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
300 double discr2 = tagColl2[tagI->first];
308 for (
unsigned int iJetLabel = 0; iJetLabel !=
tiDataFormatType.size(); ++iJetLabel) {
310 for (
int iPlotter = 0; iPlotter != plotterSize; ++iPlotter)
313 vector<edm::EDGetTokenT<edm::View<reco::BaseTagInfo>> > & tokens =
tagInfoToken[iJetLabel];
317 labels.push_back(
"label");
318 if (labels.size() != tokens.size())
throw cms::Exception(
"Configuration") <<
"Different number of Tag Infos than expected" << labels.size() << tokens.size() << endl;
320 unsigned int nInputTags = tokens.size();
321 vector< edm::Handle< View<BaseTagInfo> > > tagInfoHandles(nInputTags);
323 unsigned int nTagInfos = 0;
324 for (
unsigned int iInputTags = 0; iInputTags < tokens.size(); ++iInputTags) {
326 iEvent.
getByToken(tokens[iInputTags], tagInfoHandle);
330 if (tagInfoHandle.
isValid() ==
false) {
331 edm::LogWarning(
"BTagPerformanceAnalyzerOnData")<<
" Collection "<<
tagInfoInputTags[iJetLabel][iInputTags]<<
" not present. Skipping it for this event.";
335 unsigned int size = tagInfoHandle->size();
338 if (iInputTags == 0) {
339 jetProductID = thisProductID;
341 }
else if (jetProductID != thisProductID)
342 throw cms::Exception(
"Configuration") <<
"TagInfos are referencing a different jet collection." << endl;
343 else if (nTagInfos != size)
344 throw cms::Exception(
"Configuration") <<
"TagInfo collections are having a different size." << endl;
347 for (
unsigned int iTagInfos = 0; iTagInfos < nTagInfos; ++iTagInfos) {
348 vector<const BaseTagInfo*> baseTagInfos(nInputTags);
350 for (
unsigned int iTagInfo = 0; iTagInfo < nInputTags; iTagInfo++) {
351 const BaseTagInfo &baseTagInfo = (*tagInfoHandles[iTagInfo])[iTagInfos];
353 jetRef = baseTagInfo.
jet();
354 else if (baseTagInfo.
jet() != jetRef)
355 throw cms::Exception(
"Configuration") <<
"TagInfos pointing to different jets." << endl;
356 baseTagInfos[iTagInfo] = &baseTagInfo;
361 if(
doJEC && corrector) {
368 for (
int iPlotter = 0; iPlotter != plotterSize; ++iPlotter) {
T getParameter(std::string const &) const
transient_vector_type::const_iterator const_iterator
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const_iterator end() const
double correction(const LorentzVector &fJet) const
get correction using Jet information only
virtual edm::RefToBase< Jet > jet(void) const
returns a polymorphic reference to the tagged jet
#define DEFINE_FWK_MODULE(type)
T const * product() const
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