CMS 3D CMS Logo

FastTrackerRecHitMaskProducer.cc
Go to the documentation of this file.
1 // system includes
2 #include <memory>
3 
4 // framework stuff
11 
12 // data formats
18 
19 // other
21 
23 public:
25 
27 
28  void produce(edm::Event&, const edm::EventSetup&) override;
29 
30 private:
31  // an alias
32  using QualityMaskCollection = std::vector<unsigned char>;
33 
34  // tokens
37 
40 
42 
44 };
45 
47  : minNumberOfLayersWithMeasBeforeFiltering_(iConfig.getParameter<int>("minNumberOfLayersWithMeasBeforeFiltering")),
48  trackQuality_(reco::TrackBase::qualityByName(iConfig.getParameter<std::string>("TrackQuality"))),
49  trajectories_(iConfig.getParameter<edm::InputTag>("trajectories"), consumesCollector()),
50  recHits_(consumes<FastTrackerRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHits"))) {
51  produces<std::vector<bool> >();
52 
53  auto const& classifier = iConfig.getParameter<edm::InputTag>("trackClassifier");
54  if (!classifier.label().empty())
55  srcQuals = consumes<QualityMaskCollection>(classifier);
56 
57  auto const& oldHitRemovalInfo = iConfig.getParameter<edm::InputTag>("oldHitRemovalInfo");
58  if (!oldHitRemovalInfo.label().empty()) {
59  oldHitMaskToken_ = consumes<std::vector<bool> >(oldHitRemovalInfo);
60  }
61 }
62 
64  // the product
65 
66  std::unique_ptr<std::vector<bool> > collectedHits(new std::vector<bool>());
67 
68  // input
69 
71  iEvent.getByToken(recHits_, recHits);
72 
74  edm::Handle<std::vector<bool> > oldHitMasks;
75  iEvent.getByToken(oldHitMaskToken_, oldHitMasks);
76  collectedHits->insert(collectedHits->begin(), oldHitMasks->begin(), oldHitMasks->end());
77  }
78  collectedHits->resize(recHits->size(), false);
79 
80  auto const& tracks = trajectories_.tracks(iEvent);
81 
82  QualityMaskCollection const* pquals = nullptr;
83  if (!srcQuals.isUninitialized()) {
85  iEvent.getByToken(srcQuals, hqual);
86  pquals = hqual.product();
87  }
88 
89  // required quality
90  unsigned char qualMask = ~0;
92  qualMask = 1 << trackQuality_;
93 
94  // loop over tracks and mask hits of selected tracks
95  for (auto i = 0U; i < tracks.size(); ++i) {
96  const reco::Track& track = tracks[i];
97  bool goodTk = (pquals) ? (*pquals)[i] & qualMask : track.quality(trackQuality_);
98  if (!goodTk)
99  continue;
100  if (track.hitPattern().trackerLayersWithMeasurement() < minNumberOfLayersWithMeasBeforeFiltering_)
101  continue;
102  for (auto hitIt = track.recHitsBegin(); hitIt != track.recHitsEnd(); ++hitIt) {
103  if (!(*hitIt)->isValid())
104  continue;
105  const FastTrackerRecHit& hit = static_cast<const FastTrackerRecHit&>(*(*hitIt));
106  // note: for matched hits nIds() returns 2, otherwise 1
107  for (unsigned id_index = 0; id_index < hit.nIds(); id_index++) {
108  (*collectedHits)[unsigned(hit.id(id_index))] = true;
109  }
110  }
111  }
112 
113  iEvent.put(std::move(collectedHits));
114 }
115 
TrackCollectionTokens
Definition: TrackCollectionTokens.h:13
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
mps_fire.i
i
Definition: mps_fire.py:428
FastTrackerRecHitMaskProducer::minNumberOfLayersWithMeasBeforeFiltering_
const int minNumberOfLayersWithMeasBeforeFiltering_
Definition: FastTrackerRecHitMaskProducer.cc:35
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
hit::id
unsigned int id
Definition: SiStripHitEffFromCalibTree.cc:92
edm::Handle::product
T const * product() const
Definition: Handle.h:70
ESHandle.h
edm::EDGetTokenT< QualityMaskCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
reco::TrackBase::undefQuality
Definition: TrackBase.h:151
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
FastTrackerRecHitMaskProducer::QualityMaskCollection
std::vector< unsigned char > QualityMaskCollection
Definition: FastTrackerRecHitMaskProducer.cc:32
edm::EDGetTokenT::isUninitialized
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
reco::TrackBase::TrackQuality
TrackQuality
track quality
Definition: TrackBase.h:150
EDProducer.h
FastTrackerRecHitMaskProducer_cfi.minNumberOfLayersWithMeasBeforeFiltering_
minNumberOfLayersWithMeasBeforeFiltering_
Definition: FastTrackerRecHitMaskProducer_cfi.py:5
FastTrackerRecHit
Definition: FastTrackerRecHit.h:40
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
FastTrackerRecHitMaskProducer::FastTrackerRecHitMaskProducer
FastTrackerRecHitMaskProducer(const edm::ParameterSet &)
Definition: FastTrackerRecHitMaskProducer.cc:46
MakerMacros.h
Track.h
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
reco::Track
Definition: Track.h:27
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
FastTrackerRecHitMaskProducer
Definition: FastTrackerRecHitMaskProducer.cc:22
MixedTripletStep_cff.oldHitRemovalInfo
oldHitRemovalInfo
Definition: MixedTripletStep_cff.py:484
edm::ParameterSet
Definition: ParameterSet.h:47
FastTrackerRecHitMaskProducer::srcQuals
edm::EDGetTokenT< QualityMaskCollection > srcQuals
Definition: FastTrackerRecHitMaskProducer.cc:39
Event.h
TrackCollectionTokens::tracks
reco::TrackCollection const & tracks(edm::Event &evt) const
Definition: TrackCollectionTokens.h:26
FastTrackerRecHitMaskProducer::~FastTrackerRecHitMaskProducer
~FastTrackerRecHitMaskProducer() override
Definition: FastTrackerRecHitMaskProducer.cc:26
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:57
FastTrackerRecHitCollection.h
FastTrackerRecHitMaskProducer::trackQuality_
const reco::TrackBase::TrackQuality trackQuality_
Definition: FastTrackerRecHitMaskProducer.cc:36
FastTrackerRecHitMaskProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: FastTrackerRecHitMaskProducer.cc:63
ValueMap.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
TrackCollectionTokens.h
Frameworkfwd.h
FastTrackerRecHitMaskProducer::oldHitMaskToken_
edm::EDGetTokenT< std::vector< bool > > oldHitMaskToken_
Definition: FastTrackerRecHitMaskProducer.cc:43
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
FastTrackerRecHitMaskProducer::trajectories_
const TrackCollectionTokens trajectories_
Definition: FastTrackerRecHitMaskProducer.cc:38
FastTrackerRecHit.h
ParameterSet.h
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
FastTrackerRecHitMaskProducer::recHits_
edm::EDGetTokenT< FastTrackerRecHitCollection > recHits_
Definition: FastTrackerRecHitMaskProducer.cc:41
hit
Definition: SiStripHitEffFromCalibTree.cc:88
edm::OwnVector
Definition: OwnVector.h:24