CMS 3D CMS Logo

SeedClusterRemoverPhase2.cc
Go to the documentation of this file.
7 
10 
15 
22 
25 
30 
31 //
32 // class decleration
33 //
34 
36 public:
38  void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override;
39 
40 private:
42  bool mergeOld_;
50 
51  std::vector<uint8_t> pixels, OTs; // avoid unneed alloc/dealloc of this
52  edm::ProductID pixelSourceProdID, outerTrackerSourceProdID; // ProdIDs refs must point to (for consistency tests)
53 
54  inline void process(const TrackingRecHit *hit, float chi2, const TrackerGeometry *tg);
55 
56  std::vector<bool> collectedOuterTrackers_;
57  std::vector<bool> collectedPixels_;
58 };
59 
60 using namespace std;
61 using namespace edm;
62 
64  : doOuterTracker_(iConfig.existsAs<bool>("doOuterTracker") ? iConfig.getParameter<bool>("doOuterTracker") : true),
65  doPixel_(iConfig.existsAs<bool>("doPixel") ? iConfig.getParameter<bool>("doPixel") : true),
66  mergeOld_(iConfig.exists("oldClusterRemovalInfo")) {
67  produces<edm::ContainerMask<edmNew::DetSetVector<SiPixelCluster> > >();
68  produces<edm::ContainerMask<edmNew::DetSetVector<Phase2TrackerCluster1D> > >();
69 
70  trajectories_ = consumes<TrajectorySeedCollection>(iConfig.getParameter<InputTag>("trajectories"));
71  if (doPixel_)
72  pixelClusters_ = consumes<edmNew::DetSetVector<SiPixelCluster> >(iConfig.getParameter<InputTag>("pixelClusters"));
73  if (doOuterTracker_)
75  consumes<edmNew::DetSetVector<Phase2TrackerCluster1D> >(iConfig.getParameter<InputTag>("phase2OTClusters"));
76  if (mergeOld_) {
77  oldPxlMaskToken_ = consumes<PixelMaskContainer>(iConfig.getParameter<InputTag>("oldClusterRemovalInfo"));
78  oldPh2OTMaskToken_ = consumes<Phase2OTMaskContainer>(iConfig.getParameter<InputTag>("oldClusterRemovalInfo"));
79  }
80 }
81 
83  DetId detid = hit->geographicalId();
84  uint32_t subdet = detid.subdetId();
85 
86  assert(subdet > 0);
87 
88  const type_info &hitType = typeid(*hit);
89  if (hitType == typeid(SiPixelRecHit)) {
90  if (!doPixel_)
91  return;
92 
93  const SiPixelRecHit *pixelHit = static_cast<const SiPixelRecHit *>(hit);
94  SiPixelRecHit::ClusterRef cluster = pixelHit->cluster();
95  LogDebug("SeedClusterRemoverPhase2") << "Plain Pixel RecHit in det " << detid.rawId();
96 
97  if (cluster.id() != pixelSourceProdID)
98  throw cms::Exception("Inconsistent Data")
99  << "SeedClusterRemoverPhase2: pixel cluster ref from Product ID = " << cluster.id()
100  << " does not match with source cluster collection (ID = " << pixelSourceProdID << ")\n.";
101 
102  assert(cluster.id() == pixelSourceProdID);
103 
104  // mark as used
105  pixels[cluster.key()] = false;
106 
107  assert(collectedPixels_.size() > cluster.key());
108  collectedPixels_[cluster.key()] = true;
109 
110  } else if (hitType == typeid(Phase2TrackerRecHit1D)) {
111  if (!doOuterTracker_)
112  return;
113 
114  const Phase2TrackerRecHit1D *ph2OThit = static_cast<const Phase2TrackerRecHit1D *>(hit);
115  LogDebug("SeedClusterRemoverPhase2") << "Plain Phase2TrackerRecHit1D in det " << detid.rawId();
116 
117  Phase2TrackerRecHit1D::CluRef cluster = ph2OThit->cluster();
118  if (cluster.id() != outerTrackerSourceProdID)
119  throw cms::Exception("Inconsistent Data")
120  << "SeedClusterRemoverPhase2: strip cluster ref from Product ID = " << cluster.id()
121  << " does not match with source cluster collection (ID = " << outerTrackerSourceProdID << ")\n.";
122 
123  assert(cluster.id() == outerTrackerSourceProdID);
124 
125  OTs[cluster.key()] = false;
126  assert(collectedOuterTrackers_.size() > cluster.key());
127  collectedOuterTrackers_[cluster.key()] = true;
128 
129  } else if (hitType == typeid(VectorHit)) {
130  if (!doOuterTracker_)
131  return;
132 
133  const VectorHit *vhit = static_cast<const VectorHit *>(hit);
134  LogDebug("SeedClusterRemoverPhase2") << "Plain VectorHit in det " << detid.rawId();
135 
136  //lower cluster
138  if (cluster.id() != outerTrackerSourceProdID)
139  throw cms::Exception("Inconsistent Data")
140  << "SeedClusterRemoverPhase2: strip cluster ref from Product ID = " << cluster.id()
141  << " does not match with source cluster collection (ID = " << outerTrackerSourceProdID << ")\n.";
142 
143  OTs[cluster.key()] = false;
144  assert(collectedOuterTrackers_.size() > cluster.key());
145  collectedOuterTrackers_[cluster.key()] = true;
146 
147  // upper cluster
148  cluster = vhit->upperCluster();
149  if (cluster.id() != outerTrackerSourceProdID)
150  throw cms::Exception("Inconsistent Data")
151  << "SeedClusterRemoverPhase2: strip cluster ref from Product ID = " << cluster.id()
152  << " does not match with source cluster collection (ID = " << outerTrackerSourceProdID << ")\n.";
153 
154  OTs[cluster.key()] = false;
155  assert(collectedOuterTrackers_.size() > cluster.key());
156  collectedOuterTrackers_[cluster.key()] = true;
157  } else
158  throw cms::Exception("NOT IMPLEMENTED")
159  << "I received a hit that was neither SiPixelRecHit nor Phase2TrackerRecHit1D but " << hitType.name()
160  << " on detid " << detid.rawId() << "\n";
161 }
162 
164  ProductID pixelOldProdID, stripOldProdID;
165 
167  iSetup.get<TrackerDigiGeometryRecord>().get("", tgh); //is it correct to use "" ?
168 
170  if (doPixel_) {
171  iEvent.getByToken(pixelClusters_, pixelClusters);
173  }
174  LogDebug("SeedClusterRemoverPhase2") << "Read pixel with id " << pixelSourceProdID << std::endl;
175 
177  if (doOuterTracker_) {
180  }
181  LogDebug("SeedClusterRemoverPhase2") << "Read OT cluster with id " << outerTrackerSourceProdID << std::endl;
182 
183  if (doOuterTracker_) {
184  OTs.resize(phase2OTClusters->dataSize());
185  fill(OTs.begin(), OTs.end(), true);
186  }
187  if (doPixel_) {
188  pixels.resize(pixelClusters->dataSize());
189  fill(pixels.begin(), pixels.end(), true);
190  }
191  if (mergeOld_) {
194  iEvent.getByToken(oldPxlMaskToken_, oldPxlMask);
195  iEvent.getByToken(oldPh2OTMaskToken_, oldPh2OTMask);
196  LogDebug("SeedClusterRemoverPhase2") << "to merge in, " << oldPh2OTMask->size() << " strp and "
197  << oldPxlMask->size() << " pxl";
198  oldPh2OTMask->copyMaskTo(collectedOuterTrackers_);
199  oldPxlMask->copyMaskTo(collectedPixels_);
200  assert(phase2OTClusters->dataSize() >= collectedOuterTrackers_.size());
201  collectedOuterTrackers_.resize(phase2OTClusters->dataSize(), false); // for ondemand
202  } else {
203  collectedOuterTrackers_.resize(phase2OTClusters->dataSize(), false);
204  collectedPixels_.resize(pixelClusters->dataSize(), false);
205  }
206 
208  iEvent.getByToken(trajectories_, seeds);
209 
210  for (auto const &seed : (*seeds)) {
211  for (auto const &hit : seed.recHits()) {
212  if (!hit.isValid())
213  continue;
214  process(&hit, 0., tgh.product());
215  }
216  }
217 
218  pixels.clear();
219  OTs.clear();
220 
221  LogDebug("SeedClusterRemoverPhase2") << "total strip to skip: "
222  << std::count(
223  collectedOuterTrackers_.begin(), collectedOuterTrackers_.end(), true);
224  iEvent.put(std::make_unique<Phase2OTMaskContainer>(
226 
227  LogDebug("SeedClusterRemoverPhase2") << "total pxl to skip: "
228  << std::count(collectedPixels_.begin(), collectedPixels_.end(), true);
229  iEvent.put(std::make_unique<PixelMaskContainer>(edm::RefProd<edmNew::DetSetVector<SiPixelCluster> >(pixelClusters),
231 
232  collectedOuterTrackers_.clear();
233  collectedPixels_.clear();
234 }
235 
VectorHit::lowerCluster
ClusterRef lowerCluster() const
"lower" is logical, not geometrically lower; in pixel-strip modules the "lower" is always a pixel
Definition: VectorHit.h:91
edm::RefProd
Definition: EDProductfwd.h:25
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
SeedClusterRemoverPhase2::phase2OTClusters_
edm::EDGetTokenT< edmNew::DetSetVector< Phase2TrackerCluster1D > > phase2OTClusters_
Definition: SeedClusterRemoverPhase2.cc:46
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:393
LumiMonitor_cff.pixelClusters
pixelClusters
Definition: LumiMonitor_cff.py:10
ContainerMask.h
SeedClusterRemoverPhase2::produce
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: SeedClusterRemoverPhase2.cc:163
TrackerGeometry.h
VectorHit::upperCluster
ClusterRef upperCluster() const
Definition: VectorHit.h:92
SeedClusterRemoverPhase2::Phase2OTMaskContainer
edm::ContainerMask< edmNew::DetSetVector< Phase2TrackerCluster1D > > Phase2OTMaskContainer
Definition: SeedClusterRemoverPhase2.cc:44
ESHandle.h
edm::EDGetTokenT
Definition: EDGetToken.h:33
SeedClusterRemoverPhase2::process
void process(const TrackingRecHit *hit, float chi2, const TrackerGeometry *tg)
Definition: SeedClusterRemoverPhase2.cc:82
edm
HLT enums.
Definition: AlignableModifier.h:19
SiPixelCluster.h
GeomDetType.h
cms::cuda::assert
assert(be >=bs)
EDProducer.h
edm::ContainerMask
Definition: ContainerMask.h:36
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
SeedClusterRemoverPhase2::oldPxlMaskToken_
edm::EDGetTokenT< PixelMaskContainer > oldPxlMaskToken_
Definition: SeedClusterRemoverPhase2.cc:47
edm::Handle
Definition: AssociativeIterator.h:50
SiPixelRecHit::cluster
ClusterRef cluster() const
Definition: SiPixelRecHit.h:47
HLTEgPhaseIITestSequence_cff.phase2OTClusters
phase2OTClusters
Definition: HLTEgPhaseIITestSequence_cff.py:722
SiPixelRecHit
Our base class.
Definition: SiPixelRecHit.h:23
edm::Ref
Definition: AssociativeIterator.h:58
fileCollector.seed
seed
Definition: fileCollector.py:127
DetId
Definition: DetId.h:17
MakerMacros.h
Phase2TrackerRecHit1D::cluster
CluRef cluster() const
Definition: Phase2TrackerRecHit1D.h:24
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
SeedClusterRemoverPhase2::pixelSourceProdID
edm::ProductID pixelSourceProdID
Definition: SeedClusterRemoverPhase2.cc:52
SeedClusterRemoverPhase2::doOuterTracker_
bool doOuterTracker_
Definition: SeedClusterRemoverPhase2.cc:41
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
ProductID.h
edm::ESHandle< TrackerGeometry >
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
SiPixelRecHit.h
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
InitialStep_cff.seeds
seeds
Definition: InitialStep_cff.py:230
funct::true
true
Definition: Factorize.h:173
ntuplemaker.fill
fill
Definition: ntuplemaker.py:304
SeedClusterRemoverPhase2::trajectories_
edm::EDGetTokenT< TrajectorySeedCollection > trajectories_
Definition: SeedClusterRemoverPhase2.cc:49
TrackerDigiGeometryRecord.h
SiPixelRecHitCollection.h
Phase2TrackerRecHit1D.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
ModuleDef.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:57
DetSetVector.h
get
#define get
SeedClusterRemoverPhase2::PixelMaskContainer
edm::ContainerMask< edmNew::DetSetVector< SiPixelCluster > > PixelMaskContainer
Definition: SeedClusterRemoverPhase2.cc:43
TrajectorySeedCollection.h
edm::ContainerMask::size
size_t size() const
Definition: ContainerMask.h:53
InputTag.h
SeedClusterRemoverPhase2::pixels
std::vector< uint8_t > pixels
Definition: SeedClusterRemoverPhase2.cc:51
TrackingRecHit
Definition: TrackingRecHit.h:21
ValueMap.h
SeedClusterRemoverPhase2::doPixel_
bool doPixel_
Definition: SeedClusterRemoverPhase2.cc:41
VectorHit
Definition: VectorHit.h:28
Trajectory.h
GeomDet.h
edmNew::DetSetVector
Definition: DetSetNew.h:13
edm::Ref::id
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
SeedClusterRemoverPhase2::collectedPixels_
std::vector< bool > collectedPixels_
Definition: SeedClusterRemoverPhase2.cc:57
std
Definition: JetResolutionObject.h:76
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
edm::ContainerMask::copyMaskTo
void copyMaskTo(std::vector< bool > &) const
Definition: ContainerMask.h:87
Frameworkfwd.h
Phase2TrackerCluster1D.h
Exception
Definition: hltDiff.cc:246
SeedClusterRemoverPhase2::mergeOld_
bool mergeOld_
Definition: SeedClusterRemoverPhase2.cc:42
SeedClusterRemoverPhase2::OTs
std::vector< uint8_t > OTs
Definition: SeedClusterRemoverPhase2.cc:51
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
SeedClusterRemoverPhase2::oldPh2OTMaskToken_
edm::EDGetTokenT< Phase2OTMaskContainer > oldPh2OTMaskToken_
Definition: SeedClusterRemoverPhase2.cc:48
edm::Ref::key
key_type key() const
Accessor for product key.
Definition: Ref.h:250
cms::Exception
Definition: Exception.h:70
ParameterSet.h
SeedClusterRemoverPhase2::collectedOuterTrackers_
std::vector< bool > collectedOuterTrackers_
Definition: SeedClusterRemoverPhase2.cc:56
edm::Event
Definition: Event.h:73
SeedClusterRemoverPhase2::outerTrackerSourceProdID
edm::ProductID outerTrackerSourceProdID
Definition: SeedClusterRemoverPhase2.cc:52
SeedClusterRemoverPhase2::SeedClusterRemoverPhase2
SeedClusterRemoverPhase2(const edm::ParameterSet &iConfig)
Definition: SeedClusterRemoverPhase2.cc:63
SeedClusterRemoverPhase2::pixelClusters_
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusters_
Definition: SeedClusterRemoverPhase2.cc:45
DetSetVectorNew.h
edm::InputTag
Definition: InputTag.h:15
edm::ProductID
Definition: ProductID.h:27
hit
Definition: SiStripHitEffFromCalibTree.cc:88
Phase2TrackerRecHit1D
Definition: Phase2TrackerRecHit1D.h:10
SeedClusterRemoverPhase2
Definition: SeedClusterRemoverPhase2.cc:35
VectorHit.h
TrackerGeometry
Definition: TrackerGeometry.h:14