00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include<iostream>
00015 #include<sstream>
00016
00017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00018 #include "DQM/SiPixelCommon/interface/SiPixelHistogramId.h"
00019
00020 using namespace edm;
00021
00023 SiPixelHistogramId::SiPixelHistogramId() :
00024 dataCollection_("defaultData"),
00025 separator_("_")
00026 {
00027 }
00029 SiPixelHistogramId::SiPixelHistogramId(std::string dataCollection) :
00030 dataCollection_(dataCollection),
00031 separator_("_")
00032 {
00033 }
00034
00036 SiPixelHistogramId::~SiPixelHistogramId()
00037 {
00038 }
00040 std::string SiPixelHistogramId::setHistoId( std::string variable, uint32_t& rawId )
00041 {
00042 std::string histoId;
00043 std::ostringstream rawIdString;
00044 rawIdString<<rawId;
00045 histoId = variable + separator_ + dataCollection_ + separator_ + rawIdString.str();
00046
00047 return histoId;
00048 }
00050 std::string SiPixelHistogramId::getDataCollection( std::string histoid ) {
00051 return returnIdPart(histoid,2);
00052 }
00054 uint32_t SiPixelHistogramId::getRawId( std::string histoid ) {
00055 uint32_t local_component_id;
00056 std::istringstream input(returnIdPart(histoid,3)); input >> local_component_id;
00057 return local_component_id;
00058 }
00060 std::string SiPixelHistogramId::returnIdPart(std::string histoid, uint32_t whichpart){
00061
00062 uint32_t length1=histoid.find(separator_,0);
00063 if(length1==std::string::npos){
00064 LogWarning("PixelDQM")<<"SiPixelHistogramId::returnIdPart - no regular histoid. Returning 0";
00065 return "0";
00066 }
00067 std::string part1 = histoid.substr(0,length1);
00068 if(whichpart==1) return part1;
00069 std::string remain1 = histoid.substr(length1+separator_.size());
00070 uint32_t length2=remain1.find(separator_,0);
00071 if(length2==std::string::npos){
00072 LogWarning("PixelDQM")<<"SiPixelHistogramId::returnIdPart - no regular histoid. Returning 0";
00073 return "0";
00074 }
00075 std::string part2 = remain1.substr(0,length2);
00076 if(whichpart==2) return part2;
00077 std::string part3 = remain1.substr(length2+separator_.size());
00078 if(whichpart==3) return part3;
00079 LogWarning("PixelDQM")<<"SiPixelHistogramId::returnIdPart - no such whichpart="<<whichpart<<" returning 0";
00080 return "0";
00081 }