File indexing completed on 2024-11-14 04:15:28
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "DQM/SiPixelPhase1Common/interface/SiPixelPhase1Base.h"
0010 #include "Alignment/OfflineValidation/interface/TrackerValidationVariables.h"
0011 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0012 #include "FWCore/Framework/interface/MakerMacros.h"
0013 #include "DataFormats/VertexReco/interface/Vertex.h"
0014 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h"
0015 #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
0016 #include "Geometry/CommonTopologies/interface/PixelTopology.h"
0017 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0018 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0019 #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
0020
0021 namespace {
0022
0023 class SiPixelPhase1TrackResiduals final : public SiPixelPhase1Base {
0024 enum {
0025 RESIDUAL_X,
0026 RESIDUAL_Y,
0027 RESONEDGE_X,
0028 RESONEDGE_Y,
0029 RESOTHERBAD_X,
0030 RESOTHERBAD_Y,
0031 NormRes_X,
0032 NormRes_Y,
0033 DRNR_X,
0034 DRNR_Y
0035 };
0036
0037 public:
0038 explicit SiPixelPhase1TrackResiduals(const edm::ParameterSet& conf);
0039 void analyze(const edm::Event&, const edm::EventSetup&) override;
0040
0041 private:
0042 TrackerValidationVariables validator;
0043 const bool applyVertexCut_;
0044 const edm::InputTag vertexInputTag_;
0045 const edm::EDGetTokenT<reco::VertexCollection> offlinePrimaryVerticesToken_;
0046 const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> trackerGeomToken_;
0047 };
0048
0049 SiPixelPhase1TrackResiduals::SiPixelPhase1TrackResiduals(const edm::ParameterSet& iConfig)
0050 : SiPixelPhase1Base(iConfig),
0051 validator(iConfig, consumesCollector()),
0052 applyVertexCut_(iConfig.getUntrackedParameter<bool>("VertexCut", true)),
0053 vertexInputTag_(iConfig.getParameter<edm::InputTag>("vertices")),
0054 offlinePrimaryVerticesToken_(consumes<reco::VertexCollection>(vertexInputTag_)),
0055 trackerGeomToken_(esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>()) {}
0056
0057 void SiPixelPhase1TrackResiduals::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0058 if (!checktrigger(iEvent, iSetup, DCS))
0059 return;
0060
0061 edm::ESHandle<TrackerGeometry> tracker = iSetup.getHandle(trackerGeomToken_);
0062 assert(tracker.isValid());
0063
0064 edm::Handle<reco::VertexCollection> vertices;
0065 if (applyVertexCut_) {
0066 iEvent.getByToken(offlinePrimaryVerticesToken_, vertices);
0067 if (!vertices.isValid()) {
0068 edm::LogWarning("SiPixelPhase1TrackResiduals")
0069 << "Vertex collection: " << vertexInputTag_ << " is not valid! Skipping the event.";
0070 return;
0071 }
0072
0073 if (vertices->empty()) {
0074 edm::LogWarning("SiPixelPhase1TrackResiduals")
0075 << "Size of vertex collection: " << vertexInputTag_ << " is zero! Skipping the event.";
0076 return;
0077 }
0078 }
0079
0080 std::vector<TrackerValidationVariables::AVTrackStruct> vtracks;
0081
0082 validator.fillTrackQuantities(
0083 iEvent,
0084 iSetup,
0085
0086 [&](const reco::Track& track) -> bool {
0087 return (!applyVertexCut_ ||
0088 (track.pt() > 0.75 && std::abs(track.dxy(vertices->at(0).position())) < 5 * track.dxyError()));
0089 },
0090 vtracks);
0091
0092 for (auto& track : vtracks) {
0093 for (auto& it : track.hits) {
0094 auto id = DetId(it.rawDetId);
0095 auto isPixel = id.subdetId() == PixelSubdetector::PixelBarrel || id.subdetId() == PixelSubdetector::PixelEndcap;
0096 if (!isPixel)
0097 continue;
0098
0099 histo[RESIDUAL_X].fill(it.resXprime, id, &iEvent);
0100 histo[RESIDUAL_Y].fill(it.resYprime, id, &iEvent);
0101
0102 if (it.resXprimeErr != 0 && it.resYprimeErr != 0) {
0103 histo[NormRes_X].fill(it.resXprime / it.resXprimeErr, id, &iEvent);
0104 histo[NormRes_Y].fill(it.resYprime / it.resYprimeErr, id, &iEvent);
0105 histo[DRNR_X].fill(it.resXprime / it.resXprimeErr, id, &iEvent);
0106 histo[DRNR_Y].fill(it.resYprime / it.resYprimeErr, id, &iEvent);
0107 }
0108
0109 if (it.isOnEdgePixel) {
0110 histo[RESONEDGE_X].fill(it.resXprime, id, &iEvent);
0111 histo[RESONEDGE_Y].fill(it.resYprime, id, &iEvent);
0112 }
0113
0114 if (it.isOtherBadPixel) {
0115 histo[RESOTHERBAD_X].fill(it.resXprime, id, &iEvent);
0116 histo[RESOTHERBAD_Y].fill(it.resYprime, id, &iEvent);
0117 }
0118 }
0119 }
0120 }
0121
0122 }
0123
0124 DEFINE_FWK_MODULE(SiPixelPhase1TrackResiduals);