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 
23 
24 namespace {
25 
26  class SiPixelPhase1RecHits final : public SiPixelPhase1Base {
27  enum { NRECHITS, CLUST_X, CLUST_Y, ERROR_X, ERROR_Y, POS, CLUSTER_PROB, NONEDGE, NOTHERBAD };
28 
29  public:
30  explicit SiPixelPhase1RecHits(const edm::ParameterSet& conf);
31  void analyze(const edm::Event&, const edm::EventSetup&) override;
32 
33  private:
35  edm::EDGetTokenT<reco::VertexCollection> offlinePrimaryVerticesToken_;
36 
38 
39  bool onlyValid_;
40  bool applyVertexCut_;
41  };
42 
43  SiPixelPhase1RecHits::SiPixelPhase1RecHits(const edm::ParameterSet& iConfig) : SiPixelPhase1Base(iConfig) {
44  srcToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("src"));
45 
46  offlinePrimaryVerticesToken_ = consumes<reco::VertexCollection>(std::string("offlinePrimaryVertices"));
47 
48  trackerGeomToken_ = esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>();
49 
50  onlyValid_ = iConfig.getParameter<bool>("onlyValidHits");
51 
52  applyVertexCut_ = iConfig.getUntrackedParameter<bool>("VertexCut", true);
53  }
54 
56  if (!checktrigger(iEvent, iSetup, DCS))
57  return;
58 
59  edm::ESHandle<TrackerGeometry> tracker = iSetup.getHandle(trackerGeomToken_);
60  assert(tracker.isValid());
61 
63  iEvent.getByToken(srcToken_, tracks);
64  if (!tracks.isValid())
65  return;
66 
68  iEvent.getByToken(offlinePrimaryVerticesToken_, vertices);
69 
70  if (applyVertexCut_ && (!vertices.isValid() || vertices->empty()))
71  return;
72 
73  for (auto const& track : *tracks) {
74  if (applyVertexCut_ &&
75  (track.pt() < 0.75 || std::abs(track.dxy(vertices->at(0).position())) > 5 * track.dxyError()))
76  continue;
77 
78  bool isBpixtrack = false, isFpixtrack = false;
79 
80  auto const& trajParams = track.extra()->trajParams();
81  auto hb = track.recHitsBegin();
82  for (unsigned int h = 0; h < track.recHitsSize(); h++) {
83  auto hit = *(hb + h);
85  continue;
86 
87  DetId id = hit->geographicalId();
88  uint32_t subdetid = (id.subdetId());
89 
90  if (subdetid == PixelSubdetector::PixelBarrel)
91  isBpixtrack = true;
92  if (subdetid == PixelSubdetector::PixelEndcap)
93  isFpixtrack = true;
94  }
95 
96  if (!isBpixtrack && !isFpixtrack)
97  continue;
98 
99  // then, look at each hit
100  for (unsigned int h = 0; h < track.recHitsSize(); h++) {
101  auto rechit = *(hb + h);
102 
103  if (!trackerHitRTTI::isFromDet(*rechit))
104  continue;
105 
106  //continue if not a Pixel recHit
107  DetId id = rechit->geographicalId();
108  uint32_t subdetid = (id.subdetId());
109 
110  if (subdetid != PixelSubdetector::PixelBarrel && subdetid != PixelSubdetector::PixelEndcap)
111  continue;
112 
113  bool isHitValid = rechit->getType() == TrackingRecHit::valid;
114  if (onlyValid_ && !isHitValid)
115  continue; //useful to run on cosmics where the TrackEfficiency plugin is not used
116 
117  const SiPixelRecHit* prechit = dynamic_cast<const SiPixelRecHit*>(
118  rechit); //to be used to get the associated cluster and the cluster probability
119 
120  int sizeX = 0, sizeY = 0;
121 
122  if (isHitValid) {
123  SiPixelRecHit::ClusterRef const& clust = prechit->cluster();
124  sizeX = (*clust).sizeX();
125  sizeY = (*clust).sizeY();
126  }
127 
128  const PixelGeomDetUnit* geomdetunit = dynamic_cast<const PixelGeomDetUnit*>(tracker->idToDet(id));
129  const PixelTopology& topol = geomdetunit->specificTopology();
130 
131  LocalPoint lp = trajParams[h].position();
132  MeasurementPoint mp = topol.measurementPosition(lp);
133 
134  int row = (int)mp.x();
135  int col = (int)mp.y();
136 
137  float rechit_x = lp.x();
138  float rechit_y = lp.y();
139 
140  LocalError lerr = rechit->localPositionError();
141  float lerr_x = sqrt(lerr.xx());
142  float lerr_y = sqrt(lerr.yy());
143 
144  histo[NRECHITS].fill(id, &iEvent, col, row); //in general a inclusive counter of missing/valid/inactive hits
145  if (prechit->isOnEdge())
146  histo[NONEDGE].fill(id, &iEvent, col, row);
147  if (prechit->hasBadPixels())
148  histo[NOTHERBAD].fill(id, &iEvent, col, row);
149 
150  if (isHitValid) {
151  histo[CLUST_X].fill(sizeX, id, &iEvent, col, row);
152  histo[CLUST_Y].fill(sizeY, id, &iEvent, col, row);
153  }
154 
155  histo[ERROR_X].fill(lerr_x, id, &iEvent);
156  histo[ERROR_Y].fill(lerr_y, id, &iEvent);
157 
158  histo[POS].fill(rechit_x, rechit_y, id, &iEvent);
159 
160  if (isHitValid) {
161  double clusterProbability = prechit->clusterProbability(0);
162  if (clusterProbability > 0)
163  histo[CLUSTER_PROB].fill(log10(clusterProbability), id, &iEvent);
164  }
165  }
166  }
167 
168  histo[NRECHITS].executePerEventHarvesting(&iEvent);
169  histo[NONEDGE].executePerEventHarvesting(&iEvent);
170  histo[NOTHERBAD].executePerEventHarvesting(&iEvent);
171  }
172 
173 } //namespace
174 
175 DEFINE_FWK_MODULE(SiPixelPhase1RecHits);
Point2DBase
Definition: Point2DBase.h:9
PixelSubdetector.h
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
PixelSubdetector::PixelEndcap
Definition: PixelSubdetector.h:11
TrackerGeometry.h
PixelSubdetector::PixelBarrel
Definition: PixelSubdetector.h:11
PixelTopology.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
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
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:47
RecoTauValidation_cfi.sizeX
sizeX
Definition: RecoTauValidation_cfi.py:290
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:159
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:36
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
analyze
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EventSetup
Definition: EventSetup.h:58
hcalSimParameters_cfi.hb
hb
Definition: hcalSimParameters_cfi.py:60
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord >
TrackingRecHit::valid
Definition: TrackingRecHit.h:46
SiPixelPhase1Base::analyze
void analyze(edm::Event const &e, edm::EventSetup const &) override=0
VertexFwd.h
SiPixelPhase1Base.h
LocalPoint.h
PixelGeomDetUnit.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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