CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SeedClusterRemoverPhase2.cc
Go to the documentation of this file.
6 
9 
14 
21 
24 
29 
30 //
31 // class decleration
32 //
33 
35 public:
37  void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override;
38 
39 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 
65  doOuterTracker_(iConfig.existsAs<bool>("doOuterTracker") ? iConfig.getParameter<bool>("doOuterTracker") : true),
66  doPixel_(iConfig.existsAs<bool>("doPixel") ? iConfig.getParameter<bool>("doPixel") : true),
67  mergeOld_(iConfig.exists("oldClusterRemovalInfo")) {
68  produces<edm::ContainerMask<edmNew::DetSetVector<SiPixelCluster> > >();
69  produces<edm::ContainerMask<edmNew::DetSetVector<Phase2TrackerCluster1D> > >();
70 
71  trajectories_ = consumes<TrajectorySeedCollection>(iConfig.getParameter<InputTag>("trajectories"));
72  if (doPixel_)
73  pixelClusters_ = consumes<edmNew::DetSetVector<SiPixelCluster> >(iConfig.getParameter<InputTag>("pixelClusters"));
74  if (doOuterTracker_)
76  consumes<edmNew::DetSetVector<Phase2TrackerCluster1D> >(iConfig.getParameter<InputTag>("phase2OTClusters"));
77  if (mergeOld_) {
78  oldPxlMaskToken_ = consumes<PixelMaskContainer>(iConfig.getParameter<InputTag>("oldClusterRemovalInfo"));
79  oldPh2OTMaskToken_ = consumes<Phase2OTMaskContainer>(iConfig.getParameter<InputTag>("oldClusterRemovalInfo"));
80  }
81 }
82 
84  DetId detid = hit->geographicalId();
85  uint32_t subdet = detid.subdetId();
86 
87  assert(subdet > 0);
88 
89  const type_info &hitType = typeid(*hit);
90  if (hitType == typeid(SiPixelRecHit)) {
91  if (!doPixel_)
92  return;
93 
94  const SiPixelRecHit *pixelHit = static_cast<const SiPixelRecHit *>(hit);
95  SiPixelRecHit::ClusterRef cluster = pixelHit->cluster();
96  LogDebug("SeedClusterRemoverPhase2") << "Plain Pixel RecHit in det " << detid.rawId();
97 
98  if (cluster.id() != pixelSourceProdID)
99  throw cms::Exception("Inconsistent Data")
100  << "SeedClusterRemoverPhase2: pixel cluster ref from Product ID = " << cluster.id()
101  << " does not match with source cluster collection (ID = " << pixelSourceProdID << ")\n.";
102 
103  assert(cluster.id() == pixelSourceProdID);
104 
105  // mark as used
106  pixels[cluster.key()] = false;
107 
108  assert(collectedPixels_.size() > cluster.key());
109  collectedPixels_[cluster.key()] = true;
110 
111  } else if (hitType == typeid(Phase2TrackerRecHit1D)) {
112  if (!doOuterTracker_)
113  return;
114 
115  const Phase2TrackerRecHit1D *ph2OThit = static_cast<const Phase2TrackerRecHit1D *>(hit);
116  LogDebug("SeedClusterRemoverPhase2") << "Plain Phase2TrackerRecHit1D in det " << detid.rawId();
117 
118  Phase2TrackerRecHit1D::CluRef cluster = ph2OThit->cluster();
119  if (cluster.id() != outerTrackerSourceProdID)
120  throw cms::Exception("Inconsistent Data")
121  << "SeedClusterRemoverPhase2: strip cluster ref from Product ID = " << cluster.id()
122  << " does not match with source cluster collection (ID = " << outerTrackerSourceProdID << ")\n.";
123 
124  assert(cluster.id() == outerTrackerSourceProdID);
125 
126  OTs[cluster.key()] = false;
127  assert(collectedOuterTrackers_.size() > cluster.key());
128  collectedOuterTrackers_[cluster.key()] = true;
129 
130  } else if (hitType == typeid(VectorHit)) {
131  if (!doOuterTracker_)
132  return;
133 
134  const VectorHit *vhit = static_cast<const VectorHit *>(hit);
135  LogDebug("SeedClusterRemoverPhase2") << "Plain VectorHit in det " << detid.rawId();
136 
137  //lower cluster
139  if (cluster.id() != outerTrackerSourceProdID)
140  throw cms::Exception("Inconsistent Data")
141  << "SeedClusterRemoverPhase2: strip cluster ref from Product ID = " << cluster.id()
142  << " does not match with source cluster collection (ID = " << outerTrackerSourceProdID << ")\n.";
143 
144  OTs[cluster.key()] = false;
145  assert(collectedOuterTrackers_.size() > cluster.key());
146  collectedOuterTrackers_[cluster.key()] = true;
147 
148  // upper cluster
149  cluster = vhit->upperCluster();
150  if (cluster.id() != outerTrackerSourceProdID)
151  throw cms::Exception("Inconsistent Data")
152  << "SeedClusterRemoverPhase2: strip cluster ref from Product ID = " << cluster.id()
153  << " does not match with source cluster collection (ID = " << outerTrackerSourceProdID << ")\n.";
154 
155  OTs[cluster.key()] = false;
156  assert(collectedOuterTrackers_.size() > cluster.key());
157  collectedOuterTrackers_[cluster.key()] = true;
158  } else
159  throw cms::Exception("NOT IMPLEMENTED")
160  << "I received a hit that was neither SiPixelRecHit nor Phase2TrackerRecHit1D but " << hitType.name()
161  << " on detid " << detid.rawId() << "\n";
162 }
163 
165  ProductID pixelOldProdID, stripOldProdID;
166 
167  const auto &tgh = &iSetup.getData(tTrackerGeom_);
168 
170  if (doPixel_) {
171  iEvent.getByToken(pixelClusters_, pixelClusters);
172  pixelSourceProdID = pixelClusters.id();
173  }
174  LogDebug("SeedClusterRemoverPhase2") << "Read pixel with id " << pixelSourceProdID << std::endl;
175 
177  if (doOuterTracker_) {
178  iEvent.getByToken(phase2OTClusters_, phase2OTClusters);
179  outerTrackerSourceProdID = phase2OTClusters.id();
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);
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 
std::vector< bool > collectedPixels_
std::vector< bool > collectedOuterTrackers_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
ProductID id() const
Definition: HandleBase.cc:29
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusters_
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
key_type key() const
Accessor for product key.
Definition: Ref.h:250
edm::ContainerMask< edmNew::DetSetVector< Phase2TrackerCluster1D > > Phase2OTMaskContainer
assert(be >=bs)
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
void process(const TrackingRecHit *hit, float chi2, const TrackerGeometry *tg)
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > const tTrackerGeom_
bool getData(T &iHolder) const
Definition: EventSetup.h:128
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< TrajectorySeedCollection > trajectories_
ClusterRef upperCluster() const
Definition: VectorHit.h:92
edm::ContainerMask< edmNew::DetSetVector< SiPixelCluster > > PixelMaskContainer
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
edm::EDGetTokenT< PixelMaskContainer > oldPxlMaskToken_
ClusterRef lowerCluster() const
&quot;lower&quot; is logical, not geometrically lower; in pixel-strip modules the &quot;lower&quot; is always a pixel ...
Definition: VectorHit.h:91
Definition: DetId.h:17
void fill(std::map< std::string, TH1 * > &h, const std::string &s, double x)
SeedClusterRemoverPhase2(const edm::ParameterSet &iConfig)
ClusterRef cluster() const
Definition: SiPixelRecHit.h:47
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< Phase2OTMaskContainer > oldPh2OTMaskToken_
edm::EDGetTokenT< edmNew::DetSetVector< Phase2TrackerCluster1D > > phase2OTClusters_
DetId geographicalId() const
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Our base class.
Definition: SiPixelRecHit.h:23
#define LogDebug(id)