00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include<iostream>
00015 #include<sstream>
00016 #include<cstdio>
00017
00018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00019 #include "DQM/SiStripCommon/interface/SiStripHistoId.h"
00020 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00021 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
00022 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00023
00024 SiStripHistoId::SiStripHistoId()
00025 {
00026 }
00027
00028
00029 SiStripHistoId::~SiStripHistoId()
00030 {
00031 }
00032
00033
00034 std::string SiStripHistoId::createHistoId(std::string description, std::string id_type,uint32_t component_id){
00035 size_t pos1 = description.find("__", 0 );
00036 size_t pos2 = description.find("__", 0 );
00037 std::string local_histo_id;
00038 std::ostringstream compid;
00039 compid<<component_id;
00040
00041 if ( pos1 == std::string::npos && pos2 == std::string::npos ){
00042 if(id_type=="fed" || id_type=="det" || id_type=="fec"){
00043 local_histo_id = description + "__" + id_type + "__" + compid.str();
00044 }else{
00045 local_histo_id = description + "__dummy__" + compid.str();
00046 edm::LogError("SiStripHistoId") <<" SiStripHistoId::WrongInput "
00047 <<" no such type of component accepted: "<<id_type
00048 <<" id_type can be: fed, det, or fec.";
00049 }
00050 }else{
00051 local_histo_id = description + "_dummy___" + id_type + "__" + compid.str();
00052 edm::LogError("SiStripHistoId") <<" SiStripHistoId::WrongInput "
00053 <<" histogram description cannot contain: __ or: __"
00054 <<" histogram description = "<<description;
00055 }
00056 return local_histo_id;
00057 }
00058
00059 std::string SiStripHistoId::createHistoLayer(std::string description, std::string id_type,std::string path,std::string flag){
00060 size_t pos1 = description.find( "__", 0 );
00061 size_t pos2 = description.find( "__", 0 );
00062 std::string local_histo_id;
00063 if ( pos1 == std::string::npos && pos2 == std::string::npos ){
00064 if(id_type=="fed" || id_type=="det" || id_type=="fec" || id_type=="layer"){
00065 if(flag.size() > 0)
00066 local_histo_id = description + "__" + flag + "__" + path;
00067 else
00068 local_histo_id = description + "__" + path;
00069 LogTrace("SiStripHistoId") << "Local_histo_ID " << local_histo_id << std::endl;
00070 }else{
00071 local_histo_id = description + "___dummy___" + path;
00072 edm::LogError("SiStripHistoId") <<" SiStripHistoId::WrongInput "
00073 <<" no such type of component accepted: "<<id_type
00074 <<" id_type can be: fed, det, fec or layer ";
00075 }
00076 }else{
00077 local_histo_id = description + "_dummy___" + path;
00078 edm::LogWarning("SiStripHistoId") <<" SiStripHistoId::WrongInput "
00079 <<" histogram description cannot contain: __ or: __"
00080 <<" histogram description = "<<description;
00081 }
00082 return local_histo_id;
00083 }
00084
00085 std::string SiStripHistoId::getSubdetid(uint32_t id, const TrackerTopology* tTopo, bool flag_ring){
00086 std::string rest1;
00087
00088 const int buf_len = 50;
00089 char temp_str[buf_len];
00090
00091 StripSubdetector subdet(id);
00092 if( subdet.subdetId() == StripSubdetector::TIB){
00093
00094
00095 snprintf(temp_str, buf_len, "TIB__layer__%i", tTopo->tibLayer(id));
00096 }else if( subdet.subdetId() == StripSubdetector::TID){
00097
00098
00099 if (flag_ring) snprintf(temp_str, buf_len, "TID__side__%i__ring__%i", tTopo->tidSide(id), tTopo->tidRing(id));
00100 else snprintf(temp_str, buf_len, "TID__side__%i__wheel__%i", tTopo->tidSide(id), tTopo->tidWheel(id));
00101 }else if(subdet.subdetId() == StripSubdetector::TOB){
00102
00103
00104 snprintf(temp_str, buf_len, "TOB__layer__%i",tTopo->tobLayer(id));
00105 }else if(subdet.subdetId() == StripSubdetector::TEC){
00106
00107
00108 if (flag_ring) snprintf(temp_str, buf_len, "TEC__side__%i__ring__%i", tTopo->tecSide(id), tTopo->tecRing(id));
00109 else snprintf(temp_str, buf_len, "TEC__side__%i__wheel__%i", tTopo->tecSide(id), tTopo->tecWheel(id));
00110 }else{
00111
00112 edm::LogError("SiStripTkDQM|WrongInput")<<"no such subdetector type :"<<subdet.subdetId()<<" no folder set!"<<std::endl;
00113 snprintf(temp_str,0,"%s","");
00114 }
00115
00116 return std::string(temp_str);
00117 }
00118
00119 uint32_t SiStripHistoId::getComponentId(std::string histoid){
00120 uint32_t local_component_id;
00121 std::istringstream input(returnIdPart(histoid,3)); input >> local_component_id;
00122 return local_component_id;
00123 }
00124
00125
00126 std::string SiStripHistoId::getComponentType(std::string histoid){
00127 return returnIdPart(histoid,2);
00128 }
00129
00130
00131 std::string SiStripHistoId::returnIdPart(std::string histoid, uint32_t whichpart){
00132 size_t length1=histoid.find("__",0);
00133 if(length1==std::string::npos){
00134 edm::LogWarning("SiStripTkDQM|UnregularInput")<<"no regular histoid. Returning 0";
00135 return "0";
00136 }
00137 std::string part1 = histoid.substr(0,length1);
00138 if(whichpart==1) return part1;
00139 std::string remain1 = histoid.substr(length1+2);
00140 size_t length2=remain1.find("__",0);
00141 if(length2==std::string::npos){
00142 edm::LogWarning("SiStripTkDQM|UnregularInput")<<"no regular histoid. Returning 0";
00143 return "0";
00144 }
00145 std::string part2 = remain1.substr(0,length2);
00146 if(whichpart==2) return part2;
00147 std::string part3 = remain1.substr(length2+2);
00148 if(whichpart==3) return part3;
00149 edm::LogWarning("SiStripTkDQM|UnregularInput")<<"no such whichpart="<<whichpart<<" returning 0";
00150 return "0";
00151 }
00152