Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:21

0001 // user include files
0002 #include "FWCore/Framework/interface/MakerMacros.h"
0003 #include "FWCore/Framework/interface/Frameworkfwd.h"
0004 #include "FWCore/Framework/interface/global/EDAnalyzer.h"
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "FWCore/Framework/interface/EventSetup.h"
0007 #include "FWCore/ServiceRegistry/interface/Service.h"
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 #include "CondFormats/DataRecord/interface/SiPhase2OuterTrackerLorentzAngleRcd.h"
0011 #include "CondFormats/SiPhase2TrackerObjects/interface/SiPhase2OuterTrackerLorentzAngle.h"
0012 
0013 //
0014 //
0015 // class decleration
0016 //
0017 class SiPhase2OuterTrackerLorentzAngleReader : public edm::global::EDAnalyzer<> {
0018 public:
0019   explicit SiPhase2OuterTrackerLorentzAngleReader(const edm::ParameterSet&);
0020   ~SiPhase2OuterTrackerLorentzAngleReader() override = default;
0021   void analyze(edm::StreamID, edm::Event const&, edm::EventSetup const&) const override;
0022 
0023   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0024 
0025 private:
0026   const uint32_t printdebug_;
0027   const std::string label_;
0028   const edm::ESGetToken<SiPhase2OuterTrackerLorentzAngle, SiPhase2OuterTrackerLorentzAngleRcd> laToken_;
0029 };
0030 
0031 SiPhase2OuterTrackerLorentzAngleReader::SiPhase2OuterTrackerLorentzAngleReader(const edm::ParameterSet& iConfig)
0032     : printdebug_(iConfig.getUntrackedParameter<uint32_t>("printDebug", 5)),
0033       label_(iConfig.getUntrackedParameter<std::string>("label", "")),
0034       laToken_(esConsumes(edm::ESInputTag{"", label_})) {}
0035 
0036 void SiPhase2OuterTrackerLorentzAngleReader::analyze(edm::StreamID,
0037                                                      edm::Event const& iEvent,
0038                                                      edm::EventSetup const& iSetup) const {
0039   const auto& lorentzAngles = iSetup.getData(laToken_);
0040   edm::LogInfo("SiPhase2OuterTrackerLorentzAngleReader")
0041       << "[SiPhase2OuterTrackerLorentzAngleReader::analyze] End Reading SiPhase2OuterTrackerLorentzAngle with label "
0042       << label_ << std::endl;
0043 
0044   const auto& detid_la = lorentzAngles.getLorentzAngles();
0045   std::unordered_map<unsigned int, float>::const_iterator it;
0046   size_t count = 0;
0047   for (it = detid_la.begin(); it != detid_la.end() && count < printdebug_; it++) {
0048     edm::LogInfo("SiPhase2OuterTrackerLorentzAngleReader") << "detid " << it->first << " \t"
0049                                                            << " Lorentz angle  " << it->second;
0050     count++;
0051   }
0052 }
0053 
0054 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
0055 void SiPhase2OuterTrackerLorentzAngleReader::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0056   edm::ParameterSetDescription desc;
0057   desc.setComment("Module to read SiPhase2OuterTrackerLorentzAngle Payloads");
0058   desc.addUntracked<uint32_t>("printDebug", 5)->setComment("maximum amount of print-outs");
0059   desc.addUntracked<std::string>("label", "")->setComment("label from which to read the payload");
0060   descriptions.addWithDefaultLabel(desc);
0061 }
0062 
0063 //define this as a plug-in
0064 DEFINE_FWK_MODULE(SiPhase2OuterTrackerLorentzAngleReader);