CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
NearbyPixelClustersAnalyzer Class Reference

#include <Calibration/TkAlCaRecoProducers/plugins/NearbyPixelClustersAnalyzer.cc>

Inheritance diagram for NearbyPixelClustersAnalyzer:
edm::one::EDAnalyzer< edm::one::SharedResources, edm::one::WatchRuns > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 NearbyPixelClustersAnalyzer (const edm::ParameterSet &)
 
 ~NearbyPixelClustersAnalyzer () override=default
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources, edm::one::WatchRuns >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector
< ProductResolverIndexAndSkipBit >
const & 
itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void beginRun (edm::Run const &, edm::EventSetup const &) override
 
std::map< uint32_t, TH2F * > bookModuleHistograms (const TrackerTopology *tTopo)
 
void countClusters (const edm::Handle< SiPixelClusterCollectionNew > &handle, unsigned int &nClusGlobal)
 
bool detidIsOnPixel (const DetId &detid)
 
void endJob () override
 
void endRun (edm::Run const &, edm::EventSetup const &) override
 
void fillClusterFrames (const edm::Handle< SiPixelClusterCollectionNew > &handle)
 
std::pair< float, float > findClosestCluster (const edm::Handle< SiPixelClusterCollectionNew > &handle, const PixelClusterParameterEstimator *pixelCPE_, const TrackerGeometry *trackerGeometry_, uint32_t rawId, float traj_lx, float traj_ly)
 
TrajectoryStateOnSurface getTrajectoryStateOnSurface (const TrajectoryMeasurement &measurement)
 
std::tuple< std::string, int,
int, int > 
setTopoInfo (uint32_t detId, const TrackerTopology *tTopo)
 

Private Attributes

edm::EDGetTokenT
< SiPixelClusterCollectionNew
clustersToken_
 
edm::EDGetTokenT
< edm::ValueMap< std::vector
< float > > > 
distanceToken_
 
edm::Service< TFileServicefs
 
const edm::ESGetToken
< TrackerGeometry,
TrackerDigiGeometryRecord
geomEsToken_
 
const edm::ESGetToken
< TrackerGeometry,
TrackerDigiGeometryRecord
geomEsTokenBR_
 
TH1F * h_distClosestInactive
 
TH1F * h_distClosestMissing
 
TH1F * h_distClosestTrack
 
TH1F * h_distClosestValid
 
TH1I * h_nALCARECOClusters
 
TH1I * h_nCloseByClusters
 
std::map< uint32_t, TH2F * > histoMap_
 
edm::EDGetTokenT< edm::View
< reco::Track > > 
muonTracksToken_
 
edm::EDGetTokenT
< SiPixelClusterCollectionNew
nearByClustersToken_
 
std::map< std::string,
TFileDirectory
outputFolders_
 
bool phase_
 
const edm::ESGetToken
< PixelClusterParameterEstimator,
TkPixelCPERecord
pixelCPEEsToken_
 
SiPixelDetInfoFileReader reader_
 
const edm::ESGetToken
< TrackerTopology,
TrackerTopologyRcd
topoEsTokenBR_
 
edm::EDGetTokenT
< TrajTrackAssociationCollection
trajTrackCollectionToken_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Description: Analysis of the closebyPixelClusters collections

Definition at line 58 of file NearbyPixelClustersAnalyzer.cc.

Constructor & Destructor Documentation

NearbyPixelClustersAnalyzer::NearbyPixelClustersAnalyzer ( const edm::ParameterSet iConfig)
explicit

Definition at line 119 of file NearbyPixelClustersAnalyzer.cc.

References TFileService::kSharedResource.

121  pixelCPEEsToken_(esConsumes(edm::ESInputTag("", "PixelCPEGeneric"))),
122  geomEsTokenBR_(esConsumes<edm::Transition::BeginRun>()),
123  topoEsTokenBR_(esConsumes<edm::Transition::BeginRun>()),
124  clustersToken_(consumes<SiPixelClusterCollectionNew>(iConfig.getParameter<edm::InputTag>("clusterCollection"))),
126  consumes<SiPixelClusterCollectionNew>(iConfig.getParameter<edm::InputTag>("nearByClusterCollection"))),
128  consumes<TrajTrackAssociationCollection>(iConfig.getParameter<edm::InputTag>("trajectoryInput"))),
129  distanceToken_(consumes<edm::ValueMap<std::vector<float>>>(iConfig.getParameter<edm::InputTag>("distToTrack"))),
131  reader_(edm::FileInPath(iConfig.getParameter<std::string>("skimmedGeometryPath")).fullPath()) {
132  usesResource(TFileService::kSharedResource);
133 }
static const std::string kSharedResource
Definition: TFileService.h:76
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomEsToken_
edm::EDGetTokenT< edm::ValueMap< std::vector< float > > > distanceToken_
edm::EDGetTokenT< TrajTrackAssociationCollection > trajTrackCollectionToken_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomEsTokenBR_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< SiPixelClusterCollectionNew > clustersToken_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoEsTokenBR_
edm::EDGetTokenT< SiPixelClusterCollectionNew > nearByClustersToken_
const edm::ESGetToken< PixelClusterParameterEstimator, TkPixelCPERecord > pixelCPEEsToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< edm::View< reco::Track > > muonTracksToken_
std::string fullPath() const
Definition: FileInPath.cc:161
NearbyPixelClustersAnalyzer::~NearbyPixelClustersAnalyzer ( )
overridedefault

