18 template <
typename T1,
typename T2>
26 m_digiMaxDistanceX(iConfig.getParameter<double>(
"digiMaxDistanceX")) {
27 std::vector<edm::InputTag> inCollections = iConfig.
getParameter<std::vector<edm::InputTag>>(
"oldCollection");
28 for (
const auto &inCollection : inCollections) {
29 inputs_[inCollection.instance()] = consumes<RecHitCollection>(inCollection);
30 produces<RecHitCollection>(inCollection.instance());
37 template <
typename T1,
typename T2>
42 template <
typename T1,
typename T2>
45 m_dtGeometry = iSetup.
getHandle(m_dtGeometryToken);
46 m_cscGeometry = iSetup.
getHandle(m_cscGeometryToken);
49 template <
typename T1,
typename T2>
51 std::map<T1, std::vector<T2>> recHits_output;
52 std::vector<uint32_t> vetoHits;
56 iEvent.getByToken(mu_input_, muonHandle);
60 if (iMuon->isGlobalMuon())
61 track = iMuon->outerTrack().get();
62 else if (iMuon->isStandAloneMuon())
63 track = iMuon->outerTrack().get();
64 else if (iMuon->isRPCMuon())
65 track = iMuon->innerTrack().get();
66 else if (iMuon->isTrackerMuon())
67 track = iMuon->innerTrack().get();
69 edm::LogError(
"TauEmbedding") <<
"The imput muon: " << (*iMuon)
70 <<
" must be either global or does or be tracker muon";
76 if (!(murechit).isValid())
78 if (!checkrecHit(murechit))
80 fillVetoHits(murechit, &vetoHits);
83 sort(vetoHits.begin(), vetoHits.end());
84 vetoHits.erase(
unique(vetoHits.begin(), vetoHits.end()), vetoHits.end());
85 iEvent.getByToken(m_dtDigisToken, m_dtDigis);
86 iEvent.getByToken(m_cscDigisToken, m_cscDigis);
88 trackAssociator_.setPropagator(&iSetup.
getData(propagatorToken_));
100 const auto &lErr =
chamber.tState.localError();
101 const auto &lPos =
chamber.tState.localPosition();
102 const auto &lDir =
chamber.tState.localDirection();
103 const auto &localError = lErr.positionError();
105 matchedChamber.
x = lPos.x();
106 matchedChamber.
y = lPos.y();
107 matchedChamber.
xErr =
sqrt(localError.xx());
108 matchedChamber.
yErr =
sqrt(localError.yy());
109 matchedChamber.
dXdZ = lDir.z() != 0 ? lDir.x() / lDir.z() : 9999;
110 matchedChamber.
dYdZ = lDir.z() != 0 ? lDir.y() / lDir.z() : 9999;
114 matchedChamber.
dXdZErr = trajectoryCovMatrix(1, 1) > 0 ?
sqrt(trajectoryCovMatrix(1, 1)) : 0;
115 matchedChamber.
dYdZErr = trajectoryCovMatrix(2, 2) > 0 ?
sqrt(trajectoryCovMatrix(2, 2)) : 0;
124 double xTrack = matchedChamber.
x;
129 auto range = m_dtDigis->get(layerId);
131 for (
auto digiIt =
range.first; digiIt !=
range.second; ++digiIt) {
132 const auto topo = m_dtGeometry->layer(layerId)->specificTopology();
133 double xWire = topo.wirePosition((*digiIt).wire());
136 if (
dX < m_digiMaxDistanceX) {
137 vetoHits.push_back(matchedChamber.
id.
rawId());
145 double xTrack = matchedChamber.
x;
146 double yTrack = matchedChamber.
y;
150 const CSCDetId layerId(chId.endcap(), chId.station(), chId.ring(), chId.chamber(), iLayer);
151 auto range = m_cscDigis->get(layerId);
153 for (
auto digiIt =
range.first; digiIt !=
range.second; ++digiIt) {
154 std::vector<int> adcVals = digiIt->getADCCounts();
155 bool hasFired =
false;
159 for (
const auto &adcVal : adcVals) {
170 const CSCLayerGeometry *layerGeom = m_cscGeometry->layer(layerId)->geometry();
171 Float_t xStrip = layerGeom->
xOfStrip(digiIt->getStrip(), yTrack);
174 if (
dX < m_digiMaxDistanceX) {
175 vetoHits.push_back(matchedChamber.
id.
rawId());
185 sort(vetoHits.begin(), vetoHits.end());
186 vetoHits.erase(
unique(vetoHits.begin(), vetoHits.end()), vetoHits.end());
189 for (
auto input_ : inputs_) {
192 RecHitCollectionHandle RecHitinput;
193 iEvent.getByToken(input_.second, RecHitinput);
196 if (
find(vetoHits.begin(), vetoHits.end(), getRawDetId(*
recHit)) != vetoHits.end())
204 for (
typename std::map<T1, std::vector<T2>>::const_iterator
recHit = recHits_output.begin();
205 recHit != recHits_output.end();
214 template <
typename T1,
typename T2>
216 std::vector<const TrackingRecHit *> rh_components = rh.
recHits();
217 if (rh_components.empty()) {
218 HitsList->push_back(rh.
rawId());
220 for (std::vector<const TrackingRecHit *>::const_iterator rh_component = rh_components.begin();
221 rh_component != rh_components.end();
223 fillVetoHits(**rh_component, HitsList);
232 template <
typename T1,
typename T2>
240 return recHit.cscDetId().rawId();
245 return recHit.geographicalId().rawId();
250 return recHit.rpcId().rawId();
257 template <
typename T1,
typename T2>
259 edm::LogError(
"TauEmbedding") <<
"!!!! Please add the checkrecHit for the individual class templates " assert(0);
264 const std::type_info &hit_type =
typeid(
recHit);
276 return recHit.cscDetId().rawId();
281 return recHit.geographicalId().rawId();
286 const std::type_info &hit_type =
typeid(
recHit);
302 const std::type_info &hit_type =
typeid(
recHit);
311 const std::type_info &hit_type =
typeid(
recHit);
320 const std::type_info &hit_type =
typeid(
recHit);
MuonDetCleaner< CSCDetId, CSCSegment > CSCSegmentColCleaner
MuonDetCleaner< DTChamberId, DTRecSegment4D > DTRecSegment4DColCleaner
T getParameter(std::string const &) const
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
uint32_t getRawDetId(const T2 &)
void loadParameters(const edm::ParameterSet &, edm::ConsumesCollector &)
MuonDetCleaner< CSCDetId, CSCRecHit2D > CSCRecHitColCleaner
bool checkrecHit(const TrackingRecHit &)
~MuonDetCleaner() override
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
void beginRun(const edm::Run &, const edm::EventSetup &) override
C::const_iterator const_iterator
constant access iterator type
TrackAssociatorParameters parameters_
static const int maxLayerId
highest layer id
def unique(seq, keepstr=True)
virtual std::vector< const TrackingRecHit * > recHits() const =0
Access to component RecHits (if any)
Abs< T >::type abs(const T &t)
void produce(edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
static const int maxSuperLayerId
highest superlayer id
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
float dX(const MatchPair &match)
constexpr uint32_t rawId() const
get the raw id
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
MuonDetCleaner(const edm::ParameterSet &)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
MuonDetCleaner< RPCDetId, RPCRecHit > RPCRecHitColCleaner
void fillVetoHits(const TrackingRecHit &, std::vector< uint32_t > *)
MuonDetCleaner< DTLayerId, DTRecHit1DPair > DTRecHitColCleaner
float xOfStrip(int strip, float y=0.) const
std::map< std::string, edm::EDGetTokenT< RecHitCollection > > inputs_