CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/Validation/RecoMuon/src/MuonTrackResidualAnalyzer.h

Go to the documentation of this file.
00001 #ifndef Validation_RecoMuon_MuonTrackResidualAnalyzer_H
00002 #define Validation_RecoMuon_MuonTrackResidualAnalyzer_H
00003 
00012 // Base Class Headers
00013 #include "FWCore/Framework/interface/EDAnalyzer.h"
00014 #include "FWCore/Utilities/interface/InputTag.h"
00015 #include "FWCore/Framework/interface/ESHandle.h"
00016 #include "DataFormats/Common/interface/Handle.h"
00017 
00018 #include "DQMServices/Core/interface/DQMStore.h"
00019 #include "DQMServices/Core/interface/MonitorElement.h"
00020 #include "FWCore/ServiceRegistry/interface/Service.h"
00021 
00022 #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
00023 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
00024 #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
00025 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
00026 
00027 #include "DataFormats/DetId/interface/DetId.h"
00028 #include "TrackingTools/PatternTools/interface/Trajectory.h"
00029 
00030 namespace edm {
00031   class ParameterSet;
00032   class Event;
00033   class EventSetup;
00034 }
00035 
00036 class HTracks;
00037 class HResolution;
00038 
00039 class MuonServiceProxy;
00040 class KFUpdator;
00041 class MeasurementEstimator;
00042 class HResolution1DRecHit;
00043 
00044 class MuonTrackResidualAnalyzer: public edm::EDAnalyzer {
00045   
00046  public:
00047   enum EtaRange{all,barrel,endcap};
00048 
00049 public:
00051   MuonTrackResidualAnalyzer(const edm::ParameterSet& pset);
00052   
00054   virtual ~MuonTrackResidualAnalyzer();
00055   
00056   // Operations
00057 
00058   void analyze(const edm::Event & event, const edm::EventSetup& eventSetup);
00059 
00060   virtual void beginJob() ;
00061   virtual void endJob() ;
00062 
00063 protected:
00064 
00065 private:
00066   bool isInTheAcceptance(double eta);
00067   
00068   std::map<DetId, const PSimHit*> mapMuSimHitsPerId(edm::Handle<edm::PSimHitContainer> dtSimhits,
00069                                                     edm::Handle<edm::PSimHitContainer> cscSimhits,
00070                                                     edm::Handle<edm::PSimHitContainer> rpcSimhits);
00071   
00072   void mapMuSimHitsPerId(edm::Handle<edm::PSimHitContainer> simhits, 
00073                          std::map<DetId,const PSimHit*> &hitIdMap);
00074   
00075   void computeResolution(Trajectory &trajectory, 
00076                          std::map<DetId,const PSimHit*> &hitIdMap,
00077                          HResolution1DRecHit *histos);
00078   
00079  private:
00080   
00081   DQMStore* dbe_;
00082   std::string dirName_;
00083   
00084   std::string out;
00085   
00086   edm::InputTag theDataType;
00087   EtaRange theEtaRange;
00088   
00089   edm::InputTag theMuonTrackLabel;
00090   edm::InputTag theSeedCollectionLabel;
00091   edm::InputTag cscSimHitLabel;
00092   edm::InputTag dtSimHitLabel;
00093   edm::InputTag rpcSimHitLabel;
00094   
00095   MuonServiceProxy *theService;
00096   KFUpdator *theUpdator;
00097   MeasurementEstimator *theEstimator;
00098 
00099  private:
00100   MonitorElement *hDPtRef;
00101  
00102   // Resolution wrt the 1D Rec Hits
00103   HResolution1DRecHit *h1DRecHitRes;
00104   
00105   // Resolution wrt the 1d Sim Hits
00106   HResolution1DRecHit  *h1DSimHitRes;
00107 
00108   MonitorElement *hSimHitsPerTrack;
00109   MonitorElement *hSimHitsPerTrackVsEta; 
00110   MonitorElement *hDeltaPtVsEtaSim;
00111   MonitorElement *hDeltaPtVsEtaSim2;
00112 
00113   int theMuonSimHitNumberPerEvent;
00114   
00115   unsigned int theSimTkId;
00116 
00117 
00118   std::vector<const PSimHit*> theSimHitContainer;
00119 
00120 
00121   struct RadiusComparatorInOut{
00122 
00123     RadiusComparatorInOut(edm::ESHandle<GlobalTrackingGeometry> tg):theTG(tg){}
00124     
00125     bool operator()(const PSimHit *a,
00126                     const PSimHit *b) const{ 
00127       
00128       const GeomDet *geomDetA = theTG->idToDet(DetId(a->detUnitId()));
00129       const GeomDet *geomDetB = theTG->idToDet(DetId(b->detUnitId()));
00130       
00131       double distA = geomDetA->toGlobal(a->localPosition()).mag();
00132       double distB = geomDetB->toGlobal(b->localPosition()).mag();
00133       
00134       return distA < distB; 
00135     }
00136 
00137     edm::ESHandle<GlobalTrackingGeometry> theTG;
00138   };
00139 
00140 
00141 };
00142 #endif
00143