Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-22 06:26:40

0001 // -*- C++ -*-
0002 //
0003 // Package:    MuonAlignmentPreFilter
0004 // Class:      MuonAlignmentPreFilter
0005 //
0006 /**\class MuonAlignmentPreFilter
0007 
0008  Description: pre-select events that are worth considering in muon alignment 
0009 
0010  $Id:$
0011 */
0012 
0013 #include <memory>
0014 
0015 #include "FWCore/Framework/interface/Frameworkfwd.h"
0016 #include "FWCore/Framework/interface/stream/EDFilter.h"
0017 #include "FWCore/Framework/interface/Event.h"
0018 #include "FWCore/Framework/interface/MakerMacros.h"
0019 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0020 #include "FWCore/Framework/interface/ESHandle.h"
0021 #include "FWCore/Utilities/interface/InputTag.h"
0022 
0023 #include "DataFormats/TrackReco/interface/Track.h"
0024 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0025 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
0026 #include "DataFormats/TrackingRecHit/interface/TrackingRecHitFwd.h"
0027 #include "DataFormats/DetId/interface/DetId.h"
0028 #include "DataFormats/MuonDetId/interface/MuonSubdetId.h"
0029 
0030 class MuonAlignmentPreFilter : public edm::stream::EDFilter<> {
0031 public:
0032   explicit MuonAlignmentPreFilter(const edm::ParameterSet&);
0033   ~MuonAlignmentPreFilter() override = default;
0034 
0035 private:
0036   bool filter(edm::Event&, const edm::EventSetup&) override;
0037 
0038   // ----------member data ---------------------------
0039   const edm::InputTag m_tracksTag;
0040   const double m_minTrackPt;
0041   const double m_minTrackP;
0042   const bool m_allowTIDTEC;
0043   const int m_minTrackerHits;
0044   const int m_minDTHits;
0045   const int m_minCSCHits;
0046   const double m_minTrackEta;
0047   const double m_maxTrackEta;
0048 };
0049 
0050 MuonAlignmentPreFilter::MuonAlignmentPreFilter(const edm::ParameterSet& cfg)
0051     : m_tracksTag(cfg.getParameter<edm::InputTag>("tracksTag")),
0052       m_minTrackPt(cfg.getParameter<double>("minTrackPt")),
0053       m_minTrackP(cfg.getParameter<double>("minTrackP")),
0054       m_allowTIDTEC(cfg.getParameter<bool>("allowTIDTEC")),
0055       m_minTrackerHits(cfg.getParameter<int>("minTrackerHits")),
0056       m_minDTHits(cfg.getParameter<int>("minDTHits")),
0057       m_minCSCHits(cfg.getParameter<int>("minCSCHits")),
0058       m_minTrackEta(cfg.getParameter<double>("minTrackEta")),
0059       m_maxTrackEta(cfg.getParameter<double>("maxTrackEta")) {}
0060 
0061 bool MuonAlignmentPreFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0062   edm::Handle<reco::TrackCollection> trackColl;
0063   iEvent.getByLabel(m_tracksTag, trackColl);
0064 
0065   // check if there's at least one interesting track:
0066 
0067   for (reco::TrackCollection::const_iterator it = trackColl->begin(); it != trackColl->end(); it++) {
0068     int tracker_numHits = 0;
0069     bool contains_TIDTEC = false;
0070     int dt_numHits = 0;
0071     int csc_numHits = 0;
0072 
0073     const reco::Track* track = &(*it);
0074 
0075     if (track->pt() < m_minTrackPt || track->p() < m_minTrackP)
0076       continue;
0077     if (track->eta() < m_minTrackEta || track->eta() > m_maxTrackEta)
0078       continue;
0079 
0080     for (auto const& hit : track->recHits()) {
0081       DetId id = hit->geographicalId();
0082       if (id.det() == DetId::Tracker) {
0083         tracker_numHits++;
0084         if (id.subdetId() == StripSubdetector::TID || id.subdetId() == StripSubdetector::TEC)
0085           contains_TIDTEC = true;
0086       }
0087 
0088       if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::DT)
0089         dt_numHits++;
0090       if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::CSC)
0091         csc_numHits++;
0092     }
0093 
0094     if ((m_allowTIDTEC || !contains_TIDTEC) && m_minTrackerHits <= tracker_numHits &&
0095         (m_minDTHits <= dt_numHits || m_minCSCHits <= csc_numHits))
0096       return true;
0097   }
0098   return false;
0099 }
0100 
0101 //define this as a plug-in
0102 DEFINE_FWK_MODULE(MuonAlignmentPreFilter);