CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/DQM/SiPixelCommon/src/SiPixelHistogramId.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     SiPixelCommon
00004 // Class  :     SiPixelHistogramId
00005 // 
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  chiochia
00010 //         Created:  Wed Feb 22 16:07:58 CET 2006
00011 // $Id: SiPixelHistogramId.cc,v 1.4 2010/11/29 20:41:58 wmtan Exp $
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   size_t length1=histoid.find(separator_,0);
00063   if(length1==std::string::npos){ // no separator1 found
00064     LogWarning("PixelDQM")<<"SiPixelHistogramId::returnIdPart - no regular histoid. Returning 0";
00065     return "0";
00066   }
00067   std::string part1 = histoid.substr(0,length1); // part of 'histoid' up to 'separator1'
00068   if(whichpart==1) return part1;
00069   std::string remain1 = histoid.substr(length1+separator_.size()); // rest of 'histoid' starting at end of 'separator1'
00070   size_t length2=remain1.find(separator_,0);
00071   if(length2==std::string::npos){ // no separator2 found
00072     LogWarning("PixelDQM")<<"SiPixelHistogramId::returnIdPart - no regular histoid. Returning 0";
00073     return "0";
00074   }
00075   std::string part2 = remain1.substr(0,length2); // part of 'remain1' up to 'separator2'
00076   if(whichpart==2) return part2;
00077   std::string part3 = remain1.substr(length2+separator_.size()); // rest of remain1 starting at end of 'separator2'
00078   if(whichpart==3) return part3;
00079   LogWarning("PixelDQM")<<"SiPixelHistogramId::returnIdPart - no such whichpart="<<whichpart<<" returning 0";
00080   return "0";
00081 }