Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-05-20 02:50:35

0001 #ifndef Validation_DTRecHits_DTRecHitQuality_h
0002 #define Validation_DTRecHits_DTRecHitQuality_h
0003 
0004 /** \class DTRecHitQuality
0005  *  Basic analyzer class which accesses 1D DTRecHits
0006  *  and plot resolution comparing reconstructed and simulated quantities
0007  *
0008  *  Residual/pull plots are filled for the rechit with distance from wire
0009  *  closer to that of the muon simhit.
0010  *
0011  *  Efficiencies are defined as the fraction of muon simhits with a rechit
0012  *  in the same cell, for the given reconstruction step. Hence, for S2 and S3
0013  *  the definition incorporate the segment reconstruction efficiency.
0014  *
0015  *  \author G. Cerminara - INFN Torino
0016  */
0017 
0018 #include <map>
0019 #include <string>
0020 #include <vector>
0021 
0022 #include "DQMServices/Core/interface/DQMGlobalEDAnalyzer.h"
0023 #include "DataFormats/DTRecHit/interface/DTRecHitCollection.h"
0024 #include "DataFormats/DTRecHit/interface/DTRecSegment2DCollection.h"
0025 #include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
0026 #include "DataFormats/MuonDetId/interface/DTWireId.h"
0027 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0028 #include "FWCore/Utilities/interface/InputTag.h"
0029 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
0030 
0031 namespace edm {
0032   class ParameterSet;
0033   class Event;
0034   class EventSetup;
0035 }  // namespace edm
0036 
0037 class PSimHit;
0038 class DTLayer;
0039 class DTWireId;
0040 class DTGeometry;
0041 class HRes1DHit;
0042 class HEff1DHit;
0043 namespace dtrechit {
0044   struct Histograms;
0045 }
0046 
0047 class DTRecHitQuality : public DQMGlobalEDAnalyzer<dtrechit::Histograms> {
0048 public:
0049   /// Constructor
0050   DTRecHitQuality(const edm::ParameterSet &pset);
0051 
0052 private:
0053   /// Book the DQM plots
0054   void bookHistograms(DQMStore::IBooker &,
0055                       edm::Run const &,
0056                       edm::EventSetup const &,
0057                       dtrechit::Histograms &) const override;
0058 
0059   /// Perform the real analysis
0060   void dqmAnalyze(edm::Event const &, edm::EventSetup const &, dtrechit::Histograms const &) const override;
0061 
0062 private:
0063   // Switch for debug output
0064   bool debug_;
0065 
0066   //Get DT Geometry
0067   edm::ESGetToken<DTGeometry, MuonGeometryRecord> muonGeomToken_;
0068 
0069   // Root file name
0070   edm::EDGetTokenT<edm::PSimHitContainer> simHitToken_;
0071   edm::EDGetTokenT<DTRecHitCollection> recHitToken_;
0072   edm::EDGetTokenT<DTRecSegment2DCollection> segment2DToken_;
0073   edm::EDGetTokenT<DTRecSegment4DCollection> segment4DToken_;
0074   ;
0075 
0076   edm::InputTag simHitLabel_;
0077   edm::InputTag recHitLabel_;
0078   edm::InputTag segment2DLabel_;
0079   edm::InputTag segment4DLabel_;
0080 
0081   // Switches for analysis at various steps
0082   bool doStep1_;
0083   bool doStep2_;
0084   bool doStep3_;
0085   bool local_;
0086   bool doall_;
0087 
0088   // Return a map between DTRecHit1DPair and wireId
0089   std::map<DTWireId, std::vector<DTRecHit1DPair>> map1DRecHitsPerWire(const DTRecHitCollection *dt1DRecHitPairs) const;
0090 
0091   // Return a map between DTRecHit1D and wireId
0092   std::map<DTWireId, std::vector<DTRecHit1D>> map1DRecHitsPerWire(const DTRecSegment2DCollection *segment2Ds) const;
0093 
0094   // Return a map between DTRecHit1D and wireId
0095   std::map<DTWireId, std::vector<DTRecHit1D>> map1DRecHitsPerWire(const DTRecSegment4DCollection *segment4Ds) const;
0096 
0097   // Compute SimHit distance from wire (cm)
0098   float simHitDistFromWire(const DTLayer *layer, const DTWireId &wireId, const PSimHit &hit) const;
0099 
0100   // Compute SimHit impact angle (in direction perp to wire)
0101   float simHitImpactAngle(const DTLayer *layer, const DTWireId &wireId, const PSimHit &hit) const;
0102 
0103   // Compute SimHit distance from FrontEnd
0104   float simHitDistFromFE(const DTLayer *layer, const DTWireId &wireId, const PSimHit &hit) const;
0105 
0106   // Find the RecHit closest to the muon SimHit
0107   //   const DTRecHit1DPair*
0108   //   findBestRecHit(const DTLayer* layer,
0109   //               DTWireId wireId,
0110   //               const std::vector<DTRecHit1DPair>& recHits,
0111   //               const float simHitDist) const;
0112   template <typename type>
0113   const type *findBestRecHit(const DTLayer *layer,
0114                              const DTWireId &wireId,
0115                              const std::vector<type> &recHits,
0116                              float simHitDist) const;
0117 
0118   // Compute the distance from wire (cm) of a hits in a DTRecHit1DPair
0119   float recHitDistFromWire(const DTRecHit1DPair &hitPair, const DTLayer *layer) const;
0120   // Compute the distance from wire (cm) of a hits in a DTRecHit1D
0121   float recHitDistFromWire(const DTRecHit1D &recHit, const DTLayer *layer) const;
0122 
0123   // Return the error on the measured (cm) coordinate
0124   float recHitPositionError(const DTRecHit1DPair &recHit) const;
0125   float recHitPositionError(const DTRecHit1D &recHit) const;
0126 
0127   // Does the real job
0128   template <typename type>
0129   void compute(const DTGeometry &dtGeom,
0130                const std::map<DTWireId, std::vector<PSimHit>> &simHitsPerWire,
0131                const std::map<DTWireId, std::vector<type>> &recHitsPerWire,
0132                dtrechit::Histograms const &histograms,
0133                int step) const;
0134 };
0135 
0136 #endif  // Validation_DTRecHits_DTRecHitQuality_h