78 const std::vector<LocalPoint>& vLocalPos);
113 : throwBadComponents_(iConfig.getParameter<bool>(
"throwBadComponents")),
114 dumpWholeDetId_(iConfig.getParameter<bool>(
"dumpWholeDetIds")),
119 trajTrackCollectionToken_(
123 edm::LogPrint(
"NearbyPixelClustersProducer") <<
"WARNING: selected to dump the whole DetId's worth of clusters.\n "
124 "This will have consequences on the event size!"
137 auto outputClusters = std::make_unique<SiPixelClusterCollectionNew>();
153 if (!trajTrackCollectionHandle.isValid())
159 LogDebug(
"NearbyPixelClustersProducer") << allCrossings.size() << std::endl;
162 for (
const auto& [
id, vLocalPos] : allCrossings) {
167 const auto& clustersOnDet = clusterCollection.find(
DetId(
id));
169 if (clustersOnDet == clusterCollection.end())
173 if (!(*clustersOnDet).isValid())
186 for (
const auto& cluster : clustersToPut) {
205 std::vector<uint32_t> treatedIds;
207 for (
const auto& pair : *trajTrackCollectionHandle) {
212 if (!measurement.updatedState().isValid())
218 DetId recHitDetid = recHit->geographicalId();
219 const auto& rawId = recHitDetid.
rawId();
227 if (!(trajStateOnSurface.
isValid()))
234 if (
std::find(treatedIds.begin(), treatedIds.end(), rawId) != treatedIds.end()) {
235 crossings.at(rawId).push_back(localPosition);
237 crossings.insert(std::pair<uint32_t, std::vector<LocalPoint>>(rawId, {localPosition}));
238 treatedIds.push_back(rawId);
249 const uint32_t rawId,
250 const std::vector<LocalPoint>& vLocalPos)
253 std::vector<edmNew::DetSet<SiPixelCluster>::const_iterator>
outputClusters;
255 static constexpr
unsigned int k_maxClustersInDet = 1024;
258 if ((*clusterSet).size() > k_maxClustersInDet) {
260 << __func__ <<
"() number of clusters in det " << rawId <<
" is " << (*clusterSet).size()
261 <<
", which is larger than maximum (1024).\n Something funny with the data is going on!" << std::endl;
270 for (; itCluster != clusterSet->
end(); ++itCluster) {
271 outputClusters.push_back(itCluster);
277 for (
const auto& localPos : vLocalPos) {
280 const auto& traj_lx = localPos.x();
281 const auto& traj_ly = localPos.y();
287 LogDebug(
"NearbyPixelClustersProducer")
288 << __func__ << rawId <<
" count: " << count <<
" n. clusters: " << (*clusterSet).size() << std::endl;
290 for (; itCluster != clusterSet->
end(); ++itCluster) {
291 LocalPoint lp(itCluster->x(), itCluster->y(), 0.);
295 float D =
sqrt((lp.
x() - traj_lx) * (lp.
x() - traj_lx) + (lp.
y() - traj_ly) * (lp.
y() - traj_ly));
303 outputClusters.push_back(closest);
314 const uint32_t rawId,
315 const std::vector<LocalPoint>& vLocalPos)
318 std::vector<edmNew::DetSet<SiPixelCluster>::const_iterator>
outputClusters;
321 for (
const auto& localPos : vLocalPos) {
325 const auto& traj_lx = localPos.x();
326 const auto& traj_ly = localPos.y();
331 for (; itClusterSet != clusterCollection.
end(); itClusterSet++) {
332 DetId detId(itClusterSet->id());
333 if (detId.rawId() != rawId)
336 unsigned int subDetId = detId.subdetId();
339 <<
"ERROR: not a pixel cluster!!!" << std::endl;
347 for (; itCluster != itClusterSet->
end(); ++itCluster) {
348 outputClusters.push_back(itCluster);
354 LogDebug(
"NearbyPixelClustersProducer")
355 << __func__ << rawId <<
" count: " << count <<
" n. clusters: " << (*itClusterSet).size() << std::endl;
361 for (; itCluster != itClusterSet->
end(); ++itCluster) {
362 LocalPoint lp(itCluster->x(), itCluster->y(), 0.);
366 float D =
sqrt((lp.
x() - traj_lx) * (lp.
x() - traj_lx) + (lp.
y() - traj_ly) * (lp.
y() - traj_ly));
374 outputClusters.push_back(closest);
405 if (forwardPredictedState.isValid() && backwardPredictedState.isValid())
406 return trajStateCombiner(forwardPredictedState, backwardPredictedState);
408 else if (backwardPredictedState.isValid())
409 return backwardPredictedState;
411 else if (forwardPredictedState.isValid())
412 return forwardPredictedState;
414 edm::LogError(
"NearbyPixelClustersProducer") <<
"Error saving traj. measurement data."
415 <<
" Trajectory state on surface cannot be determined." << std::endl;
424 "Produces the collection of SiPixelClusters closest, hit by hit, to the trajectory measurements of a given "
426 desc.
add<
bool>(
"throwBadComponents",
false)
428 "do not consider modules flagged as bad components. Careful, it changes the efficiency denominator!");
429 desc.
add<
bool>(
"dumpWholeDetIds",
false)
430 ->setComment(
"put in the event all the pixel cluster on the impacted module, by default only the closest");
const std::vector< edmNew::DetSet< SiPixelCluster >::const_iterator > findAllNearbyClusters(const SiPixelClusterCollectionNew::const_iterator &clusterSet, const uint32_t rawId, const std::vector< LocalPoint > &vLocalPos)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
void push_back(data_type const &d)
const_iterator end(bool update=false) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
edm::EDPutTokenT< SiPixelClusterCollectionNew > clusterPutToken_
const PixelClusterParameterEstimator * pixelCPE_
#define DEFINE_FWK_MODULE(type)
LocalPoint localPosition() const
constexpr unsigned int subDetId[21]
constexpr uint32_t rawId() const
get the raw id
edm::EDGetTokenT< TrajTrackAssociationCollection > trajTrackCollectionToken_
const trajCrossings_t findAllTrajectoriesCrossings(const edm::Handle< TrajTrackAssociationCollection > &trajTrackCollectionHandle)
data_type const * const_iterator
key_type key() const
Accessor for product key.
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
virtual ReturnType getParameters(const SiPixelCluster &cl, const GeomDetUnit &det) const =0
bool getData(T &iHolder) const
bool detidIsOnPixel(const DetId &detid)
void setComment(std::string const &value)
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
const bool dumpWholeDetId_
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
const edm::ESGetToken< PixelClusterParameterEstimator, TkPixelCPERecord > pixelCPEEsToken_
const bool throwBadComponents_
NearbyPixelClustersProducer(const edm::ParameterSet &)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Log< level::Warning, true > LogPrint
TrajectoryStateOnSurface getTrajectoryStateOnSurface(const TrajectoryMeasurement &measurement)
const TrackerGeometry * trackerGeometry_
TrajectoryStateOnSurface const & forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
std::map< uint32_t, std::vector< LocalPoint >> trajCrossings_t
const edm::ESGetToken< SiPixelQuality, SiPixelQualityFromDbRcd > badModuleToken_
~NearbyPixelClustersProducer() override=default
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
DecomposeProduct< arg, typename Div::arg > D
void produce(edm::Event &, const edm::EventSetup &) override
Log< level::Warning, false > LogWarning
edm::EDGetTokenT< SiPixelClusterCollectionNew > clustersToken_
const_iterator begin(bool update=false) const
TrajectoryStateOnSurface const & backwardPredictedState() const
Access to backward predicted state (from smoother)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
constexpr Detector det() const
get the detector field from this detid
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomEsToken_