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);
ClusterRef cluster() const
Definition: SiPixelRecHit.h:47
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
bool isOnEdge() const
Definition: SiPixelRecHit.h:97
bool isFromDet(TrackingRecHit const &hit)
bool hasBadPixels() const
Definition: SiPixelRecHit.h:99
T x() const
Definition: PV2DBase.h:43
assert(be >=bs)
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
T y() const
Definition: PV2DBase.h:44
float yy() const
Definition: LocalError.h:24
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
int iEvent
Definition: GenABIO.cc:224
T sqrt(T t)
Definition: SSEVec.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
float clusterProbability(unsigned int flags=0) const
Definition: SiPixelRecHit.cc:9
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
Definition: DetId.h:17
void analyze(edm::Event const &e, edm::EventSetup const &) override=0
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
col
Definition: cuy.py:1009
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
float xx() const
Definition: LocalError.h:22
Our base class.
Definition: SiPixelRecHit.h:23