Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-03-17 02:46:12

0001 #include "FWCore/Framework/interface/Event.h"
0002 #include "FWCore/Framework/interface/MakerMacros.h"
0003 #include "FWCore/Utilities/interface/InputTag.h"
0004 #include "FWCore/Utilities/interface/EDGetToken.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 #include "FWCore/ServiceRegistry/interface/Service.h"
0007 #include "FWCore/PluginManager/interface/ModuleDef.h"
0008 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0009 #include "SimMuon/MCTruth/interface/PSimHitMap.h"
0010 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
0011 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0012 #include "Validation/CSCRecHits/interface/CSCRecHit2DValidation.h"
0013 #include "Validation/CSCRecHits/interface/CSCSegmentValidation.h"
0014 
0015 class CSCRecHitValidation : public DQMEDAnalyzer {
0016 public:
0017   explicit CSCRecHitValidation(const edm::ParameterSet &);
0018   ~CSCRecHitValidation() override{};
0019   void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
0020   void analyze(const edm::Event &, const edm::EventSetup &) override;
0021 
0022 private:
0023   PSimHitMap theSimHitMap;
0024   edm::ESGetToken<CSCGeometry, MuonGeometryRecord> geomToken_;
0025 
0026   std::unique_ptr<CSCRecHit2DValidation> the2DValidation;
0027   std::unique_ptr<CSCSegmentValidation> theSegmentValidation;
0028 };
0029 
0030 DEFINE_FWK_MODULE(CSCRecHitValidation);
0031 
0032 CSCRecHitValidation::CSCRecHitValidation(const edm::ParameterSet &ps)
0033     : theSimHitMap(ps.getParameter<edm::InputTag>("simHitsTag"), consumesCollector()),
0034       the2DValidation(nullptr),
0035       theSegmentValidation(nullptr) {
0036   the2DValidation = std::make_unique<CSCRecHit2DValidation>(ps, consumesCollector());
0037   theSegmentValidation = std::make_unique<CSCSegmentValidation>(ps, consumesCollector());
0038   geomToken_ = esConsumes<CSCGeometry, MuonGeometryRecord>();
0039 }
0040 
0041 void CSCRecHitValidation::bookHistograms(DQMStore::IBooker &iBooker, edm::Run const &iRun, edm::EventSetup const &) {
0042   iBooker.setCurrentFolder("CSCRecHitsV/CSCRecHitTask");
0043 
0044   the2DValidation->bookHistograms(iBooker);
0045   theSegmentValidation->bookHistograms(iBooker);
0046 }
0047 
0048 void CSCRecHitValidation::analyze(const edm::Event &e, const edm::EventSetup &eventSetup) {
0049   theSimHitMap.fill(e);
0050 
0051   // find the geometry & conditions for this event
0052   const CSCGeometry *theCSCGeometry = &eventSetup.getData(geomToken_);
0053 
0054   the2DValidation->setGeometry(theCSCGeometry);
0055   the2DValidation->setSimHitMap(&theSimHitMap);
0056 
0057   theSegmentValidation->setGeometry(theCSCGeometry);
0058   theSegmentValidation->setSimHitMap(&theSimHitMap);
0059 
0060   the2DValidation->analyze(e, eventSetup);
0061   theSegmentValidation->analyze(e, eventSetup);
0062 }