File indexing completed on 2023-03-17 10:51:29
0001 #include "DataFormats/TrackerCommon/interface/ClusterSummary.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003
0004 const std::vector<std::string> ClusterSummary::subDetNames{
0005 "STRIP", "TOB", "TIB", "TID", "TEC", "PIXEL", "BPIX", "FPIX"};
0006 const std::vector<std::vector<std::string> > ClusterSummary::subDetSelections{
0007 {"0x1e000000-0x1A000000", "0x1e000000-0x16000000", "0x1e000000-0x18000000", "0x1e000000-0x1C000000"},
0008 {"0x1e000000-0x1A000000"},
0009 {"0x1e000000-0x16000000"},
0010 {"0x1e000000-0x18000000"},
0011 {"0x1e000000-0x1C000000"},
0012 {"0x1e000000-0x12000000", "0x1e000000-0x14000000"},
0013 {"0x1e000000-0x12000000"},
0014 {"0x1e000000-0x14000000"}};
0015 const std::vector<std::string> ClusterSummary::variableNames{"NCLUSTERS", "CLUSTERSIZE", "CLUSTERCHARGE"};
0016
0017 ClusterSummary::ClusterSummary() : ClusterSummary(NVALIDENUMS) {}
0018
0019 ClusterSummary::ClusterSummary(const int nSelections)
0020 : modules(nSelections), nClus(nSelections), clusSize(nSelections), clusCharge(nSelections) {
0021 for (int i = 0; i < nSelections; ++i)
0022 modules[i] = i;
0023 }
0024
0025 ClusterSummary& ClusterSummary::operator=(const ClusterSummary& rhs) {
0026 modules = rhs.modules;
0027 nClus = rhs.nClus;
0028 clusSize = rhs.clusSize;
0029 clusCharge = rhs.clusCharge;
0030 return *this;
0031 }
0032
0033
0034 ClusterSummary::ClusterSummary(ClusterSummary&& other) : ClusterSummary() { *this = other; }
0035
0036 ClusterSummary::ClusterSummary(const ClusterSummary& src)
0037 : modules(src.getModules()),
0038 nClus(src.getNClusVector()),
0039 clusSize(src.getClusSizeVector()),
0040 clusCharge(src.getClusChargeVector()) {}
0041
0042 int ClusterSummary::getModuleLocation(int mod, bool warn) const {
0043 int iM = -1;
0044 for (auto m : modules) {
0045 ++iM;
0046 if (m == mod)
0047 return iM;
0048 }
0049
0050 if (warn)
0051 edm::LogWarning("NoModule") << "No information for requested module " << mod << " (" << subDetNames[mod] << ")"
0052 << ". Please check in the Provenance Infomation for proper modules.";
0053
0054 return -1;
0055 }
0056
0057 void ClusterSummary::copyNonEmpty(const ClusterSummary& src) {
0058 modules.clear();
0059 nClus.clear();
0060 clusSize.clear();
0061 clusCharge.clear();
0062
0063 const std::vector<int>& src_modules = src.getModules();
0064 const std::vector<int>& src_nClus = src.getNClusVector();
0065 const std::vector<int>& src_clusSize = src.getClusSizeVector();
0066 const std::vector<float>& src_clusCharge = src.getClusChargeVector();
0067
0068 modules.reserve(src_modules.size());
0069 nClus.reserve(src_modules.size());
0070 clusSize.reserve(src_modules.size());
0071 clusCharge.reserve(src_modules.size());
0072
0073 for (unsigned int iM = 0; iM < src_nClus.size(); ++iM) {
0074 if (src.nClus[iM] != 0) {
0075 modules.push_back(src_modules[iM]);
0076 nClus.push_back(src_nClus[iM]);
0077 clusSize.push_back(src_clusSize[iM]);
0078 clusCharge.push_back(src_clusCharge[iM]);
0079 }
0080 }
0081 }
0082
0083 void ClusterSummary::reset() {
0084 for (unsigned int iM = 0; iM < modules.size(); ++iM) {
0085 nClus[iM] = 0;
0086 clusSize[iM] = 0;
0087 clusCharge[iM] = 0;
0088 }
0089 }