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 
21 
23  SiPixelPhase1Base(iConfig)
24 {
25  srcToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("src"));
26 
27  offlinePrimaryVerticesToken_ = consumes<reco::VertexCollection>(std::string("offlinePrimaryVertices"));
28 
29  onlyValid_=iConfig.getParameter<bool>("onlyValidHits");
30 
31  applyVertexCut_=iConfig.getUntrackedParameter<bool>("VertexCut",true);
32 
33 }
34 
36 
38  iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
39  assert(tracker.isValid());
40 
42  iEvent.getByToken( srcToken_, tracks);
43  if (!tracks.isValid()) return;
44 
46  iEvent.getByToken(offlinePrimaryVerticesToken_, vertices);
47 
48  if (applyVertexCut_ && (!vertices.isValid() || vertices->size() == 0)) return;
49 
50 
51  for (auto const & track : *tracks) {
52 
53  if (applyVertexCut_ && (track.pt() < 0.75 || std::abs( track.dxy(vertices->at(0).position()) ) > 5*track.dxyError())) continue;
54 
55  bool isBpixtrack = false, isFpixtrack = false;
56 
57  auto const & trajParams = track.extra()->trajParams();
58  auto hb = track.recHitsBegin();
59  for(unsigned int h=0;h<track.recHitsSize();h++){
60 
61  auto hit = *(hb+h);
62  if(!hit->isValid()) continue;
63 
64  DetId id = hit->geographicalId();
65  uint32_t subdetid = (id.subdetId());
66 
67  if (subdetid == PixelSubdetector::PixelBarrel) isBpixtrack = true;
68  if (subdetid == PixelSubdetector::PixelEndcap) isFpixtrack = true;
69  }
70 
71  if (!isBpixtrack && !isFpixtrack) continue;
72 
73  // then, look at each hit
74  for(unsigned int h=0;h<track.recHitsSize();h++){
75  auto rechit = *(hb+h);
76 
77  if(!rechit->isValid()) continue;
78 
79  //continue if not a Pixel recHit
80  DetId id = rechit->geographicalId();
81  uint32_t subdetid = (id.subdetId());
82 
83  if ( subdetid != PixelSubdetector::PixelBarrel
84  && subdetid != PixelSubdetector::PixelEndcap) continue;
85 
86  bool isHitValid = rechit->getType()==TrackingRecHit::valid;
87  if (onlyValid_ && !isHitValid) continue; //useful to run on cosmics where the TrackEfficiency plugin is not used
88 
89  const SiPixelRecHit* prechit = dynamic_cast<const SiPixelRecHit*>(rechit);//to be used to get the associated cluster and the cluster probability
90 
91  int sizeX=0, sizeY=0;
92 
93  if (isHitValid){
94  SiPixelRecHit::ClusterRef const& clust = prechit->cluster();
95  sizeX = (*clust).sizeX();
96  sizeY = (*clust).sizeY();
97  }
98 
99  const PixelGeomDetUnit* geomdetunit = dynamic_cast<const PixelGeomDetUnit*> ( tracker->idToDet(id) );
100  const PixelTopology& topol = geomdetunit->specificTopology();
101 
102  LocalPoint lp = trajParams[h].position();
103  MeasurementPoint mp = topol.measurementPosition(lp);
104 
105  int row = (int) mp.x();
106  int col = (int) mp.y();
107 
108  float rechit_x = lp.x();
109  float rechit_y = lp.y();
110 
111  LocalError lerr = rechit->localPositionError();
112  float lerr_x = sqrt(lerr.xx());
113  float lerr_y = sqrt(lerr.yy());
114 
115  histo[NRECHITS].fill(id, &iEvent, col, row); //in general a inclusive counter of missing/valid/inactive hits
116 
117  if (isHitValid){
118  histo[CLUST_X].fill(sizeX, id, &iEvent, col, row);
119  histo[CLUST_Y].fill(sizeY, id, &iEvent, col, row);
120  }
121 
122  histo[ERROR_X].fill(lerr_x, id, &iEvent);
123  histo[ERROR_Y].fill(lerr_y, id, &iEvent);
124 
125  histo[POS].fill(rechit_x, rechit_y, id, &iEvent);
126 
127  if (isHitValid){
128  double clusterProbability= prechit->clusterProbability(0);
129  if (clusterProbability > 0)
130  histo[CLUSTER_PROB].fill(log10(clusterProbability), id, &iEvent);
131  }
132  }
133  }
134 
135  histo[NRECHITS].executePerEventHarvesting(&iEvent);
136 }
137 
139 
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
float xx() const
Definition: LocalError.h:24
float clusterProbability(unsigned int flags=0) 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:460
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void analyze(const edm::Event &, const edm::EventSetup &)
SiPixelPhase1RecHits(const edm::ParameterSet &conf)
T y() const
Definition: PV3DBase.h:63
int iEvent
Definition: GenABIO.cc:230
float yy() const
Definition: LocalError.h:26
T sqrt(T t)
Definition: SSEVec.h:18
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isValid() const
Definition: HandleBase.h:74
Definition: DetId.h:18
ClusterRef cluster() const
Definition: SiPixelRecHit.h:49
const T & get() const
Definition: EventSetup.h:55
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
std::vector< HistogramManager > histo
col
Definition: cuy.py:1008
const TrackerGeomDet * idToDet(DetId) const override
bool isValid() const
Definition: ESHandle.h:47
T x() const
Definition: PV2DBase.h:45
T x() const
Definition: PV3DBase.h:62
edm::EDGetTokenT< reco::VertexCollection > offlinePrimaryVerticesToken_
edm::EDGetTokenT< reco::TrackCollection > srcToken_
Our base class.
Definition: SiPixelRecHit.h:23