Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:33:45

0001 #ifndef Validation_RecoMuon_MuonTrackResidualAnalyzer_H
0002 #define Validation_RecoMuon_MuonTrackResidualAnalyzer_H
0003 
0004 /** \class MuonTrackResidualAnalyzer
0005  *  No description available.
0006  *
0007  *  \author R. Bellan - INFN Torino <riccardo.bellan@cern.ch>
0008  */
0009 
0010 // Base Class Headers
0011 #include <DQMServices/Core/interface/DQMOneEDAnalyzer.h>
0012 #include "FWCore/Utilities/interface/InputTag.h"
0013 #include "FWCore/Framework/interface/ESHandle.h"
0014 #include "DataFormats/Common/interface/Handle.h"
0015 
0016 #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
0017 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0018 #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
0019 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
0020 
0021 #include "DataFormats/TrackReco/interface/Track.h"
0022 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0023 
0024 #include "DataFormats/DetId/interface/DetId.h"
0025 #include "TrackingTools/PatternTools/interface/Trajectory.h"
0026 
0027 namespace edm {
0028   class ParameterSet;
0029   class Event;
0030   class EventSetup;
0031 }  // namespace edm
0032 class HTracks;
0033 class HResolution;
0034 
0035 class MuonServiceProxy;
0036 class KFUpdator;
0037 class MeasurementEstimator;
0038 class HResolution1DRecHit;
0039 
0040 class MuonTrackResidualAnalyzer : public DQMOneEDAnalyzer<> {
0041 public:
0042   enum EtaRange { all, barrel, endcap };
0043 
0044 public:
0045   /// Constructor
0046   MuonTrackResidualAnalyzer(const edm::ParameterSet &ps);
0047 
0048   /// Destructor
0049   ~MuonTrackResidualAnalyzer() override;
0050 
0051   // Operations
0052 
0053   void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override;
0054 
0055   void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
0056   void dqmEndRun(edm::Run const &, edm::EventSetup const &) override;
0057 
0058 protected:
0059 private:
0060   bool isInTheAcceptance(double eta);
0061 
0062   std::map<DetId, const PSimHit *> mapMuSimHitsPerId(edm::Handle<edm::PSimHitContainer> dtSimhits,
0063                                                      edm::Handle<edm::PSimHitContainer> cscSimhits,
0064                                                      edm::Handle<edm::PSimHitContainer> rpcSimhits);
0065 
0066   void mapMuSimHitsPerId(edm::Handle<edm::PSimHitContainer> simhits, std::map<DetId, const PSimHit *> &hitIdMap);
0067 
0068   void computeResolution(Trajectory &trajectory,
0069                          std::map<DetId, const PSimHit *> &hitIdMap,
0070                          HResolution1DRecHit *histos);
0071 
0072 private:
0073   DQMStore *dbe_;
0074   std::string dirName_;
0075   std::string subsystemname_;
0076   edm::ParameterSet pset;
0077   std::string out;
0078 
0079   edm::InputTag theDataType;
0080   edm::EDGetTokenT<edm::SimTrackContainer> theDataTypeToken;
0081   EtaRange theEtaRange;
0082 
0083   edm::InputTag theMuonTrackLabel;
0084   edm::InputTag cscSimHitLabel;
0085   edm::InputTag dtSimHitLabel;
0086   edm::InputTag rpcSimHitLabel;
0087 
0088   edm::EDGetTokenT<reco::TrackCollection> theMuonTrackToken;
0089   edm::EDGetTokenT<std::vector<PSimHit> > theCSCSimHitToken;
0090   edm::EDGetTokenT<std::vector<PSimHit> > theDTSimHitToken;
0091   edm::EDGetTokenT<std::vector<PSimHit> > theRPCSimHitToken;
0092 
0093   MuonServiceProxy *theService;
0094   KFUpdator *theUpdator;
0095   MeasurementEstimator *theEstimator;
0096 
0097 private:
0098   MonitorElement *hDPtRef;
0099 
0100   // Resolution wrt the 1D Rec Hits
0101   HResolution1DRecHit *h1DRecHitRes;
0102 
0103   // Resolution wrt the 1d Sim Hits
0104   HResolution1DRecHit *h1DSimHitRes;
0105 
0106   MonitorElement *hSimHitsPerTrack;
0107   MonitorElement *hSimHitsPerTrackVsEta;
0108   MonitorElement *hDeltaPtVsEtaSim;
0109   MonitorElement *hDeltaPtVsEtaSim2;
0110 
0111   int theMuonSimHitNumberPerEvent;
0112 
0113   unsigned int theSimTkId;
0114 
0115   std::vector<const PSimHit *> theSimHitContainer;
0116 
0117   struct RadiusComparatorInOut {
0118     RadiusComparatorInOut(edm::ESHandle<GlobalTrackingGeometry> tg) : theTG(tg) {}
0119 
0120     bool operator()(const PSimHit *a, const PSimHit *b) const {
0121       const GeomDet *geomDetA = theTG->idToDet(DetId(a->detUnitId()));
0122       const GeomDet *geomDetB = theTG->idToDet(DetId(b->detUnitId()));
0123 
0124       double distA = geomDetA->toGlobal(a->localPosition()).mag();
0125       double distB = geomDetB->toGlobal(b->localPosition()).mag();
0126 
0127       return distA < distB;
0128     }
0129 
0130     edm::ESHandle<GlobalTrackingGeometry> theTG;
0131   };
0132 };
0133 #endif