Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-11 03:56:56

0001 #include "FWCore/Utilities/interface/Exception.h"
0002 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/Framework/interface/EventSetup.h"
0005 #include "FWCore/Framework/interface/ESHandle.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "CommonTools/TrackerMap/interface/TrackerMap.h"
0008 #include "CalibTracker/Records/interface/SiStripDetCablingRcd.h"
0009 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
0010 #include "CommonTools/TrackerMap/interface/TrackerMap.h"
0011 
0012 #include <sstream>
0013 
0014 class SiStripCablingTrackerMap : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
0015 public:
0016   SiStripCablingTrackerMap(const edm::ParameterSet& conf);
0017   ~SiStripCablingTrackerMap() override = default;
0018 
0019   void beginRun(const edm::Run& run, const edm::EventSetup& es) override;
0020   void endJob() override;
0021   void endRun(const edm::Run& run, const edm::EventSetup& es) override{};
0022   void analyze(const edm::Event& e, const edm::EventSetup& c) override;
0023 
0024 private:
0025   const edm::ESGetToken<SiStripDetCabling, SiStripDetCablingRcd> detCablingToken_;
0026 
0027   std::unique_ptr<TrackerMap> tkMap_detCab;  //0 for onTrack, 1 for offTrack, 2 for All
0028 };
0029 
0030 SiStripCablingTrackerMap::SiStripCablingTrackerMap(edm::ParameterSet const& conf) : detCablingToken_(esConsumes()) {}
0031 
0032 void SiStripCablingTrackerMap::beginRun(const edm::Run& run, const edm::EventSetup& es) {
0033   tkMap_detCab = std::make_unique<TrackerMap>("DetCabling");
0034 }
0035 
0036 //------------------------------------------------------------------------------------------
0037 void SiStripCablingTrackerMap::endJob() {
0038   tkMap_detCab->save(true, 0, 0, "DetCabling.png");
0039   tkMap_detCab->print(true, 0, 0, "DetCabling");
0040 }
0041 //------------------------------------------------------------------------------------------
0042 
0043 void SiStripCablingTrackerMap::analyze(const edm::Event& e, const edm::EventSetup& es) {
0044   const auto& detCabling = es.getData(detCablingToken_);
0045   //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
0046   // get list of active detectors from SiStripDetCabling
0047   //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
0048   std::vector<uint32_t> vdetId_;
0049   detCabling.addActiveDetectorsRawIds(vdetId_);
0050   for (std::vector<uint32_t>::const_iterator detid_iter = vdetId_.begin(); detid_iter != vdetId_.end(); detid_iter++) {
0051     uint32_t detid = *detid_iter;
0052     tkMap_detCab->fill(detid, 1);
0053   }
0054 }
0055 
0056 #include "FWCore/PluginManager/interface/ModuleDef.h"
0057 #include "FWCore/Framework/interface/MakerMacros.h"
0058 
0059 DEFINE_FWK_MODULE(SiStripCablingTrackerMap);