Member Function Documentation

void NearbyPixelClustersAnalyzer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 140 of file NearbyPixelClustersAnalyzer.cc.

References clustersToken_, countClusters(), counter, detidIsOnPixel(), HLT_FULL_cff::distance, distanceToken_, fillClusterFrames(), findClosestCluster(), geomEsToken_, edm::EventSetup::getData(), edm::Event::getHandle(), getTrajectoryStateOnSurface(), h_distClosestInactive, h_distClosestMissing, h_distClosestTrack, h_distClosestValid, h_nALCARECOClusters, h_nCloseByClusters, TrackingRecHit::inactive, TrajectoryStateOnSurface::isValid(), edm::Ref< C, T, F >::key(), TrajectoryStateOnSurface::localPosition(), LogDebug, TrackingRecHit::missing, HLT_FULL_cff::muon, muonTracksToken_, nearByClustersToken_, pixelCPEEsToken_, DetId::rawId(), mathSSE::sqrt(), HLT_FULL_cff::track, trajTrackCollectionToken_, TrackingRecHit::valid, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

140  {
141  using namespace edm;
142 
143  // get the Tracker geometry from event setup
144  const TrackerGeometry* trackerGeometry_ = &iSetup.getData(geomEsToken_);
145 
146  // get the Pixel CPE from event setup
147  const PixelClusterParameterEstimator* pixelCPE_ = &iSetup.getData(pixelCPEEsToken_);
148 
149  // get the muon track collection
150  const auto& muonTrackCollectionHandle = iEvent.getHandle(muonTracksToken_);
151  auto const& muonTracks = *muonTrackCollectionHandle;
152 
153  // get the track distances
154  const auto& distancesToTrack = iEvent.getHandle(distanceToken_);
155 
156  unsigned int nMuons = muonTracks.size();
157  for (unsigned int ij = 0; ij < nMuons; ij++) {
158  auto muon = muonTrackCollectionHandle->ptrAt(ij);
159  edm::RefToBase<reco::Track> trackRef = muonTrackCollectionHandle->refAt(ij);
160  const auto& distances = (*distancesToTrack)[trackRef];
161 
162  LogDebug("NearbyPixelClustersAnalyzer") << "distances size: " << distances.size() << std::endl;
163 
164  unsigned counter = 0;
165  double closestDR = 999.;
166  for (const auto& distance : distances) {
167  counter++;
168  LogDebug("NearbyPixelClustersAnalyzer")
169  << "track: " << counter << " distance:" << std::sqrt(distance) << std::endl;
170  if (distance < closestDR && distance > 0) {
171  closestDR = distance;
172  }
173  }
174 
175  h_distClosestTrack->Fill(std::sqrt(closestDR));
176  }
177 
178  // Get cluster collection
179  const auto& clusterCollectionHandle = iEvent.getHandle(clustersToken_);
180 
181  unsigned int nClusGlobal = 0;
182  countClusters(clusterCollectionHandle, nClusGlobal);
183 
184  h_nALCARECOClusters->Fill(nClusGlobal);
185  edm::LogInfo("NearbyPixelClustersAnalyzer") << "total ALCARECO clusters: " << nClusGlobal << std::endl;
186 
187  // Get nearby cluster collection
188  const auto& nearByClusterCollectionHandle = iEvent.getHandle(nearByClustersToken_);
189 
190  unsigned int nNearByClusGlobal = 0;
191  countClusters(nearByClusterCollectionHandle, /*trackerGeometry_,*/ nNearByClusGlobal);
192 
193  h_nCloseByClusters->Fill(nNearByClusGlobal);
194  edm::LogInfo("NearbyPixelClustersAnalyzer") << "total close-by clusters: " << nNearByClusGlobal << std::endl;
195 
196  // fill the detector frames
197  fillClusterFrames(nearByClusterCollectionHandle);
198 
199  // Get Traj-Track Collection
200  const auto& trajTrackCollectionHandle = iEvent.getHandle(trajTrackCollectionToken_);
201 
202  if (!trajTrackCollectionHandle.isValid())
203  return;
204 
205  for (const auto& pair : *trajTrackCollectionHandle) {
206  const edm::Ref<std::vector<Trajectory>> traj = pair.key;
207  const reco::TrackRef track = pair.val;
208 
209  for (const TrajectoryMeasurement& measurement : traj->measurements()) {
210  if (!measurement.updatedState().isValid())
211  return;
212 
213  const TransientTrackingRecHit::ConstRecHitPointer& recHit = measurement.recHit();
214 
215  // Only looking for pixel hits
216  DetId r_rawId = recHit->geographicalId();
217 
218  if (!this->detidIsOnPixel(r_rawId))
219  continue;
220 
221  // Skipping hits with undeterminable positions
222  TrajectoryStateOnSurface trajStateOnSurface = this->getTrajectoryStateOnSurface(measurement);
223 
224  if (!(trajStateOnSurface.isValid()))
225  continue;
226 
227  // Position measurements
228  // Looking for valid and missing hits
229  LocalPoint localPosition = trajStateOnSurface.localPosition();
230 
231  const auto& traj_lx = localPosition.x();
232  const auto& traj_ly = localPosition.y();
233 
234  const auto loc = this->findClosestCluster(
235  nearByClusterCollectionHandle, pixelCPE_, trackerGeometry_, r_rawId.rawId(), traj_lx, traj_ly);
236 
237  float dist = (loc.first != -999.) ? std::sqrt(loc.first * loc.first + loc.second * loc.second) : -0.1;
238 
239  if (recHit->getType() == TrackingRecHit::valid) {
240  edm::LogInfo("NearbyPixelClustersAnalyzer")
241  << "RawID:" << r_rawId.rawId() << " (valid hit), distance: " << dist << std::endl;
242  h_distClosestValid->Fill(dist);
243  }
244 
245  if (recHit->getType() == TrackingRecHit::missing) {
246  edm::LogInfo("NearbyPixelClustersAnalyzer")
247  << "RawID:" << r_rawId.rawId() << " (missing hit), distance: " << dist << std::endl;
248  h_distClosestMissing->Fill(dist);
249  }
250 
251  if (recHit->getType() == TrackingRecHit::inactive) {
252  edm::LogInfo("NearbyPixelClustersAnalyzer")
253  << "RawID:" << r_rawId.rawId() << " (inactive hit), distance: " << dist << std::endl;
254  h_distClosestInactive->Fill(dist);
255  }
256  }
257  }
258 }
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomEsToken_
edm::EDGetTokenT< edm::ValueMap< std::vector< float > > > distanceToken_
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
T y() const
Definition: PV3DBase.h:60
edm::EDGetTokenT< TrajTrackAssociationCollection > trajTrackCollectionToken_
key_type key() const
Accessor for product key.
Definition: Ref.h:250
TrajectoryStateOnSurface getTrajectoryStateOnSurface(const TrajectoryMeasurement &measurement)
bool getData(T &iHolder) const
Definition: EventSetup.h:122
edm::EDGetTokenT< SiPixelClusterCollectionNew > clustersToken_
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:563
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
T sqrt(T t)
Definition: SSEVec.h:19
void fillClusterFrames(const edm::Handle< SiPixelClusterCollectionNew > &handle)
edm::EDGetTokenT< SiPixelClusterCollectionNew > nearByClustersToken_
const edm::ESGetToken< PixelClusterParameterEstimator, TkPixelCPERecord > pixelCPEEsToken_
std::pair< float, float > findClosestCluster(const edm::Handle< SiPixelClusterCollectionNew > &handle, const PixelClusterParameterEstimator *pixelCPE_, const TrackerGeometry *trackerGeometry_, uint32_t rawId, float traj_lx, float traj_ly)
Log< level::Info, false > LogInfo
Definition: DetId.h:17
static std::atomic< unsigned int > counter
edm::EDGetTokenT< edm::View< reco::Track > > muonTracksToken_
void countClusters(const edm::Handle< SiPixelClusterCollectionNew > &handle, unsigned int &nClusGlobal)
T x() const
Definition: PV3DBase.h:59
#define LogDebug(id)
void NearbyPixelClustersAnalyzer::beginJob ( )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 261 of file NearbyPixelClustersAnalyzer.cc.

