Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-05-23 00:28:13

0001 #include "DQMServices/Core/interface/DQMStore.h"
0002 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0003 #include "FWCore/Utilities/interface/EDGetToken.h"
0004 #include "FWCore/Framework/interface/Frameworkfwd.h"
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "FWCore/Framework/interface/MakerMacros.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/ServiceRegistry/interface/Service.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0010 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0011 #include "FWCore/ParameterSet/interface/Registry.h"
0012 #include "FWCore/Utilities/interface/transform.h"
0013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0014 #include "CommonTools/Utils/interface/StringCutObjectSelector.h"
0015 #include "CommonTools/TriggerUtils/interface/GenericTriggerEventFlag.h"
0016 #include "DataFormats/Math/interface/deltaR.h"
0017 #include "DataFormats/Common/interface/ValueMap.h"
0018 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0019 #include "DataFormats/MuonReco/interface/Muon.h"
0020 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0021 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
0022 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
0023 #include "DataFormats/EgammaCandidates/interface/Photon.h"
0024 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
0025 #include "DataFormats/JetReco/interface/PFJet.h"
0026 #include "DataFormats/JetReco/interface/PFJetCollection.h"
0027 #include "DataFormats/BTauReco/interface/JetTag.h"
0028 #include "DataFormats/METReco/interface/PFMET.h"
0029 #include "DataFormats/METReco/interface/PFMETCollection.h"
0030 #include "DQMOffline/Trigger/plugins/TriggerDQMBase.h"
0031 
0032 //Tagging variables
0033 #include "DataFormats/BTauReco/interface/ShallowTagInfo.h"
0034 
0035 #include <string>
0036 #include <vector>
0037 #include <memory>
0038 #include <map>
0039 
0040 class BTagAndProbe : public DQMEDAnalyzer, public TriggerDQMBase {
0041 public:
0042   typedef dqm::reco::MonitorElement MonitorElement;
0043   typedef dqm::reco::DQMStore DQMStore;
0044 
0045   BTagAndProbe(const edm::ParameterSet&);
0046   ~BTagAndProbe() throw() override;
0047   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0048 
0049 protected:
0050   void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
0051   void analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) override;
0052 
0053   struct JetRefCompare {
0054     inline bool operator()(const edm::RefToBase<reco::Jet>& j1, const edm::RefToBase<reco::Jet>& j2) const {
0055       return (j1.id() < j2.id()) || ((j1.id() == j2.id()) && (j1.key() < j2.key()));
0056     }
0057   };
0058   typedef std::map<edm::RefToBase<reco::Jet>, float, JetRefCompare> JetTagMap;
0059 
0060 private:
0061   const std::string folderName_;
0062 
0063   const bool requireValidHLTPaths_;
0064   bool hltPathsAreValid_;
0065 
0066   const edm::EDGetTokenT<reco::VertexCollection> vtxToken_;
0067   const edm::EDGetTokenT<reco::MuonCollection> muoToken_;
0068   const edm::EDGetTokenT<edm::View<reco::GsfElectron> > eleToken_;
0069   const edm::EDGetTokenT<edm::ValueMap<bool> > elecIDToken_;
0070   const std::vector<edm::EDGetTokenT<reco::JetTagCollection> > jetTagTokens_;
0071 
0072   //Tag info
0073   const edm::EDGetTokenT<std::vector<reco::ShallowTagInfo> > shallowTagInfosToken_;
0074   struct PVcut {
0075     double dxy;
0076     double dz;
0077 
0078     PVcut(double dxy_, double dz_) {
0079       dxy = dxy_;
0080       dz = dz_;
0081     }
0082   };
0083 
0084   // for the tag and probe
0085   MonitorElement* h_nElectrons1 = nullptr;
0086   MonitorElement* h_nElectrons2 = nullptr;
0087   MonitorElement* h_nElectrons3 = nullptr;
0088   MonitorElement* h_nElectrons4 = nullptr;
0089   MonitorElement* h_nElectrons5 = nullptr;
0090   MonitorElement* h_nElectrons6 = nullptr;
0091   MonitorElement* h_nElectrons7 = nullptr;
0092   MonitorElement* h_nElectrons8 = nullptr;
0093 
0094   MonitorElement* h_nMuons1 = nullptr;
0095   MonitorElement* h_nMuons2 = nullptr;
0096   MonitorElement* h_nMuons3 = nullptr;
0097   MonitorElement* h_nMuons4 = nullptr;
0098   MonitorElement* h_nMuons5 = nullptr;
0099   MonitorElement* h_nMuons6 = nullptr;
0100   MonitorElement* h_nMuons7 = nullptr;
0101 
0102   MonitorElement* h_nJets = nullptr;
0103   MonitorElement* h_btagVal = nullptr;
0104   MonitorElement* h_btagVal2 = nullptr;
0105   MonitorElement* h_btagVal_pp = nullptr;
0106   MonitorElement* h_btagVal_pf = nullptr;
0107   MonitorElement* h_btagVal_pa = nullptr;
0108 
0109   MonitorElement* h_nJets1 = nullptr;
0110   MonitorElement* h_nJets2 = nullptr;
0111   MonitorElement* h_nJets3 = nullptr;
0112   MonitorElement* h_nJets4 = nullptr;
0113   MonitorElement* h_nJets5 = nullptr;
0114   MonitorElement* h_nJets6 = nullptr;
0115   MonitorElement* h_nJets7 = nullptr;
0116   MonitorElement* h_nJets8 = nullptr;
0117   MonitorElement* h_nJets9 = nullptr;
0118   MonitorElement* h_nJets10 = nullptr;
0119   MonitorElement* h_nJets11 = nullptr;
0120   MonitorElement* h_nJets12 = nullptr;
0121 
0122   //muon pt
0123   MonitorElement* h_Muons1_pt = nullptr;
0124   MonitorElement* h_Muons2_pt = nullptr;
0125   MonitorElement* h_Muons3_pt = nullptr;
0126   MonitorElement* h_Muons4_pt = nullptr;
0127   MonitorElement* h_Muons5_pt = nullptr;
0128 
0129   //muon eta
0130   MonitorElement* h_Muons1_eta = nullptr;
0131   MonitorElement* h_Muons2_eta = nullptr;
0132   MonitorElement* h_Muons3_eta = nullptr;
0133   MonitorElement* h_Muons4_eta = nullptr;
0134   MonitorElement* h_Muons5_eta = nullptr;
0135 
0136   //electron pt
0137   MonitorElement* h_Electrons1_pt = nullptr;
0138   MonitorElement* h_Electrons2_pt = nullptr;
0139   MonitorElement* h_Electrons3_pt = nullptr;
0140   MonitorElement* h_Electrons4_pt = nullptr;
0141 
0142   //electron eta
0143   MonitorElement* h_Electrons1_eta = nullptr;
0144   MonitorElement* h_Electrons2_eta = nullptr;
0145   MonitorElement* h_Electrons3_eta = nullptr;
0146   MonitorElement* h_Electrons4_eta = nullptr;
0147 
0148   MonitorElement* cutFlow = nullptr;
0149 
0150   // new for tnp
0151   ObjME jetNSecondaryVertices_;
0152   ObjME jet_tagVal_;
0153   ObjME jet_pt_;
0154   ObjME jet_eta_;
0155   ObjME trackSumJetEtRatio_;
0156   ObjME trackSip2dValAboveCharm_;
0157   ObjME trackSip2dSigAboveCharm_;
0158   ObjME trackSip3dValAboveCharm_;
0159   ObjME trackSip3dSigAboveCharm_;
0160   ObjME jetNTracksEtaRel_;
0161   ObjME jetNSelectedTracks_;
0162   ObjME vertexCategory_;
0163   ObjME trackSumJetDeltaR_;
0164 
0165   ObjME trackJetDistVal_;
0166   ObjME trackPtRel_;
0167   ObjME trackDeltaR_;
0168   ObjME trackPtRatio_;
0169   ObjME trackSip3dSig_;
0170   ObjME trackSip2dSig_;
0171   ObjME trackDecayLenVal_;
0172   ObjME trackEtaRel_;
0173 
0174   ObjME vertexMass_;
0175   ObjME vertexNTracks_;
0176   ObjME vertexEnergyRatio_;
0177   ObjME vertexJetDeltaR_;
0178   ObjME flightDistance2dVal_;
0179   ObjME flightDistance3dVal_;
0180   ObjME flightDistance2dSig_;
0181   ObjME flightDistance3dSig_;
0182 
0183   std::unique_ptr<GenericTriggerEventFlag> genTriggerEventFlag_;
0184 
0185   StringCutObjectSelector<reco::PFJet, true> jetSelection_;
0186   StringCutObjectSelector<reco::GsfElectron, true> eleSelection_;
0187   StringCutObjectSelector<reco::Muon, true> muoSelection_;
0188 
0189   StringCutObjectSelector<reco::Vertex, true> vtxSelection_;
0190 
0191   StringCutObjectSelector<reco::Jet, true> bjetSelection_;
0192 
0193   const unsigned int nelectrons_;
0194   const unsigned int nmuons_;
0195   const double leptJetDeltaRmin_;
0196   const double bJetDeltaEtaMax_;
0197   const unsigned int nbjets_;
0198   const double workingpoint_;
0199   const std::string btagalgoName_;
0200   const PVcut lepPVcuts_;
0201   const bool applyLeptonPVcuts_;
0202   const bool debug_;
0203 
0204   const bool applyMETcut_ = false;
0205 };
0206 
0207 BTagAndProbe::BTagAndProbe(const edm::ParameterSet& iConfig)
0208     : folderName_(iConfig.getParameter<std::string>("FolderName")),
0209       requireValidHLTPaths_(iConfig.getParameter<bool>("requireValidHLTPaths")),
0210       hltPathsAreValid_(false),
0211       vtxToken_(mayConsume<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertices"))),
0212       muoToken_(mayConsume<reco::MuonCollection>(iConfig.getParameter<edm::InputTag>("muons"))),
0213       eleToken_(mayConsume<edm::View<reco::GsfElectron> >(iConfig.getParameter<edm::InputTag>("electrons"))),
0214       elecIDToken_(consumes<edm::ValueMap<bool> >(iConfig.getParameter<edm::InputTag>("elecID"))),
0215       jetTagTokens_(
0216           edm::vector_transform(iConfig.getParameter<std::vector<edm::InputTag> >("btagAlgos"),
0217                                 [this](edm::InputTag const& tag) { return mayConsume<reco::JetTagCollection>(tag); })),
0218       shallowTagInfosToken_(
0219           consumes<std::vector<reco::ShallowTagInfo> >(edm::InputTag("hltDeepCombinedSecondaryVertexBJetTagsInfos"))),
0220       genTriggerEventFlag_(new GenericTriggerEventFlag(
0221           iConfig.getParameter<edm::ParameterSet>("genericTriggerEventPSet"), consumesCollector(), *this)),
0222       jetSelection_(iConfig.getParameter<std::string>("jetSelection")),
0223       eleSelection_(iConfig.getParameter<std::string>("eleSelection")),
0224       muoSelection_(iConfig.getParameter<std::string>("muoSelection")),
0225       vtxSelection_(iConfig.getParameter<std::string>("vertexSelection")),
0226       bjetSelection_(iConfig.getParameter<std::string>("bjetSelection")),
0227       nelectrons_(iConfig.getParameter<unsigned int>("nelectrons")),
0228       nmuons_(iConfig.getParameter<unsigned int>("nmuons")),
0229       leptJetDeltaRmin_(iConfig.getParameter<double>("leptJetDeltaRmin")),
0230       bJetDeltaEtaMax_(iConfig.getParameter<double>("bJetDeltaEtaMax")),
0231       nbjets_(iConfig.getParameter<unsigned int>("nbjets")),
0232       workingpoint_(iConfig.getParameter<double>("workingpoint")),
0233       lepPVcuts_(((iConfig.getParameter<edm::ParameterSet>("leptonPVcuts")).getParameter<double>("dxy")),
0234                  ((iConfig.getParameter<edm::ParameterSet>("leptonPVcuts")).getParameter<double>("dz"))),
0235       applyLeptonPVcuts_(iConfig.getParameter<bool>("applyLeptonPVcuts")),
0236       debug_(iConfig.getParameter<bool>("debug")) {
0237   ObjME empty;
0238 }
0239 
0240 BTagAndProbe::~BTagAndProbe() throw() {
0241   if (genTriggerEventFlag_)
0242     genTriggerEventFlag_.reset();
0243 }
0244 
0245 void BTagAndProbe::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) {
0246   std::string histname, histtitle;
0247   std::string title;
0248   std::string currentFolder = folderName_;
0249   ibooker.setCurrentFolder(currentFolder);
0250 
0251   histname = "cutFlow";
0252   title = "cutFlow";
0253   cutFlow = ibooker.book1D(histname.c_str(), title.c_str(), 20, 1, 21);
0254   cutFlow->setBinLabel(1, "all");
0255 
0256   // Initialize the GenericTriggerEventFlag
0257   if (genTriggerEventFlag_ && genTriggerEventFlag_->on())
0258     genTriggerEventFlag_->initRun(iRun, iSetup);
0259 
0260   // check if every HLT path specified in numerator and denominator has a valid match in the HLT Menu
0261   hltPathsAreValid_ =
0262       (genTriggerEventFlag_ && genTriggerEventFlag_->on() && genTriggerEventFlag_->allHLTPathsAreValid());
0263 
0264   // if valid HLT paths are required,
0265   // create DQM outputs only if all paths are valid
0266   if (requireValidHLTPaths_ && (!hltPathsAreValid_)) {
0267     return;
0268   }
0269 
0270   if (debug_) {
0271     histname = "nElectrons1";
0272     title = "number of electrons1";
0273     h_nElectrons1 = ibooker.book1D(histname.c_str(), title.c_str(), 10, 0, 10);
0274 
0275     histname = "nElectrons2";
0276     title = "number of electrons2";
0277     h_nElectrons2 = ibooker.book1D(histname.c_str(), title.c_str(), 10, 0, 10);
0278 
0279     histname = "nElectrons3";
0280     title = "number of electrons3";
0281     h_nElectrons3 = ibooker.book1D(histname.c_str(), title.c_str(), 10, 0, 10);
0282 
0283     histname = "nElectrons4";
0284     title = "number of electrons4";
0285     h_nElectrons4 = ibooker.book1D(histname.c_str(), title.c_str(), 10, 0, 10);
0286 
0287     histname = "nElectrons5";
0288     title = "number of electrons5";
0289     h_nElectrons5 = ibooker.book1D(histname.c_str(), title.c_str(), 10, 0, 10);
0290 
0291     histname = "nElectrons6";
0292     title = "number of electrons6";
0293     h_nElectrons6 = ibooker.book1D(histname.c_str(), title.c_str(), 10, 0, 10);
0294 
0295     histname = "nElectrons7";
0296     title = "number of electrons7";
0297     h_nElectrons7 = ibooker.book1D(histname.c_str(), title.c_str(), 10, 0, 10);
0298 
0299     histname = "nElectrons8";
0300     title = "number of electrons8";
0301     h_nElectrons8 = ibooker.book1D(histname.c_str(), title.c_str(), 10, 0, 10);
0302 
0303     histname = "nMuons1";
0304     title = "number of muons1";
0305     h_nMuons1 = ibooker.book1D(histname.c_str(), title.c_str(), 10, 0, 10);
0306 
0307     histname = "nMuons2";
0308     title = "number of muons2";
0309     h_nMuons2 = ibooker.book1D(histname.c_str(), title.c_str(), 10, 0, 10);
0310 
0311     histname = "nMuons3";
0312     title = "number of muons3";
0313     h_nMuons3 = ibooker.book1D(histname.c_str(), title.c_str(), 10, 0, 10);
0314 
0315     histname = "nMuons4";
0316     title = "number of muons4";
0317     h_nMuons4 = ibooker.book1D(histname.c_str(), title.c_str(), 10, 0, 10);
0318 
0319     histname = "nMuons5";
0320     title = "number of muons5";
0321     h_nMuons5 = ibooker.book1D(histname.c_str(), title.c_str(), 10, 0, 10);
0322 
0323     histname = "nMuons6";
0324     title = "number of muons6";
0325     h_nMuons6 = ibooker.book1D(histname.c_str(), title.c_str(), 10, 0, 10);
0326 
0327     histname = "nMuons7";
0328     title = "number of muons7";
0329     h_nMuons7 = ibooker.book1D(histname.c_str(), title.c_str(), 10, 0, 10);
0330 
0331     //muon pt
0332     histname = "Muons1_pt";
0333     title = "muons1 pt";
0334     h_Muons1_pt = ibooker.book1D(histname.c_str(), title.c_str(), 50, 0, 100);
0335 
0336     histname = "Muons2_pt";
0337     title = "muons2 pt";
0338     h_Muons2_pt = ibooker.book1D(histname.c_str(), title.c_str(), 50, 0, 100);
0339 
0340     histname = "Muons3_pt";
0341     title = "muons3 pt";
0342     h_Muons3_pt = ibooker.book1D(histname.c_str(), title.c_str(), 50, 0, 100);
0343 
0344     histname = "Muons4_pt";
0345     title = "muons4 pt";
0346     h_Muons4_pt = ibooker.book1D(histname.c_str(), title.c_str(), 50, 0, 50);
0347 
0348     histname = "Muons5_pt";
0349     title = "muons5 pt";
0350     h_Muons5_pt = ibooker.book1D(histname.c_str(), title.c_str(), 50, 0, 50);
0351 
0352     //muon eta
0353     histname = "Muons1_eta";
0354     title = "muons1 eta";
0355     h_Muons1_eta = ibooker.book1D(histname.c_str(), title.c_str(), 10, -5, 5);
0356 
0357     histname = "Muons2_eta";
0358     title = "muons2 eta";
0359     h_Muons2_eta = ibooker.book1D(histname.c_str(), title.c_str(), 10, -5, 5);
0360 
0361     histname = "Muons3_eta";
0362     title = "muons3 eta";
0363     h_Muons3_eta = ibooker.book1D(histname.c_str(), title.c_str(), 10, -5, 5);
0364 
0365     histname = "Muons4_eta";
0366     title = "muons4 eta";
0367     h_Muons4_eta = ibooker.book1D(histname.c_str(), title.c_str(), 10, -2.50, 2.50);
0368 
0369     histname = "Muons5_eta";
0370     title = "muons5 eta";
0371     h_Muons5_eta = ibooker.book1D(histname.c_str(), title.c_str(), 10, -2.50, 2.50);
0372 
0373     //electron pt
0374     histname = "Electrons1_pt";
0375     title = "electrons1 pt";
0376     h_Electrons1_pt = ibooker.book1D(histname.c_str(), title.c_str(), 50, 0, 100);
0377 
0378     histname = "Electrons2_pt";
0379     title = "Electrons2 pt";
0380     h_Electrons2_pt = ibooker.book1D(histname.c_str(), title.c_str(), 50, 0, 100);
0381 
0382     histname = "Electrons3_pt";
0383     title = "Electrons3 pt";
0384     h_Electrons3_pt = ibooker.book1D(histname.c_str(), title.c_str(), 50, 0, 100);
0385 
0386     histname = "Electrons4_pt";
0387     title = "Electrons4 pt";
0388     h_Electrons4_pt = ibooker.book1D(histname.c_str(), title.c_str(), 50, 0, 100);
0389 
0390     //electron eta
0391     histname = "Electrons1_eta";
0392     title = "Electrons1 eta";
0393     h_Electrons1_eta = ibooker.book1D(histname.c_str(), title.c_str(), 10, -2.50, 2.50);
0394 
0395     histname = "Electrons2_eta";
0396     title = "Electrons2 eta";
0397     h_Electrons2_eta = ibooker.book1D(histname.c_str(), title.c_str(), 10, -2.50, 2.50);
0398 
0399     histname = "Electrons3_eta";
0400     title = "Electrons3 eta";
0401     h_Electrons3_eta = ibooker.book1D(histname.c_str(), title.c_str(), 10, -2.50, 2.50);
0402 
0403     histname = "Electrons4_eta";
0404     title = "Electrons4 eta";
0405     h_Electrons4_eta = ibooker.book1D(histname.c_str(), title.c_str(), 10, -2.50, 2.50);
0406 
0407     //nJets
0408     histname = "nJets1";
0409     title = "number of jets1";
0410     h_nJets1 = ibooker.book1D(histname.c_str(), title.c_str(), 20, 0, 20);
0411 
0412     histname = "nJets2";
0413     title = "number of jets2";
0414     h_nJets2 = ibooker.book1D(histname.c_str(), title.c_str(), 20, 0, 20);
0415 
0416     histname = "nJets3";
0417     title = "number of jets3";
0418     h_nJets3 = ibooker.book1D(histname.c_str(), title.c_str(), 20, 0, 20);
0419 
0420     histname = "nJets4";
0421     title = "number of jets4";
0422     h_nJets4 = ibooker.book1D(histname.c_str(), title.c_str(), 20, 0, 20);
0423 
0424     histname = "nJets5";
0425     title = "number of jets5";
0426     h_nJets5 = ibooker.book1D(histname.c_str(), title.c_str(), 20, 0, 20);
0427 
0428     histname = "nJets6";
0429     title = "number of jets6";
0430     h_nJets6 = ibooker.book1D(histname.c_str(), title.c_str(), 20, 0, 20);
0431 
0432     histname = "nJets7";
0433     title = "number of jets7";
0434     h_nJets7 = ibooker.book1D(histname.c_str(), title.c_str(), 20, 0, 20);
0435 
0436     histname = "nJets8";
0437     title = "number of jets8";
0438     h_nJets8 = ibooker.book1D(histname.c_str(), title.c_str(), 20, 0, 20);
0439 
0440     histname = "nJets9";
0441     title = "number of jets9";
0442     h_nJets9 = ibooker.book1D(histname.c_str(), title.c_str(), 20, 0, 20);
0443 
0444     histname = "nJets10";
0445     title = "number of jets10";
0446     h_nJets10 = ibooker.book1D(histname.c_str(), title.c_str(), 20, 0, 20);
0447 
0448     histname = "nJets11";
0449     title = "number of jets11";
0450     h_nJets11 = ibooker.book1D(histname.c_str(), title.c_str(), 20, 0, 20);
0451 
0452     histname = "nJets12";
0453     title = "number of jets12";
0454     h_nJets12 = ibooker.book1D(histname.c_str(), title.c_str(), 20, 0, 20);
0455   }
0456 
0457   histname = "btagVal";
0458   title = "btagVal";
0459   h_btagVal = ibooker.book1D(histname.c_str(), title.c_str(), 10, 0, 1);
0460 
0461   histname = "btagVal2";
0462   title = "btagVal";
0463   h_btagVal2 = ibooker.book1D(histname.c_str(), title.c_str(), 10, 0, 1);
0464 
0465   histname = "btagVal_probe_pass";
0466   title = "btagVal";
0467   h_btagVal_pp = ibooker.book1D(histname.c_str(), title.c_str(), 10, 0, 1);
0468 
0469   histname = "btagVal_probe_fail";
0470   title = "btagVal";
0471   h_btagVal_pf = ibooker.book1D(histname.c_str(), title.c_str(), 10, 0, 1);
0472 
0473   histname = "btagVal_probe_all";
0474   title = "btagVal";
0475   h_btagVal_pa = ibooker.book1D(histname.c_str(), title.c_str(), 10, 0, 1);
0476 
0477   histname = "jetNSecondaryVertices";
0478   title = "jetNSecondaryVertices";
0479   bookME(ibooker, jetNSecondaryVertices_, histname, title, 10, -0.5, 9.5);
0480   setMETitle(jetNSecondaryVertices_, "jetNSecondaryVertices", "Entries");
0481 
0482   histname = "jet_bTagVal";
0483   title = "jet bTag Val";
0484   bookME(ibooker, jet_tagVal_, histname, title, 10, 0., 1.);
0485   setMETitle(jet_tagVal_, "jet bTag Val", "Entries");
0486 
0487   histname = "jet_pt";
0488   title = "jet p_{T}";
0489   bookME(ibooker, jet_pt_, histname, title, 100, -0.1, 400.);
0490   setMETitle(jet_pt_, "jet pt", "Entries");
0491 
0492   histname = "jet_eta";
0493   title = "jet #eta";
0494   bookME(ibooker, jet_eta_, histname, title, 20, -2.5, 2.5);
0495   setMETitle(jet_eta_, "#eta", "Entries");
0496 
0497   histname = "jetNSecondaryVertices";
0498   title = "jet NSecondary Vertices";
0499   bookME(ibooker, jetNSecondaryVertices_, histname, title, 10, -0.5, 9.5);
0500   setMETitle(jetNSecondaryVertices_, "N Secondary Vertices", "Entries");
0501 
0502   histname = "trackSumJetEtRatio";
0503   title = "trackSumJetEtRatio";
0504   bookME(ibooker, trackSumJetEtRatio_, histname, title, 100, -.1, 1.5);
0505   setMETitle(trackSumJetEtRatio_, "trackSumJetEtRatio", "Entries");
0506 
0507   histname = "trackSumJetDeltaR";
0508   title = "trackSumJetDeltaR";
0509   bookME(ibooker, trackSumJetDeltaR_, histname, title, 100, -0.1, 0.35);
0510   setMETitle(trackSumJetDeltaR_, "trackSumJetDeltaR", "Entries");
0511 
0512   histname = "vertexCategory";
0513   title = "vertexCategory";
0514   bookME(ibooker, vertexCategory_, histname, title, 4, -1.5, 2.5);
0515   setMETitle(vertexCategory_, "vertexCategory", "Entries");
0516 
0517   histname = "trackSip2dValAboveCharm";
0518   title = "trackSip2dValAboveCharm";
0519   bookME(ibooker, trackSip2dValAboveCharm_, histname, title, 100, -0.2, 0.2);
0520   setMETitle(trackSip2dValAboveCharm_, "trackSip2dValAboveCharm", "Entries");
0521 
0522   histname = "trackSip2dSigAboveCharm";
0523   title = "trackSip2dSigAboveCharm";
0524   bookME(ibooker, trackSip2dSigAboveCharm_, histname, title, 100, -50, 50);
0525   setMETitle(trackSip2dSigAboveCharm_, "trackSip2dSigAboveCharm", "Entries");
0526 
0527   histname = "trackSip3dValAboveCharm";
0528   title = "trackSip3dValAboveCharm";
0529   bookME(ibooker, trackSip3dValAboveCharm_, histname, title, 100, -0.2, 0.2);
0530   setMETitle(trackSip3dValAboveCharm_, "trackSip3dValAboveCharm", "Entries");
0531 
0532   histname = "trackSip3dSigAboveCharm";
0533   title = "trackSip3dSigAboveCharm";
0534   bookME(ibooker, trackSip3dSigAboveCharm_, histname, title, 100, -50, 50);
0535   setMETitle(trackSip3dSigAboveCharm_, "trackSip3dSigAboveCharm", "Entries");
0536 
0537   histname = "jetNSelectedTracks";
0538   title = "jetNSelectedTracks";
0539   bookME(ibooker, jetNSelectedTracks_, histname, title, 42, -1.5, 40.5);
0540   setMETitle(jetNSelectedTracks_, "jetNSelectedTracks", "Entries");
0541 
0542   histname = "jetNTracksEtaRel";
0543   title = "jetNTracksEtaRel";
0544   bookME(ibooker, jetNTracksEtaRel_, histname, title, 42, -1.5, 40.5);
0545   setMETitle(jetNTracksEtaRel_, "jetNTracksEtaRel", "Entries");
0546 
0547   histname = "trackJetDistVal";
0548   title = "trackJetDistVal";
0549   bookME(ibooker, trackJetDistVal_, histname, title, 100, -1, 0.01);
0550   setMETitle(trackJetDistVal_, "trackJetDistVal", "Entries");
0551 
0552   histname = "trackPtRel";
0553   title = "trackPtRel";
0554   bookME(ibooker, trackPtRel_, histname, title, 100, -0.1, 7);
0555   setMETitle(trackPtRel_, "trackPtRel", "Entries");
0556 
0557   histname = "trackDeltaR";
0558   title = "trackDeltaR";
0559   bookME(ibooker, trackDeltaR_, histname, title, 160, -0.05, 0.47);
0560   setMETitle(trackDeltaR_, "trackDeltaR", "Entries");
0561 
0562   histname = "trackPtRatio";
0563   title = "trackPtRatio";
0564   bookME(ibooker, trackPtRatio_, histname, title, 100, -0.01, 0.3);
0565   setMETitle(trackPtRatio_, "trackPtRatio", "Entries");
0566 
0567   histname = "trackSip3dSig";
0568   title = "trackSip3dSig";
0569   bookME(ibooker, trackSip3dSig_, histname, title, 40, -40, 40);
0570   setMETitle(trackSip3dSig_, "trackSip3dSig", "Entries");
0571 
0572   histname = "trackSip2dSig";
0573   title = "trackSip2dSig";
0574   bookME(ibooker, trackSip2dSig_, histname, title, 100, -50, 50.);
0575   setMETitle(trackSip2dSig_, "trackSip2dSig", "Entries");
0576 
0577   histname = "trackDecayLenVal";
0578   title = "trackDecayLenVal";
0579   bookME(ibooker, trackDecayLenVal_, histname, title, 100, -0.1, 22);
0580   setMETitle(trackDecayLenVal_, "trackDecayLenVal", "Entries");
0581 
0582   histname = "trackEtaRel";
0583   title = "trackEtaRel";
0584   bookME(ibooker, trackEtaRel_, histname, title, 31, -0.1, 30);
0585   setMETitle(trackEtaRel_, "trackEtaRel", "Entries");
0586 
0587   histname = "vertexMass";
0588   title = "vertexMass";
0589   bookME(ibooker, vertexMass_, histname, title, 20, 0, 10);
0590   setMETitle(vertexMass_, "vertexMass", "Entries");
0591 
0592   histname = "vertexNTracks";
0593   title = "vertexNTracks";
0594   bookME(ibooker, vertexNTracks_, histname, title, 20, -0.5, 19.5);
0595   setMETitle(vertexNTracks_, "vertexNTracks", "Entries");
0596 
0597   histname = "vertexEnergyRatio";
0598   title = "vertexEnergyRatio";
0599   bookME(ibooker, vertexEnergyRatio_, histname, title, 100, -0.1, 3);
0600   setMETitle(vertexEnergyRatio_, "vertexEnergyRatio", "Entries");
0601 
0602   histname = "vertexJetDeltaR";
0603   title = "vertexJetDeltaR";
0604   bookME(ibooker, vertexJetDeltaR_, histname, title, 100, -0.01, .4);
0605   setMETitle(vertexJetDeltaR_, "vertexJetDeltaR", "Entries");
0606 
0607   histname = "flightDistance2dVal";
0608   title = "flightDistance2dVal";
0609   bookME(ibooker, flightDistance2dVal_, histname, title, 100, -0.1, 5);
0610   setMETitle(flightDistance2dVal_, "flightDistance2dVal", "Entries");
0611 
0612   histname = "flightDistance2dSig";
0613   title = "flightDistance2dSig";
0614   bookME(ibooker, flightDistance2dSig_, histname, title, 100, -10, 150.);
0615   setMETitle(flightDistance2dSig_, "flightDistance2dSig", "Entries");
0616 
0617   histname = "flightDistance3dVal";
0618   title = "flightDistance3dVal";
0619   bookME(ibooker, flightDistance3dVal_, histname, title, 100, -0.1, 5);
0620   setMETitle(flightDistance3dVal_, "flightDistance3dVal", "Entries");
0621 
0622   histname = "flightDistance3dSig";
0623   title = "flightDistance3dSig";
0624   bookME(ibooker, flightDistance3dSig_, histname, title, 100, -10, 150.);
0625   setMETitle(flightDistance3dSig_, "flightDistance3dSig", "Entries");
0626 }
0627 
0628 void BTagAndProbe::analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) {
0629   //vector definitions
0630   std::vector<reco::GsfElectron> electrons;
0631   std::vector<reco::Muon> muons;
0632 
0633   //clear vectors
0634   electrons.clear();
0635   muons.clear();
0636 
0637   //jets map definition
0638   // map of Jet,btagValues (for all jets passing bJetSelection_)
0639   //  - btagValue of each jet is calculated as sum of values from InputTags in jetTagTokens_
0640   JetTagMap allJetBTagVals;
0641 
0642   JetTagMap bjets;
0643 
0644   allJetBTagVals.clear();
0645   bjets.clear();
0646 
0647   int cutFlowStatus = 1;
0648   cutFlow->Fill(cutFlowStatus);
0649 
0650   cutFlowStatus++;
0651   cutFlow->setBinLabel(cutFlowStatus, "allValid");
0652   // if valid HLT paths are required,
0653   // analyze event only if all paths are valid
0654   if (requireValidHLTPaths_ && (!hltPathsAreValid_))
0655     return;
0656 
0657   // electron Handle valid
0658   edm::Handle<edm::View<reco::GsfElectron> > eleHandle;
0659   iEvent.getByToken(eleToken_, eleHandle);
0660   if (!eleHandle.isValid() && nelectrons_ > 0) {
0661     edm::LogWarning("BTagAndProbe") << "Electron handle not valid \n";
0662     return;
0663   }
0664 
0665   //electron ID Handle valid
0666   edm::Handle<edm::ValueMap<bool> > eleIDHandle;
0667   iEvent.getByToken(elecIDToken_, eleIDHandle);
0668   if (!eleIDHandle.isValid() && nelectrons_ > 0) {
0669     edm::LogWarning("BTagAndProbe") << "Electron ID handle not valid \n";
0670     return;
0671   }
0672 
0673   //muon handle valid
0674   edm::Handle<reco::MuonCollection> muoHandle;
0675   iEvent.getByToken(muoToken_, muoHandle);
0676   if (!muoHandle.isValid() && nmuons_ > 0) {
0677     edm::LogWarning("BTagAndProbe") << "Muon handle not valid \n";
0678     return;
0679   }
0680 
0681   for (const auto& jetTagToken : jetTagTokens_) {
0682     edm::Handle<reco::JetTagCollection> bjetHandle;
0683     iEvent.getByToken(jetTagToken, bjetHandle);
0684     if (!bjetHandle.isValid() && nbjets_ > 0) {
0685       edm::LogWarning("BTagAndProbe") << "B-Jet handle not valid, will skip event \n";
0686       return;
0687     }
0688   }
0689 
0690   //tag info
0691   edm::Handle<std::vector<reco::ShallowTagInfo> > shallowTagInfos;
0692   iEvent.getByToken(shallowTagInfosToken_, shallowTagInfos);
0693   if (!shallowTagInfos.isValid()) {
0694     edm::LogWarning("BTagAndProbe") << "shallow tag handle not valid, will skip event \n";
0695     return;
0696   }
0697 
0698   cutFlow->Fill(cutFlowStatus);
0699 
0700   // Filter out events if Trigger Filtering is requested
0701   if (genTriggerEventFlag_->on() && !genTriggerEventFlag_->accept(iEvent, iSetup))
0702     return;
0703   cutFlowStatus++;
0704   cutFlow->setBinLabel(cutFlowStatus, "passTrigger");
0705   cutFlow->Fill(cutFlowStatus);
0706 
0707   edm::Handle<reco::VertexCollection> primaryVertices;
0708   iEvent.getByToken(vtxToken_, primaryVertices);
0709   //Primary Vertex selection
0710   const reco::Vertex* pv = nullptr;
0711   for (auto const& v : *primaryVertices) {
0712     if (!vtxSelection_(v))
0713       continue;
0714     pv = &v;
0715     break;
0716   }
0717 
0718   cutFlowStatus++;
0719   cutFlow->setBinLabel(cutFlowStatus, "LeptonPVcuts");
0720   if (applyLeptonPVcuts_ && (pv == nullptr)) {
0721     edm::LogWarning("BTagAndProbe") << "Invalid handle to reco::VertexCollection, event will be skipped";
0722     return;
0723   }
0724   cutFlow->Fill(cutFlowStatus);
0725 
0726   unsigned int nElectrons = 0;
0727   if (nelectrons_ > 0) {
0728     if (debug_) {
0729       h_nElectrons1->Fill(eleHandle->size());
0730       h_nElectrons2->Fill(eleIDHandle->size());
0731     }
0732 
0733     for (size_t index = 0; index < eleHandle->size(); index++) {
0734       const auto e = eleHandle->at(index);
0735       const auto el = eleHandle->ptrAt(index);
0736 
0737       bool pass_id = (*eleIDHandle)[el];
0738 
0739       if (debug_) {
0740         h_Electrons1_pt->Fill(e.pt());
0741         h_Electrons1_eta->Fill(e.eta());
0742       }
0743 
0744       if (eleSelection_(e) && pass_id) {
0745         if (debug_) {
0746           h_Electrons2_pt->Fill(e.pt());
0747           h_Electrons2_eta->Fill(e.eta());
0748         }
0749 
0750         if (applyLeptonPVcuts_ && ((std::fabs(e.gsfTrack()->dxy(pv->position())) >= lepPVcuts_.dxy) ||
0751                                    (std::fabs(e.gsfTrack()->dz(pv->position())) >= lepPVcuts_.dz))) {
0752           continue;
0753         }
0754         electrons.push_back(e);
0755 
0756         if (debug_) {
0757           h_Electrons3_pt->Fill(e.pt());
0758           h_Electrons3_eta->Fill(e.eta());
0759         }
0760       }
0761     }
0762     nElectrons = electrons.size();
0763     if (debug_)
0764       h_nElectrons3->Fill(nElectrons);
0765   }
0766 
0767   if (debug_)
0768     h_nMuons1->Fill(muoHandle->size());
0769 
0770   unsigned int nMuons = 0;
0771   if (nmuons_ > 0) {  // need nmuons_ at least be '1'
0772     for (auto const& m : *muoHandle) {
0773       if (debug_) {
0774         h_Muons1_pt->Fill(m.pt());
0775         h_Muons1_eta->Fill(m.eta());
0776       }
0777       if (muoSelection_(m)) {
0778         if (debug_) {
0779           h_Muons2_pt->Fill(m.pt());
0780           h_Muons2_eta->Fill(m.eta());
0781         }
0782 
0783         if (applyLeptonPVcuts_ && ((std::fabs(m.muonBestTrack()->dxy(pv->position())) >= lepPVcuts_.dxy) ||
0784                                    (std::fabs(m.muonBestTrack()->dz(pv->position())) >= lepPVcuts_.dz))) {
0785           continue;
0786         }
0787         muons.push_back(m);
0788 
0789         if (debug_) {
0790           h_Muons3_pt->Fill(m.pt());
0791           h_Muons3_eta->Fill(m.eta());
0792         }
0793       }
0794     }
0795     if (debug_)
0796       h_nMuons2->Fill(muons.size());
0797 
0798     nMuons = muons.size();
0799     if (nMuons < nmuons_)
0800       return;
0801     if (debug_)
0802       h_nMuons3->Fill(nMuons);
0803   }
0804 
0805   int nbjets1 = 0;
0806   int nbjets2 = 0;
0807   int nbjets3 = 0;
0808 
0809   for (const auto& jetTagToken : jetTagTokens_) {
0810     edm::Handle<reco::JetTagCollection> bjetHandle;
0811     iEvent.getByToken(jetTagToken, bjetHandle);
0812 
0813     const reco::JetTagCollection& bTags = *(bjetHandle.product());
0814 
0815     for (const auto& i_jetTag : bTags) {
0816       const auto& jetRef = i_jetTag.first;  // where jet that is tagged exists
0817       nbjets1++;
0818       if (not bjetSelection_(*dynamic_cast<const reco::Jet*>(jetRef.get())))
0819         continue;
0820       nbjets2++;
0821       const auto btagVal = i_jetTag.second;  // bTagVal exists
0822       h_btagVal->Fill(btagVal);
0823 
0824       if (not std::isfinite(btagVal))
0825         continue;  // checks bTagVal exists
0826       nbjets3++;
0827       if (allJetBTagVals.find(jetRef) != allJetBTagVals.end()) {
0828         allJetBTagVals.at(jetRef) += btagVal;  // add bjet tagVal to map
0829       } else {
0830         allJetBTagVals.insert(JetTagMap::value_type(jetRef, btagVal));
0831       }
0832     }
0833   }
0834 
0835   if (debug_) {
0836     h_nJets1->Fill(nbjets1);
0837     h_nJets2->Fill(nbjets2);
0838     h_nJets3->Fill(nbjets3);
0839   }
0840 
0841   int nbjets4 = 0;
0842   int nbjets5 = 0;
0843   int nbjets6 = 0;
0844   for (const auto& jetBTagVal : allJetBTagVals) {
0845     bool isJetOverlappedWithLepton = false;
0846     nbjets4++;
0847     if (nmuons_ > 0) {
0848       for (auto const& m : muons) {
0849         if (deltaR2(*jetBTagVal.first, m) < leptJetDeltaRmin_ * leptJetDeltaRmin_) {
0850           isJetOverlappedWithLepton = true;
0851           break;
0852         }
0853         if (debug_) {
0854           h_Muons4_pt->Fill(m.pt());
0855           h_Muons4_eta->Fill(m.eta());
0856         }
0857       }
0858     }
0859     if (isJetOverlappedWithLepton)
0860       continue;
0861     nbjets5++;
0862 
0863     isJetOverlappedWithLepton = false;
0864     if (nelectrons_ > 0) {
0865       for (auto const& e : electrons) {
0866         if (deltaR2(*jetBTagVal.first, e) < leptJetDeltaRmin_ * leptJetDeltaRmin_) {
0867           isJetOverlappedWithLepton = true;
0868           break;
0869         }
0870       }
0871     }
0872     if (isJetOverlappedWithLepton)
0873       continue;
0874     nbjets6++;
0875 
0876     bjets.insert(JetTagMap::value_type(jetBTagVal.first, jetBTagVal.second));
0877   }
0878   if (debug_) {
0879     h_nJets4->Fill(nbjets4);
0880     h_nJets5->Fill(nbjets5);
0881     h_nJets6->Fill(nbjets6);
0882 
0883     h_nJets7->Fill(bjets.size());
0884     h_nElectrons4->Fill(nElectrons);
0885     h_nMuons4->Fill(nMuons);
0886 
0887     h_nJets8->Fill(bjets.size());
0888   }
0889 
0890   unsigned int nbJets = bjets.size();
0891 
0892   cutFlowStatus++;
0893   cutFlow->setBinLabel(cutFlowStatus, "PassJetDeltaEta");
0894   if (bjets.size() > 1) {
0895     double deltaEta = std::abs(bjets.begin()->first->eta() - (++bjets.begin())->first->eta());
0896     if (deltaEta > bJetDeltaEtaMax_)
0897       return;
0898   }
0899   cutFlow->Fill(cutFlowStatus);
0900   if (debug_)
0901     h_nJets9->Fill(bjets.size());
0902 
0903   // Event selection //
0904   if (debug_)
0905     h_nElectrons5->Fill(nElectrons);
0906   cutFlowStatus++;
0907   cutFlow->setBinLabel(cutFlowStatus, "reqNumElectrons " + std::to_string(nelectrons_));
0908   if (nElectrons < nelectrons_)
0909     return;
0910   cutFlow->Fill(cutFlowStatus);
0911   if (debug_) {
0912     h_nJets10->Fill(bjets.size());
0913     h_nElectrons6->Fill(nElectrons);
0914     h_nMuons5->Fill(nMuons);
0915   }
0916   cutFlowStatus++;
0917   cutFlow->setBinLabel(cutFlowStatus, "reqNumMuons " + std::to_string(nmuons_));
0918   if (nMuons < nmuons_)
0919     return;
0920   cutFlow->Fill(cutFlowStatus);
0921   if (debug_) {
0922     h_nJets11->Fill(bjets.size());
0923     h_nElectrons7->Fill(nElectrons);
0924     h_nMuons6->Fill(nMuons);
0925   }
0926   cutFlowStatus++;
0927   cutFlow->setBinLabel(cutFlowStatus, "twoOrMoreJets");
0928 
0929   if (nbJets < 2)
0930     return;
0931 
0932   cutFlow->Fill(cutFlowStatus);
0933   if (debug_)
0934     h_nJets12->Fill(nbJets);
0935 
0936   //loop electron, muon distributions
0937   if (debug_) {
0938     for (auto const& m : muons) {
0939       h_Muons5_pt->Fill(m.pt());
0940       h_Muons5_eta->Fill(m.eta());
0941     }
0942 
0943     for (auto const& e : electrons) {
0944       h_Electrons4_pt->Fill(e.pt());
0945       h_Electrons4_eta->Fill(e.eta());
0946     }
0947     h_nElectrons8->Fill(nElectrons);  //Fill electron counter
0948     h_nMuons7->Fill(nMuons);          //Fill muon counter
0949   }
0950 
0951   bool isProbe;
0952   bool passProbe;
0953   for (auto& jet1 : bjets) {
0954     isProbe = false;
0955     for (auto& jet2 : bjets) {
0956       if (deltaR2(*jet1.first, *jet2.first) < 0.3 * 0.3)
0957         continue;                          // check if same jet
0958       if (jet2.second >= workingpoint_) {  // check if passing btag
0959         isProbe = true;
0960         break;
0961       }
0962     }
0963 
0964     if (isProbe) {
0965       h_btagVal_pa->Fill(jet1.second);
0966       passProbe = false;
0967 
0968       if (jet1.second >= workingpoint_) {
0969         h_btagVal_pp->Fill(jet1.second);
0970         passProbe = true;
0971       } else
0972         h_btagVal_pf->Fill(jet1.second);
0973 
0974       for (const auto& shallowTagInfo : *shallowTagInfos) {
0975         const auto tagJet = shallowTagInfo.jet();
0976         const auto& tagVars = shallowTagInfo.taggingVariables();
0977 
0978         if (deltaR2(jet1.first->eta(), jet1.first->phi(), tagJet->eta(), tagJet->phi()) > 0.3 * 0.3)
0979           continue;
0980 
0981         jet_pt_.fill(passProbe, tagJet->pt());
0982         jet_eta_.fill(passProbe, tagJet->eta());
0983 
0984         for (const auto& tagVar : tagVars.getList(reco::btau::jetNSecondaryVertices, false)) {
0985           jetNSecondaryVertices_.fill(passProbe, tagVar);
0986         }
0987 
0988         for (const auto& tagVar : tagVars.getList(reco::btau::trackSumJetEtRatio, false)) {
0989           trackSumJetEtRatio_.fill(passProbe, tagVar);
0990         }
0991 
0992         for (const auto& tagVar : tagVars.getList(reco::btau::trackSumJetDeltaR, false)) {
0993           trackSumJetDeltaR_.fill(passProbe, tagVar);
0994         }
0995 
0996         for (const auto& tagVar : tagVars.getList(reco::btau::vertexCategory, false)) {
0997           vertexCategory_.fill(passProbe, tagVar);
0998         }
0999 
1000         for (const auto& tagVar : tagVars.getList(reco::btau::trackSip2dValAboveCharm, false)) {
1001           trackSip2dValAboveCharm_.fill(passProbe, tagVar);
1002         }
1003 
1004         for (const auto& tagVar : tagVars.getList(reco::btau::trackSip2dSigAboveCharm, false)) {
1005           trackSip2dSigAboveCharm_.fill(passProbe, tagVar);
1006         }
1007 
1008         for (const auto& tagVar : tagVars.getList(reco::btau::trackSip3dValAboveCharm, false)) {
1009           trackSip3dValAboveCharm_.fill(passProbe, tagVar);
1010         }
1011 
1012         for (const auto& tagVar : tagVars.getList(reco::btau::trackSip3dSigAboveCharm, false)) {
1013           trackSip3dSigAboveCharm_.fill(passProbe, tagVar);
1014         }
1015 
1016         for (const auto& tagVar : tagVars.getList(reco::btau::jetNSelectedTracks, false)) {
1017           jetNSelectedTracks_.fill(passProbe, tagVar);
1018         }
1019 
1020         for (const auto& tagVar : tagVars.getList(reco::btau::jetNTracksEtaRel, false)) {
1021           jetNTracksEtaRel_.fill(passProbe, tagVar);
1022         }
1023 
1024         for (const auto& tagVar : tagVars.getList(reco::btau::trackJetDistVal, false)) {
1025           trackJetDistVal_.fill(passProbe, tagVar);
1026         }
1027 
1028         for (const auto& tagVar : tagVars.getList(reco::btau::trackPtRel, false)) {
1029           trackPtRel_.fill(passProbe, tagVar);
1030         }
1031 
1032         for (const auto& tagVar : tagVars.getList(reco::btau::trackDeltaR, false)) {
1033           trackDeltaR_.fill(passProbe, tagVar);
1034         }
1035 
1036         for (const auto& tagVar : tagVars.getList(reco::btau::trackPtRatio, false)) {
1037           trackPtRatio_.fill(passProbe, tagVar);
1038         }
1039 
1040         for (const auto& tagVar : tagVars.getList(reco::btau::trackSip3dSig, false)) {
1041           trackSip3dSig_.fill(passProbe, tagVar);
1042         }
1043 
1044         for (const auto& tagVar : tagVars.getList(reco::btau::trackSip2dSig, false)) {
1045           trackSip2dSig_.fill(passProbe, tagVar);
1046         }
1047 
1048         for (const auto& tagVar : tagVars.getList(reco::btau::trackDecayLenVal, false)) {
1049           trackDecayLenVal_.fill(passProbe, tagVar);
1050         }
1051 
1052         for (const auto& tagVar : tagVars.getList(reco::btau::trackEtaRel, false)) {
1053           trackEtaRel_.fill(passProbe, tagVar);
1054         }
1055 
1056         for (const auto& tagVar : tagVars.getList(reco::btau::vertexMass, false)) {
1057           vertexMass_.fill(passProbe, tagVar);
1058         }
1059 
1060         for (const auto& tagVar : tagVars.getList(reco::btau::vertexNTracks, false)) {
1061           vertexNTracks_.fill(passProbe, tagVar);
1062         }
1063 
1064         for (const auto& tagVar : tagVars.getList(reco::btau::vertexEnergyRatio, false)) {
1065           vertexEnergyRatio_.fill(passProbe, tagVar);
1066         }
1067 
1068         for (const auto& tagVar : tagVars.getList(reco::btau::vertexJetDeltaR, false)) {
1069           vertexJetDeltaR_.fill(passProbe, tagVar);
1070         }
1071 
1072         for (const auto& tagVar : tagVars.getList(reco::btau::flightDistance2dVal, false)) {
1073           flightDistance2dVal_.fill(passProbe, tagVar);
1074         }
1075 
1076         for (const auto& tagVar : tagVars.getList(reco::btau::flightDistance2dSig, false)) {
1077           flightDistance2dSig_.fill(passProbe, tagVar);
1078         }
1079 
1080         for (const auto& tagVar : tagVars.getList(reco::btau::flightDistance3dVal, false)) {
1081           flightDistance3dVal_.fill(passProbe, tagVar);
1082         }
1083 
1084         for (const auto& tagVar : tagVars.getList(reco::btau::flightDistance3dSig, false)) {
1085           flightDistance3dSig_.fill(passProbe, tagVar);
1086         }
1087       }
1088     }
1089   }
1090 }
1091 
1092 void BTagAndProbe::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
1093   edm::ParameterSetDescription desc;
1094   desc.add<std::string>("FolderName", "HLT/BTV");
1095 
1096   desc.add<bool>("requireValidHLTPaths", true);
1097 
1098   desc.add<edm::InputTag>("vertices", edm::InputTag("offlinePrimaryVertices"));
1099   desc.add<edm::InputTag>("muons", edm::InputTag("muons"));
1100   desc.add<edm::InputTag>("electrons", edm::InputTag("gedGsfElectrons"));
1101   desc.add<edm::InputTag>("elecID", edm::InputTag("egmGsfElectronIDsForDQM:cutBasedElectronID-Fall17-94X-V1-tight"));
1102   desc.add<std::vector<edm::InputTag> >(
1103       "btagAlgos", {edm::InputTag("pfDeepCSVJetTags:probb"), edm::InputTag("pfDeepCSVJetTags:probbb")});
1104 
1105   desc.add<std::string>("jetSelection", "pt > 30");
1106   desc.add<std::string>("eleSelection", "pt > 0 && abs(eta) < 2.5");
1107   desc.add<std::string>("muoSelection", "pt > 6 && abs(eta) < 2.4");
1108   desc.add<std::string>("vertexSelection", "!isFake");
1109   desc.add<std::string>("bjetSelection", "pt > 30");
1110   desc.add<unsigned int>("nelectrons", 0);
1111   desc.add<unsigned int>("nmuons", 0);
1112   desc.add<double>("leptJetDeltaRmin", 0);
1113   desc.add<double>("bJetMuDeltaRmax", 9999.);
1114   desc.add<double>("bJetDeltaEtaMax", 9999.);
1115 
1116   desc.add<unsigned int>("nbjets", 0);
1117   desc.add<double>("workingpoint", 0.4941);  // DeepCSV Medium wp
1118   desc.add<bool>("applyLeptonPVcuts", false);
1119   desc.add<bool>("debug", false);
1120 
1121   edm::ParameterSetDescription genericTriggerEventPSet;
1122   GenericTriggerEventFlag::fillPSetDescription(genericTriggerEventPSet);
1123 
1124   desc.add<edm::ParameterSetDescription>("genericTriggerEventPSet", genericTriggerEventPSet);
1125 
1126   edm::ParameterSetDescription lPVcutPSet;
1127   lPVcutPSet.add<double>("dxy", 9999.);
1128   lPVcutPSet.add<double>("dz", 9999.);
1129   desc.add<edm::ParameterSetDescription>("leptonPVcuts", lPVcutPSet);
1130 
1131   descriptions.add("BTagAndProbeMonitoring", desc);
1132 }
1133 
1134 // Define this as a plug-in
1135 DEFINE_FWK_MODULE(BTagAndProbe);