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 
36  public:
38  void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override ;
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 
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 {
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_) pixelClusters_ = consumes<edmNew::DetSetVector<SiPixelCluster> >(iConfig.getParameter<InputTag>("pixelClusters"));
73  if (doOuterTracker_) phase2OTClusters_ = consumes<edmNew::DetSetVector<Phase2TrackerCluster1D> >(iConfig.getParameter<InputTag>("phase2OTClusters"));
74  if (mergeOld_) {
75  oldPxlMaskToken_ = consumes<PixelMaskContainer>(iConfig.getParameter<InputTag>("oldClusterRemovalInfo"));
76  oldPh2OTMaskToken_ = consumes<Phase2OTMaskContainer>(iConfig.getParameter<InputTag>("oldClusterRemovalInfo"));
77  }
78 }
79 
80 
82 
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 
91  if(!doPixel_) 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) 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 
111  if(!doOuterTracker_) 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) throw cms::Exception("Inconsistent Data") <<
118  "SeedClusterRemoverPhase2: strip cluster ref from Product ID = " << cluster.id() <<
119  " does not match with source cluster collection (ID = " << outerTrackerSourceProdID << ")\n.";
120 
121  assert(cluster.id() == outerTrackerSourceProdID);
122 
123  OTs[cluster.key()] = false;
124  assert(collectedOuterTrackers_.size() > cluster.key());
125  collectedOuterTrackers_[cluster.key()]=true;
126 
127  } else throw cms::Exception("NOT IMPLEMENTED") << "I received a hit that was neither SiPixelRecHit nor Phase2TrackerRecHit1D but " << hitType.name() << " on detid " << detid.rawId() << "\n";
128 
129 
130 }
131 
132 void
134 {
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);
143  pixelSourceProdID = pixelClusters.id();
144  }
145  LogDebug("SeedClusterRemoverPhase2") << "Read pixel with id " << pixelSourceProdID << std::endl;
146 
148  if (doOuterTracker_) {
149  iEvent.getByToken(phase2OTClusters_, phase2OTClusters);
150  outerTrackerSourceProdID = phase2OTClusters.id();
151  }
152  LogDebug("SeedClusterRemoverPhase2") << "Read OT cluster with id " << outerTrackerSourceProdID << std::endl;
153 
154 
155  if (doOuterTracker_) {
156  OTs.resize(phase2OTClusters->dataSize()); fill(OTs.begin(), OTs.end(), true);
157  }
158  if (doPixel_) {
159  pixels.resize(pixelClusters->dataSize()); fill(pixels.begin(), pixels.end(), true);
160  }
161  if(mergeOld_) {
164  iEvent.getByToken(oldPxlMaskToken_ ,oldPxlMask);
165  iEvent.getByToken(oldPh2OTMaskToken_ ,oldPh2OTMask);
166  LogDebug("SeedClusterRemoverPhase2") << "to merge in, "<<oldPh2OTMask->size()<<" strp and "<<oldPxlMask->size()<<" pxl";
167  oldPh2OTMask->copyMaskTo(collectedOuterTrackers_);
168  oldPxlMask->copyMaskTo(collectedPixels_);
169  assert(phase2OTClusters->dataSize()>=collectedOuterTrackers_.size());
170  collectedOuterTrackers_.resize(phase2OTClusters->dataSize(),false); // for ondemand
171  }else {
172  collectedOuterTrackers_.resize(phase2OTClusters->dataSize(), false);
173  collectedPixels_.resize(pixelClusters->dataSize(), false);
174  }
175 
176 
178  iEvent.getByToken(trajectories_,seeds);
179 
180  for (auto const & seed : (*seeds) ){
181  auto hits=seed.recHits();
182  auto hit=hits.first;
183  for (;hit!=hits.second;++hit){
184  if (!hit->isValid()) continue;
185  process( &(*hit), 0. , tgh.product());
186  }
187  }
188 
189 
190  pixels.clear(); OTs.clear();
191 
192 
193  LogDebug("SeedClusterRemoverPhase2")<<"total strip to skip: "<<std::count(collectedOuterTrackers_.begin(),collectedOuterTrackers_.end(),true);
194  iEvent.put(std::make_unique<Phase2OTMaskContainer>(edm::RefProd<edmNew::DetSetVector<Phase2TrackerCluster1D> >(phase2OTClusters),collectedOuterTrackers_));
195 
196  LogDebug("SeedClusterRemoverPhase2")<<"total pxl to skip: "<<std::count(collectedPixels_.begin(),collectedPixels_.end(),true);
197  iEvent.put(std::make_unique<PixelMaskContainer>(edm::RefProd<edmNew::DetSetVector<SiPixelCluster> >(pixelClusters),collectedPixels_));
198 
199  collectedOuterTrackers_.clear();
200  collectedPixels_.clear();
201 
202 }
203 
#define LogDebug(id)
std::vector< bool > collectedPixels_
std::vector< bool > collectedOuterTrackers_
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
ProductID id() const
Definition: HandleBase.cc:15
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusters_
key_type key() const
Accessor for product key.
Definition: Ref.h:265
edm::ContainerMask< edmNew::DetSetVector< Phase2TrackerCluster1D > > Phase2OTMaskContainer
void copyMaskTo(std::vector< bool > &) const
Definition: ContainerMask.h:91
ProductID id() const
Accessor for product ID.
Definition: Ref.h:259
void process(const TrackingRecHit *hit, float chi2, const TrackerGeometry *tg)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< TrajectorySeedCollection > trajectories_
edm::ContainerMask< edmNew::DetSetVector< SiPixelCluster > > PixelMaskContainer
edm::EDGetTokenT< PixelMaskContainer > oldPxlMaskToken_
size_t size() const
Definition: ContainerMask.h:55
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
Definition: DetId.h:18
SeedClusterRemoverPhase2(const edm::ParameterSet &iConfig)
ClusterRef cluster() const
Definition: SiPixelRecHit.h:49
const T & get() const
Definition: EventSetup.h:58
edm::EDGetTokenT< Phase2OTMaskContainer > oldPh2OTMaskToken_
HLT enums.
edm::EDGetTokenT< edmNew::DetSetVector< Phase2TrackerCluster1D > > phase2OTClusters_
DetId geographicalId() const
T const * product() const
Definition: ESHandle.h:86
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Our base class.
Definition: SiPixelRecHit.h:23