test
CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelPhase1TrackEfficiency.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiPixelPhase1TrackEfficiency
4 // Class: SiPixelPhase1TrackEfficiency
5 //
6 
7 // Original Author: Marcel Schneider
8 
11 
22 
23 
25  SiPixelPhase1Base(iConfig)
26 {
27  trackAssociationToken_ = consumes<TrajTrackAssociationCollection>(iConfig.getParameter<edm::InputTag>("trajectories"));
28  vtxToken_ = consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("primaryvertices"));
29 }
30 
32 
33  // get geometry
35  iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
36  assert(tracker.isValid());
37 
38  // get primary vertex
40  iEvent.getByToken( vtxToken_, vertices);
41  if (!vertices.isValid() || vertices->size() == 0) return;
42  // should be used for weird cuts
43  //const auto primaryVertex = vertices->at(0);
44 
45  // get the map
47  iEvent.getByToken( trackAssociationToken_, ttac);
48 
49  for (auto& item : *ttac) {
50  auto trajectory_ref = item.key;
51  reco::TrackRef track_ref = item.val;
52 
53  bool isBpixtrack = false, isFpixtrack = false;
54  int nStripHits = 0;
55 
56  // first, look at the full track to see whether it is good
57  for (auto& measurement : trajectory_ref->measurements()) {
58  // check if things are all valid
59  if (!measurement.updatedState().isValid()) continue;
60  auto hit = measurement.recHit();
61  if (!hit->isValid()) continue;
62 
63  DetId id = hit->geographicalId();
64  uint32_t subdetid = (id.subdetId());
65 
66  // count strip hits
67  if(subdetid==StripSubdetector::TIB) nStripHits++;
68  if(subdetid==StripSubdetector::TOB) nStripHits++;
69  if(subdetid==StripSubdetector::TID) nStripHits++;
70  if(subdetid==StripSubdetector::TEC) nStripHits++;
71 
72  // check that we are in the pixel
73  if (subdetid == PixelSubdetector::PixelBarrel) isBpixtrack = true;
74  if (subdetid == PixelSubdetector::PixelEndcap) isFpixtrack = true;
75  }
76 
77  if (!isBpixtrack && !isFpixtrack) continue;
78 
79  // then, look at each hit
80  for (auto& measurement : trajectory_ref->measurements()) {
81  if (!measurement.updatedState().isValid()) continue;
82  auto hit = measurement.recHit();
83 
84  DetId id = hit->geographicalId();
85  uint32_t subdetid = (id.subdetId());
86  if ( subdetid != PixelSubdetector::PixelBarrel
87  && subdetid != PixelSubdetector::PixelEndcap) continue;
88 
89  bool isHitValid = hit->getType()==TrackingRecHit::valid;
90  bool isHitMissing = hit->getType()==TrackingRecHit::missing;
91 
92  const SiPixelRecHit* pixhit = dynamic_cast<const SiPixelRecHit*>(hit->hit());
93  int row = 0, col = 0;
94  if (pixhit) {
95  double clusterProbability= pixhit->clusterProbability(0);
96  if (clusterProbability > 0)
97  histo[CLUSTER_PROB].fill(log10(clusterProbability), id, &iEvent);
98 
99  const PixelGeomDetUnit* geomdetunit = dynamic_cast<const PixelGeomDetUnit*> ( tracker->idToDet(id) );
100  const PixelTopology& topol = geomdetunit->specificTopology();
101  LocalPoint const& lp = pixhit->localPositionFast();
102  MeasurementPoint mp = topol.measurementPosition(lp);
103  row = (int) mp.x();
104  col = (int) mp.y();
105  }
106 
107  if (isHitValid) histo[VALID ].fill(id, &iEvent, col, row);
108  if (isHitMissing) histo[MISSING].fill(id, &iEvent, col, row);
109  }
110  }
111 }
112 
114 
T getParameter(std::string const &) const
float clusterProbability(unsigned int flags=0) const
T y() const
Definition: PV2DBase.h:46
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
assert(m_qm.get())
void analyze(const edm::Event &, const edm::EventSetup &)
int iEvent
Definition: GenABIO.cc:230
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
Definition: DetId.h:18
edm::EDGetTokenT< reco::VertexCollection > vtxToken_
const T & get() const
Definition: EventSetup.h:56
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
std::vector< HistogramManager > histo
const LocalPoint & localPositionFast() const
bool isValid() const
Definition: ESHandle.h:47
int col
Definition: cuy.py:1008
T x() const
Definition: PV2DBase.h:45
SiPixelPhase1TrackEfficiency(const edm::ParameterSet &conf)
Our base class.
Definition: SiPixelRecHit.h:23
edm::EDGetTokenT< TrajTrackAssociationCollection > trackAssociationToken_