CMS 3D CMS Logo

SiPixelPhase1TrackClusters.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiPixelPhase1TrackClusters
4 // Class : SiPixelPhase1TrackClusters
5 //
6 
7 // Original Author: Marcel Schneider
8 
11 
16 
19 
29 
31 
34 
35 namespace {
36 
37  class SiPixelPhase1TrackClusters final : public SiPixelPhase1Base {
38  enum {
39  ON_TRACK_CHARGE,
40  ON_TRACK_BIGPIXELCHARGE,
41  ON_TRACK_NOTBIGPIXELCHARGE,
42  ON_TRACK_SIZE,
43  ON_TRACK_SHAPE,
44  ON_TRACK_NCLUSTERS,
45  ON_TRACK_POSITIONB,
46  ON_TRACK_POSITIONF,
47  DIGIS_HITMAP_ON_TRACK,
48  ON_TRACK_NDIGIS,
49 
50  NTRACKS,
51  NTRACKS_INVOLUME,
52 
53  SIZE_VS_ETA_ON_TRACK_OUTER,
54  SIZE_VS_ETA_ON_TRACK_INNER,
55  ON_TRACK_CHARGE_OUTER,
56  ON_TRACK_CHARGE_INNER,
57 
58  ON_TRACK_SHAPE_OUTER,
59  ON_TRACK_SHAPE_INNER,
60 
61  ON_TRACK_SIZE_X_OUTER,
62  ON_TRACK_SIZE_X_INNER,
63  ON_TRACK_SIZE_X_F,
64  ON_TRACK_SIZE_Y_OUTER,
65  ON_TRACK_SIZE_Y_INNER,
66  ON_TRACK_SIZE_Y_F,
67 
68  ON_TRACK_SIZE_XY_OUTER,
69  ON_TRACK_SIZE_XY_INNER,
70  ON_TRACK_SIZE_XY_F,
71  CHARGE_VS_SIZE_ON_TRACK,
72 
73  ENUM_SIZE
74  };
75 
76  public:
77  explicit SiPixelPhase1TrackClusters(const edm::ParameterSet& conf);
78  void analyze(const edm::Event&, const edm::EventSetup&) override;
79 
80  private:
81  const bool applyVertexCut_;
82 
84  edm::EDGetTokenT<reco::VertexCollection> offlinePrimaryVerticesToken_;
85  edm::EDGetTokenT<SiPixelClusterShapeCache> pixelClusterShapeCacheToken_;
86  };
87 
88  SiPixelPhase1TrackClusters::SiPixelPhase1TrackClusters(const edm::ParameterSet& iConfig)
89  : SiPixelPhase1Base(iConfig), applyVertexCut_(iConfig.getUntrackedParameter<bool>("VertexCut", true)) {
90  tracksToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("tracks"));
91 
92  offlinePrimaryVerticesToken_ =
93  applyVertexCut_ ? consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertices"))
94  : edm::EDGetTokenT<reco::VertexCollection>();
95 
96  pixelClusterShapeCacheToken_ =
97  consumes<SiPixelClusterShapeCache>(iConfig.getParameter<edm::InputTag>("clusterShapeCache"));
98  }
99 
101  if (!checktrigger(iEvent, iSetup, DCS))
102  return;
103 
104  if (histo.size() != ENUM_SIZE) {
105  edm::LogError("SiPixelPhase1TrackClusters")
106  << "incompatible configuration " << histo.size() << "!=" << ENUM_SIZE << std::endl;
107  return;
108  }
109 
110  // get geometry
113  assert(tracker.isValid());
114 
115  edm::ESHandle<TrackerTopology> tTopoHandle;
116  iSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
117  auto const& tkTpl = *tTopoHandle;
118 
120  iSetup.get<CkfComponentsRecord>().get("ClusterShapeHitFilter", shapeFilterH);
121  auto const& shapeFilter = *shapeFilterH;
122 
124  if (applyVertexCut_) {
125  iEvent.getByToken(offlinePrimaryVerticesToken_, vertices);
126  if (!vertices.isValid() || vertices->empty())
127  return;
128  }
129 
130  //get the map
132  iEvent.getByToken(tracksToken_, tracks);
133 
134  if (!tracks.isValid()) {
135  edm::LogWarning("SiPixelPhase1TrackClusters") << "track collection is not valid";
136  return;
137  }
138 
139  edm::Handle<SiPixelClusterShapeCache> pixelClusterShapeCacheH;
140  iEvent.getByToken(pixelClusterShapeCacheToken_, pixelClusterShapeCacheH);
141  if (!pixelClusterShapeCacheH.isValid()) {
142  edm::LogWarning("SiPixelPhase1TrackClusters") << "PixelClusterShapeCache collection is not valid";
143  return;
144  }
145  auto const& pixelClusterShapeCache = *pixelClusterShapeCacheH;
146 
147  for (auto const& track : *tracks) {
148  if (applyVertexCut_ &&
149  (track.pt() < 0.75 || std::abs(track.dxy((*vertices)[0].position())) > 5 * track.dxyError()))
150  continue;
151 
152  bool isBpixtrack = false, isFpixtrack = false, crossesPixVol = false;
153 
154  // find out whether track crosses pixel fiducial volume (for cosmic tracks)
155  auto d0 = track.d0(), dz = track.dz();
156  if (std::abs(d0) < 16 && std::abs(dz) < 50)
157  crossesPixVol = true;
158 
159  auto etatk = track.eta();
160 
161  auto const& trajParams = track.extra()->trajParams();
162  assert(trajParams.size() == track.recHitsSize());
163  auto hb = track.recHitsBegin();
164 
165  for (unsigned int h = 0; h < track.recHitsSize(); h++) {
166  auto hit = *(hb + h);
167  if (!hit->isValid())
168  continue;
169  auto id = hit->geographicalId();
170 
171  // check that we are in the pixel
172  auto subdetid = (id.subdetId());
173  if (subdetid == PixelSubdetector::PixelBarrel)
174  isBpixtrack = true;
175  if (subdetid == PixelSubdetector::PixelEndcap)
176  isFpixtrack = true;
177  if (subdetid != PixelSubdetector::PixelBarrel && subdetid != PixelSubdetector::PixelEndcap)
178  continue;
179  bool iAmBarrel = subdetid == PixelSubdetector::PixelBarrel;
180 
181  // PXB_L4 IS IN THE OTHER WAY
182  // CAN BE XORed BUT LETS KEEP THINGS SIMPLE
183  bool iAmOuter = ((tkTpl.pxbLadder(id) % 2 == 1) && tkTpl.pxbLayer(id) != 4) ||
184  ((tkTpl.pxbLadder(id) % 2 != 1) && tkTpl.pxbLayer(id) == 4);
185 
186  auto pixhit = dynamic_cast<const SiPixelRecHit*>(hit->hit());
187  if (!pixhit)
188  continue;
189 
190  auto geomdetunit = dynamic_cast<const PixelGeomDetUnit*>(pixhit->detUnit());
191  auto const& topol = geomdetunit->specificTopology();
192 
193  // get the cluster
194  auto clustp = pixhit->cluster();
195  if (clustp.isNull())
196  continue;
197  auto const& cluster = *clustp;
198  const std::vector<SiPixelCluster::Pixel> pixelsVec = cluster.pixels();
199  for (unsigned int i = 0; i < pixelsVec.size(); ++i) {
200  float pixx = pixelsVec[i].x; // index as float=iteger, row index
201  float pixy = pixelsVec[i].y; // same, col index
202 
203  bool bigInX = topol.isItBigPixelInX(int(pixx));
204  bool bigInY = topol.isItBigPixelInY(int(pixy));
205  float pixel_charge = pixelsVec[i].adc;
206 
207  if (bigInX == true || bigInY == true) {
208  histo[ON_TRACK_BIGPIXELCHARGE].fill(pixel_charge, id, &iEvent);
209  } else {
210  histo[ON_TRACK_NOTBIGPIXELCHARGE].fill(pixel_charge, id, &iEvent);
211  }
212  } // End loop over pixels
213  auto const& ltp = trajParams[h];
214 
215  auto localDir = ltp.momentum() / ltp.momentum().mag();
216 
217  // correct charge for track impact angle
218  auto charge = cluster.charge() * ltp.absdz();
219 
220  auto clustgp = pixhit->globalPosition(); // from rechit
221 
222  int part;
224  std::pair<float, float> pred;
225  if (shapeFilter.getSizes(*pixhit, localDir, pixelClusterShapeCache, part, meas, pred)) {
226  auto shape = shapeFilter.isCompatible(*pixhit, localDir, pixelClusterShapeCache);
227  unsigned shapeVal = (shape ? 1 : 0);
228 
229  if (iAmBarrel) {
230  if (iAmOuter) {
231  histo[ON_TRACK_SIZE_X_OUTER].fill(pred.first, cluster.sizeX(), id, &iEvent);
232  histo[ON_TRACK_SIZE_Y_OUTER].fill(pred.second, cluster.sizeY(), id, &iEvent);
233  histo[ON_TRACK_SIZE_XY_OUTER].fill(cluster.sizeY(), cluster.sizeX(), id, &iEvent);
234 
235  histo[ON_TRACK_SHAPE_OUTER].fill(shapeVal, id, &iEvent);
236  } else {
237  histo[ON_TRACK_SIZE_X_INNER].fill(pred.first, cluster.sizeX(), id, &iEvent);
238  histo[ON_TRACK_SIZE_Y_INNER].fill(pred.second, cluster.sizeY(), id, &iEvent);
239  histo[ON_TRACK_SIZE_XY_INNER].fill(cluster.sizeY(), cluster.sizeX(), id, &iEvent);
240 
241  histo[ON_TRACK_SHAPE_INNER].fill(shapeVal, id, &iEvent);
242  }
243  } else {
244  histo[ON_TRACK_SIZE_X_F].fill(pred.first, cluster.sizeX(), id, &iEvent);
245  histo[ON_TRACK_SIZE_Y_F].fill(pred.second, cluster.sizeY(), id, &iEvent);
246  histo[ON_TRACK_SIZE_XY_F].fill(cluster.sizeY(), cluster.sizeX(), id, &iEvent);
247  }
248  histo[ON_TRACK_SHAPE].fill(shapeVal, id, &iEvent);
249  }
250 
251  for (int i = 0; i < cluster.size(); i++) {
252  SiPixelCluster::Pixel const& vecipxl = cluster.pixel(i);
253  histo[DIGIS_HITMAP_ON_TRACK].fill(id, &iEvent, vecipxl.y, vecipxl.x);
254  histo[ON_TRACK_NDIGIS].fill(id, &iEvent);
255  }
256 
257  histo[ON_TRACK_NCLUSTERS].fill(id, &iEvent);
258  histo[ON_TRACK_CHARGE].fill(charge, id, &iEvent);
259  histo[ON_TRACK_SIZE].fill(cluster.size(), id, &iEvent);
260 
261  histo[ON_TRACK_POSITIONB].fill(clustgp.z(), clustgp.phi(), id, &iEvent);
262  histo[ON_TRACK_POSITIONF].fill(clustgp.x(), clustgp.y(), id, &iEvent);
263 
264  histo[CHARGE_VS_SIZE_ON_TRACK].fill(cluster.size(), charge, id, &iEvent);
265 
266  if (iAmBarrel) // Avoid mistakes even if specification < should > handle it
267  {
268  if (iAmOuter) {
269  histo[SIZE_VS_ETA_ON_TRACK_OUTER].fill(etatk, cluster.sizeY(), id, &iEvent);
270  histo[ON_TRACK_CHARGE_OUTER].fill(charge, id, &iEvent);
271  } else {
272  histo[SIZE_VS_ETA_ON_TRACK_INNER].fill(etatk, cluster.sizeY(), id, &iEvent);
273  histo[ON_TRACK_CHARGE_INNER].fill(charge, id, &iEvent);
274  }
275  }
276  }
277 
278  // statistics on tracks
279  histo[NTRACKS].fill(1, DetId(0), &iEvent);
280  if (isBpixtrack || isFpixtrack)
281  histo[NTRACKS].fill(2, DetId(0), &iEvent);
282  if (isBpixtrack)
283  histo[NTRACKS].fill(3, DetId(0), &iEvent);
284  if (isFpixtrack)
285  histo[NTRACKS].fill(4, DetId(0), &iEvent);
286 
287  if (crossesPixVol) {
288  if (isBpixtrack || isFpixtrack)
289  histo[NTRACKS_INVOLUME].fill(1, DetId(0), &iEvent);
290  else
291  histo[NTRACKS_INVOLUME].fill(0, DetId(0), &iEvent);
292  }
293  }
294 
295  histo[ON_TRACK_NCLUSTERS].executePerEventHarvesting(&iEvent);
296  histo[ON_TRACK_NDIGIS].executePerEventHarvesting(&iEvent);
297  }
298 
299 } // namespace
300 
302 DEFINE_FWK_MODULE(SiPixelPhase1TrackClusters);
ClusterShapeHitFilter.h
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
electrons_cff.bool
bool
Definition: electrons_cff.py:372
mps_fire.i
i
Definition: mps_fire.py:355
PixelSubdetector.h
MessageLogger.h
PixelSubdetector::PixelEndcap
Definition: PixelSubdetector.h:11
TrackerGeometry.h
PixelSubdetector::PixelBarrel
Definition: PixelSubdetector.h:11
PixelTopology.h
ESHandle.h
edm::EDGetTokenT< reco::TrackCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
SiPixelCluster.h
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
cms::cuda::assert
assert(be >=bs)
CkfComponentsRecord.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle< reco::VertexCollection >
SiPixelCluster::Pixel
Definition: SiPixelCluster.h:29
SiPixelPhase1Base
Definition: SiPixelPhase1Base.h:46
DetId
Definition: DetId.h:17
MakerMacros.h
part
part
Definition: HCALResponse.h:20
Track.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
CkfComponentsRecord
Definition: CkfComponentsRecord.h:22
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
edm::ESHandle< TrackerGeometry >
h
SiPixelRecHit.h
Vertex.h
edm::LogWarning
Definition: MessageLogger.h:141
PbPb_ZMuSkimMuonDPG_cff.tracker
tracker
Definition: PbPb_ZMuSkimMuonDPG_cff.py:60
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
funct::true
true
Definition: Factorize.h:173
TrackerDigiGeometryRecord.h
edm::VecArray< std::pair< int, int >, 9 >
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
CertificationClient_cfi.DCS
DCS
Definition: CertificationClient_cfi.py:9
iEvent
int iEvent
Definition: GenABIO.cc:224
analyze
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
SiPixelCluster::Pixel::y
uint16_t y
Definition: SiPixelCluster.h:34
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
hcalSimParameters_cfi.hb
hb
Definition: hcalSimParameters_cfi.py:57
SiPixelPhase1Base::analyze
void analyze(edm::Event const &e, edm::EventSetup const &) override=0
VertexFwd.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
SiPixelPhase1Base.h
PVValHelper::dz
Definition: PVValidationHelpers.h:50
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
LocalPoint.h
PixelGeomDetUnit.h
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
SiPixelCluster::Pixel::x
uint16_t x
Definition: SiPixelCluster.h:33
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
d0
static constexpr float d0
Definition: L1EGammaCrystalsEmulatorProducer.cc:85
GlobalPoint.h
edm::InputTag
Definition: InputTag.h:15
hit
Definition: SiStripHitEffFromCalibTree.cc:88
SiPixelClusterShapeCache.h
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7