File indexing completed on 2024-04-06 12:14:50
0001 #include <iostream>
0002 #include <map>
0003
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/Framework/interface/EventSetup.h"
0006 #include "FWCore/Framework/interface/MakerMacros.h"
0007 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009
0010 #include "Geometry/HcalTestBeamData/interface/HcalTB02Parameters.h"
0011 #include "Geometry/HcalTestBeamData/interface/HcalTB06BeamParameters.h"
0012 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0013
0014 class HcalTBParameterTester : public edm::one::EDAnalyzer<> {
0015 public:
0016 explicit HcalTBParameterTester(const edm::ParameterSet&);
0017 ~HcalTBParameterTester() override = default;
0018
0019 void beginJob() override {}
0020 void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
0021 void endJob() override {}
0022
0023 private:
0024 const std::string name_;
0025 edm::ESGetToken<HcalTB02Parameters, IdealGeometryRecord> token1_;
0026 edm::ESGetToken<HcalTB06BeamParameters, IdealGeometryRecord> token2_;
0027 const int mode_;
0028 };
0029
0030 HcalTBParameterTester::HcalTBParameterTester(const edm::ParameterSet& ic)
0031 : name_(ic.getUntrackedParameter<std::string>("Name")),
0032 token1_(esConsumes<HcalTB02Parameters, IdealGeometryRecord>(edm::ESInputTag{"", name_})),
0033 token2_(esConsumes<HcalTB06BeamParameters, IdealGeometryRecord>(edm::ESInputTag{})),
0034 mode_(ic.getUntrackedParameter<int>("Mode")) {}
0035
0036 void HcalTBParameterTester::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0037 if (mode_ == 0) {
0038 const auto& hcp = iSetup.getData(token1_);
0039 const auto* php = &hcp;
0040 edm::LogVerbatim("HCalGeom") << "TB02Parameters for " << name_;
0041 edm::LogVerbatim("HCalGeom") << "Length map with " << php->lengthMap_.size() << " elements";
0042 std::map<std::string, double>::const_iterator itr = php->lengthMap_.begin();
0043 int i(0);
0044 for (; itr != php->lengthMap_.end(); ++itr, ++i)
0045 edm::LogVerbatim("HCalGeom") << "[" << i << "] " << itr->first << " " << itr->second << " mm";
0046 } else {
0047 const auto& hcp = iSetup.getData(token2_);
0048 const auto* php = &hcp;
0049 edm::LogVerbatim("HCalGeom") << "TB06BeamParameters:: Material " << php->material_;
0050 edm::LogVerbatim("HCalGeom") << "TB06BeamParameters:: " << php->wchambers_.size() << " wire chambers:";
0051 for (unsigned int k = 0; k < php->wchambers_.size(); ++k)
0052 edm::LogVerbatim("HCalGeom") << "[" << k << "] " << php->wchambers_[k];
0053 }
0054 }
0055
0056 DEFINE_FWK_MODULE(HcalTBParameterTester);