File indexing completed on 2024-04-06 12:05:15
0001
0002 #include <string>
0003 #include <iostream>
0004 #include <iomanip>
0005 #include <sstream>
0006 #include <time.h>
0007
0008
0009 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
0010 #include "DataFormats/SiStripCommon/interface/SiStripDetKey.h"
0011 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
0012 #include "DataFormats/SiStripCommon/interface/SiStripFecKey.h"
0013 #include "DataFormats/SiStripCommon/interface/SiStripFedKey.h"
0014 #include "FWCore/Framework/interface/Event.h"
0015 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0018
0019
0020
0021
0022
0023
0024 class testSiStripKey : public edm::one::EDAnalyzer<> {
0025 public:
0026 testSiStripKey(const edm::ParameterSet&);
0027 ~testSiStripKey();
0028
0029 void beginJob();
0030 void analyze(const edm::Event&, const edm::EventSetup&);
0031
0032 private:
0033 sistrip::KeyType keyType_;
0034 uint32_t key_;
0035 std::string path_;
0036 };
0037
0038 using namespace sistrip;
0039
0040
0041
0042 testSiStripKey::testSiStripKey(const edm::ParameterSet& pset)
0043 : keyType_(sistrip::UNKNOWN_KEY), key_(0), path_(pset.getUntrackedParameter<std::string>("Path", "")) {
0044 LogTrace(mlDqmCommon_) << "[testSiStripKey::" << __func__ << "]"
0045 << " Constructing object...";
0046
0047
0048 std::string key_type = pset.getUntrackedParameter<std::string>("KeyType", "");
0049 keyType_ = SiStripEnumsAndStrings::keyType(key_type);
0050
0051
0052 std::stringstream key;
0053 std::string tmp = pset.getUntrackedParameter<std::string>("Key", "0x0");
0054 if (tmp.find(sistrip::hex_) != std::string::npos) {
0055 key << std::string(tmp, (sizeof(sistrip::hex_) - 1), tmp.size());
0056 } else {
0057 key << tmp;
0058 }
0059 key >> std::hex >> key_;
0060 }
0061
0062
0063
0064 testSiStripKey::~testSiStripKey() {
0065 LogTrace(mlDqmCommon_) << "[testSiStripKey::" << __func__ << "]"
0066 << " Destructing object...";
0067 }
0068
0069
0070
0071 void testSiStripKey::beginJob() {
0072 edm::LogVerbatim(mlDqmCommon_) << "[SiStripKey::" << __func__ << "]"
0073 << " Tests the generation of keys...";
0074
0075 if (keyType_ == sistrip::FED_KEY) {
0076 SiStripFedKey from_key(key_);
0077 edm::LogVerbatim(mlDqmCommon_) << "[SiStripKey::" << __func__ << "]"
0078 << " FED key object built from 32-bit key: " << std::endl
0079 << from_key;
0080
0081 SiStripFedKey from_path(path_);
0082 edm::LogVerbatim(mlDqmCommon_) << "[SiStripKey::" << __func__ << "]"
0083 << " FED key object built from directory string: " << std::endl
0084 << from_path;
0085
0086 } else if (keyType_ == sistrip::FEC_KEY) {
0087 SiStripFecKey from_key(key_);
0088 edm::LogVerbatim(mlDqmCommon_) << "[SiStripKey::" << __func__ << "]"
0089 << " FEC key object built from 32-bit key: " << std::endl
0090 << from_key;
0091
0092 SiStripFecKey from_path(path_);
0093 edm::LogVerbatim(mlDqmCommon_) << "[SiStripKey::" << __func__ << "]"
0094 << " FEC key object built from directory string: " << std::endl
0095 << from_path;
0096
0097 } else if (keyType_ == sistrip::DET_KEY) {
0098 SiStripDetKey from_key(key_);
0099 edm::LogVerbatim(mlDqmCommon_) << "[SiStripKey::" << __func__ << "]"
0100 << " DET key object built from 32-bit key: " << std::endl
0101 << from_key;
0102
0103 SiStripDetKey from_path(path_);
0104 edm::LogVerbatim(mlDqmCommon_) << "[SiStripKey::" << __func__ << "]"
0105 << " DET key object built from directory string: " << std::endl
0106 << from_path;
0107
0108 } else {
0109
0110 edm::LogWarning(mlDqmCommon_) << "[SiStripKey::" << __func__ << "]"
0111 << " KeyType is of type: " << SiStripEnumsAndStrings::keyType(keyType_);
0112
0113
0114 {
0115 SiStripFedKey from_key(key_);
0116 edm::LogVerbatim(mlDqmCommon_) << "[SiStripKey::" << __func__ << "]"
0117 << " FED key object built from 32-bit key: " << std::endl
0118 << from_key;
0119
0120 SiStripFedKey from_path(path_);
0121 edm::LogVerbatim(mlDqmCommon_) << "[SiStripKey::" << __func__ << "]"
0122 << " FED key object built from directory string: " << std::endl
0123 << from_path;
0124 }
0125
0126
0127 {
0128 SiStripFecKey from_key(key_);
0129 edm::LogVerbatim(mlDqmCommon_) << "[SiStripKey::" << __func__ << "]"
0130 << " FEC key object built from 32-bit key: " << std::endl
0131 << from_key;
0132
0133 SiStripFecKey from_path(path_);
0134 edm::LogVerbatim(mlDqmCommon_) << "[SiStripKey::" << __func__ << "]"
0135 << " FEC key object built from directory string: " << std::endl
0136 << from_path;
0137 }
0138
0139
0140 {
0141 SiStripDetKey from_key(key_);
0142 edm::LogVerbatim(mlDqmCommon_) << "[SiStripKey::" << __func__ << "]"
0143 << " DET key object built from 32-bit key: " << std::endl
0144 << from_key;
0145
0146 SiStripDetKey from_path(path_);
0147 edm::LogVerbatim(mlDqmCommon_) << "[SiStripKey::" << __func__ << "]"
0148 << " DET key object built from directory string: " << std::endl
0149 << from_path;
0150 }
0151 }
0152 }
0153
0154
0155
0156 void testSiStripKey::analyze(const edm::Event& event, const edm::EventSetup& setup) {
0157 LogTrace(mlDqmCommon_) << "[SiStripKey::" << __func__ << "]"
0158 << " Analyzing run/event " << event.id().run() << "/" << event.id().event();
0159 }
0160
0161 #include "FWCore/Framework/interface/MakerMacros.h"
0162 DEFINE_FWK_MODULE(testSiStripKey);