File indexing completed on 2024-04-06 12:03:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include <stdexcept>
0014 #include <string>
0015 #include <iostream>
0016 #include <map>
0017 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0018 #include "FWCore/Framework/interface/Event.h"
0019 #include "FWCore/Framework/interface/ESHandle.h"
0020 #include "FWCore/Framework/interface/MakerMacros.h"
0021
0022 #include "FWCore/Framework/interface/EventSetup.h"
0023 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0024
0025 #include "CondFormats/HcalObjects/interface/HcalPedestals.h"
0026 #include "CondFormats/HcalObjects/interface/HcalPedestalWidths.h"
0027 #include "CondFormats/HcalObjects/interface/HcalGains.h"
0028 #include "CondFormats/HcalObjects/interface/HcalGainWidths.h"
0029 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0030 #include "CondFormats/DataRecord/interface/HcalPedestalsRcd.h"
0031 #include "CondFormats/DataRecord/interface/HcalPedestalWidthsRcd.h"
0032 #include "CondFormats/DataRecord/interface/HcalGainsRcd.h"
0033 #include "CondFormats/DataRecord/interface/HcalGainWidthsRcd.h"
0034
0035 using namespace std;
0036
0037 namespace edmtest {
0038 class HcalCalibrationsAnalyzer : public edm::one::EDAnalyzer<> {
0039 public:
0040 explicit HcalCalibrationsAnalyzer(edm::ParameterSet const& p);
0041 ~HcalCalibrationsAnalyzer() override = default;
0042 virtual void analyze(const edm::Event& e, const edm::EventSetup& c);
0043
0044 private:
0045 const edm::ESGetToken<HcalPedestalWidths, HcalPedestalWidthsRcd> tok_pPedWs_;
0046 const edm::ESGetToken<HcalGains, HcalGainsRcd> tok_pGains_;
0047 const edm::ESGetToken<HcalGainWidths, HcalGainWidthsRcd> tok_pGainWs_;
0048 const edm::ESGetToken<HcalPedestals, HcalPedestalsRcd> tok_pPeds_;
0049 };
0050
0051 HcalCalibrationsAnalyzer::HcalCalibrationsAnalyzer(edm::ParameterSet const&)
0052 :
0053
0054
0055 tok_pPeds_(esConsumes<HcalPedestals, HcalPedestalsRcd>()) {}
0056
0057 void HcalCalibrationsAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context) {
0058 using namespace edm::eventsetup;
0059
0060 std::cout << "HcalCalibrationsAnalyzer::analyze-> I AM IN RUN NUMBER " << e.id().run() << std::endl;
0061 std::cout << "HcalCalibrationsAnalyzer::analyze-> ---EVENT NUMBER " << e.id().run() << std::endl;
0062 const auto& pPeds = context.getHandle(tok_pPeds_);
0063
0064
0065
0066
0067
0068
0069 const HcalPedestals* myped = pPeds.product();
0070 std::vector<DetId> mychannels = myped->getAllChannels();
0071
0072 for (std::vector<DetId>::const_iterator it = mychannels.begin(); it != mychannels.end(); it++) {
0073 HcalDetId mydetid(*it);
0074 int eta = mydetid.ieta();
0075 int phi = mydetid.iphi();
0076 int depth = mydetid.depth();
0077 int subdet = mydetid.subdet();
0078 char id;
0079 int rawid = mydetid.rawId();
0080 switch (subdet) {
0081 case 1:
0082 id = 'B';
0083 break;
0084 case 2:
0085 id = 'E';
0086 break;
0087 case 3:
0088 id = 'O';
0089 break;
0090 case 4:
0091 id = 'F';
0092 break;
0093 }
0094
0095
0096 const float* values = (myped->getValues(mydetid))->getValues();
0097
0098
0099
0100 printf(" %d %d %d H%c %f %f %f %f %X\n",
0101 eta,
0102 phi,
0103 depth,
0104 id,
0105 values[0],
0106 values[1],
0107 values[2],
0108 values[3],
0109 rawid);
0110 }
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131 }
0132 DEFINE_FWK_MODULE(HcalCalibrationsAnalyzer);
0133 }