File indexing completed on 2024-04-06 12:01:39
0001
0002
0003
0004
0005
0006
0007 #include <stdexcept>
0008 #include <string>
0009 #include <iostream>
0010 #include <map>
0011 #include <typeinfo>
0012
0013 #include "CondFormats/Calibration/interface/Efficiency.h"
0014 #include "CondFormats/DataRecord/interface/ExEfficiency.h"
0015
0016 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0017 #include "FWCore/Framework/interface/Event.h"
0018 #include "FWCore/Framework/interface/EventSetup.h"
0019 #include "FWCore/Framework/interface/MakerMacros.h"
0020
0021 using namespace std;
0022
0023 namespace edmtest {
0024 class EfficiencyByLabelAnalyzer : public edm::one::EDAnalyzer<> {
0025 public:
0026 explicit EfficiencyByLabelAnalyzer(edm::ParameterSet const& p)
0027 : theEffToken1_(esConsumes()), theEffToken2_(esConsumes()) {
0028 edm::LogPrint("EfficiencyByLabelAnalyzer") << "EfficiencyByLabelAnalyzer";
0029 }
0030 explicit EfficiencyByLabelAnalyzer(int i) {
0031 edm::LogPrint("EfficiencyByLabelAnalyzer") << "EfficiencyByLabelAnalyzer " << i;
0032 }
0033 virtual ~EfficiencyByLabelAnalyzer() {
0034 edm::LogPrint("EfficiencyByLabelAnalyzer") << "~EfficiencyByLabelAnalyzer ";
0035 }
0036 virtual void analyze(const edm::Event& e, const edm::EventSetup& c);
0037
0038 private:
0039 const edm::ESGetToken<condex::Efficiency, ExEfficiencyRcd> theEffToken1_, theEffToken2_;
0040 };
0041
0042 void EfficiencyByLabelAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context) {
0043 using namespace edm::eventsetup;
0044
0045 edm::LogPrint("EfficiencyByLabelAnalyzer") << " I AM IN RUN NUMBER " << e.id().run();
0046 edm::LogPrint("EfficiencyByLabelAnalyzer") << " ---EVENT NUMBER " << e.id().event();
0047 edm::eventsetup::EventSetupRecordKey recordKey(
0048 edm::eventsetup::EventSetupRecordKey::TypeTag::findType("ExEfficiencyRcd"));
0049 if (recordKey.type() == edm::eventsetup::EventSetupRecordKey::TypeTag()) {
0050
0051 edm::LogPrint("EfficiencyByLabelAnalyzer") << "Record \"ExEfficiencyRcd\" does not exist";
0052 }
0053 edm::LogPrint("EfficiencyByLabelAnalyzer") << "got context";
0054 {
0055 condex::Efficiency const& eff = context.getData(theEffToken2_);
0056 edm::LogPrint("EfficiencyByLabelAnalyzer")
0057 << "Efficiency*, type (2) " << (void*)(&eff) << " " << typeid(eff).name();
0058 }
0059 condex::Efficiency const& eff = context.getData(theEffToken1_);
0060 edm::LogPrint("EfficiencyByLabelAnalyzer") << "Efficiency*, type " << (void*)(&eff) << " " << typeid(eff).name();
0061 for (float pt = 0; pt < 10; pt += 2) {
0062 edm::LogPrint("EfficiencyByLabelAnalyzer") << "\npt=" << pt << " :";
0063 for (float eta = -3; eta < 3; eta += 1)
0064 edm::LogPrint("EfficiencyByLabelAnalyzer") << eff(pt, eta) << " ";
0065 }
0066 edm::LogPrint("EfficiencyByLabelAnalyzer");
0067 }
0068
0069 DEFINE_FWK_MODULE(EfficiencyByLabelAnalyzer);
0070 }