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) {
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())
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) {
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));
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();
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) {
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));
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 TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
edm::EDPutTokenT< SiPixelClusterCollectionNew > clusterPutToken_
LocalPoint localPosition() const
std::map< uint32_t, std::vector< LocalPoint > > trajCrossings_t
const PixelClusterParameterEstimator * pixelCPE_
TrajectoryStateOnSurface const & forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
constexpr unsigned int subDetId[21]
edm::EDGetTokenT< TrajTrackAssociationCollection > trajTrackCollectionToken_
const trajCrossings_t findAllTrajectoriesCrossings(const edm::Handle< TrajTrackAssociationCollection > &trajTrackCollectionHandle)
data_type const * const_iterator
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
constexpr Detector det() const
get the detector field from this detid
key_type key() const
Accessor for product key.
virtual ReturnType getParameters(const SiPixelCluster &cl, const GeomDetUnit &det) const =0
bool detidIsOnPixel(const DetId &detid)
const bool dumpWholeDetId_
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
TrajectoryStateOnSurface const & backwardPredictedState() const
Access to backward predicted state (from smoother)
#define DEFINE_FWK_MODULE(type)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
bool getData(T &iHolder) const
const edm::ESGetToken< PixelClusterParameterEstimator, TkPixelCPERecord > pixelCPEEsToken_
const bool throwBadComponents_
NearbyPixelClustersProducer(const edm::ParameterSet &)
Log< level::Warning, true > LogPrint
TrajectoryStateOnSurface getTrajectoryStateOnSurface(const TrajectoryMeasurement &measurement)
const TrackerGeometry * trackerGeometry_
const edm::ESGetToken< SiPixelQuality, SiPixelQualityFromDbRcd > badModuleToken_
~NearbyPixelClustersProducer() override=default
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
DecomposeProduct< arg, typename Div::arg > D
constexpr uint32_t rawId() const
get the raw id
void produce(edm::Event &, const edm::EventSetup &) override
Log< level::Warning, false > LogWarning
edm::EDGetTokenT< SiPixelClusterCollectionNew > clustersToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomEsToken_