File indexing completed on 2023-03-17 10:55:59
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include <iostream>
0014 #include <sstream>
0015
0016 #include "DQM/SiPixelCommon/interface/SiPixelHistogramId.h"
0017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0018
0019 using namespace edm;
0020
0021
0022 SiPixelHistogramId::SiPixelHistogramId() : dataCollection_("defaultData"), separator_("_") {}
0023
0024 SiPixelHistogramId::SiPixelHistogramId(std::string dataCollection) : dataCollection_(dataCollection), separator_("_") {}
0025
0026
0027 SiPixelHistogramId::~SiPixelHistogramId() {}
0028
0029 std::string SiPixelHistogramId::setHistoId(std::string variable, uint32_t &rawId) {
0030 std::string histoId;
0031 std::ostringstream rawIdString;
0032 rawIdString << rawId;
0033 histoId = variable + separator_ + dataCollection_ + separator_ + rawIdString.str();
0034
0035 return histoId;
0036 }
0037
0038 std::string SiPixelHistogramId::getDataCollection(std::string histoid) { return returnIdPart(histoid, 2); }
0039
0040 uint32_t SiPixelHistogramId::getRawId(std::string histoid) {
0041 uint32_t local_component_id;
0042 std::istringstream input(returnIdPart(histoid, 3));
0043 input >> local_component_id;
0044 return local_component_id;
0045 }
0046
0047 std::string SiPixelHistogramId::returnIdPart(std::string histoid, uint32_t whichpart) {
0048 size_t length1 = histoid.find(separator_, 0);
0049 if (length1 == std::string::npos) {
0050 LogWarning("PixelDQM") << "SiPixelHistogramId::returnIdPart - no regular histoid. Returning 0";
0051 return "0";
0052 }
0053 std::string part1 = histoid.substr(0, length1);
0054 if (whichpart == 1)
0055 return part1;
0056 std::string remain1 =
0057 histoid.substr(length1 + separator_.size());
0058 size_t length2 = remain1.find(separator_, 0);
0059 if (length2 == std::string::npos) {
0060 LogWarning("PixelDQM") << "SiPixelHistogramId::returnIdPart - no regular histoid. Returning 0";
0061 return "0";
0062 }
0063 std::string part2 = remain1.substr(0, length2);
0064 if (whichpart == 2)
0065 return part2;
0066 std::string part3 = remain1.substr(length2 + separator_.size());
0067 if (whichpart == 3)
0068 return part3;
0069 LogWarning("PixelDQM") << "SiPixelHistogramId::returnIdPart - no such whichpart=" << whichpart << " returning 0";
0070 return "0";
0071 }