File indexing completed on 2024-04-06 12:07:26
0001 #ifndef DQM_GEM_GEMEfficiencyAnalyzer_h
0002 #define DQM_GEM_GEMEfficiencyAnalyzer_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include "DQM/GEM/interface/GEMDQMEfficiencySourceBase.h"
0018 #include "FWCore/Utilities/interface/EDGetToken.h"
0019 #include "FWCore/Framework/interface/ESHandle.h"
0020 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0021 #include "DataFormats/GEMRecHit/interface/GEMRecHitCollection.h"
0022 #include "DataFormats/PatCandidates/interface/Muon.h"
0023 #include "DataFormats/MuonReco/interface/MuonSelectors.h"
0024 #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
0025 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
0026 #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
0027 #include "TrackingTools/Records/interface/TransientTrackRecord.h"
0028 #include "Geometry/GEMGeometry/interface/GEMGeometry.h"
0029 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0030
0031 class GEMEfficiencyAnalyzer : public GEMDQMEfficiencySourceBase {
0032 public:
0033 explicit GEMEfficiencyAnalyzer(const edm::ParameterSet &);
0034 ~GEMEfficiencyAnalyzer() override;
0035 static void fillDescriptions(edm::ConfigurationDescriptions &);
0036
0037
0038 enum class StartingStateType {
0039 kOutermostMeasurementState = 0,
0040 kInnermostMeasurementState,
0041 kStateOnSurfaceWithCSCSegment,
0042 kAlignmentStyle,
0043 };
0044
0045
0046 enum class MatchingMetric {
0047 kDeltaPhi = 0,
0048 kRdPhi,
0049 };
0050
0051
0052 enum class ScenarioOption {
0053 kPP = 0,
0054 kCosmics,
0055 kHeavyIons,
0056 };
0057
0058 struct GEMLayer {
0059 GEMLayer(Disk::DiskPointer disk, std::vector<const GEMChamber *> chambers, GEMDetId id)
0060 : disk(disk), chambers(chambers), id(id) {}
0061 Disk::DiskPointer disk;
0062 std::vector<const GEMChamber *> chambers;
0063 GEMDetId id;
0064 };
0065
0066 using StartingState = std::tuple<bool, TrajectoryStateOnSurface, DetId>;
0067
0068 protected:
0069 void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override;
0070 void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
0071 void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override;
0072
0073 private:
0074 StartingStateType getStartingStateType(const std::string);
0075 MatchingMetric getMatchingMetric(const std::string);
0076 reco::Muon::MuonTrackType getMuonTrackType(const std::string);
0077 ScenarioOption getScenarioOption(const std::string);
0078
0079 void buildGEMLayers(const GEMGeometry *);
0080
0081 bool checkPropagationDirection(const reco::Track *, const GEMLayer &);
0082
0083 StartingState buildStartingState(const reco::Muon &, const reco::TransientTrack &, const GEMLayer &);
0084 StartingState getInnermostMeasurementState(const reco::TransientTrack &);
0085 StartingState getOutermostMeasurementState(const reco::TransientTrack &);
0086 StartingState buildStateOnSurfaceWithCSCSegment(const reco::Muon &, const reco::TransientTrack &, const GEMLayer &);
0087 StartingState buildStartingStateAlignmentStyle(const reco::Muon &, const reco::TransientTrack &, const GEMLayer &);
0088
0089
0090 const CSCSegment *findCSCSegment(const reco::Muon &, const reco::TransientTrack &, const GEMLayer &);
0091 const CSCSegment *findCSCSegmentBeam(const reco::TransientTrack &, const GEMLayer &);
0092 const CSCSegment *findCSCSegmentCosmics(const reco::Muon &, const GEMLayer &);
0093 bool isMuonSubdetAllowed(const DetId &, const int);
0094 bool isCSCAllowed(const CSCDetId &, const int);
0095
0096 bool checkBounds(const Plane &, const GlobalPoint &);
0097 bool checkBounds(const Plane &, const GlobalPoint &, const GlobalError &, float);
0098 const GEMEtaPartition *findEtaPartition(const GlobalPoint &,
0099 const GlobalError &,
0100 const std::vector<const GEMChamber *> &);
0101
0102 float computeRdPhi(const GlobalPoint &, const LocalPoint &, const GEMEtaPartition *);
0103 float computeDeltaPhi(const GlobalPoint &, const LocalPoint &, const GEMEtaPartition *);
0104 float computeMatchingMetric(const GlobalPoint &, const LocalPoint &, const GEMEtaPartition *);
0105
0106 std::pair<const GEMRecHit *, float> findClosestHit(const GlobalPoint &,
0107 const GEMRecHitCollection::range &,
0108 const GEMEtaPartition *);
0109
0110
0111 inline bool isInsideOut(const reco::Track &);
0112
0113
0114
0115
0116
0117
0118 const edm::ESGetToken<GEMGeometry, MuonGeometryRecord> kGEMGeometryTokenBeginRun_;
0119 const edm::ESGetToken<TransientTrackBuilder, TransientTrackRecord> kTransientTrackBuilderToken_;
0120
0121 const edm::EDGetTokenT<GEMRecHitCollection> kGEMRecHitCollectionToken_;
0122 const edm::EDGetTokenT<edm::View<reco::Muon> > kMuonViewToken_;
0123
0124 const std::string kMuonTrackTypeName_;
0125 const reco::Muon::MuonTrackType kMuonTrackType_;
0126 const TString kMuonName_;
0127 const std::string kFolder_;
0128 const ScenarioOption kScenario_;
0129
0130 const StartingStateType kStartingStateType_;
0131 const std::vector<std::vector<int> > kMuonSubdetForGEM_;
0132 const std::vector<std::vector<int> > kCSCForGEM_;
0133 const float kMuonSegmentMatchDRCut_;
0134
0135 const std::vector<double> kMuonPtMinCuts_;
0136 const std::vector<double> kMuonEtaMinCuts_;
0137 const std::vector<double> kMuonEtaMaxCuts_;
0138 const float kPropagationErrorRCut_;
0139 const float kPropagationErrorPhiCut_;
0140 const float kBoundsErrorScale_;
0141
0142 const MatchingMetric kMatchingMetric_;
0143 const float kMatchingCut_;
0144
0145 const std::vector<double> kMuonPtBins_;
0146 const std::vector<int> kMuonEtaNbins_;
0147 const std::vector<double> kMuonEtaLow_;
0148 const std::vector<double> kMuonEtaUp_;
0149
0150
0151 const bool kModeDev_;
0152
0153
0154
0155
0156
0157
0158 const int kCSCSegmentDimension_ = 4;
0159
0160
0161
0162
0163 std::unique_ptr<MuonServiceProxy> muon_service_;
0164 std::vector<GEMLayer> gem_layers_;
0165
0166
0167
0168 MEMap me_chamber_ieta_, me_chamber_ieta_matched_;
0169 MEMap me_muon_pt_, me_muon_pt_matched_;
0170 MEMap me_muon_eta_, me_muon_eta_matched_;
0171 MEMap me_muon_phi_, me_muon_phi_matched_;
0172 MEMap me_residual_phi_;
0173
0174 MEMap me_matching_metric_all_;
0175 MEMap me_matching_metric_;
0176 MEMap me_residual_phi_muon_;
0177 MEMap me_residual_phi_antimuon_;
0178 MEMap me_residual_x_;
0179 MEMap me_residual_y_;
0180 MEMap me_residual_strip_;
0181 MEMap me_prop_path_length_, me_prop_path_length_matched_;
0182 MEMap me_prop_err_r_, me_prop_err_r_matched_;
0183 MEMap me_prop_err_phi_, me_prop_err_phi_matched_;
0184 MEMap me_muon_pt_all_, me_muon_pt_all_matched_;
0185 MEMap me_muon_eta_all_, me_muon_eta_all_matched_;
0186 MEMap me_muon_charge_, me_muon_charge_matched_;
0187 MEMap me_cutflow_, me_cutflow_matched_;
0188 };
0189
0190 #endif