References fs, h_distClosestInactive, h_distClosestMissing, h_distClosestTrack, h_distClosestValid, h_nALCARECOClusters, h_nCloseByClusters, TFileDirectory::make(), and TFileService::mkdir().

261  {
262  TFileDirectory ClusterCounts = fs->mkdir("ClusterCounts");
263  h_nALCARECOClusters = ClusterCounts.make<TH1I>(
264  "h_nALCARECOClusters", "Number of Pixel clusters per event (ALCARECO) ;N_{clusters};events", 20, 0, 20);
265  h_nCloseByClusters = ClusterCounts.make<TH1I>(
266  "h_nCloseByClusters", "Number of Pixel clusters per event (close-by) ;N_{clusters};events", 20, 0, 20);
267 
268  TFileDirectory Distances = fs->mkdir("TrajDistance");
269  h_distClosestValid = Distances.make<TH1F>(
270  "h_distClosestValid",
271  "Distance of Closest cluster to trajectory (valid);distance (cm); valid trajectory measurements",
272  110,
273  -0.105,
274  0.995);
275  h_distClosestMissing = Distances.make<TH1F>(
276  "h_distClosestMissing",
277  "Distance of Closest cluster to trajectory (missing);distance (cm);missing trajectory measurements",
278  110,
279  -0.105,
280  0.995);
281  h_distClosestInactive = Distances.make<TH1F>(
282  "h_distClosestInactive",
283  "Distance of Closest cluster to trajectory (inactive);distance (cm);inactive trajectory measurements",
284  110,
285  -0.105,
286  0.995);
287 
288  TFileDirectory TkDistances = fs->mkdir("OtherTrackDistance");
289  h_distClosestTrack = TkDistances.make<TH1F>(
290  "h_distClosestTrack",
291  "#DeltaR Distance of Closest track to the muon trajectory;#DeltaR distance; muon trajectories",
292  100,
293  0.,
294  5.);
295 }
T * make(const Args &...args) const
make new ROOT object
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
void NearbyPixelClustersAnalyzer::beginRun ( edm::Run const &  iRun,
edm::EventSetup const &  iSetup 
)
overrideprivate

