CMS 3D CMS Logo

TrackerCleaner.cc
Go to the documentation of this file.
2 
7 
10 
13 
14 template <typename T>
16  : mu_input_(consumes<edm::View<pat::Muon>>(iConfig.getParameter<edm::InputTag>("MuonCollection")))
17 
18 {
19  std::vector<edm::InputTag> inCollections = iConfig.getParameter<std::vector<edm::InputTag>>("oldCollection");
20  for (const auto &inCollection : inCollections) {
21  inputs_[inCollection.instance()] = consumes<TrackClusterCollection>(inCollection);
22  produces<TrackClusterCollection>(inCollection.instance());
23  }
24 }
25 
26 template <typename T>
28  // nothing to be done yet...
29 }
30 
31 template <typename T>
33  using namespace edm;
34 
36  iEvent.getByToken(mu_input_, muonHandle);
37  edm::View<pat::Muon> muons = *muonHandle;
38 
39  for (auto input_ : inputs_) {
41  iEvent.getByToken(input_.second, inputClusters);
42 
43  std::vector<bool> vetodClusters;
44 
45  vetodClusters.resize(inputClusters->dataSize(), false);
46 
47  for (edm::View<pat::Muon>::const_iterator iMuon = muons.begin(); iMuon != muons.end(); ++iMuon) {
48  if (!iMuon->isGlobalMuon())
49  continue;
50  const reco::Track *mutrack = iMuon->globalTrack().get();
51  for (trackingRecHit_iterator hitIt = mutrack->recHitsBegin(); hitIt != mutrack->recHitsEnd(); ++hitIt) {
52  const TrackingRecHit &murechit = **hitIt;
53  if (!(murechit).isValid())
54  continue;
55 
56  if (match_rechit_type(murechit)) {
57  auto &thit = reinterpret_cast<BaseTrackerRecHit const &>(murechit);
58  auto const &cluster = thit.firstClusterRef();
59  vetodClusters[cluster.key()] = true;
60  }
61  auto &thit = reinterpret_cast<BaseTrackerRecHit const &>(murechit);
62  if (trackerHitRTTI::isMatched(thit)) {
63  vetodClusters[reinterpret_cast<SiStripMatchedRecHit2D const &>(murechit).stereoClusterRef().key()] = true;
64  }
65  }
66  }
67  std::unique_ptr<TrackClusterCollection> output(new TrackClusterCollection());
68 
69  int idx = 0;
70  for (typename TrackClusterCollection::const_iterator clustSet = inputClusters->begin();
71  clustSet != inputClusters->end();
72  ++clustSet) {
73  DetId detIdObject(clustSet->detId());
74  typename TrackClusterCollection::FastFiller spc(*output, detIdObject);
75  for (typename edmNew::DetSet<T>::const_iterator clustIt = clustSet->begin(); clustIt != clustSet->end();
76  ++clustIt) {
77  idx++;
78  if (vetodClusters[idx - 1])
79  continue;
80  spc.push_back(*clustIt);
81  }
82  }
83  iEvent.put(std::move(output), input_.first);
84  }
85 }
86 
87 //-------------------------------------------------------------------------------
88 // define 'buildRecHit' functions used for different types of recHits
89 //-------------------------------------------------------------------------------
90 
91 template <typename T>
93  assert(0); // CV: make sure general function never gets called;
94  // always use template specializations
95  return false;
96 }
97 
98 template <>
100  const std::type_info &hit_type = typeid(murechit);
101  if (hit_type == typeid(SiStripRecHit2D))
102  return true;
103  else if (hit_type == typeid(SiStripRecHit1D))
104  return true;
105  else if (hit_type == typeid(SiStripMatchedRecHit2D))
106  return true;
107  else if (hit_type == typeid(ProjectedSiStripRecHit2D))
108  return true;
109 
110  return false;
111 }
112 
113 template <>
115  const std::type_info &hit_type = typeid(murechit);
116  if (hit_type == typeid(SiPixelRecHit))
117  return true;
118 
119  return false;
120 }
121 
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
TrackerCleaner< SiPixelCluster > PixelColCleaner
data_type const * const_iterator
Definition: DetSetNew.h:31
TrackerCleaner(const edm::ParameterSet &)
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
assert(be >=bs)
void produce(edm::Event &, const edm::EventSetup &) override
~TrackerCleaner() override
Definition: HeavyIon.h:7
int iEvent
Definition: GenABIO.cc:224
Definition: Muon.py:1
TrackerCleaner< SiStripCluster > StripColCleaner
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:91
bool isMatched(TrackingRecHit const &hit)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:88
std::map< std::string, edm::EDGetTokenT< TrackClusterCollection > > inputs_
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
Definition: DetId.h:17
virtual OmniClusterRef const & firstClusterRef() const =0
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:88
Definition: output.py:1
bool match_rechit_type(const TrackingRecHit &murechit)
def move(src, dest)
Definition: eostools.py:511
Our base class.
Definition: SiPixelRecHit.h:23