CMS 3D CMS Logo

SeedClusterRemoverPhase2.cc
Go to the documentation of this file.
7 
10 
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:
41  bool mergeOld_;
49 
50  std::vector<uint8_t> pixels, OTs; // avoid unneed alloc/dealloc of this
51  edm::ProductID pixelSourceProdID, outerTrackerSourceProdID; // ProdIDs refs must point to (for consistency tests)
52 
53  inline void process(const TrackingRecHit *hit, float chi2, const TrackerGeometry *tg);
54 
55  std::vector<bool> collectedOuterTrackers_;
56  std::vector<bool> collectedPixels_;
57 };
58 
59 using namespace std;
60 using namespace edm;
61 
63  : doOuterTracker_(iConfig.existsAs<bool>("doOuterTracker") ? iConfig.getParameter<bool>("doOuterTracker") : true),
64  doPixel_(iConfig.existsAs<bool>("doPixel") ? iConfig.getParameter<bool>("doPixel") : true),
65  mergeOld_(iConfig.exists("oldClusterRemovalInfo")) {
66  produces<edm::ContainerMask<edmNew::DetSetVector<SiPixelCluster> > >();
67  produces<edm::ContainerMask<edmNew::DetSetVector<Phase2TrackerCluster1D> > >();
68 
69  trajectories_ = consumes<TrajectorySeedCollection>(iConfig.getParameter<InputTag>("trajectories"));
70  if (doPixel_)
71  pixelClusters_ = consumes<edmNew::DetSetVector<SiPixelCluster> >(iConfig.getParameter<InputTag>("pixelClusters"));
72  if (doOuterTracker_)
74  consumes<edmNew::DetSetVector<Phase2TrackerCluster1D> >(iConfig.getParameter<InputTag>("phase2OTClusters"));
75  if (mergeOld_) {
76  oldPxlMaskToken_ = consumes<PixelMaskContainer>(iConfig.getParameter<InputTag>("oldClusterRemovalInfo"));
77  oldPh2OTMaskToken_ = consumes<Phase2OTMaskContainer>(iConfig.getParameter<InputTag>("oldClusterRemovalInfo"));
78  }
79 }
80 
82  DetId detid = hit->geographicalId();
83  uint32_t subdet = detid.subdetId();
84 
85  assert(subdet > 0);
86 
87  const type_info &hitType = typeid(*hit);
88  if (hitType == typeid(SiPixelRecHit)) {
89  if (!doPixel_)
90  return;
91 
92  const SiPixelRecHit *pixelHit = static_cast<const SiPixelRecHit *>(hit);
93  SiPixelRecHit::ClusterRef cluster = pixelHit->cluster();
94  LogDebug("SeedClusterRemoverPhase2") << "Plain Pixel RecHit in det " << detid.rawId();
95 
96  if (cluster.id() != pixelSourceProdID)
97  throw cms::Exception("Inconsistent Data")
98  << "SeedClusterRemoverPhase2: pixel cluster ref from Product ID = " << cluster.id()
99  << " does not match with source cluster collection (ID = " << pixelSourceProdID << ")\n.";
100 
101  assert(cluster.id() == pixelSourceProdID);
102 
103  // mark as used
104  pixels[cluster.key()] = false;
105 
106  assert(collectedPixels_.size() > cluster.key());
107  collectedPixels_[cluster.key()] = true;
108 
109  } else if (hitType == typeid(Phase2TrackerRecHit1D)) {
110  if (!doOuterTracker_)
111  return;
112 
113  const Phase2TrackerRecHit1D *ph2OThit = static_cast<const Phase2TrackerRecHit1D *>(hit);
114  LogDebug("SeedClusterRemoverPhase2") << "Plain Phase2TrackerRecHit1D in det " << detid.rawId();
115 
116  Phase2TrackerRecHit1D::CluRef cluster = ph2OThit->cluster();
117  if (cluster.id() != outerTrackerSourceProdID)
118  throw cms::Exception("Inconsistent Data")
119  << "SeedClusterRemoverPhase2: strip cluster ref from Product ID = " << cluster.id()
120  << " does not match with source cluster collection (ID = " << outerTrackerSourceProdID << ")\n.";
121 
122  assert(cluster.id() == outerTrackerSourceProdID);
123 
124  OTs[cluster.key()] = false;
125  assert(collectedOuterTrackers_.size() > cluster.key());
126  collectedOuterTrackers_[cluster.key()] = true;
127 
128  } else
129  throw cms::Exception("NOT IMPLEMENTED")
130  << "I received a hit that was neither SiPixelRecHit nor Phase2TrackerRecHit1D but " << hitType.name()
131  << " on detid " << detid.rawId() << "\n";
132 }
133 
135  ProductID pixelOldProdID, stripOldProdID;
136 
138  iSetup.get<TrackerDigiGeometryRecord>().get("", tgh); //is it correct to use "" ?
139 
141  if (doPixel_) {
142  iEvent.getByToken(pixelClusters_, pixelClusters);
144  }
145  LogDebug("SeedClusterRemoverPhase2") << "Read pixel with id " << pixelSourceProdID << std::endl;
146 
148  if (doOuterTracker_) {
151  }
152  LogDebug("SeedClusterRemoverPhase2") << "Read OT cluster with id " << outerTrackerSourceProdID << std::endl;
153 
154  if (doOuterTracker_) {
155  OTs.resize(phase2OTClusters->dataSize());
156  fill(OTs.begin(), OTs.end(), true);
157  }
158  if (doPixel_) {
159  pixels.resize(pixelClusters->dataSize());
160  fill(pixels.begin(), pixels.end(), true);
161  }
162  if (mergeOld_) {
165  iEvent.getByToken(oldPxlMaskToken_, oldPxlMask);
166  iEvent.getByToken(oldPh2OTMaskToken_, oldPh2OTMask);
167  LogDebug("SeedClusterRemoverPhase2") << "to merge in, " << oldPh2OTMask->size() << " strp and "
168  << oldPxlMask->size() << " pxl";
169  oldPh2OTMask->copyMaskTo(collectedOuterTrackers_);
170  oldPxlMask->copyMaskTo(collectedPixels_);
171  assert(phase2OTClusters->dataSize() >= collectedOuterTrackers_.size());
172  collectedOuterTrackers_.resize(phase2OTClusters->dataSize(), false); // for ondemand
173  } else {
174  collectedOuterTrackers_.resize(phase2OTClusters->dataSize(), false);
175  collectedPixels_.resize(pixelClusters->dataSize(), false);
176  }
177 
179  iEvent.getByToken(trajectories_, seeds);
180 
181  for (auto const &seed : (*seeds)) {
182  auto hits = seed.recHits();
183  auto hit = hits.first;
184  for (; hit != hits.second; ++hit) {
185  if (!hit->isValid())
186  continue;
187  process(&(*hit), 0., tgh.product());
188  }
189  }
190 
191  pixels.clear();
192  OTs.clear();
193 
194  LogDebug("SeedClusterRemoverPhase2") << "total strip to skip: "
195  << std::count(
196  collectedOuterTrackers_.begin(), collectedOuterTrackers_.end(), true);
197  iEvent.put(std::make_unique<Phase2OTMaskContainer>(
199 
200  LogDebug("SeedClusterRemoverPhase2") << "total pxl to skip: "
201  << std::count(collectedPixels_.begin(), collectedPixels_.end(), true);
202  iEvent.put(std::make_unique<PixelMaskContainer>(edm::RefProd<edmNew::DetSetVector<SiPixelCluster> >(pixelClusters),
204 
205  collectedOuterTrackers_.clear();
206  collectedPixels_.clear();
207 }
208 
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:45
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:372
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:134
TrackerGeometry.h
SeedClusterRemoverPhase2::Phase2OTMaskContainer
edm::ContainerMask< edmNew::DetSetVector< Phase2TrackerCluster1D > > Phase2OTMaskContainer
Definition: SeedClusterRemoverPhase2.cc:43
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
ESHandle.h
edm::EDGetTokenT
Definition: EDGetToken.h:33
SeedClusterRemoverPhase2::process
void process(const TrackingRecHit *hit, float chi2, const TrackerGeometry *tg)
Definition: SeedClusterRemoverPhase2.cc:81
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:46
edm::Handle
Definition: AssociativeIterator.h:50
SiPixelRecHit::cluster
ClusterRef cluster() const
Definition: SiPixelRecHit.h:47
SiPixelRecHit
Our base class.
Definition: SiPixelRecHit.h:23
edm::Ref
Definition: AssociativeIterator.h:58
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:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
SeedClusterRemoverPhase2::pixelSourceProdID
edm::ProductID pixelSourceProdID
Definition: SeedClusterRemoverPhase2.cc:51
SeedClusterRemoverPhase2::doOuterTracker_
bool doOuterTracker_
Definition: SeedClusterRemoverPhase2.cc:40
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
ProductID.h
edm::ESHandle< TrackerGeometry >
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:232
funct::true
true
Definition: Factorize.h:173
ntuplemaker.fill
fill
Definition: ntuplemaker.py:304
SeedClusterRemoverPhase2::trajectories_
edm::EDGetTokenT< TrajectorySeedCollection > trajectories_
Definition: SeedClusterRemoverPhase2.cc:48
TrackerDigiGeometryRecord.h
SiPixelRecHitCollection.h
Phase2TrackerRecHit1D.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
KineDebug3::count
void count()
Definition: KinematicConstrainedVertexUpdatorT.h:21
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:42
TrajectorySeedCollection.h
edm::ContainerMask::size
size_t size() const
Definition: ContainerMask.h:53
seedClusterRemoverPhase2_cfi.phase2OTClusters
phase2OTClusters
Definition: seedClusterRemoverPhase2_cfi.py:5
InputTag.h
SeedClusterRemoverPhase2::pixels
std::vector< uint8_t > pixels
Definition: SeedClusterRemoverPhase2.cc:50
TrackingRecHit
Definition: TrackingRecHit.h:21
ValueMap.h
SeedClusterRemoverPhase2::doPixel_
bool doPixel_
Definition: SeedClusterRemoverPhase2.cc:40
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
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:56
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:41
SeedClusterRemoverPhase2::OTs
std::vector< uint8_t > OTs
Definition: SeedClusterRemoverPhase2.cc:50
SeedClusterRemoverPhase2::oldPh2OTMaskToken_
edm::EDGetTokenT< Phase2OTMaskContainer > oldPh2OTMaskToken_
Definition: SeedClusterRemoverPhase2.cc:47
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:55
edm::Event
Definition: Event.h:73
SeedClusterRemoverPhase2::outerTrackerSourceProdID
edm::ProductID outerTrackerSourceProdID
Definition: SeedClusterRemoverPhase2.cc:51
SeedClusterRemoverPhase2::SeedClusterRemoverPhase2
SeedClusterRemoverPhase2(const edm::ParameterSet &iConfig)
Definition: SeedClusterRemoverPhase2.cc:62
SeedClusterRemoverPhase2::pixelClusters_
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusters_
Definition: SeedClusterRemoverPhase2.cc:44
DetSetVectorNew.h
edm::InputTag
Definition: InputTag.h:15
edm::ProductID
Definition: ProductID.h:27
SurveyInfoScenario_cff.seed
seed
Definition: SurveyInfoScenario_cff.py:295
hit
Definition: SiStripHitEffFromCalibTree.cc:88
Phase2TrackerRecHit1D
Definition: Phase2TrackerRecHit1D.h:10
SeedClusterRemoverPhase2
Definition: SeedClusterRemoverPhase2.cc:34
TrackerGeometry
Definition: TrackerGeometry.h:14