Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-22 04:08:18

0001 // -*- C++ -*-
0002 //
0003 // Package:     SiPixelPhase1TrackResiduals
0004 // Class:       SiPixelPhase1TrackResiduals
0005 //
0006 
0007 // Original Author: Marcel Schneider
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     edm::EDGetTokenT<reco::VertexCollection> offlinePrimaryVerticesToken_;
0044 
0045     edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> trackerGeomToken_;
0046 
0047     bool applyVertexCut_;
0048   };
0049 
0050   SiPixelPhase1TrackResiduals::SiPixelPhase1TrackResiduals(const edm::ParameterSet& iConfig)
0051       : SiPixelPhase1Base(iConfig), validator(iConfig, consumesCollector()) {
0052     applyVertexCut_ = iConfig.getUntrackedParameter<bool>("VertexCut", true);
0053 
0054     offlinePrimaryVerticesToken_ = consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertices"));
0055 
0056     trackerGeomToken_ = esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>();
0057   }
0058 
0059   void SiPixelPhase1TrackResiduals::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0060     if (!checktrigger(iEvent, iSetup, DCS))
0061       return;
0062 
0063     edm::ESHandle<TrackerGeometry> tracker = iSetup.getHandle(trackerGeomToken_);
0064     assert(tracker.isValid());
0065 
0066     edm::Handle<reco::VertexCollection> vertices;
0067     if (applyVertexCut_) {
0068       iEvent.getByToken(offlinePrimaryVerticesToken_, vertices);
0069       if (!vertices.isValid() || vertices->empty())
0070         return;
0071     }
0072 
0073     std::vector<TrackerValidationVariables::AVTrackStruct> vtracks;
0074 
0075     validator.fillTrackQuantities(
0076         iEvent,
0077         iSetup,
0078         // tell the validator to only look at good tracks
0079         [&](const reco::Track& track) -> bool {
0080           return (!applyVertexCut_ ||
0081                   (track.pt() > 0.75 && std::abs(track.dxy(vertices->at(0).position())) < 5 * track.dxyError()));
0082         },
0083         vtracks);
0084 
0085     for (auto& track : vtracks) {
0086       for (auto& it : track.hits) {
0087         auto id = DetId(it.rawDetId);
0088         auto isPixel = id.subdetId() == 1 || id.subdetId() == 2;
0089         if (!isPixel)
0090           continue;
0091 
0092         histo[RESIDUAL_X].fill(it.resXprime, id, &iEvent);
0093         histo[RESIDUAL_Y].fill(it.resYprime, id, &iEvent);
0094 
0095         if (it.resXprimeErr != 0 && it.resYprimeErr != 0) {
0096           histo[NormRes_X].fill(it.resXprime / it.resXprimeErr, id, &iEvent);
0097           histo[NormRes_Y].fill(it.resYprime / it.resYprimeErr, id, &iEvent);
0098           histo[DRNR_X].fill(it.resXprime / it.resXprimeErr, id, &iEvent);
0099           histo[DRNR_Y].fill(it.resYprime / it.resYprimeErr, id, &iEvent);
0100         }
0101 
0102         if (it.isOnEdgePixel) {
0103           histo[RESONEDGE_X].fill(it.resXprime, id, &iEvent);
0104           histo[RESONEDGE_Y].fill(it.resYprime, id, &iEvent);
0105         }
0106 
0107         if (it.isOtherBadPixel) {
0108           histo[RESOTHERBAD_X].fill(it.resXprime, id, &iEvent);
0109           histo[RESOTHERBAD_Y].fill(it.resYprime, id, &iEvent);
0110         }
0111       }
0112     }
0113   }
0114 
0115 }  // namespace
0116 
0117 DEFINE_FWK_MODULE(SiPixelPhase1TrackResiduals);