Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /*
0002   BTVHLTOffline DQM code
0003 */
0004 //
0005 // Originally created by:  Anne-Catherine Le Bihan
0006 //                         June 2015
0007 //                         John Alison <johnalison@cmu.edu>
0008 //                         June 2020
0009 // Following the structure used in JetMetHLTOfflineSource
0010 
0011 // system include files
0012 #include <fstream>
0013 #include <iostream>
0014 #include <memory>
0015 #include <sstream>
0016 #include <string>
0017 #include <utility>
0018 #include <vector>
0019 #include <unistd.h>
0020 #include <cmath>
0021 #include <iostream>
0022 
0023 // user include files
0024 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0025 #include "DQMServices/Core/interface/DQMStore.h"
0026 #include "DQMOffline/Trigger/plugins/TriggerDQMBase.h"
0027 #include "DataFormats/Common/interface/TriggerResults.h"
0028 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
0029 #include "DataFormats/HLTReco/interface/TriggerObject.h"
0030 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
0031 #include "DataFormats/VertexReco/interface/Vertex.h"
0032 #include "DataFormats/BTauReco/interface/JetTag.h"
0033 #include "DataFormats/BTauReco/interface/ShallowTagInfo.h"
0034 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
0035 #include "FWCore/Framework/interface/MakerMacros.h"
0036 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0037 #include "FWCore/ServiceRegistry/interface/Service.h"
0038 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0039 #include "FWCore/Common/interface/TriggerNames.h"
0040 #include "CommonTools/UtilAlgos/interface/DeltaR.h"
0041 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0042 #include "DataFormats/BTauReco/interface/SecondaryVertexTagInfo.h"
0043 #include "DataFormats/TrackReco/interface/Track.h"
0044 
0045 #include "TMath.h"
0046 #include "TPRegexp.h"
0047 
0048 class BTVHLTOfflineSource : public DQMEDAnalyzer {
0049 public:
0050   explicit BTVHLTOfflineSource(const edm::ParameterSet&);
0051   ~BTVHLTOfflineSource() override;
0052 
0053 private:
0054   void analyze(const edm::Event&, const edm::EventSetup&) override;
0055 
0056   std::vector<const reco::Track*> getOfflineBTagTracks(float hltJetEta,
0057                                                        float hltJetPhi,
0058                                                        edm::Handle<edm::View<reco::BaseTagInfo>> offlineIPTagHandle,
0059                                                        std::vector<float>& offlineIP3D,
0060                                                        std::vector<float>& offlineIP3DSig);
0061 
0062   typedef reco::TemplatedSecondaryVertexTagInfo<reco::CandIPTagInfo, reco::VertexCompositePtrCandidate> SVTagInfo;
0063 
0064   template <class Base>
0065   std::vector<const reco::Track*> getOnlineBTagTracks(float hltJetEta,
0066                                                       float hltJetPhi,
0067                                                       edm::Handle<std::vector<Base>> jetSVTagsColl,
0068                                                       std::vector<float>& onlineIP3D,
0069                                                       std::vector<float>& onlineIP3DSig);
0070 
0071   void bookHistograms(DQMStore::IBooker&, edm::Run const& run, edm::EventSetup const& c) override;
0072 
0073   void dqmBeginRun(edm::Run const& run, edm::EventSetup const& c) override;
0074 
0075   std::string dirname_;
0076   std::string processname_;
0077   bool verbose_;
0078 
0079   std::vector<std::pair<std::string, std::string>> custompathnamepairs_;
0080 
0081   edm::InputTag triggerSummaryLabel_;
0082   edm::InputTag triggerResultsLabel_;
0083 
0084   float turnon_threshold_loose_;
0085   float turnon_threshold_medium_;
0086   float turnon_threshold_tight_;
0087 
0088   edm::EDGetTokenT<reco::JetTagCollection> offlineDiscrTokenb_;
0089   edm::EDGetTokenT<reco::JetTagCollection> offlineDiscrTokenbb_;
0090   edm::EDGetTokenT<edm::View<reco::BaseTagInfo>> offlineIPToken_;
0091 
0092   edm::EDGetTokenT<std::vector<reco::Vertex>> hltFastPVToken_;
0093   edm::EDGetTokenT<std::vector<reco::Vertex>> hltPFPVToken_;
0094   edm::EDGetTokenT<std::vector<reco::Vertex>> hltCaloPVToken_;
0095   edm::EDGetTokenT<std::vector<reco::Vertex>> offlinePVToken_;
0096 
0097   edm::EDGetTokenT<edm::TriggerResults> triggerResultsToken;
0098   edm::EDGetTokenT<edm::TriggerResults> triggerResultsFUToken;
0099   edm::EDGetTokenT<trigger::TriggerEvent> triggerSummaryToken;
0100   edm::EDGetTokenT<trigger::TriggerEvent> triggerSummaryFUToken;
0101 
0102   edm::EDGetTokenT<std::vector<reco::ShallowTagInfo>> shallowTagInfosTokenCalo_;
0103   edm::EDGetTokenT<std::vector<reco::ShallowTagInfo>> shallowTagInfosTokenPf_;
0104 
0105   edm::EDGetTokenT<std::vector<reco::SecondaryVertexTagInfo>> SVTagInfosTokenCalo_;
0106   edm::EDGetTokenT<std::vector<SVTagInfo>> SVTagInfosTokenPf_;
0107 
0108   edm::EDGetTokenT<reco::JetTagCollection> caloTagsToken_;
0109   edm::EDGetTokenT<reco::JetTagCollection> pfTagsToken_;
0110   edm::Handle<reco::JetTagCollection> caloTags;
0111   edm::Handle<reco::JetTagCollection> pfTags;
0112 
0113   float minDecayLength_;
0114   float maxDecayLength_;
0115   float minJetDistance_;
0116   float maxJetDistance_;
0117   float dRTrackMatch_;
0118 
0119   HLTConfigProvider hltConfig_;
0120 
0121   class PathInfo : public TriggerDQMBase {
0122   public:
0123     PathInfo()
0124         : prescaleUsed_(-1),
0125           pathName_("unset"),
0126           filterName_("unset"),
0127           processName_("unset"),
0128           objectType_(-1),
0129           triggerType_("unset") {}
0130 
0131     ~PathInfo() override = default;
0132 
0133     PathInfo(const int prescaleUsed,
0134              const std::string& pathName,
0135              const std::string& filterName,
0136              const std::string& processName,
0137              const int type,
0138              const std::string& triggerType)
0139         : prescaleUsed_(prescaleUsed),
0140           pathName_(pathName),
0141           filterName_(filterName),
0142           processName_(processName),
0143           objectType_(type),
0144           triggerType_(triggerType) {}
0145 
0146     const std::string getLabel() const { return filterName_; }
0147     void setLabel(std::string labelName) { filterName_ = std::move(labelName); }
0148     const std::string getPath() const { return pathName_; }
0149     const int getprescaleUsed() const { return prescaleUsed_; }
0150     const std::string getProcess() const { return processName_; }
0151     const int getObjectType() const { return objectType_; }
0152     const std::string getTriggerType() const { return triggerType_; }
0153     const edm::InputTag getTag() const { return edm::InputTag(filterName_, "", processName_); }
0154     const bool operator==(const std::string& v) const { return v == pathName_; }
0155 
0156     MonitorElement* Discr = nullptr;
0157     MonitorElement* Pt = nullptr;
0158     MonitorElement* Eta = nullptr;
0159     MonitorElement* Discr_HLTvsRECO = nullptr;
0160     MonitorElement* Discr_HLTMinusRECO = nullptr;
0161     ObjME Discr_turnon_loose;
0162     ObjME Discr_turnon_medium;
0163     ObjME Discr_turnon_tight;
0164     MonitorElement* PVz = nullptr;
0165     MonitorElement* fastPVz = nullptr;
0166     MonitorElement* PVz_HLTMinusRECO = nullptr;
0167     MonitorElement* fastPVz_HLTMinusRECO = nullptr;
0168     MonitorElement* n_vtx = nullptr;
0169     MonitorElement* vtx_mass = nullptr;
0170     MonitorElement* n_vtx_trks = nullptr;
0171     MonitorElement* n_sel_tracks = nullptr;
0172     MonitorElement* h_3d_ip_distance = nullptr;
0173     MonitorElement* h_3d_ip_error = nullptr;
0174     MonitorElement* h_3d_ip_sig = nullptr;
0175 
0176     //NEW
0177     MonitorElement* h_jetNSecondaryVertices = nullptr;
0178     MonitorElement* h_jet_pt = nullptr;
0179     MonitorElement* h_jet_eta = nullptr;
0180     MonitorElement* h_trackSumJetEtRatio = nullptr;
0181     MonitorElement* h_trackSip2dValAboveCharm = nullptr;
0182     MonitorElement* h_trackSip2dSigAboveCharm = nullptr;
0183     MonitorElement* h_trackSip3dValAboveCharm = nullptr;
0184     MonitorElement* h_trackSip3dSigAboveCharm = nullptr;
0185     MonitorElement* h_jetNSelectedTracks = nullptr;
0186     MonitorElement* h_jetNTracksEtaRel = nullptr;
0187     MonitorElement* h_vertexCategory = nullptr;
0188     MonitorElement* h_trackSumJetDeltaR = nullptr;
0189 
0190     MonitorElement* h_trackJetDistVal = nullptr;
0191     MonitorElement* h_trackPtRel = nullptr;
0192     MonitorElement* h_trackDeltaR = nullptr;
0193     MonitorElement* h_trackPtRatio = nullptr;
0194     MonitorElement* h_trackSip3dSig = nullptr;
0195     MonitorElement* h_trackSip2dSig = nullptr;
0196     MonitorElement* h_trackDecayLenVal = nullptr;
0197     MonitorElement* h_trackEtaRel = nullptr;
0198 
0199     MonitorElement* h_vertexEnergyRatio = nullptr;
0200     MonitorElement* h_vertexJetDeltaR = nullptr;
0201     MonitorElement* h_flightDistance2dVal = nullptr;
0202     MonitorElement* h_flightDistance2dSig = nullptr;
0203     MonitorElement* h_flightDistance3dVal = nullptr;
0204     MonitorElement* h_flightDistance3dSig = nullptr;
0205 
0206     ObjME OnlineTrkEff_Pt;
0207     ObjME OnlineTrkEff_Eta;
0208     ObjME OnlineTrkEff_3d_ip_distance;
0209     ObjME OnlineTrkEff_3d_ip_sig;
0210     ObjME OnlineTrkFake_Pt;
0211     ObjME OnlineTrkFake_Eta;
0212     ObjME OnlineTrkFake_3d_ip_distance;
0213     ObjME OnlineTrkFake_3d_ip_sig;
0214     // MonitorElement*  n_pixel_hits_;
0215     // MonitorElement*  n_total_hits_;
0216 
0217   private:
0218     int prescaleUsed_;
0219     std::string pathName_;
0220     std::string filterName_;
0221     std::string processName_;
0222     int objectType_;
0223     std::string triggerType_;
0224   };
0225 
0226   class PathInfoCollection : public std::vector<PathInfo> {
0227   public:
0228     PathInfoCollection() : std::vector<PathInfo>(){};
0229     std::vector<PathInfo>::iterator find(const std::string& pathName) { return std::find(begin(), end(), pathName); }
0230   };
0231 
0232   PathInfoCollection hltPathsAll_;
0233 };
0234 
0235 using namespace edm;
0236 using namespace reco;
0237 using namespace std;
0238 using namespace trigger;
0239 
0240 BTVHLTOfflineSource::BTVHLTOfflineSource(const edm::ParameterSet& iConfig)
0241     : dirname_(iConfig.getUntrackedParameter("dirname", std::string("HLT/BTV/"))),
0242       processname_(iConfig.getParameter<std::string>("processname")),
0243       verbose_(iConfig.getUntrackedParameter<bool>("verbose", false)),
0244       triggerSummaryLabel_(iConfig.getParameter<edm::InputTag>("triggerSummaryLabel")),
0245       triggerResultsLabel_(iConfig.getParameter<edm::InputTag>("triggerResultsLabel")),
0246       turnon_threshold_loose_(iConfig.getParameter<double>("turnon_threshold_loose")),
0247       turnon_threshold_medium_(iConfig.getParameter<double>("turnon_threshold_medium")),
0248       turnon_threshold_tight_(iConfig.getParameter<double>("turnon_threshold_tight")),
0249       offlineDiscrTokenb_(consumes<reco::JetTagCollection>(iConfig.getParameter<edm::InputTag>("offlineDiscrLabelb"))),
0250       offlineDiscrTokenbb_(
0251           consumes<reco::JetTagCollection>(iConfig.getParameter<edm::InputTag>("offlineDiscrLabelbb"))),
0252       offlineIPToken_(consumes<View<BaseTagInfo>>(iConfig.getParameter<edm::InputTag>("offlineIPLabel"))),
0253 
0254       hltFastPVToken_(consumes<std::vector<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("hltFastPVLabel"))),
0255       hltPFPVToken_(consumes<std::vector<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("hltPFPVLabel"))),
0256       hltCaloPVToken_(consumes<std::vector<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("hltCaloPVLabel"))),
0257       offlinePVToken_(consumes<std::vector<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("offlinePVLabel"))),
0258       triggerResultsToken(consumes<edm::TriggerResults>(triggerResultsLabel_)),
0259       triggerResultsFUToken(consumes<edm::TriggerResults>(
0260           edm::InputTag(triggerResultsLabel_.label(), triggerResultsLabel_.instance(), std::string("FU")))),
0261       triggerSummaryToken(consumes<trigger::TriggerEvent>(triggerSummaryLabel_)),
0262       triggerSummaryFUToken(consumes<trigger::TriggerEvent>(
0263           edm::InputTag(triggerSummaryLabel_.label(), triggerSummaryLabel_.instance(), std::string("FU")))),
0264       shallowTagInfosTokenCalo_(
0265           consumes<vector<reco::ShallowTagInfo>>(edm::InputTag("hltDeepCombinedSecondaryVertexBJetTagsInfosCalo"))),
0266       shallowTagInfosTokenPf_(
0267           consumes<vector<reco::ShallowTagInfo>>(edm::InputTag("hltDeepCombinedSecondaryVertexBJetTagsInfos"))),
0268       SVTagInfosTokenCalo_(consumes<std::vector<reco::SecondaryVertexTagInfo>>(
0269           edm::InputTag("hltInclusiveSecondaryVertexFinderTagInfos"))),
0270       SVTagInfosTokenPf_(consumes<std::vector<SVTagInfo>>(edm::InputTag("hltDeepSecondaryVertexTagInfosPF"))),
0271       caloTagsToken_(consumes<reco::JetTagCollection>(iConfig.getParameter<edm::InputTag>("onlineDiscrLabelCalo"))),
0272       pfTagsToken_(consumes<reco::JetTagCollection>(iConfig.getParameter<edm::InputTag>("onlineDiscrLabelPF"))),
0273       minDecayLength_(iConfig.getParameter<double>("minDecayLength")),
0274       maxDecayLength_(iConfig.getParameter<double>("maxDecayLength")),
0275       minJetDistance_(iConfig.getParameter<double>("minJetDistance")),
0276       maxJetDistance_(iConfig.getParameter<double>("maxJetDistance")),
0277       dRTrackMatch_(iConfig.getParameter<double>("dRTrackMatch")) {
0278   std::vector<edm::ParameterSet> paths = iConfig.getParameter<std::vector<edm::ParameterSet>>("pathPairs");
0279   for (const auto& path : paths) {
0280     custompathnamepairs_.push_back(
0281         make_pair(path.getParameter<std::string>("pathname"), path.getParameter<std::string>("pathtype")));
0282   }
0283 }
0284 
0285 BTVHLTOfflineSource::~BTVHLTOfflineSource() = default;
0286 
0287 void BTVHLTOfflineSource::dqmBeginRun(const edm::Run& run, const edm::EventSetup& c) {
0288   bool changed = true;
0289   if (!hltConfig_.init(run, c, processname_, changed)) {
0290     LogDebug("BTVHLTOfflineSource") << "HLTConfigProvider failed to initialize.";
0291   }
0292 
0293   for (unsigned int idx = 0; idx != hltConfig_.size(); ++idx) {
0294     const auto& pathname = hltConfig_.triggerName(idx);
0295 
0296     for (const auto& custompathnamepair : custompathnamepairs_) {
0297       if (pathname.find(custompathnamepair.first) != std::string::npos) {
0298         hltPathsAll_.push_back(PathInfo(1, pathname, "dummy", processname_, 0, custompathnamepair.second));
0299       }
0300     }
0301   }
0302 }
0303 
0304 void BTVHLTOfflineSource::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0305   edm::Handle<edm::TriggerResults> triggerResults;
0306   iEvent.getByToken(triggerResultsToken, triggerResults);
0307   if (!triggerResults.isValid()) {
0308     iEvent.getByToken(triggerResultsFUToken, triggerResults);
0309     if (!triggerResults.isValid()) {
0310       edm::LogInfo("BTVHLTOfflineSource") << "TriggerResults not found, skipping event";
0311       return;
0312     }
0313   }
0314 
0315   const edm::TriggerNames& triggerNames = iEvent.triggerNames(*triggerResults);
0316 
0317   edm::Handle<trigger::TriggerEvent> triggerObj;
0318   iEvent.getByToken(triggerSummaryToken, triggerObj);
0319   if (!triggerObj.isValid()) {
0320     iEvent.getByToken(triggerSummaryFUToken, triggerObj);
0321     if (!triggerObj.isValid()) {
0322       edm::LogInfo("BTVHLTOfflineSource") << "TriggerEvent not found, skipping event";
0323       return;
0324     }
0325   }
0326 
0327   edm::Handle<reco::JetTagCollection> caloTags;
0328   iEvent.getByToken(caloTagsToken_, caloTags);
0329 
0330   edm::Handle<reco::JetTagCollection> pfTags;
0331   iEvent.getByToken(pfTagsToken_, pfTags);
0332 
0333   Handle<reco::VertexCollection> VertexHandler;
0334 
0335   Handle<reco::JetTagCollection> offlineJetTagHandlerb;
0336   iEvent.getByToken(offlineDiscrTokenb_, offlineJetTagHandlerb);
0337 
0338   Handle<reco::JetTagCollection> offlineJetTagHandlerbb;
0339   iEvent.getByToken(offlineDiscrTokenbb_, offlineJetTagHandlerbb);
0340 
0341   Handle<View<BaseTagInfo>> offlineIPTagHandle;
0342   iEvent.getByToken(offlineIPToken_, offlineIPTagHandle);
0343 
0344   Handle<reco::VertexCollection> offlineVertexHandler;
0345   iEvent.getByToken(offlinePVToken_, offlineVertexHandler);
0346 
0347   if (verbose_ && iEvent.id().event() % 10000 == 0)
0348     cout << "Run = " << iEvent.id().run() << ", LS = " << iEvent.luminosityBlock()
0349          << ", Event = " << iEvent.id().event() << endl;
0350 
0351   if (!triggerResults.isValid())
0352     return;
0353 
0354   edm::Handle<std::vector<SVTagInfo>> jetSVTagsCollPF;
0355   edm::Handle<std::vector<reco::SecondaryVertexTagInfo>> jetSVTagsCollCalo;
0356 
0357   for (auto& v : hltPathsAll_) {
0358     unsigned index = triggerNames.triggerIndex(v.getPath());
0359     if (!(index < triggerNames.size())) {
0360       edm::LogInfo("BTVHLTOfflineSource") << "Path " << v.getPath() << " not in menu, skipping event";
0361       continue;
0362     }
0363 
0364     if (!triggerResults->accept(index)) {
0365       edm::LogInfo("BTVHLTOfflineSource") << "Path " << v.getPath() << " not accepted, skipping event";
0366       continue;
0367     }
0368 
0369     if (v.getTriggerType() == "PF") {
0370       iEvent.getByToken(SVTagInfosTokenPf_, jetSVTagsCollPF);
0371     } else {
0372       iEvent.getByToken(SVTagInfosTokenCalo_, jetSVTagsCollCalo);
0373     }
0374 
0375     // PF and Calo btagging
0376     if ((v.getTriggerType() == "PF" && pfTags.isValid()) ||
0377         (v.getTriggerType() == "Calo" && caloTags.isValid() && !caloTags->empty())) {
0378       const auto& iter = (v.getTriggerType() == "PF") ? pfTags->begin() : caloTags->begin();
0379 
0380       float Discr_online = iter->second;
0381       if (Discr_online < 0)
0382         Discr_online = -0.05;
0383 
0384       v.Discr->Fill(Discr_online);
0385       v.Pt->Fill(iter->first->pt());
0386       v.Eta->Fill(iter->first->eta());
0387 
0388       if (offlineJetTagHandlerb.isValid()) {
0389         for (auto const& iterOffb : *offlineJetTagHandlerb) {
0390           float DR = reco::deltaR(iterOffb.first->eta(), iterOffb.first->phi(), iter->first->eta(), iter->first->phi());
0391           if (DR < 0.3) {
0392             float Discr_offline = iterOffb.second;
0393 
0394             // offline probb and probbb must be added (if probbb isn't specified, it'll just use probb)
0395             if (offlineJetTagHandlerbb.isValid()) {
0396               for (auto const& iterOffbb : *offlineJetTagHandlerbb) {
0397                 DR = reco::deltaR(
0398                     iterOffbb.first->eta(), iterOffbb.first->phi(), iter->first->eta(), iter->first->phi());
0399                 if (DR < 0.3) {
0400                   Discr_offline += iterOffbb.second;
0401                   break;
0402                 }
0403               }
0404             }
0405 
0406             if (Discr_offline < 0)
0407               Discr_offline = -0.05;
0408             v.Discr_HLTvsRECO->Fill(Discr_online, Discr_offline);
0409             v.Discr_HLTMinusRECO->Fill(Discr_online - Discr_offline);
0410 
0411             v.Discr_turnon_loose.denominator->Fill(Discr_offline);
0412             v.Discr_turnon_medium.denominator->Fill(Discr_offline);
0413             v.Discr_turnon_tight.denominator->Fill(Discr_offline);
0414 
0415             if (Discr_online > turnon_threshold_loose_)
0416               v.Discr_turnon_loose.numerator->Fill(Discr_offline);
0417             if (Discr_online > turnon_threshold_medium_)
0418               v.Discr_turnon_medium.numerator->Fill(Discr_offline);
0419             if (Discr_online > turnon_threshold_tight_)
0420               v.Discr_turnon_tight.numerator->Fill(Discr_offline);
0421 
0422             break;
0423           }
0424         }
0425       }  ///offline
0426 
0427       bool pfSVTagCollValid = (v.getTriggerType() == "PF" && jetSVTagsCollPF.isValid());
0428       bool caloSVTagCollValid = (v.getTriggerType() == "Calo" && jetSVTagsCollCalo.isValid());
0429       if (offlineIPTagHandle.isValid() && (pfSVTagCollValid || caloSVTagCollValid)) {
0430         std::vector<float> offlineIP3D;
0431         std::vector<float> offlineIP3DSig;
0432         std::vector<const reco::Track*> offlineTracks = getOfflineBTagTracks(
0433             iter->first->eta(), iter->first->phi(), offlineIPTagHandle, offlineIP3D, offlineIP3DSig);
0434         std::vector<const reco::Track*> onlineTracks;
0435         std::vector<float> onlineIP3D;
0436         std::vector<float> onlineIP3DSig;
0437         if (pfSVTagCollValid)
0438           onlineTracks = getOnlineBTagTracks<SVTagInfo>(
0439               iter->first->eta(), iter->first->phi(), jetSVTagsCollPF, onlineIP3D, onlineIP3DSig);
0440         if (caloSVTagCollValid)
0441           onlineTracks = getOnlineBTagTracks<reco::SecondaryVertexTagInfo>(
0442               iter->first->eta(), iter->first->phi(), jetSVTagsCollCalo, onlineIP3D, onlineIP3DSig);
0443 
0444         for (unsigned int iOffTrk = 0; iOffTrk < offlineTracks.size(); ++iOffTrk) {
0445           const reco::Track* offTrk = offlineTracks.at(iOffTrk);
0446           bool hasMatch = false;
0447           float offTrkEta = offTrk->eta();
0448           float offTrkPhi = offTrk->phi();
0449 
0450           for (const reco::Track* onTrk : onlineTracks) {
0451             float DR = reco::deltaR(offTrkEta, offTrkPhi, onTrk->eta(), onTrk->phi());
0452             if (DR < dRTrackMatch_) {
0453               hasMatch = true;
0454             }
0455           }
0456 
0457           float offTrkPt = offTrk->pt();
0458           v.OnlineTrkEff_Pt.denominator->Fill(offTrkPt);
0459           if (hasMatch)
0460             v.OnlineTrkEff_Pt.numerator->Fill(offTrkPt);
0461 
0462           v.OnlineTrkEff_Eta.denominator->Fill(offTrkEta);
0463           if (hasMatch)
0464             v.OnlineTrkEff_Eta.numerator->Fill(offTrkEta);
0465 
0466           v.OnlineTrkEff_3d_ip_distance.denominator->Fill(offlineIP3D.at(iOffTrk));
0467           if (hasMatch)
0468             v.OnlineTrkEff_3d_ip_distance.numerator->Fill(offlineIP3D.at(iOffTrk));
0469 
0470           v.OnlineTrkEff_3d_ip_sig.denominator->Fill(offlineIP3DSig.at(iOffTrk));
0471           if (hasMatch)
0472             v.OnlineTrkEff_3d_ip_sig.numerator->Fill(offlineIP3DSig.at(iOffTrk));
0473         }
0474 
0475         for (unsigned int iOnTrk = 0; iOnTrk < onlineTracks.size(); ++iOnTrk) {
0476           const reco::Track* onTrk = onlineTracks.at(iOnTrk);
0477           bool hasMatch = false;
0478           float onTrkEta = onTrk->eta();
0479           float onTrkPhi = onTrk->phi();
0480 
0481           for (const reco::Track* offTrk : offlineTracks) {
0482             float DR = reco::deltaR(onTrkEta, onTrkPhi, offTrk->eta(), offTrk->phi());
0483             if (DR < dRTrackMatch_) {
0484               hasMatch = true;
0485             }
0486           }
0487 
0488           float onTrkPt = onTrk->pt();
0489           v.OnlineTrkFake_Pt.denominator->Fill(onTrkPt);
0490           if (!hasMatch)
0491             v.OnlineTrkFake_Pt.numerator->Fill(onTrkPt);
0492 
0493           v.OnlineTrkFake_Eta.denominator->Fill(onTrkEta);
0494           if (!hasMatch)
0495             v.OnlineTrkFake_Eta.numerator->Fill(onTrkEta);
0496 
0497           v.OnlineTrkFake_3d_ip_distance.denominator->Fill(onlineIP3D.at(iOnTrk));
0498           if (!hasMatch)
0499             v.OnlineTrkFake_3d_ip_distance.numerator->Fill(onlineIP3D.at(iOnTrk));
0500 
0501           v.OnlineTrkFake_3d_ip_sig.denominator->Fill(onlineIP3DSig.at(iOnTrk));
0502           if (!hasMatch)
0503             v.OnlineTrkFake_3d_ip_sig.numerator->Fill(onlineIP3DSig.at(iOnTrk));
0504         }
0505       }
0506 
0507       if (v.getTriggerType() == "PF") {
0508         iEvent.getByToken(hltPFPVToken_, VertexHandler);
0509       } else {
0510         iEvent.getByToken(hltFastPVToken_, VertexHandler);
0511       }
0512       if (VertexHandler.isValid()) {
0513         v.PVz->Fill(VertexHandler->begin()->z());
0514         if (offlineVertexHandler.isValid()) {
0515           v.PVz_HLTMinusRECO->Fill(VertexHandler->begin()->z() - offlineVertexHandler->begin()->z());
0516         }
0517       }
0518     }  // caloTagsValid or PFTagsValid
0519 
0520     // specific to Calo b-tagging
0521     if (caloTags.isValid() && v.getTriggerType() == "Calo" && !caloTags->empty()) {
0522       iEvent.getByToken(hltCaloPVToken_, VertexHandler);
0523       if (VertexHandler.isValid()) {
0524         v.fastPVz->Fill(VertexHandler->begin()->z());
0525         if (offlineVertexHandler.isValid()) {
0526           v.fastPVz_HLTMinusRECO->Fill(VertexHandler->begin()->z() - offlineVertexHandler->begin()->z());
0527         }
0528       }
0529     }
0530 
0531     // additional plots from tag info collections
0532     /////////////////////////////////////////////
0533 
0534     edm::Handle<std::vector<reco::ShallowTagInfo>> shallowTagInfosCalo;
0535     iEvent.getByToken(shallowTagInfosTokenCalo_, shallowTagInfosCalo);
0536 
0537     edm::Handle<std::vector<reco::ShallowTagInfo>> shallowTagInfosPf;
0538     iEvent.getByToken(shallowTagInfosTokenPf_, shallowTagInfosPf);
0539 
0540     //    edm::Handle<std::vector<reco::TemplatedSecondaryVertexTagInfo<reco::IPTagInfo<edm::RefVector<std::vector<reco::Track>, reco::Track, edm::refhelper::FindUsingAdvance<std::vector<reco::Track>, reco::Track> >, reco::JTATagInfo>, reco::Vertex> > > caloTagInfos;
0541     //    iEvent.getByToken(caloTagInfosToken_, caloTagInfos);
0542 
0543     //    edm::Handle<std::vector<reco::TemplatedSecondaryVertexTagInfo<reco::IPTagInfo<edm::RefVector<std::vector<reco::Track>, reco::Track, edm::refhelper::FindUsingAdvance<std::vector<reco::Track>, reco::Track> >, reco::JTATagInfo>, reco::Vertex> > > pfTagInfos;
0544     //    iEvent.getByToken(pfTagInfosToken_, pfTagInfos);
0545 
0546     // first try to get info from shallowTagInfos ...
0547     if ((v.getTriggerType() == "PF" && shallowTagInfosPf.isValid()) ||
0548         (v.getTriggerType() == "Calo" && shallowTagInfosCalo.isValid())) {
0549       const auto& shallowTagInfoCollection = (v.getTriggerType() == "PF") ? shallowTagInfosPf : shallowTagInfosCalo;
0550       for (const auto& shallowTagInfo : *shallowTagInfoCollection) {
0551         const auto& tagVars = shallowTagInfo.taggingVariables();
0552 
0553         // n secondary vertices and n selected tracks
0554         for (const auto& tagVar : tagVars.getList(reco::btau::jetNSecondaryVertices, false)) {
0555           v.h_jetNSecondaryVertices->Fill(tagVar);
0556           v.n_vtx->Fill(tagVar);
0557         }
0558 
0559         for (const auto& tagVar : tagVars.getList(reco::btau::jetNSelectedTracks, false)) {
0560           v.n_sel_tracks->Fill(tagVar);
0561           v.h_jetNSelectedTracks->Fill(tagVar);
0562         }
0563 
0564         for (const auto& tagVar : tagVars.getList(reco::btau::jetPt, false)) {
0565           v.h_jet_pt->Fill(tagVar);
0566         }
0567 
0568         for (const auto& tagVar : tagVars.getList(reco::btau::jetEta, false)) {
0569           v.h_jet_eta->Fill(tagVar);
0570         }
0571 
0572         for (const auto& tagVar : tagVars.getList(reco::btau::trackSumJetEtRatio, false)) {
0573           v.h_trackSumJetEtRatio->Fill(tagVar);
0574         }
0575 
0576         for (const auto& tagVar : tagVars.getList(reco::btau::trackSumJetDeltaR, false)) {
0577           v.h_trackSumJetDeltaR->Fill(tagVar);
0578         }
0579 
0580         for (const auto& tagVar : tagVars.getList(reco::btau::vertexCategory, false)) {
0581           v.h_vertexCategory->Fill(tagVar);
0582         }
0583 
0584         for (const auto& tagVar : tagVars.getList(reco::btau::trackSip2dValAboveCharm, false)) {
0585           v.h_trackSip2dValAboveCharm->Fill(tagVar);
0586         }
0587 
0588         for (const auto& tagVar : tagVars.getList(reco::btau::trackSip2dSigAboveCharm, false)) {
0589           v.h_trackSip2dSigAboveCharm->Fill(tagVar);
0590         }
0591 
0592         for (const auto& tagVar : tagVars.getList(reco::btau::trackSip3dValAboveCharm, false)) {
0593           v.h_trackSip3dValAboveCharm->Fill(tagVar);
0594         }
0595 
0596         for (const auto& tagVar : tagVars.getList(reco::btau::trackSip3dSigAboveCharm, false)) {
0597           v.h_trackSip3dSigAboveCharm->Fill(tagVar);
0598         }
0599 
0600         for (const auto& tagVar : tagVars.getList(reco::btau::jetNTracksEtaRel, false)) {
0601           v.h_jetNTracksEtaRel->Fill(tagVar);
0602         }
0603 
0604         // impact parameter
0605         // and new info
0606         const auto& trackSip3dVal = tagVars.getList(reco::btau::trackSip3dVal, false);
0607         const auto& trackSip3dSig = tagVars.getList(reco::btau::trackSip3dSig, false);
0608         const auto& trackJetDistVal = tagVars.getList(reco::btau::trackJetDistVal, false);
0609         const auto& trackPtRel = tagVars.getList(reco::btau::trackPtRel, false);
0610         const auto& trackSip2dSig = tagVars.getList(reco::btau::trackSip2dSig, false);
0611         const auto& trackDeltaR = tagVars.getList(reco::btau::trackDeltaR, false);
0612         const auto& trackPtRatio = tagVars.getList(reco::btau::trackPtRatio, false);
0613         const auto& trackDecayLenVal = tagVars.getList(reco::btau::trackDecayLenVal, false);
0614         const auto& trackEtaRel = tagVars.getList(reco::btau::trackEtaRel, false);
0615 
0616         for (unsigned i_trk = 0; i_trk < trackEtaRel.size(); i_trk++) {
0617           v.h_trackEtaRel->Fill(trackEtaRel[i_trk]);
0618         }
0619 
0620         for (unsigned i_trk = 0; i_trk < trackJetDistVal.size(); i_trk++) {
0621           v.h_trackJetDistVal->Fill(trackJetDistVal[i_trk]);
0622         }
0623 
0624         for (unsigned i_trk = 0; i_trk < trackPtRel.size(); i_trk++) {
0625           v.h_trackPtRel->Fill(trackPtRel[i_trk]);
0626         }
0627 
0628         for (unsigned i_trk = 0; i_trk < trackDeltaR.size(); i_trk++) {
0629           v.h_trackDeltaR->Fill(trackDeltaR[i_trk]);
0630         }
0631 
0632         for (unsigned i_trk = 0; i_trk < trackPtRatio.size(); i_trk++) {
0633           v.h_trackPtRatio->Fill(trackPtRatio[i_trk]);
0634         }
0635 
0636         for (unsigned i_trk = 0; i_trk < trackDecayLenVal.size(); i_trk++) {
0637           v.h_trackDecayLenVal->Fill(trackDecayLenVal[i_trk]);
0638         }
0639 
0640         for (unsigned i_trk = 0; i_trk < trackSip3dVal.size(); i_trk++) {
0641           float val = trackSip3dVal[i_trk];
0642           float sig = trackSip3dSig[i_trk];
0643           v.h_3d_ip_distance->Fill(val);
0644           v.h_3d_ip_error->Fill(val / sig);
0645           v.h_3d_ip_sig->Fill(sig);
0646 
0647           v.h_trackSip2dSig->Fill(trackSip2dSig[i_trk]);
0648         }
0649 
0650         // vertex mass and tracks per vertex
0651         for (const auto& tagVar : tagVars.getList(reco::btau::vertexMass, false)) {
0652           v.vtx_mass->Fill(tagVar);
0653         }
0654         for (const auto& tagVar : tagVars.getList(reco::btau::vertexNTracks, false)) {
0655           v.n_vtx_trks->Fill(tagVar);
0656         }
0657 
0658         for (const auto& tagVar : tagVars.getList(reco::btau::vertexEnergyRatio, false)) {
0659           v.h_vertexEnergyRatio->Fill(tagVar);
0660         }
0661 
0662         for (const auto& tagVar : tagVars.getList(reco::btau::vertexJetDeltaR, false)) {
0663           v.h_vertexJetDeltaR->Fill(tagVar);
0664         }
0665 
0666         for (const auto& tagVar : tagVars.getList(reco::btau::flightDistance2dVal, false)) {
0667           v.h_flightDistance2dVal->Fill(tagVar);
0668         }
0669 
0670         for (const auto& tagVar : tagVars.getList(reco::btau::flightDistance2dSig, false)) {
0671           v.h_flightDistance2dSig->Fill(tagVar);
0672         }
0673 
0674         for (const auto& tagVar : tagVars.getList(reco::btau::flightDistance3dVal, false)) {
0675           v.h_flightDistance3dVal->Fill(tagVar);
0676         }
0677 
0678         for (const auto& tagVar : tagVars.getList(reco::btau::flightDistance3dSig, false)) {
0679           v.h_flightDistance3dSig->Fill(tagVar);
0680         }
0681 
0682         // // track N total/pixel hits
0683         // for (const auto & tagVar : tagVars.getList(reco::btau::trackNPixelHits, false)) {
0684         //   v.n_pixel_hits->Fill(tagVar);}
0685         // for (const auto & tagVar : tagVars.getList(reco::btau::trackNTotalHits, false)) {
0686         //   v.n_total_hits->Fill(tagVar);}
0687       }
0688     }
0689 
0690     // ... otherwise from usual tag infos.
0691     // else
0692     // if (   (v.getTriggerType() == "PF"   && pfTagInfos.isValid())
0693     //     || (v.getTriggerType() == "Calo" && caloTagInfos.isValid()) )
0694     // {
0695     //   const auto & DiscrTagInfoCollection = (v.getTriggerType() == "PF") ? pfTagInfos : caloTagInfos;
0696 
0697     //   // loop over secondary vertex tag infos
0698     //   for (const auto & DiscrTagInfo : *DiscrTagInfoCollection) {
0699     //     v.n_vtx->Fill(DiscrTagInfo.nVertexCandidates());
0700     //     v.n_sel_tracks->Fill(DiscrTagInfo.nSelectedTracks());
0701 
0702     //     // loop over selected tracks in each tag info
0703     //     for (unsigned i_trk=0; i_trk < DiscrTagInfo.nSelectedTracks(); i_trk++) {
0704     //       const auto & ip3d = DiscrTagInfo.trackIPData(i_trk).ip3d;
0705     //       v.h_3d_ip_distance->Fill(ip3d.value());
0706     //       v.h_3d_ip_error->Fill(ip3d.error());
0707     //       v.h_3d_ip_sig->Fill(ip3d.significance());
0708     //     }
0709 
0710     //     // loop over vertex candidates in each tag info
0711     //     for (unsigned i_sv=0; i_sv < DiscrTagInfo.nVertexCandidates(); i_sv++) {
0712     //       const auto & sv = DiscrTagInfo.secondaryVertex(i_sv);
0713     //       v.vtx_mass->Fill(sv.p4().mass());
0714     //       v.n_vtx_trks->Fill(sv.nTracks());
0715 
0716     //       // loop over tracks for number of pixel and total hits
0717     //       const auto & trkIPTagInfo = DiscrTagInfo.trackIPTagInfoRef().get();
0718     //       for (const auto & trk : trkIPTagInfo->selectedTracks()) {
0719     //         v.n_pixel_hits->Fill(trk.get()->hitPattern().numberOfValidPixelHits());
0720     //         v.n_total_hits->Fill(trk.get()->hitPattern().numberOfValidHits());
0721     //       }
0722     //     }
0723     //   }
0724     // }
0725   }  //end paths loop
0726 }
0727 
0728 std::vector<const reco::Track*> BTVHLTOfflineSource::getOfflineBTagTracks(float hltJetEta,
0729                                                                           float hltJetPhi,
0730                                                                           Handle<View<BaseTagInfo>> offlineIPTagHandle,
0731                                                                           std::vector<float>& offlineIP3D,
0732                                                                           std::vector<float>& offlineIP3DSig) {
0733   std::vector<const reco::Track*> offlineTracks;
0734 
0735   for (auto const& iterOffIP : *offlineIPTagHandle) {
0736     float DR = reco::deltaR(iterOffIP.jet()->eta(), iterOffIP.jet()->phi(), hltJetEta, hltJetPhi);
0737 
0738     if (DR > 0.3)
0739       continue;
0740 
0741     const reco::IPTagInfo<vector<reco::CandidatePtr>, reco::JetTagInfo>* tagInfo =
0742         dynamic_cast<const reco::IPTagInfo<vector<reco::CandidatePtr>, reco::JetTagInfo>*>(&iterOffIP);
0743 
0744     if (!tagInfo) {
0745       throw cms::Exception("Configuration")
0746           << "BTagPerformanceAnalyzer: Extended TagInfo not of type TrackIPTagInfo. " << std::endl;
0747     }
0748 
0749     const GlobalPoint pv(tagInfo->primaryVertex()->position().x(),
0750                          tagInfo->primaryVertex()->position().y(),
0751                          tagInfo->primaryVertex()->position().z());
0752 
0753     const std::vector<reco::btag::TrackIPData>& ip = tagInfo->impactParameterData();
0754 
0755     std::vector<std::size_t> sortedIndices = tagInfo->sortedIndexes(reco::btag::IP2DSig);
0756     std::vector<reco::CandidatePtr> sortedTracks = tagInfo->sortedTracks(sortedIndices);
0757     std::vector<std::size_t> selectedIndices;
0758     vector<reco::CandidatePtr> selectedTracks;
0759     for (unsigned int n = 0; n != sortedIndices.size(); ++n) {
0760       double decayLength = (ip[sortedIndices[n]].closestToJetAxis - pv).mag();
0761       double jetDistance = ip[sortedIndices[n]].distanceToJetAxis.value();
0762       if (decayLength > minDecayLength_ && decayLength < maxDecayLength_ && fabs(jetDistance) >= minJetDistance_ &&
0763           fabs(jetDistance) < maxJetDistance_) {
0764         selectedIndices.push_back(sortedIndices[n]);
0765         selectedTracks.push_back(sortedTracks[n]);
0766       }
0767     }
0768 
0769     for (unsigned int n = 0; n != selectedIndices.size(); ++n) {
0770       const reco::Track* track = reco::btag::toTrack(selectedTracks[n]);
0771       offlineTracks.push_back(track);
0772       offlineIP3D.push_back(ip[n].ip3d.value());
0773       offlineIP3DSig.push_back(ip[n].ip3d.significance());
0774     }
0775   }
0776   return offlineTracks;
0777 }
0778 
0779 template <class Base>
0780 std::vector<const reco::Track*> BTVHLTOfflineSource::getOnlineBTagTracks(float hltJetEta,
0781                                                                          float hltJetPhi,
0782                                                                          edm::Handle<std::vector<Base>> jetSVTagsColl,
0783                                                                          std::vector<float>& onlineIP3D,
0784                                                                          std::vector<float>& onlineIP3DSig) {
0785   std::vector<const reco::Track*> onlineTracks;
0786 
0787   for (auto iterTI = jetSVTagsColl->begin(); iterTI != jetSVTagsColl->end(); ++iterTI) {
0788     float DR = reco::deltaR(iterTI->jet()->eta(), iterTI->jet()->phi(), hltJetEta, hltJetPhi);
0789     if (DR > 0.3)
0790       continue;
0791 
0792     const auto& ipInfo = *(iterTI->trackIPTagInfoRef().get());
0793     const std::vector<reco::btag::TrackIPData>& ip = ipInfo.impactParameterData();
0794 
0795     unsigned int trackSize = ipInfo.selectedTracks().size();
0796     for (unsigned int itt = 0; itt < trackSize; ++itt) {
0797       const auto ptrackRef = (ipInfo.selectedTracks()[itt]);  //TrackRef or
0798       const reco::Track* ptrackPtr = reco::btag::toTrack(ptrackRef);
0799       onlineTracks.push_back(ptrackPtr);
0800       onlineIP3D.push_back(ip[itt].ip3d.value());
0801       onlineIP3DSig.push_back(ip[itt].ip3d.significance());
0802     }
0803   }
0804   return onlineTracks;
0805 }
0806 
0807 void BTVHLTOfflineSource::bookHistograms(DQMStore::IBooker& iBooker, edm::Run const& run, edm::EventSetup const& c) {
0808   iBooker.setCurrentFolder(dirname_);
0809   for (auto& v : hltPathsAll_) {
0810     std::string trgPathName = HLTConfigProvider::removeVersion(v.getPath());
0811     std::string subdirName = dirname_ + "/" + trgPathName + v.getTriggerType();
0812     std::string trigPath = "(" + trgPathName + ")";
0813     iBooker.setCurrentFolder(subdirName);
0814 
0815     std::string labelname("HLT");
0816     std::string histoname(labelname + "");
0817     std::string title(labelname + "");
0818 
0819     histoname = labelname + "_Discr";
0820     title = labelname + "_Discr " + trigPath;
0821     v.Discr = iBooker.book1D(histoname.c_str(), title.c_str(), 110, -0.1, 1);
0822 
0823     histoname = labelname + "_Pt";
0824     title = labelname + "_Pt " + trigPath;
0825     v.Pt = iBooker.book1D(histoname.c_str(), title.c_str(), 100, 0, 400);
0826 
0827     histoname = labelname + "_Eta";
0828     title = labelname + "_Eta " + trigPath;
0829     v.Eta = iBooker.book1D(histoname.c_str(), title.c_str(), 60, -3.0, 3.0);
0830 
0831     histoname = "HLTvsRECO_Discr";
0832     title = "online discr vs offline discr " + trigPath;
0833     v.Discr_HLTvsRECO = iBooker.book2D(histoname.c_str(), title.c_str(), 110, -0.1, 1, 110, -0.1, 1);
0834 
0835     histoname = "HLTMinusRECO_Discr";
0836     title = "online discr minus offline discr " + trigPath;
0837     v.Discr_HLTMinusRECO = iBooker.book1D(histoname.c_str(), title.c_str(), 100, -1, 1);
0838 
0839     histoname = "Turnon_loose_Discr";
0840     title = "turn-on with loose threshold " + trigPath;
0841     v.bookME(iBooker, v.Discr_turnon_loose, histoname, title, 22, -0.1, 1.);
0842 
0843     histoname = "Turnon_medium_Discr";
0844     title = "turn-on with medium threshold " + trigPath;
0845     v.bookME(iBooker, v.Discr_turnon_medium, histoname, title, 22, -0.1, 1.);
0846 
0847     histoname = "Turnon_tight_Discr";
0848     title = "turn-on with tight threshold " + trigPath;
0849     v.bookME(iBooker, v.Discr_turnon_tight, histoname, title, 22, -0.1, 1.);
0850 
0851     histoname = labelname + "_PVz";
0852     title = "online z(PV) " + trigPath;
0853     v.PVz = iBooker.book1D(histoname.c_str(), title.c_str(), 80, -20, 20);
0854 
0855     histoname = labelname + "_fastPVz";
0856     title = "online z(fastPV) " + trigPath;
0857     v.fastPVz = iBooker.book1D(histoname.c_str(), title.c_str(), 80, -20, 20);
0858 
0859     histoname = "HLTMinusRECO_PVz";
0860     title = "online z(PV) - offline z(PV) " + trigPath;
0861     v.PVz_HLTMinusRECO = iBooker.book1D(histoname.c_str(), title.c_str(), 200, -0.5, 0.5);
0862 
0863     histoname = "HLTMinusRECO_fastPVz";
0864     title = "online z(fastPV) - offline z(PV) " + trigPath;
0865     v.fastPVz_HLTMinusRECO = iBooker.book1D(histoname.c_str(), title.c_str(), 100, -2, 2);
0866 
0867     histoname = "n_vtx";
0868     title = "N vertex candidates " + trigPath;
0869     v.n_vtx = iBooker.book1D(histoname.c_str(), title.c_str(), 10, -0.5, 9.5);
0870 
0871     histoname = "vtx_mass";
0872     title = "secondary vertex mass (GeV)" + trigPath;
0873     v.vtx_mass = iBooker.book1D(histoname.c_str(), title.c_str(), 20, 0, 10);
0874 
0875     histoname = "n_vtx_trks";
0876     title = "N tracks associated to secondary vertex" + trigPath;
0877     v.n_vtx_trks = iBooker.book1D(histoname.c_str(), title.c_str(), 20, -0.5, 19.5);
0878 
0879     histoname = "n_sel_tracks";
0880     title = "N selected tracks" + trigPath;
0881     v.n_sel_tracks = iBooker.book1D(histoname.c_str(), title.c_str(), 25, -0.5, 24.5);
0882 
0883     histoname = "3d_ip_distance";
0884     title = "3D IP distance of tracks (cm)" + trigPath;
0885     v.h_3d_ip_distance = iBooker.book1D(histoname.c_str(), title.c_str(), 40, -0.1, 0.1);
0886 
0887     histoname = "3d_ip_error";
0888     title = "3D IP error of tracks (cm)" + trigPath;
0889     v.h_3d_ip_error = iBooker.book1D(histoname.c_str(), title.c_str(), 40, 0., 0.1);
0890 
0891     histoname = "3d_ip_sig";
0892     title = "3D IP significance of tracks (cm)" + trigPath;
0893     v.h_3d_ip_sig = iBooker.book1D(histoname.c_str(), title.c_str(), 40, -40, 40);
0894 
0895     //new
0896     histoname = "jetNSecondaryVertices";
0897     title = "jet N Secondary Vertices" + trigPath;
0898     v.h_jetNSecondaryVertices = iBooker.book1D(histoname.c_str(), title.c_str(), 10, -0.5, 9.5);
0899 
0900     histoname = "jet_pt";
0901     title = "jet pt" + trigPath;
0902     v.h_jet_pt = iBooker.book1D(histoname.c_str(), title.c_str(), 100, -0.1, 100);
0903 
0904     histoname = "jet_eta";
0905     title = "jet eta" + trigPath;
0906     v.h_jet_eta = iBooker.book1D(histoname.c_str(), title.c_str(), 100, -2.5, 2.5);
0907 
0908     histoname = "trackSumJetEtRatio";
0909     title = "trackSumJetEtRatio" + trigPath;
0910     v.h_trackSumJetEtRatio = iBooker.book1D(histoname.c_str(), title.c_str(), 100, -0.1, 1.5);
0911 
0912     histoname = "trackSip2dValAboveCharm";
0913     title = "trackSip2dSigAboveCharm" + trigPath;
0914     v.h_trackSip2dSigAboveCharm = iBooker.book1D(histoname.c_str(), title.c_str(), 100, -0.2, 0.2);
0915 
0916     histoname = "trackSip2dSigAboveCharm";
0917     title = "trackSip2dSigAboveCharm" + trigPath;
0918     v.h_trackSip2dValAboveCharm = iBooker.book1D(histoname.c_str(), title.c_str(), 100, -50, 50);
0919 
0920     histoname = "trackSip3dValAboveCharm";
0921     title = "trackSip3dValAboveCharm" + trigPath;
0922     v.h_trackSip3dValAboveCharm = iBooker.book1D(histoname.c_str(), title.c_str(), 100, -0.2, 0.2);
0923 
0924     histoname = "trackSip3dSigAboveCharm";
0925     title = "trackSip3dSigAboveCharm" + trigPath;
0926     v.h_trackSip3dSigAboveCharm = iBooker.book1D(histoname.c_str(), title.c_str(), 100, -50, 50);
0927 
0928     histoname = "jetNSelectedTracks";
0929     title = "jet N Selected Tracks" + trigPath;
0930     v.h_jetNSelectedTracks = iBooker.book1D(histoname.c_str(), title.c_str(), 42, -1.5, 40.5);
0931 
0932     histoname = "jetNTracksEtaRel";
0933     title = "jetNTracksEtaRel" + trigPath;
0934     v.h_jetNTracksEtaRel = iBooker.book1D(histoname.c_str(), title.c_str(), 42, -1.5, 40.5);
0935 
0936     histoname = "vertexCategory";
0937     title = "vertex category" + trigPath;
0938     v.h_vertexCategory = iBooker.book1D(histoname.c_str(), title.c_str(), 4, -1.5, 2.5);
0939 
0940     histoname = "trackSumJetDeltaR";
0941     title = "trackSumJetDeltaR" + trigPath;
0942     v.h_trackSumJetDeltaR = iBooker.book1D(histoname.c_str(), title.c_str(), 100, -0.1, 0.35);
0943 
0944     //new 2 below
0945     histoname = "trackJetDistVal";
0946     title = "trackJetDistVal" + trigPath;
0947     v.h_trackJetDistVal = iBooker.book1D(histoname.c_str(), title.c_str(), 100, -1, 0.01);
0948 
0949     histoname = "trackPtRel";
0950     title = "track pt rel" + trigPath;
0951     v.h_trackPtRel = iBooker.book1D(histoname.c_str(), title.c_str(), 100, -0.1, 7);
0952 
0953     histoname = "trackDeltaR";
0954     title = "trackDeltaR" + trigPath;
0955     v.h_trackDeltaR = iBooker.book1D(histoname.c_str(), title.c_str(), 160, -0.05, .47);
0956 
0957     histoname = "trackPtRatio";
0958     title = "trackPtRatio" + trigPath;
0959     v.h_trackPtRatio = iBooker.book1D(histoname.c_str(), title.c_str(), 100, -0.01, 0.3);
0960 
0961     histoname = "trackSip2dSig";
0962     title = "trackSip2dSig" + trigPath;
0963     v.h_trackSip2dSig = iBooker.book1D(histoname.c_str(), title.c_str(), 100, -55, 55);
0964 
0965     histoname = "trackDecayLenVal";
0966     title = "trackDecayLenVal" + trigPath;
0967     v.h_trackDecayLenVal = iBooker.book1D(histoname.c_str(), title.c_str(), 100, -0.1, 22);
0968 
0969     histoname = "trackEtaRel";
0970     title = "trackEtaRel" + trigPath;
0971     v.h_trackEtaRel = iBooker.book1D(histoname.c_str(), title.c_str(), 31, 0, 30);
0972 
0973     //new 3 below
0974     histoname = "vertexEnergyRatio";
0975     title = "vertexEnergyRatio" + trigPath;
0976     v.h_vertexEnergyRatio = iBooker.book1D(histoname.c_str(), title.c_str(), 100, -0.1, 3);
0977 
0978     histoname = "vertexJetDeltaR";
0979     title = "vertexJetDeltaR" + trigPath;
0980     v.h_vertexJetDeltaR = iBooker.book1D(histoname.c_str(), title.c_str(), 100, -0.01, 0.4);
0981 
0982     histoname = "flightDistance2dVal";
0983     title = "flightDistance2dVal" + trigPath;
0984     v.h_flightDistance2dVal = iBooker.book1D(histoname.c_str(), title.c_str(), 100, -0.1, 5);
0985 
0986     histoname = "flightDistance2dSig";
0987     title = "flightDistance2dSig" + trigPath;
0988     v.h_flightDistance2dSig = iBooker.book1D(histoname.c_str(), title.c_str(), 100, -10, 150);
0989 
0990     histoname = "flightDistance3dVal";
0991     title = "flightDistance3dVal" + trigPath;
0992     v.h_flightDistance3dVal = iBooker.book1D(histoname.c_str(), title.c_str(), 100, -0.1, 5);
0993 
0994     histoname = "flightDistance3dSig";
0995     title = "flightDistance3dSig" + trigPath;
0996     v.h_flightDistance3dSig = iBooker.book1D(histoname.c_str(), title.c_str(), 100, -10, 150);
0997 
0998     //end new
0999 
1000     histoname = "OnlineTrkEff_Pt";
1001     title = "Relative Online Trk Efficiency vs Pt " + trigPath;
1002     v.bookME(iBooker, v.OnlineTrkEff_Pt, histoname, title, 50, -0.5, 20.);
1003 
1004     histoname = "OnlineTrkEff_Eta";
1005     title = "Relative Online Trk Efficiency vs Eta " + trigPath;
1006     v.bookME(iBooker, v.OnlineTrkEff_Eta, histoname, title, 60, -3.0, 3.0);
1007 
1008     histoname = "OnlineTrkEff_3d_ip_distance";
1009     title = "Relative Online Trk Efficiency vs IP3D " + trigPath;
1010     v.bookME(iBooker, v.OnlineTrkEff_3d_ip_distance, histoname, title, 40, -0.1, 0.1);
1011 
1012     histoname = "OnlineTrkEff_3d_ip_sig";
1013     title = "Relative Online Trk Efficiency vs IP3D significance " + trigPath;
1014     v.bookME(iBooker, v.OnlineTrkEff_3d_ip_sig, histoname, title, 40, -40, 40);
1015 
1016     histoname = "OnlineTrkFake_Pt";
1017     title = "Relative Online Trk Fake Rate  vs Pt " + trigPath;
1018     v.bookME(iBooker, v.OnlineTrkFake_Pt, histoname, title, 50, -0.5, 20.);
1019 
1020     histoname = "OnlineTrkFake_Eta";
1021     title = "Relative Online Trk Fake Rate vs Eta " + trigPath;
1022     v.bookME(iBooker, v.OnlineTrkFake_Eta, histoname, title, 60, -3.0, 3.0);
1023 
1024     histoname = "OnlineTrkFake_3d_ip_distance";
1025     title = "Relative Online Trk Fake Rate vs IP3D " + trigPath;
1026     v.bookME(iBooker, v.OnlineTrkFake_3d_ip_distance, histoname, title, 40, -0.1, 0.1);
1027 
1028     histoname = "OnlineTrkFake_3d_ip_sig";
1029     title = "Relative Online Trk Fake Rate vs IP3D significance " + trigPath;
1030     v.bookME(iBooker, v.OnlineTrkFake_3d_ip_sig, histoname, title, 40, -40, 40);
1031 
1032     // histoname = "n_pixel_hits";
1033     // title = "N pixel hits"+trigPath;
1034     // v.n_pixel_hits = iBooker.book1D(histoname.c_str(), title.c_str(), 16, -0.5, 15.5);
1035 
1036     // histoname = "n_total_hits";
1037     // title = "N hits"+trigPath;
1038     // v.n_total_hits = iBooker.book1D(histoname.c_str(), title.c_str(), 40, -0.5, 39.5);
1039   }
1040 }
1041 
1042 // Define this as a plug-in
1043 DEFINE_FWK_MODULE(BTVHLTOfflineSource);