@@ -78,66 +78,46 @@ std::string SiStripHistoId::createHistoLayer(std::string description,
7878 return local_histo_id;
7979}
8080
81- // std::string SiStripHistoId::getSubdetid(uint32_t id, const TrackerTopology* tTopo, bool flag_ring, bool flag_thickness){
81+ // std::string SiStripHistoId::getSubdetid(uint32_t id, const TrackerTopology* tTopo, bool flag_ring, bool flag_thickness) {
8282std::string SiStripHistoId::getSubdetid (uint32_t id, const TrackerTopology *tTopo, bool flag_ring) {
83- const int buf_len = 50 ;
84- char temp_str[buf_len];
85-
8683 StripSubdetector subdet (id);
84+
8785 if (subdet.subdetId () == StripSubdetector::TIB) {
8886 // --------------------------- TIB --------------------------- //
89-
90- snprintf (temp_str, buf_len, " TIB__layer__%i" , tTopo->tibLayer (id));
87+ return " TIB__layer__" + std::to_string (tTopo->tibLayer (id));
9188 } else if (subdet.subdetId () == StripSubdetector::TID) {
9289 // --------------------------- TID --------------------------- //
93-
94- const char *side = " " ;
95- if (tTopo->tidSide (id) == 1 )
96- side = " MINUS" ;
97- else if (tTopo->tidSide (id) == 2 )
98- side = " PLUS" ;
90+ std::string side = (tTopo->tidSide (id) == 1 ) ? " MINUS" : " PLUS" ;
9991
10092 if (flag_ring)
101- snprintf (temp_str, buf_len, " TID__%s__ring__%i " , side, tTopo->tidRing (id));
93+ return " TID__" + side + " __ring__ " + std::to_string ( tTopo->tidRing (id));
10294 else
103- snprintf (temp_str, buf_len, " TID__%s__wheel__%i" , side, tTopo->tidWheel (id));
104-
95+ return " TID__" + side + " __wheel__" + std::to_string (tTopo->tidWheel (id));
10596 } else if (subdet.subdetId () == StripSubdetector::TOB) {
10697 // --------------------------- TOB --------------------------- //
107-
108- snprintf (temp_str, buf_len, " TOB__layer__%i" , tTopo->tobLayer (id));
98+ return " TOB__layer__" + std::to_string (tTopo->tobLayer (id));
10999 } else if (subdet.subdetId () == StripSubdetector::TEC) {
110100 // --------------------------- TEC --------------------------- //
101+ std::string side = (tTopo->tecSide (id) == 1 ) ? " MINUS" : " PLUS" ;
111102
112- const char *side = " " ;
113- if (tTopo->tecSide (id) == 1 )
114- side = " MINUS" ;
115- else if (tTopo->tecSide (id) == 2 )
116- side = " PLUS" ;
117-
118- if (flag_ring)
119- snprintf (temp_str, buf_len, " TEC__%s__ring__%i" , side, tTopo->tecRing (id));
120- else {
103+ if (flag_ring) {
104+ return " TEC__" + side + " __ring__" + std::to_string (tTopo->tecRing (id));
105+ } else {
121106 /*
122107 if (flag_thickness) {
123- uint32_t ring = tTopo->tecRing(id);
124- if ( ring >= 1 && ring <= 4 )
125- snprintf(temp_str, buf_len, "TEC__%s__wheel__%i__THIN", side.c_str(), tTopo->tecWheel(id));
126- else
127- snprintf(temp_str, buf_len, "TEC__%s__wheel__%i__THICK", side.c_str(), tTopo->tecWheel(id));
128- }
129- else
130- */
131- snprintf (temp_str, buf_len, " TEC__%s__wheel__%i" , side, tTopo->tecWheel (id));
108+ uint32_t ring = tTopo->tecRing(id);
109+ std::string thickness = (ring >= 1 && ring <= 4) ? "__THIN" : "__THICK";
110+ return "TEC__" + side + "__wheel__" + std::to_string(tTopo->tecWheel(id)) + thickness;
111+ } else
112+ */
113+ return " TEC__" + side + " __wheel__" + std::to_string (tTopo->tecWheel (id));
132114 }
133115 } else {
134116 // --------------------------- ??? --------------------------- //
135117 edm::LogError (" SiStripTkDQM|WrongInput" )
136- << " no such subdetector type : " << subdet.subdetId () << " no folder set!" << std::endl;
137- snprintf (temp_str, 0 , " %s " , " " );
118+ << " no such subdetector type: " << subdet.subdetId () << " no folder set!" << std::endl;
119+ return " " ; // Return an empty string on error
138120 }
139-
140- return std::string (temp_str);
141121}
142122
143123uint32_t SiStripHistoId::getComponentId (std::string histoid) {
0 commit comments