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