Definition at line 422 of file NearbyPixelClustersAnalyzer.cc.

References bookModuleHistograms(), runTheMatrix::const, TrackerGeometry::detUnits(), Exception, fs, geomEsTokenBR_, SiPixelDetInfoFileReader::getAllDetIds(), edm::EventSetup::getData(), histoMap_, TrackerGeometry::isThere(), LogDebug, TFileService::mkdir(), outputFolders_, GeomDetEnumerators::P1PXB, GeomDetEnumerators::P1PXEC, phase_, reader_, setTopoInfo(), AlCaHLTBitMon_QueryRunRegistry::string, and topoEsTokenBR_.

424 {
425  edm::LogInfo("NearbyPixelClustersAnalyzer")
426  << "@SUB=NearbyPixelClustersAnalyzer::beginRun() before booking histoMap_.size(): " << histoMap_.size()
427  << std::endl;
428 
429  const TrackerTopology* tTopo_ = &iSetup.getData(topoEsTokenBR_);
430  const TrackerGeometry* pDD_ = &iSetup.getData(geomEsTokenBR_);
431 
433  phase_ = true;
434  } else {
435  phase_ = false;
436  }
437 
438  unsigned nPixelDets = 0;
439  for (const auto& it : pDD_->detUnits()) {
440  const PixelGeomDetUnit* mit = dynamic_cast<PixelGeomDetUnit const*>(it);
441  if (mit != nullptr) {
442  nPixelDets++;
443  }
444  }
445 
446  const auto& detIds = reader_.getAllDetIds();
447  if (detIds.size() != nPixelDets) {
448  throw cms::Exception("Inconsistent Data")
449  << "The size of the detId list specified from file (" << detIds.size()
450  << ") differs from the one in TrackerGeometry (" << nPixelDets << ")! Please cross-check" << std::endl;
451  }
452 
453  for (const auto& it : detIds) {
454  auto topolInfo = setTopoInfo(it, tTopo_);
455 
456  std::string thePart = std::get<0>(topolInfo);
457 
458  // book the TFileDirectory if it's not already done
459  if (!outputFolders_.count(thePart)) {
460  LogDebug("NearbyPixelClustersAnalyzer") << "booking " << thePart << std::endl;
461  outputFolders_[thePart] = fs->mkdir(thePart);
462  }
463  }
464 
465  if (histoMap_.empty()) {
467  }
468 
469  edm::LogInfo("NearbyPixelClusterAnalyzer")
470  << "@SUB=NearbyPixelClusterAnalyzer::beginRun() After booking histoMap_.size(): " << histoMap_.size()
471  << std::endl;
472 }
std::map< std::string, TFileDirectory > outputFolders_
const std::vector< uint32_t > & getAllDetIds() const
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomEsTokenBR_
bool isThere(GeomDetEnumerators::SubDetector subdet) const
std::map< uint32_t, TH2F * > bookModuleHistograms(const TrackerTopology *tTopo)
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoEsTokenBR_
Log< level::Info, false > LogInfo
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
std::tuple< std::string, int, int, int > setTopoInfo(uint32_t detId, const TrackerTopology *tTopo)
std::map< uint32_t, TH2F * > histoMap_
#define LogDebug(id)
std::map< uint32_t, TH2F * > NearbyPixelClustersAnalyzer::bookModuleHistograms ( const TrackerTopology tTopo)
private

