File indexing completed on 2024-04-06 12:02:11
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <sstream>
0010 #include "FWCore/Framework/interface/global/EDAnalyzer.h"
0011 #include "FWCore/Framework/interface/Event.h"
0012 #include "FWCore/Framework/interface/MakerMacros.h"
0013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0014
0015 #include "FWCore/Framework/interface/EventSetup.h"
0016
0017 #include "CondFormats/EcalObjects/interface/EcalPedestals.h"
0018 #include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h"
0019
0020 #include "CondFormats/EcalObjects/interface/EcalXtalGroupId.h"
0021 #include "CondFormats/EcalObjects/interface/EcalWeightXtalGroups.h"
0022 #include "CondFormats/DataRecord/interface/EcalWeightXtalGroupsRcd.h"
0023
0024 #include "CondFormats/EcalObjects/interface/EcalWeightSet.h"
0025 #include "CondFormats/EcalObjects/interface/EcalTBWeights.h"
0026 #include "CondFormats/DataRecord/interface/EcalTBWeightsRcd.h"
0027
0028 #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h"
0029 #include "CondFormats/DataRecord/interface/EcalIntercalibConstantsRcd.h"
0030 #include "CondFormats/EcalObjects/interface/EcalIntercalibErrors.h"
0031 #include "CondFormats/DataRecord/interface/EcalIntercalibErrorsRcd.h"
0032
0033 #include "CondFormats/EcalObjects/interface/EcalTimeCalibConstants.h"
0034 #include "CondFormats/DataRecord/interface/EcalTimeCalibConstantsRcd.h"
0035 #include "CondFormats/EcalObjects/interface/EcalTimeCalibErrors.h"
0036 #include "CondFormats/DataRecord/interface/EcalTimeCalibErrorsRcd.h"
0037
0038 #include "CondFormats/EcalObjects/interface/EcalMGPAGainRatio.h"
0039 #include "CondFormats/EcalObjects/interface/EcalGainRatios.h"
0040 #include "CondFormats/DataRecord/interface/EcalGainRatiosRcd.h"
0041
0042 #include "CondFormats/EcalObjects/interface/EcalADCToGeVConstant.h"
0043 #include "CondFormats/DataRecord/interface/EcalADCToGeVConstantRcd.h"
0044
0045 #include "CondFormats/EcalObjects/interface/EcalChannelStatus.h"
0046 #include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"
0047
0048 #include "CondFormats/EcalObjects/interface/EcalLaserAlphas.h"
0049 #include "CondFormats/DataRecord/interface/EcalLaserAlphasRcd.h"
0050 #include "CondFormats/EcalObjects/interface/EcalLaserAPDPNRatios.h"
0051 #include "CondFormats/DataRecord/interface/EcalLaserAPDPNRatiosRcd.h"
0052 #include "CondFormats/EcalObjects/interface/EcalLaserAPDPNRatiosRef.h"
0053 #include "CondFormats/DataRecord/interface/EcalLaserAPDPNRatiosRefRcd.h"
0054
0055 #include "CondFormats/EcalObjects/interface/EcalMappingElectronics.h"
0056 #include "CondFormats/DataRecord/interface/EcalMappingElectronicsRcd.h"
0057
0058 using namespace std;
0059
0060 class EcalObjectAnalyzer : public edm::global::EDAnalyzer<> {
0061 public:
0062 explicit EcalObjectAnalyzer(edm::ParameterSet const &p);
0063 ~EcalObjectAnalyzer() override = default;
0064
0065 void analyze(edm::StreamID, edm::Event const &, edm::EventSetup const &) const override;
0066
0067 private:
0068 const edm::ESGetToken<EcalPedestals, EcalPedestalsRcd> pedestalsToken_;
0069 const edm::ESGetToken<EcalADCToGeVConstant, EcalADCToGeVConstantRcd> adcToGeVConstantToken_;
0070 const edm::ESGetToken<EcalWeightXtalGroups, EcalWeightXtalGroupsRcd> weightXtalGroupsToken_;
0071 const edm::ESGetToken<EcalChannelStatus, EcalChannelStatusRcd> channelStatusToken_;
0072 const edm::ESGetToken<EcalGainRatios, EcalGainRatiosRcd> gainRatiosToken_;
0073 const edm::ESGetToken<EcalIntercalibConstants, EcalIntercalibConstantsRcd> intercalibConstantsToken_;
0074 const edm::ESGetToken<EcalIntercalibErrors, EcalIntercalibErrorsRcd> intercalibErrorsToken_;
0075 const edm::ESGetToken<EcalTimeCalibConstants, EcalTimeCalibConstantsRcd> timeCalibConstantsToken_;
0076 const edm::ESGetToken<EcalTimeCalibErrors, EcalTimeCalibErrorsRcd> timeCalibErrorsToken_;
0077 const edm::ESGetToken<EcalTBWeights, EcalTBWeightsRcd> tbWeightsToken_;
0078 const edm::ESGetToken<EcalLaserAPDPNRatios, EcalLaserAPDPNRatiosRcd> laserAPDPNRatiosToken_;
0079 const edm::ESGetToken<EcalLaserAlphas, EcalLaserAlphasRcd> laserAlphasToken_;
0080 const edm::ESGetToken<EcalLaserAPDPNRatiosRef, EcalLaserAPDPNRatiosRefRcd> laserAPDPNRatiosRefToken_;
0081 const edm::ESGetToken<EcalMappingElectronics, EcalMappingElectronicsRcd> mappingElectronicsToken_;
0082 };
0083
0084 EcalObjectAnalyzer::EcalObjectAnalyzer(edm::ParameterSet const &p)
0085 : pedestalsToken_(esConsumes()),
0086 adcToGeVConstantToken_(esConsumes()),
0087 weightXtalGroupsToken_(esConsumes()),
0088 channelStatusToken_(esConsumes()),
0089 gainRatiosToken_(esConsumes()),
0090 intercalibConstantsToken_(esConsumes()),
0091 intercalibErrorsToken_(esConsumes()),
0092 timeCalibConstantsToken_(esConsumes()),
0093 timeCalibErrorsToken_(esConsumes()),
0094 tbWeightsToken_(esConsumes()),
0095 laserAPDPNRatiosToken_(esConsumes()),
0096 laserAlphasToken_(esConsumes()),
0097 laserAPDPNRatiosRefToken_(esConsumes()),
0098 mappingElectronicsToken_(esConsumes()) {}
0099
0100 void EcalObjectAnalyzer::analyze(edm::StreamID, const edm::Event &e, const edm::EventSetup &context) const {
0101 using namespace edm::eventsetup;
0102
0103 edm::LogVerbatim("EcalObjectAnalyzer") << ">>> EcalObjectAnalyzer: processing run " << e.id().run()
0104 << " event: " << e.id().event() << "\n";
0105
0106
0107 const auto &agc = context.getData(adcToGeVConstantToken_);
0108 edm::LogVerbatim("EcalObjectAnalyzer") << "Global ADC->GeV scale: EB " << agc.getEBValue() << " GeV/ADC count"
0109 << " EE " << agc.getEEValue() << " GeV/ADC count\n";
0110
0111 const auto &myped = context.getData(pedestalsToken_);
0112
0113 int cnt = 0;
0114 for (const auto &item : myped.barrelItems()) {
0115 edm::LogVerbatim("EcalObjectAnalyzer")
0116 << "EcalPedestal: "
0117 << " BARREL " << cnt << " "
0118 << " mean_x1: " << item.mean_x1 << " rms_x1: " << item.rms_x1 << " mean_x6: " << item.mean_x6
0119 << " rms_x6: " << item.rms_x6 << " mean_x12: " << item.mean_x12 << " rms_x12: " << item.rms_x12 << "\n";
0120 ++cnt;
0121 }
0122
0123 for (const auto &item : myped.endcapItems()) {
0124 edm::LogVerbatim("EcalObjectAnalyzer")
0125 << "EcalPedestal: "
0126 << " ENDCAP "
0127 << " mean_x1: " << item.mean_x1 << " rms_x1: " << item.rms_x1 << " mean_x6: " << item.mean_x6
0128 << " rms_x6: " << item.rms_x6 << " mean_x12: " << item.mean_x12 << " rms_x12: " << item.rms_x12 << "\n";
0129 }
0130
0131
0132 const auto &grp = context.getData(weightXtalGroupsToken_);
0133
0134 for (const auto &item : grp.barrelItems()) {
0135 edm::LogVerbatim("EcalObjectAnalyzer") << "XtalGroupId gid: " << item.id() << "\n";
0136 }
0137
0138 for (const auto &item : grp.endcapItems()) {
0139 edm::LogVerbatim("EcalObjectAnalyzer") << "XtalGroupId gid: " << item.id() << "\n";
0140 }
0141
0142
0143 const auto &ch = context.getData(channelStatusToken_);
0144
0145 for (const auto &chst : ch.barrelItems()) {
0146 edm::LogVerbatim("EcalObjectAnalyzer") << "Ecal channel status " << chst.getStatusCode() << "\n";
0147 }
0148
0149 for (const auto &chst : ch.endcapItems()) {
0150 edm::LogVerbatim("EcalObjectAnalyzer") << "Ecal channel status " << chst.getStatusCode() << "\n";
0151 }
0152
0153 const auto &gr = context.getData(gainRatiosToken_);
0154
0155 for (const auto &mgpa : gr.barrelItems()) {
0156 edm::LogVerbatim("EcalObjectAnalyzer")
0157 << "EcalMGPAGainRatio: gain 12/6: " << mgpa.gain12Over6() << " gain 6/1: " << mgpa.gain6Over1() << "\n";
0158 }
0159
0160 for (const auto &mgpa : gr.endcapItems()) {
0161 edm::LogVerbatim("EcalObjectAnalyzer")
0162 << "EcalMGPAGainRatio: gain 12/6: " << mgpa.gain12Over6() << " gain 6/1: " << mgpa.gain6Over1() << "\n";
0163 }
0164
0165
0166 const auto &ical = context.getData(intercalibConstantsToken_);
0167
0168 for (const auto &item : ical.barrelItems()) {
0169 edm::LogVerbatim("EcalObjectAnalyzer") << "EcalIntercalibConstant: icalconst: " << item << "\n";
0170 }
0171
0172 for (const auto &item : ical.endcapItems()) {
0173 edm::LogVerbatim("EcalObjectAnalyzer") << "EcalIntercalibConstant: icalconst: " << item << "\n";
0174 }
0175
0176 const auto &icalerr = context.getData(intercalibErrorsToken_);
0177
0178 for (const auto &item : icalerr.barrelItems()) {
0179 edm::LogVerbatim("EcalObjectAnalyzer") << "EcalIntercalibConstant: error: " << item << "\n";
0180 }
0181
0182 for (const auto &item : icalerr.endcapItems()) {
0183 edm::LogVerbatim("EcalObjectAnalyzer") << "EcalIntercalibConstant: error: " << item << "\n";
0184 }
0185
0186
0187 {
0188 const auto &ical = context.getData(timeCalibConstantsToken_);
0189
0190 for (const auto &item : ical.barrelItems()) {
0191 edm::LogVerbatim("EcalObjectAnalyzer") << "EcalTimeCalibConstant: icalconst: " << item << "\n";
0192 }
0193
0194 for (const auto &item : ical.endcapItems()) {
0195 edm::LogVerbatim("EcalObjectAnalyzer") << "EcalTimeCalibConstant: icalconst: " << item << "\n";
0196 }
0197
0198 const auto &icalerr = context.getData(timeCalibErrorsToken_);
0199
0200 for (const auto &item : icalerr.barrelItems()) {
0201 edm::LogVerbatim("EcalObjectAnalyzer") << "EcalTimeCalibConstant: error: " << item << "\n";
0202 }
0203
0204 for (const auto &item : icalerr.endcapItems()) {
0205 edm::LogVerbatim("EcalObjectAnalyzer") << "EcalTimeCalibConstant: error: " << item << "\n";
0206 }
0207 }
0208
0209
0210 const auto &wgts = context.getData(tbWeightsToken_);
0211 edm::LogVerbatim("EcalObjectAnalyzer") << "EcalTBWeightMap.size(): " << wgts.getMap().size() << "\n";
0212
0213
0214
0215
0216 for (const auto &item : wgts.getMap()) {
0217 edm::LogVerbatim("EcalObjectAnalyzer")
0218 << "EcalWeights " << item.first.first.id() << "," << item.first.second << "\n";
0219 std::ostringstream oss;
0220 item.second.print(oss);
0221 edm::LogVerbatim("EcalObjectAnalyzer") << oss.str() << "\n";
0222 }
0223
0224
0225 const auto &apdPnRatios = context.getData(laserAPDPNRatiosToken_);
0226
0227 const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap &laserRatiosMap = apdPnRatios.getLaserMap();
0228 const EcalLaserAPDPNRatios::EcalLaserTimeStampMap &laserTimeMap = apdPnRatios.getTimeMap();
0229
0230
0231 for (const auto &apdPnRatioPair : laserRatiosMap.barrelItems()) {
0232 edm::LogVerbatim("EcalObjectAnalyzer")
0233 << "EcalAPDPnRatio: first " << apdPnRatioPair.p1 << " second " << apdPnRatioPair.p2 << "\n";
0234 }
0235
0236 for (const auto &apdPnRatioPair : laserRatiosMap.endcapItems()) {
0237 edm::LogVerbatim("EcalObjectAnalyzer")
0238 << "EcalAPDPnRatio: first " << apdPnRatioPair.p1 << " second " << apdPnRatioPair.p2 << "\n";
0239 }
0240
0241 for (unsigned int i = 0; i < laserTimeMap.size(); ++i) {
0242 EcalLaserAPDPNRatios::EcalLaserTimeStamp timestamp = laserTimeMap[i];
0243 edm::LogVerbatim("EcalObjectAnalyzer")
0244 << "EcalAPDPnRatio: timestamp : " << i << " " << timestamp.t1.value() << " , " << timestamp.t2.value() << endl;
0245 }
0246
0247
0248 const auto &alphaMap = context.getData(laserAlphasToken_);
0249
0250 for (const auto &item : alphaMap.barrelItems()) {
0251 edm::LogVerbatim("EcalObjectAnalyzer") << "EcalLaserAlphas: icalconst: " << item << "\n";
0252 }
0253
0254 for (const auto &item : alphaMap.endcapItems()) {
0255 edm::LogVerbatim("EcalObjectAnalyzer") << "EcalLaserAlphas: icalconst: " << item << "\n";
0256 }
0257
0258
0259 const auto &apdPnRatioRefMap = context.getData(laserAPDPNRatiosRefToken_);
0260
0261 for (const auto &item : apdPnRatioRefMap.barrelItems()) {
0262 edm::LogVerbatim("EcalObjectAnalyzer") << "EcalLaserAPDPNRatiosRef: icalconst: " << item << "\n";
0263 }
0264
0265 for (const auto &item : apdPnRatioRefMap.endcapItems()) {
0266 edm::LogVerbatim("EcalObjectAnalyzer") << "EcalLaserAPDPNRatiosRef: icalconst: " << item << "\n";
0267 }
0268
0269 const auto &mapping = context.getData(mappingElectronicsToken_);
0270 for (const auto &item : mapping.endcapItems()) {
0271 edm::LogVerbatim("EcalObjectAnalyzer")
0272 << "EcalMappingElectronics: " << item.electronicsid << " " << item.triggerid << "\n";
0273 }
0274
0275 }
0276 DEFINE_FWK_MODULE(EcalObjectAnalyzer);