CMS 3D CMS Logo

SiPixelPhase1RecHits.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiPixelPhase1RecHits
4 // Class: SiPixelPhase1RecHits
5 //
6 
7 // Original Author: Marcel Schneider
8 
24 
25 namespace {
26 
27  class SiPixelPhase1RecHits final : public SiPixelPhase1Base {
28  enum { NRECHITS, CLUST_X, CLUST_Y, ERROR_X, ERROR_Y, POS, CLUSTER_PROB, NONEDGE, NOTHERBAD };
29 
30  public:
31  explicit SiPixelPhase1RecHits(const edm::ParameterSet& conf);
32  void analyze(const edm::Event&, const edm::EventSetup&) override;
33 
34  private:
36  edm::EDGetTokenT<reco::VertexCollection> offlinePrimaryVerticesToken_;
37 
38  bool onlyValid_;
39  bool applyVertexCut_;
40  };
41 
42  SiPixelPhase1RecHits::SiPixelPhase1RecHits(const edm::ParameterSet& iConfig) : SiPixelPhase1Base(iConfig) {
43  srcToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("src"));
44 
45  offlinePrimaryVerticesToken_ = consumes<reco::VertexCollection>(std::string("offlinePrimaryVertices"));
46 
47  onlyValid_ = iConfig.getParameter<bool>("onlyValidHits");
48 
49  applyVertexCut_ = iConfig.getUntrackedParameter<bool>("VertexCut", true);
50  }
51 
53  if (!checktrigger(iEvent, iSetup, DCS))
54  return;
55 
58  assert(tracker.isValid());
59 
61  iEvent.getByToken(srcToken_, tracks);
62  if (!tracks.isValid())
63  return;
64 
66  iEvent.getByToken(offlinePrimaryVerticesToken_, vertices);
67 
68  if (applyVertexCut_ && (!vertices.isValid() || vertices->empty()))
69  return;
70 
71  for (auto const& track : *tracks) {
72  if (applyVertexCut_ &&
73  (track.pt() < 0.75 || std::abs(track.dxy(vertices->at(0).position())) > 5 * track.dxyError()))
74  continue;
75 
76  bool isBpixtrack = false, isFpixtrack = false;
77 
78  auto const& trajParams = track.extra()->trajParams();
79  auto hb = track.recHitsBegin();
80  for (unsigned int h = 0; h < track.recHitsSize(); h++) {
81  auto hit = *(hb + h);
83  continue;
84 
85  DetId id = hit->geographicalId();
86  uint32_t subdetid = (id.subdetId());
87 
88  if (subdetid == PixelSubdetector::PixelBarrel)
89  isBpixtrack = true;
90  if (subdetid == PixelSubdetector::PixelEndcap)
91  isFpixtrack = true;
92  }
93 
94  if (!isBpixtrack && !isFpixtrack)
95  continue;
96 
97  // then, look at each hit
98  for (unsigned int h = 0; h < track.recHitsSize(); h++) {
99  auto rechit = *(hb + h);
100 
101  if (!trackerHitRTTI::isFromDet(*rechit))
102  continue;
103 
104  //continue if not a Pixel recHit
105  DetId id = rechit->geographicalId();
106  uint32_t subdetid = (id.subdetId());
107 
108  if (subdetid != PixelSubdetector::PixelBarrel && subdetid != PixelSubdetector::PixelEndcap)
109  continue;
110 
111  bool isHitValid = rechit->getType() == TrackingRecHit::valid;
112  if (onlyValid_ && !isHitValid)
113  continue; //useful to run on cosmics where the TrackEfficiency plugin is not used
114 
115  const SiPixelRecHit* prechit = dynamic_cast<const SiPixelRecHit*>(
116  rechit); //to be used to get the associated cluster and the cluster probability
117 
118  int sizeX = 0, sizeY = 0;
119 
120  if (isHitValid) {
121  SiPixelRecHit::ClusterRef const& clust = prechit->cluster();
122  sizeX = (*clust).sizeX();
123  sizeY = (*clust).sizeY();
124  }
125 
126  const PixelGeomDetUnit* geomdetunit = dynamic_cast<const PixelGeomDetUnit*>(tracker->idToDet(id));
127  const PixelTopology& topol = geomdetunit->specificTopology();
128 
129  LocalPoint lp = trajParams[h].position();
130  MeasurementPoint mp = topol.measurementPosition(lp);
131 
132  int row = (int)mp.x();
133  int col = (int)mp.y();
134 
135  float rechit_x = lp.x();
136  float rechit_y = lp.y();
137 
138  LocalError lerr = rechit->localPositionError();
139  float lerr_x = sqrt(lerr.xx());
140  float lerr_y = sqrt(lerr.yy());
141 
142  histo[NRECHITS].fill(id, &iEvent, col, row); //in general a inclusive counter of missing/valid/inactive hits
143  if (prechit->isOnEdge())
144  histo[NONEDGE].fill(id, &iEvent, col, row);
145  if (prechit->hasBadPixels())
146  histo[NOTHERBAD].fill(id, &iEvent, col, row);
147 
148  if (isHitValid) {
149  histo[CLUST_X].fill(sizeX, id, &iEvent, col, row);
150  histo[CLUST_Y].fill(sizeY, id, &iEvent, col, row);
151  }
152 
153  histo[ERROR_X].fill(lerr_x, id, &iEvent);
154  histo[ERROR_Y].fill(lerr_y, id, &iEvent);
155 
156  histo[POS].fill(rechit_x, rechit_y, id, &iEvent);
157 
158  if (isHitValid) {
159  double clusterProbability = prechit->clusterProbability(0);
160  if (clusterProbability > 0)
161  histo[CLUSTER_PROB].fill(log10(clusterProbability), id, &iEvent);
162  }
163  }
164  }
165 
166  histo[NRECHITS].executePerEventHarvesting(&iEvent);
167  histo[NONEDGE].executePerEventHarvesting(&iEvent);
168  histo[NOTHERBAD].executePerEventHarvesting(&iEvent);
169  }
170 
171 } //namespace
172 
173 DEFINE_FWK_MODULE(SiPixelPhase1RecHits);
Point2DBase
Definition: Point2DBase.h:9
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
PixelSubdetector.h
PixelSubdetector::PixelEndcap
Definition: PixelSubdetector.h:11
TrackerGeometry.h
PixelSubdetector::PixelBarrel
Definition: PixelSubdetector.h:11
PixelTopology.h
ESHandle.h
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
edm::EDGetTokenT< reco::TrackCollection >
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
cuy.col
col
Definition: cuy.py:1010
SiPixelCluster.h
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
cms::cuda::assert
assert(be >=bs)
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::Handle< reco::TrackCollection >
SiPixelRecHit::cluster
ClusterRef cluster() const
Definition: SiPixelRecHit.h:47
SiPixelRecHit
Our base class.
Definition: SiPixelRecHit.h:23
edm::Ref
Definition: AssociativeIterator.h:58
SiPixelPhase1Base
Definition: SiPixelPhase1Base.h:46
DetId
Definition: DetId.h:17
MakerMacros.h
Track.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
LocalError::xx
float xx() const
Definition: LocalError.h:22
PixelGeomDetUnit
Definition: PixelGeomDetUnit.h:15
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
edm::ESHandle< TrackerGeometry >
RecoTauValidation_cfi.sizeY
sizeY
Definition: RecoTauValidation_cfi.py:291
h
Point3DBase< float, LocalTag >
SiPixelRecHit.h
PixelTopology
Definition: PixelTopology.h:10
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Vertex.h
PbPb_ZMuSkimMuonDPG_cff.tracker
tracker
Definition: PbPb_ZMuSkimMuonDPG_cff.py:60
ntuplemaker.fill
fill
Definition: ntuplemaker.py:304
TrackerDigiGeometryRecord.h
edm::ParameterSet
Definition: ParameterSet.h:36
RecoTauValidation_cfi.sizeX
sizeX
Definition: RecoTauValidation_cfi.py:290
LocalError
Definition: LocalError.h:12
PV2DBase::y
T y() const
Definition: PV2DBase.h:44
PixelGeomDetUnit::specificTopology
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
Definition: PixelGeomDetUnit.cc:17
PV2DBase::x
T x() const
Definition: PV2DBase.h:43
CertificationClient_cfi.DCS
DCS
Definition: CertificationClient_cfi.py:9
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
trackerHitRTTI::isFromDet
bool isFromDet(TrackingRecHit const &hit)
Definition: trackerHitRTTI.h:35
analyze
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
TrackingRecHit::valid
Definition: TrackingRecHit.h:46
SiPixelPhase1Base::analyze
void analyze(edm::Event const &e, edm::EventSetup const &) override=0
VertexFwd.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
SiPixelPhase1Base.h
es_hardcode_cfi.hb
hb
Definition: es_hardcode_cfi.py:85
LocalPoint.h
PixelGeomDetUnit.h
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::Event
Definition: Event.h:73
LocalError::yy
float yy() const
Definition: LocalError.h:24
SiPixelRecHit::clusterProbability
float clusterProbability(unsigned int flags=0) const
Definition: SiPixelRecHit.cc:9
SiPixelRecHit::hasBadPixels
bool hasBadPixels() const
Definition: SiPixelRecHit.h:99
edm::InputTag
Definition: InputTag.h:15
hit
Definition: SiStripHitEffFromCalibTree.cc:88
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7
SiPixelRecHit::isOnEdge
bool isOnEdge() const
Definition: SiPixelRecHit.h:97