Definition at line 504 of file NearbyPixelClustersAnalyzer.cc.

References SiPixelDetInfoFileReader::getAllDetIds(), SiPixelDetInfoFileReader::getDetUnitDimensions(), convertParamsToOnlineFormat::moduleName, PixelBarrelName::name(), PixelEndcapName::name(), outputFolders_, phase_, PixelSubdetector::PixelBarrel, reader_, setTopoInfo(), AlCaHLTBitMon_QueryRunRegistry::string, and DetId::subdetId().

Referenced by beginRun().

506 {
507  std::map<uint32_t, TH2F*> hd;
508 
509  const auto& detIds = reader_.getAllDetIds();
510  for (const auto& it : detIds) {
511  // check if det id is correct and if it is actually cabled in the detector
512  if (it == 0 || it == 0xFFFFFFFF) {
513  edm::LogError("DetIdNotGood") << "@SUB=analyze"
514  << "Wrong det id: " << it << " ... neglecting!" << std::endl;
515  continue;
516  }
517 
518  auto topolInfo = setTopoInfo(it, tTopo_);
519  std::string thePart = std::get<0>(topolInfo);
520 
521  unsigned int nCols = reader_.getDetUnitDimensions(it).first;
522  unsigned int nRows = reader_.getDetUnitDimensions(it).second;
523 
524  int subdetId = DetId(it).subdetId();
525 
527  : PixelEndcapName(it, tTopo_, phase_).name();
528 
529  hd[it] = outputFolders_[thePart].make<TH2F>(
530  Form("ClusterFrame_%s", moduleName.c_str()),
531  Form("Cluster Map for module %s;n. cols;n. rows;pixel charge [ADC counts]", moduleName.c_str()),
532  nCols,
533  0,
534  nCols,
535  nRows,
536  0,
537  nRows);
538  }
539 
540  return hd;
541 }
const std::pair< int, int > & getDetUnitDimensions(uint32_t detId) const
std::map< std::string, TFileDirectory > outputFolders_
const std::vector< uint32_t > & getAllDetIds() const
Log< level::Error, false > LogError
std::string name() const override
from base class
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
Definition: DetId.h:17
std::string name() const override
from base class
std::tuple< std::string, int, int, int > setTopoInfo(uint32_t detId, const TrackerTopology *tTopo)
void NearbyPixelClustersAnalyzer::countClusters ( const edm::Handle< SiPixelClusterCollectionNew > &  handle,
unsigned int &  nClusGlobal 
)
private

Definition at line 341 of file NearbyPixelClustersAnalyzer.cc.

References LogDebug.

Referenced by analyze().

345 {
346  for (const auto& DSVItr : *handle) {
347  uint32_t rawid(DSVItr.detId());
348  DetId detId(rawid);
349  LogDebug("NearbyPixelClustersAnalyzer") << "DetId: " << detId.rawId() << " size: " << DSVItr.size() << std::endl;
350  nClusGlobal += DSVItr.size();
351  }
352 }
Definition: DetId.h:17
#define LogDebug(id)
bool NearbyPixelClustersAnalyzer::detidIsOnPixel ( const DetId detid)
private

Definition at line 303 of file NearbyPixelClustersAnalyzer.cc.

References DetId::det(), PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, DetId::subdetId(), and DetId::Tracker.

Referenced by analyze().

305 {
306  if (detid.det() != DetId::Tracker)
307  return false;
309  return true;
311  return true;
312  return false;
313 }
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
void NearbyPixelClustersAnalyzer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 298 of file NearbyPixelClustersAnalyzer.cc.

Referenced by o2olib.O2ORunMgr::executeJob().

298  {
299  // please remove this method if not needed
300 }
void NearbyPixelClustersAnalyzer::endRun ( edm::Run const &  ,
edm::EventSetup const &   
)
inlineoverrideprivate

Definition at line 69 of file NearbyPixelClustersAnalyzer.cc.

