CMS 3D CMS Logo

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  tracksToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracks"));
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 
42  if (!vertices.isValid()) return;
43  histo[VERTICES].fill(vertices->size(),DetId(0),&iEvent);
44  if (vertices->size() == 0) return;
45 
46  // should be used for weird cuts
47  //const auto primaryVertex = vertices->at(0);
48 
49  // get the map
51  iEvent.getByToken( tracksToken_, tracks);
52 
53  for (auto const & track : *tracks) {
54 
55  bool isBpixtrack = false, isFpixtrack = false;
56  int nStripHits = 0;
57 
58  // first, look at the full track to see whether it is good
59  auto const & trajParams = track.extra()->trajParams();
60  auto hb = track.recHitsBegin();
61  for(unsigned int h=0;h<track.recHitsSize();h++){
62  auto hit = *(hb+h);
63  if(!hit->isValid()) continue;
64 
65  DetId id = hit->geographicalId();
66  uint32_t subdetid = (id.subdetId());
67 
68  // count strip hits
69  if(subdetid==StripSubdetector::TIB) nStripHits++;
70  if(subdetid==StripSubdetector::TOB) nStripHits++;
71  if(subdetid==StripSubdetector::TID) nStripHits++;
72  if(subdetid==StripSubdetector::TEC) nStripHits++;
73 
74  // check that we are in the pixel
75  if (subdetid == PixelSubdetector::PixelBarrel) isBpixtrack = true;
76  if (subdetid == PixelSubdetector::PixelEndcap) isFpixtrack = true;
77  }
78 
79  if (!isBpixtrack && !isFpixtrack) continue;
80 
81  // then, look at each hit
82  for(unsigned int h=0;h<track.recHitsSize();h++){
83  auto hit = *(hb+h);
84 
85  DetId id = hit->geographicalId();
86  uint32_t subdetid = (id.subdetId());
87  if ( subdetid != PixelSubdetector::PixelBarrel
88  && subdetid != PixelSubdetector::PixelEndcap) continue;
89 
90  bool isHitValid = hit->getType()==TrackingRecHit::valid;
91  bool isHitMissing = hit->getType()==TrackingRecHit::missing;
92 
93  const SiPixelRecHit* pixhit = dynamic_cast<const SiPixelRecHit*>(hit);
94  const PixelGeomDetUnit* geomdetunit = dynamic_cast<const PixelGeomDetUnit*> ( tracker->idToDet(id) );
95  const PixelTopology& topol = geomdetunit->specificTopology();
96  LocalPoint lp;
97  if (pixhit) {
98  lp = pixhit->localPosition();
99  } else {
100  lp = trajParams[h].position();
101  }
102 
103  MeasurementPoint mp = topol.measurementPosition(lp);
104  int row = (int) mp.x();
105  int col = (int) mp.y();
106 
107 
108  if (isHitValid) {
109  histo[VALID].fill(id, &iEvent, col, row);
110  histo[EFFICIENCY].fill(1, id, &iEvent, col, row);
111  }
112  if (isHitMissing) {
113  histo[MISSING].fill(id, &iEvent, col, row);
114  histo[EFFICIENCY].fill(0, id, &iEvent, col, row);
115  }
116  }
117  }
118 histo[VALID ].executePerEventHarvesting(&iEvent);
119 histo[MISSING].executePerEventHarvesting(&iEvent);
120 }
121 
123 
edm::EDGetTokenT< reco::TrackCollection > tracksToken_
T getParameter(std::string const &) const
T y() const
Definition: PV2DBase.h:46
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void analyze(const edm::Event &, const edm::EventSetup &)
int iEvent
Definition: GenABIO.cc:230
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
virtual LocalPoint localPosition() const final
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
col
Definition: cuy.py:1008
bool isValid() const
Definition: ESHandle.h:47
T x() const
Definition: PV2DBase.h:45
SiPixelPhase1TrackEfficiency(const edm::ParameterSet &conf)
const TrackerGeomDet * idToDet(DetId) const
Our base class.
Definition: SiPixelRecHit.h:23