Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:48

0001 #include "Alignment/CommonAlignmentProducer/interface/AlignmentCSCTrackSelector.h"
0002 
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 
0006 #include "FWCore/Framework/interface/Event.h"
0007 
0008 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
0009 #include "DataFormats/TrackReco/interface/Track.h"
0010 #include "DataFormats/DetId/interface/DetId.h"
0011 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0012 
0013 // constructor ----------------------------------------------------------------
0014 
0015 AlignmentCSCTrackSelector::AlignmentCSCTrackSelector(const edm::ParameterSet& cfg)
0016     : m_src(cfg.getParameter<edm::InputTag>("src")),
0017       m_stationA(cfg.getParameter<int>("stationA")),
0018       m_stationB(cfg.getParameter<int>("stationB")),
0019       m_minHitsDT(cfg.getParameter<int>("minHitsDT")),
0020       m_minHitsPerStation(cfg.getParameter<int>("minHitsPerStation")),
0021       m_maxHitsPerStation(cfg.getParameter<int>("maxHitsPerStation")) {}
0022 
0023 // destructor -----------------------------------------------------------------
0024 
0025 AlignmentCSCTrackSelector::~AlignmentCSCTrackSelector() {}
0026 
0027 // do selection ---------------------------------------------------------------
0028 
0029 AlignmentCSCTrackSelector::Tracks AlignmentCSCTrackSelector::select(const Tracks& tracks, const edm::Event& evt) const {
0030   Tracks result;
0031 
0032   for (auto const& track : tracks) {
0033     int hitsOnStationA = 0;
0034     int hitsOnStationB = 0;
0035 
0036     for (auto const& hit : track->recHits()) {
0037       DetId id = hit->geographicalId();
0038 
0039       if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::DT) {
0040         if (m_stationA == 0)
0041           hitsOnStationA++;
0042         if (m_stationB == 0)
0043           hitsOnStationB++;
0044       } else if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::CSC) {
0045         CSCDetId cscid(id.rawId());
0046         int station = (cscid.endcap() == 1 ? 1 : -1) * cscid.station();
0047 
0048         if (station == m_stationA)
0049           hitsOnStationA++;
0050         if (station == m_stationB)
0051           hitsOnStationB++;
0052 
0053       }  // end if CSC
0054     }    // end loop over hits
0055 
0056     bool stationAokay;
0057     if (m_stationA == 0)
0058       stationAokay = (m_minHitsDT <= hitsOnStationA);
0059     else
0060       stationAokay = (m_minHitsPerStation <= hitsOnStationA && hitsOnStationA <= m_maxHitsPerStation);
0061 
0062     bool stationBokay;
0063     if (m_stationB == 0)
0064       stationBokay = (m_minHitsDT <= hitsOnStationB);
0065     else
0066       stationBokay = (m_minHitsPerStation <= hitsOnStationB && hitsOnStationB <= m_maxHitsPerStation);
0067 
0068     if (stationAokay && stationBokay) {
0069       result.push_back(track);
0070     }
0071   }  // end loop over tracks
0072 
0073   return result;
0074 }