69 {};
void NearbyPixelClustersAnalyzer::fillClusterFrames ( const edm::Handle< SiPixelClusterCollectionNew > &  handle)
private

Definition at line 401 of file NearbyPixelClustersAnalyzer.cc.

References edmNew::DetSetVector< T >::begin(), edmNew::DetSetVector< T >::end(), patZpeak::handle, histoMap_, and mps_fire::i.

Referenced by analyze().

401  {
402  const SiPixelClusterCollectionNew& clusterCollection = *handle;
403  SiPixelClusterCollectionNew::const_iterator itClusterSet = clusterCollection.begin();
404 
405  for (; itClusterSet != clusterCollection.end(); itClusterSet++) {
406  DetId detId(itClusterSet->id());
407 
408  edmNew::DetSet<SiPixelCluster>::const_iterator itCluster = itClusterSet->begin();
409  for (; itCluster != itClusterSet->end(); ++itCluster) {
410  const std::vector<SiPixelCluster::Pixel> pixelsVec = (*itCluster).pixels();
411  for (unsigned int i = 0; i < pixelsVec.size(); ++i) {
412  float pixx = pixelsVec[i].x; // index as float=iteger, row index
413  float pixy = pixelsVec[i].y; // same, col index
414  float pixel_charge = pixelsVec[i].adc;
415  histoMap_[detId.rawId()]->Fill(pixy, pixx, pixel_charge);
416  }
417  }
418  }
419 }
const_iterator end(bool update=false) const
data_type const * const_iterator
Definition: DetSetNew.h:31
tuple handle
Definition: patZpeak.py:25
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
Definition: DetId.h:17
std::map< uint32_t, TH2F * > histoMap_
const_iterator begin(bool update=false) const
void NearbyPixelClustersAnalyzer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 544 of file NearbyPixelClustersAnalyzer.cc.

References edm::ParameterSetDescription::add(), edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, HLT_FULL_cff::InputTag, edm::ParameterSetDescription::setComment(), and AlCaHLTBitMon_QueryRunRegistry::string.

