File indexing completed on 2024-09-07 04:34:29
0001 #include "Alignment/CommonAlignmentProducer/interface/AlignmentCSCOverlapSelector.h"
0002
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005
0006 #include "DataFormats/DetId/interface/DetId.h"
0007 #include "DataFormats/MuonDetId/interface/MuonSubdetId.h"
0008 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0009 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
0010 #include "DataFormats/TrackingRecHit/interface/TrackingRecHitFwd.h"
0011
0012
0013
0014 AlignmentCSCOverlapSelector::AlignmentCSCOverlapSelector(const edm::ParameterSet &iConfig)
0015 : m_station(iConfig.getParameter<int>("station")),
0016 m_minHitsPerChamber(iConfig.getParameter<unsigned int>("minHitsPerChamber")) {
0017 if (m_station == 0) {
0018 edm::LogInfo("AlignmentCSCOverlapSelector")
0019 << "Acceptable tracks must have " << m_minHitsPerChamber << " in two chambers on all stations." << std::endl;
0020 } else {
0021 edm::LogInfo("AlignmentCSCOverlapSelector") << "Acceptable tracks must have " << m_minHitsPerChamber
0022 << " in two chambers on station " << m_station << "." << std::endl;
0023 }
0024 }
0025
0026
0027
0028 AlignmentCSCOverlapSelector::~AlignmentCSCOverlapSelector() {}
0029
0030
0031
0032 AlignmentCSCOverlapSelector::Tracks AlignmentCSCOverlapSelector::select(const Tracks &tracks,
0033 const edm::Event &iEvent) const {
0034 Tracks result;
0035
0036 for (auto const &track : tracks) {
0037 unsigned int MEminus4_even = 0;
0038 unsigned int MEminus4_odd = 0;
0039 unsigned int MEminus3_even = 0;
0040 unsigned int MEminus3_odd = 0;
0041 unsigned int MEminus2_even = 0;
0042 unsigned int MEminus2_odd = 0;
0043 unsigned int MEminus1_even = 0;
0044 unsigned int MEminus1_odd = 0;
0045
0046 unsigned int MEplus1_even = 0;
0047 unsigned int MEplus1_odd = 0;
0048 unsigned int MEplus2_even = 0;
0049 unsigned int MEplus2_odd = 0;
0050 unsigned int MEplus3_even = 0;
0051 unsigned int MEplus3_odd = 0;
0052 unsigned int MEplus4_even = 0;
0053 unsigned int MEplus4_odd = 0;
0054
0055 for (auto const &hit : track->recHits()) {
0056 DetId id = hit->geographicalId();
0057 if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::CSC) {
0058 CSCDetId cscid(id.rawId());
0059 int station = (cscid.endcap() == 1 ? 1 : -1) * cscid.station();
0060
0061 if (station == -4) {
0062 if (cscid.chamber() % 2 == 0)
0063 MEminus4_even++;
0064 else
0065 MEminus4_odd++;
0066 } else if (station == -3) {
0067 if (cscid.chamber() % 2 == 0)
0068 MEminus3_even++;
0069 else
0070 MEminus3_odd++;
0071 } else if (station == -2) {
0072 if (cscid.chamber() % 2 == 0)
0073 MEminus2_even++;
0074 else
0075 MEminus2_odd++;
0076 } else if (station == -1) {
0077 if (cscid.chamber() % 2 == 0)
0078 MEminus1_even++;
0079 else
0080 MEminus1_odd++;
0081 }
0082
0083 else if (station == 1) {
0084 if (cscid.chamber() % 2 == 0)
0085 MEplus1_even++;
0086 else
0087 MEplus1_odd++;
0088 } else if (station == 2) {
0089 if (cscid.chamber() % 2 == 0)
0090 MEplus2_even++;
0091 else
0092 MEplus2_odd++;
0093 } else if (station == 3) {
0094 if (cscid.chamber() % 2 == 0)
0095 MEplus3_even++;
0096 else
0097 MEplus3_odd++;
0098 } else if (station == 4) {
0099 if (cscid.chamber() % 2 == 0)
0100 MEplus4_even++;
0101 else
0102 MEplus4_odd++;
0103 }
0104
0105 }
0106 }
0107
0108 if ((m_station == 0 || m_station == -4) && (MEminus4_even >= m_minHitsPerChamber) &&
0109 (MEminus4_odd >= m_minHitsPerChamber))
0110 result.push_back(track);
0111
0112 else if ((m_station == 0 || m_station == -3) && (MEminus3_even >= m_minHitsPerChamber) &&
0113 (MEminus3_odd >= m_minHitsPerChamber))
0114 result.push_back(track);
0115
0116 else if ((m_station == 0 || m_station == -2) && (MEminus2_even >= m_minHitsPerChamber) &&
0117 (MEminus2_odd >= m_minHitsPerChamber))
0118 result.push_back(track);
0119
0120 else if ((m_station == 0 || m_station == -1) && (MEminus1_even >= m_minHitsPerChamber) &&
0121 (MEminus1_odd >= m_minHitsPerChamber))
0122 result.push_back(track);
0123
0124 else if ((m_station == 0 || m_station == 1) && (MEplus1_even >= m_minHitsPerChamber) &&
0125 (MEplus1_odd >= m_minHitsPerChamber))
0126 result.push_back(track);
0127
0128 else if ((m_station == 0 || m_station == 2) && (MEplus2_even >= m_minHitsPerChamber) &&
0129 (MEplus2_odd >= m_minHitsPerChamber))
0130 result.push_back(track);
0131
0132 else if ((m_station == 0 || m_station == 3) && (MEplus3_even >= m_minHitsPerChamber) &&
0133 (MEplus3_odd >= m_minHitsPerChamber))
0134 result.push_back(track);
0135
0136 else if ((m_station == 0 || m_station == 4) && (MEplus4_even >= m_minHitsPerChamber) &&
0137 (MEplus4_odd >= m_minHitsPerChamber))
0138 result.push_back(track);
0139
0140 }
0141
0142 return result;
0143 }