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 
10 
13 
18 
20 
22 
24 
26 
28  SiPixelPhase1Base(iConfig)
29 {
30  srcToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("src"));
31  onlyValid_=iConfig.getParameter<bool>("onlyValidHits");
32 }
33 
35 
37  iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
38  assert(tracker.isValid());
39 
41  iEvent.getByToken( srcToken_, tracks);
42  if (!tracks.isValid()) return;
43 
44  for (auto const & track : *tracks) {
45 
46  bool isBpixtrack = false, isFpixtrack = false;
47 
48  auto const & trajParams = track.extra()->trajParams();
49  auto hb = track.recHitsBegin();
50  for(unsigned int h=0;h<track.recHitsSize();h++){
51 
52  auto hit = *(hb+h);
53  if(!hit->isValid()) continue;
54 
55  DetId id = hit->geographicalId();
56  uint32_t subdetid = (id.subdetId());
57 
58  if (subdetid == PixelSubdetector::PixelBarrel) isBpixtrack = true;
59  if (subdetid == PixelSubdetector::PixelEndcap) isFpixtrack = true;
60  }
61 
62  if (!isBpixtrack && !isFpixtrack) continue;
63 
64  // then, look at each hit
65  for(unsigned int h=0;h<track.recHitsSize();h++){
66  auto rechit = *(hb+h);
67 
68  if(!rechit->isValid()) continue;
69 
70  //continue if not a Pixel recHit
71  DetId id = rechit->geographicalId();
72  uint32_t subdetid = (id.subdetId());
73 
74  if ( subdetid != PixelSubdetector::PixelBarrel
75  && subdetid != PixelSubdetector::PixelEndcap) continue;
76 
77  bool isHitValid = rechit->getType()==TrackingRecHit::valid;
78  if (onlyValid_ && !isHitValid) continue; //useful to run on cosmics where the TrackEfficiency plugin is not used
79 
80  const SiPixelRecHit* prechit = dynamic_cast<const SiPixelRecHit*>(rechit);//to be used to get the associated cluster and the cluster probability
81 
82  int sizeX=0, sizeY=0;
83 
84  if (isHitValid){
85  SiPixelRecHit::ClusterRef const& clust = prechit->cluster();
86  sizeX = (*clust).sizeX();
87  sizeY = (*clust).sizeY();
88  }
89 
90  const PixelGeomDetUnit* geomdetunit = dynamic_cast<const PixelGeomDetUnit*> ( tracker->idToDet(id) );
91  const PixelTopology& topol = geomdetunit->specificTopology();
92 
93  LocalPoint lp = trajParams[h].position();
95 
96  int row = (int) mp.x();
97  int col = (int) mp.y();
98 
99  float rechit_x = lp.x();
100  float rechit_y = lp.y();
101 
102  LocalError lerr = rechit->localPositionError();
103  float lerr_x = sqrt(lerr.xx());
104  float lerr_y = sqrt(lerr.yy());
105 
106  histo[NRECHITS].fill(id, &iEvent, col, row); //in general a inclusive counter of missing/valid/inactive hits
107 
108  if (isHitValid){
109  histo[CLUST_X].fill(sizeX, id, &iEvent, col, row);
110  histo[CLUST_Y].fill(sizeY, id, &iEvent, col, row);
111  }
112 
113  histo[ERROR_X].fill(lerr_x, id, &iEvent);
114  histo[ERROR_Y].fill(lerr_y, id, &iEvent);
115 
116  histo[POS].fill(rechit_x, rechit_y, id, &iEvent);
117 
118  if (isHitValid){
119  double clusterProbability= prechit->clusterProbability(0);
120  if (clusterProbability > 0)
121  histo[CLUSTER_PROB].fill(log10(clusterProbability), id, &iEvent);
122  }
123  }
124  }
125 
126  histo[NRECHITS].executePerEventHarvesting(&iEvent);
127 }
128 
130 
T getParameter(std::string 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:457
#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
Definition: DetId.h:18
ClusterRef cluster() const
Definition: SiPixelRecHit.h:49
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
T x() const
Definition: PV3DBase.h:62
edm::EDGetTokenT< reco::TrackCollection > srcToken_
const TrackerGeomDet * idToDet(DetId) const
Our base class.
Definition: SiPixelRecHit.h:23