544  {
546  desc.setComment("Analysis of the closebyPixelClusters collections");
547  desc.add<edm::InputTag>("clusterCollection", edm::InputTag("ALCARECOSiPixelCalSingleMuonTight"));
548  desc.add<edm::InputTag>("nearByClusterCollection", edm::InputTag("closebyPixelClusters"));
549  desc.add<edm::InputTag>("trajectoryInput", edm::InputTag("refittedTracks"));
550  desc.add<edm::InputTag>("muonTracks", edm::InputTag("ALCARECOSiPixelCalSingleMuonTight"));
551  desc.add<edm::InputTag>("distToTrack", edm::InputTag("trackDistances"));
552  desc.add<std::string>("skimmedGeometryPath",
553  "SLHCUpgradeSimulations/Geometry/data/PhaseI/PixelSkimmedGeometry_phase1.txt");
554  descriptions.addWithDefaultLabel(desc);
555 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
void setComment(std::string const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::pair< float, float > NearbyPixelClustersAnalyzer::findClosestCluster ( const edm::Handle< SiPixelClusterCollectionNew > &  handle,
const PixelClusterParameterEstimator pixelCPE_,
const TrackerGeometry trackerGeometry_,
uint32_t  rawId,
float  traj_lx,
float  traj_ly 
)
private

Definition at line 355 of file NearbyPixelClustersAnalyzer.cc.

References edmNew::DetSetVector< T >::begin(), edmNew::DetSet< T >::end(), edmNew::DetSetVector< T >::end(), PixelClusterParameterEstimator::getParameters(), patZpeak::handle, TrackerGeometry::idToDetUnit(), submitPVValidationJobs::params, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, mathSSE::sqrt(), GeomDetEnumerators::subDetId, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by analyze().

363 {
364  const SiPixelClusterCollectionNew& clusterCollection = *handle;
365  SiPixelClusterCollectionNew::const_iterator itClusterSet = clusterCollection.begin();
366 
367  float minD = 10000.;
368 
369  auto loc = std::make_pair(-999., -999.);
370 
371  for (; itClusterSet != clusterCollection.end(); itClusterSet++) {
372  DetId detId(itClusterSet->id());
373  if (detId.rawId() != rawId)
374  continue;
375 
376  unsigned int subDetId = detId.subdetId();
377  if (subDetId != PixelSubdetector::PixelBarrel && subDetId != PixelSubdetector::PixelEndcap) {
378  edm::LogError("NearByPixelClustersAnalyzer")
379  << "ERROR: not a pixel cluster!!!" << std::endl; // should not happen
380  continue;
381  }
382 
383  const PixelGeomDetUnit* pixdet = (const PixelGeomDetUnit*)trackerGeometry_->idToDetUnit(detId);
384  edmNew::DetSet<SiPixelCluster>::const_iterator itCluster = itClusterSet->begin();
385  for (; itCluster != itClusterSet->end(); ++itCluster) {
386  LocalPoint lp(itCluster->x(), itCluster->y(), 0.);
387  PixelClusterParameterEstimator::ReturnType params = pixelCPE_->getParameters(*itCluster, *pixdet);
388  lp = std::get<0>(params);
389 
390  float D = sqrt((lp.x() - traj_lx) * (lp.x() - traj_lx) + (lp.y() - traj_ly) * (lp.y() - traj_ly));
391  if (D < minD) {
392  minD = D;
393  loc.first = (lp.x() - traj_lx);
394  loc.second = (lp.y() - traj_ly);
395  }
396  } // loop on cluster sets
397  }
398  return loc;
399 }
const_iterator end(bool update=false) const
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
constexpr unsigned int subDetId[21]
data_type const * const_iterator
Definition: DetSetNew.h:31
Log< level::Error, false > LogError
virtual ReturnType getParameters(const SiPixelCluster &cl, const GeomDetUnit &det) const =0
T sqrt(T t)
Definition: SSEVec.h:19
tuple handle
Definition: patZpeak.py:25
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
Definition: DetId.h:17
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:141
iterator end()
Definition: DetSetNew.h:56
std::tuple< LocalPoint, LocalError, SiPixelRecHitQuality::QualWordType > ReturnType
const_iterator begin(bool update=false) const
TrajectoryStateOnSurface NearbyPixelClustersAnalyzer::getTrajectoryStateOnSurface ( const TrajectoryMeasurement measurement)
private

Definition at line 316 of file NearbyPixelClustersAnalyzer.cc.

References TrajectoryMeasurement::backwardPredictedState(), and TrajectoryMeasurement::forwardPredictedState().

Referenced by analyze().

319 {
320  const static TrajectoryStateCombiner trajStateCombiner;
321 
322  const auto& forwardPredictedState = measurement.forwardPredictedState();
323  const auto& backwardPredictedState = measurement.backwardPredictedState();
324 
325  if (forwardPredictedState.isValid() && backwardPredictedState.isValid())
326  return trajStateCombiner(forwardPredictedState, backwardPredictedState);
327 
328  else if (backwardPredictedState.isValid())
329  return backwardPredictedState;
330 
331  else if (forwardPredictedState.isValid())
332  return forwardPredictedState;
333 
334  edm::LogError("NearbyPixelClusterProducer") << "Error saving traj. measurement data."
335  << " Trajectory state on surface cannot be determined." << std::endl;
336 
337  return TrajectoryStateOnSurface();
338 }
Log< level::Error, false > LogError
TrajectoryStateOnSurface const & forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
TrajectoryStateOnSurface const & backwardPredictedState() const
Access to backward predicted state (from smoother)
std::tuple< std::string, int, int, int > NearbyPixelClustersAnalyzer::setTopoInfo ( uint32_t  detId,
const TrackerTopology tTopo 
)
private

Definition at line 475 of file NearbyPixelClustersAnalyzer.cc.

References sistrip::layer_, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, TrackerTopology::pxbLayer(), TrackerTopology::pxfDisk(), TrackerTopology::pxfSide(), runTheMatrix::ret, side_(), AlCaHLTBitMon_QueryRunRegistry::string, and DetId::subdetId().

Referenced by beginRun(), and bookModuleHistograms().

478 {
479  int subdetId_(-999), layer_(-999), side_(-999);
480  std::string ret = "";
481 
482  subdetId_ = DetId(detId).subdetId();
483  switch (subdetId_) {
484  case PixelSubdetector::PixelBarrel: // PXB
485  layer_ = tTopo->pxbLayer(detId);
486  side_ = 0;
487  ret += Form("BPix_Layer%i", layer_);
488  break;
490  side_ = tTopo->pxfSide(detId);
491  layer_ = tTopo->pxfDisk(detId);
492  ret += ("FPix_");
493  ret += (side_ == 1) ? Form("P_disk%i", layer_) : Form("M_disk%i", layer_);
494  break;
495  default:
496  edm::LogError("NearbyPixelClusterAnalyzer") << "we should never be here!" << std::endl;
497  break;
498  }
499 
500  return std::make_tuple(ret, subdetId_, layer_, side_);
501 }
tuple ret
prodAgent to be discontinued
static const char layer_[]
unsigned int pxfDisk(const DetId &id) const
Log< level::Error, false > LogError
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
unsigned int pxbLayer(const DetId &id) const
side_(iConfig.getUntrackedParameter< int >("side", 3))
Definition: DetId.h:17
unsigned int pxfSide(const DetId &id) const

Member Data Documentation

edm::EDGetTokenT<SiPixelClusterCollectionNew> NearbyPixelClustersAnalyzer::clustersToken_
private

Definition at line 95 of file NearbyPixelClustersAnalyzer.cc.

Referenced by analyze().

edm::EDGetTokenT<edm::ValueMap<std::vector<float> > > NearbyPixelClustersAnalyzer::distanceToken_
private

Definition at line 98 of file NearbyPixelClustersAnalyzer.cc.

Referenced by analyze().

edm::Service<TFileService> NearbyPixelClustersAnalyzer::fs
private

Definition at line 101 of file NearbyPixelClustersAnalyzer.cc.

Referenced by beginJob(), and beginRun().

const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> NearbyPixelClustersAnalyzer::geomEsToken_
private

Definition at line 90 of file NearbyPixelClustersAnalyzer.cc.

Referenced by analyze().

const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> NearbyPixelClustersAnalyzer::geomEsTokenBR_
private

Definition at line 92 of file NearbyPixelClustersAnalyzer.cc.

Referenced by beginRun().

TH1F* NearbyPixelClustersAnalyzer::h_distClosestInactive
private

Definition at line 107 of file NearbyPixelClustersAnalyzer.cc.

Referenced by analyze(), and beginJob().

TH1F* NearbyPixelClustersAnalyzer::h_distClosestMissing
private

Definition at line 106 of file NearbyPixelClustersAnalyzer.cc.

Referenced by analyze(), and beginJob().

TH1F* NearbyPixelClustersAnalyzer::h_distClosestTrack
private

Definition at line 108 of file NearbyPixelClustersAnalyzer.cc.

Referenced by analyze(), and beginJob().

TH1F* NearbyPixelClustersAnalyzer::h_distClosestValid
private

Definition at line 105 of file NearbyPixelClustersAnalyzer.cc.

Referenced by analyze(), and beginJob().

TH1I* NearbyPixelClustersAnalyzer::h_nALCARECOClusters
private

Definition at line 103 of file NearbyPixelClustersAnalyzer.cc.

Referenced by analyze(), and beginJob().

TH1I* NearbyPixelClustersAnalyzer::h_nCloseByClusters
private

Definition at line 104 of file NearbyPixelClustersAnalyzer.cc.

Referenced by analyze(), and beginJob().

std::map<uint32_t, TH2F*> NearbyPixelClustersAnalyzer::histoMap_
private

Definition at line 112 of file NearbyPixelClustersAnalyzer.cc.

Referenced by beginRun(), and fillClusterFrames().

edm::EDGetTokenT<edm::View<reco::Track> > NearbyPixelClustersAnalyzer::muonTracksToken_
private

Definition at line 99 of file NearbyPixelClustersAnalyzer.cc.

Referenced by analyze().

edm::EDGetTokenT<SiPixelClusterCollectionNew> NearbyPixelClustersAnalyzer::nearByClustersToken_
private

Definition at line 96 of file NearbyPixelClustersAnalyzer.cc.

Referenced by analyze().

std::map<std::string, TFileDirectory> NearbyPixelClustersAnalyzer::outputFolders_
private

Definition at line 111 of file NearbyPixelClustersAnalyzer.cc.

Referenced by beginRun(), and bookModuleHistograms().

bool NearbyPixelClustersAnalyzer::phase_
private

Definition at line 113 of file NearbyPixelClustersAnalyzer.cc.

Referenced by beginRun(), and bookModuleHistograms().

const edm::ESGetToken<PixelClusterParameterEstimator, TkPixelCPERecord> NearbyPixelClustersAnalyzer::pixelCPEEsToken_
private

Definition at line 91 of file NearbyPixelClustersAnalyzer.cc.

Referenced by analyze().

SiPixelDetInfoFileReader NearbyPixelClustersAnalyzer::reader_
private

Definition at line 110 of file NearbyPixelClustersAnalyzer.cc.

Referenced by beginRun(), and bookModuleHistograms().

const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> NearbyPixelClustersAnalyzer::topoEsTokenBR_
private

Definition at line 93 of file NearbyPixelClustersAnalyzer.cc.

Referenced by beginRun().

edm::EDGetTokenT<TrajTrackAssociationCollection> NearbyPixelClustersAnalyzer::trajTrackCollectionToken_
private

Definition at line 97 of file NearbyPixelClustersAnalyzer.cc.

Referenced by analyze().