Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-08 23:51:42

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