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  if (!tracks.isValid()) return;
53 
54  for (auto const & track : *tracks) {
55 
56  bool isBpixtrack = false, isFpixtrack = false;
57  int nStripHits = 0;
58 
59  // first, look at the full track to see whether it is good
60  // auto const & trajParams = track.extra()->trajParams();
61  auto hb = track.recHitsBegin();
62  for(unsigned int h=0;h<track.recHitsSize();h++){
63 
64  auto hit = *(hb+h);
65  if(!hit->isValid()) continue;
66 
67  DetId id = hit->geographicalId();
68  uint32_t subdetid = (id.subdetId());
69 
70  // count strip hits
71  if(subdetid==StripSubdetector::TIB) nStripHits++;
72  if(subdetid==StripSubdetector::TOB) nStripHits++;
73  if(subdetid==StripSubdetector::TID) nStripHits++;
74  if(subdetid==StripSubdetector::TEC) nStripHits++;
75 
76  // check that we are in the pixel
77  if (subdetid == PixelSubdetector::PixelBarrel) isBpixtrack = true;
78  if (subdetid == PixelSubdetector::PixelEndcap) isFpixtrack = true;
79  }
80 
81  if (!isBpixtrack && !isFpixtrack) continue;
82 
83  // then, look at each hit
84  for(unsigned int h=0;h<track.recHitsSize();h++){
85  auto hit = *(hb+h);
86 
87  DetId id = hit->geographicalId();
88  uint32_t subdetid = (id.subdetId());
89  if ( subdetid != PixelSubdetector::PixelBarrel
90  && subdetid != PixelSubdetector::PixelEndcap) continue;
91 
92  bool isHitValid = hit->getType()==TrackingRecHit::valid;
93  bool isHitMissing = hit->getType()==TrackingRecHit::missing;
94 
95  /*
96  const SiPixelRecHit* pixhit = dynamic_cast<const SiPixelRecHit*>(hit);
97  const PixelGeomDetUnit* geomdetunit = dynamic_cast<const PixelGeomDetUnit*> ( tracker->idToDet(id) );
98  const PixelTopology& topol = geomdetunit->specificTopology();
99 
100  // this commented part is useful if one wants ROC level maps of hits, however the local position may fall out of a ROC and the ROC maps will look very strange (with no white cross)
101  LocalPoint lp;
102 
103  if (pixhit) {
104  lp = pixhit->localPosition();
105  } else {
106  lp = trajParams[h].position();
107  }
108 
109  MeasurementPoint mp = topol.measurementPosition(lp);
110  int row = (int) mp.x();
111  int col = (int) mp.y();
112  */
113 
114  if (isHitValid) {
115  histo[VALID].fill(id, &iEvent);
116  histo[EFFICIENCY].fill(1, id, &iEvent);
117  }
118  if (isHitMissing) {
119  histo[MISSING].fill(id, &iEvent);
120  histo[EFFICIENCY].fill(0, id, &iEvent);
121  }
122  }
123  }
124 histo[VALID ].executePerEventHarvesting(&iEvent);
125 histo[MISSING].executePerEventHarvesting(&iEvent);
126 }
127 
129 
edm::EDGetTokenT< reco::TrackCollection > tracksToken_
T getParameter(std::string const &) const
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void analyze(const edm::Event &, const edm::EventSetup &)
int iEvent
Definition: GenABIO.cc:230
bool isValid() const
Definition: HandleBase.h:74
Definition: DetId.h:18
edm::EDGetTokenT< reco::VertexCollection > vtxToken_
const T & get() const
Definition: EventSetup.h:56
std::vector< HistogramManager > histo
bool isValid() const
Definition: ESHandle.h:47
SiPixelPhase1TrackEfficiency(const edm::ParameterSet &conf)