CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripHistoId.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiStripCommon
4 // Class : SiStripHistoId
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: dkcira
10 // Created: Wed Feb 22 16:07:58 CET 2006
11 //
12 
13 #include<iostream>
14 #include<sstream>
15 #include<cstdio>
16 
22 
24 {
25 }
26 
27 
29 {
30 }
31 
32 
34  size_t pos1 = description.find("__", 0 ); // check if std::string 'description' contains by mistake the 'separator1'
35  size_t pos2 = description.find("__", 0 ); // check if std::string 'description' contains by mistake the 'separator2'
36  std::string local_histo_id;
37  std::ostringstream compid;
38  compid<<component_id; // use std::ostringstream for casting integer to std::string
39 
40  if ( pos1 == std::string::npos && pos2 == std::string::npos ){ // ok, not found either separator
41  if(id_type=="fed" || id_type=="det" || id_type=="fec"){ // ok! is one of the accepted id_type-s
42  local_histo_id = description + "__" + id_type + "__" + compid.str();
43  }else{
44  local_histo_id = description + "__dummy__" + compid.str();
45  edm::LogError("SiStripHistoId") <<" SiStripHistoId::WrongInput "
46  <<" no such type of component accepted: "<<id_type
47  <<" id_type can be: fed, det, or fec.";
48  }
49  }else{
50  local_histo_id = description + "_dummy___" + id_type + "__" + compid.str();
51  edm::LogError("SiStripHistoId") <<" SiStripHistoId::WrongInput "
52  <<" histogram description cannot contain: __ or: __"
53  <<" histogram description = "<<description;
54  }
55  return local_histo_id;
56 }
57 
59  size_t pos1 = description.find( "__", 0 ); // check if std::string 'description' contains by mistake the 'separator1'
60  size_t pos2 = description.find( "__", 0 ); // check if std::string 'description' contains by mistake the 'separator2'
61  std::string local_histo_id;
62  if ( pos1 == std::string::npos && pos2 == std::string::npos ){ // ok, not found either separator
63  if(id_type=="fed" || id_type=="det" || id_type=="fec" || id_type=="layer"){ // ok! is one of the accepted id_type-s
64  if(flag.size() > 0)
65  local_histo_id = description + "__" + flag + "__" + path;
66  else
67  local_histo_id = description + "__" + path;
68  LogTrace("SiStripHistoId") << "Local_histo_ID " << local_histo_id << std::endl;
69  }else{
70  local_histo_id = description + "___dummy___" + path;
71  edm::LogError("SiStripHistoId") <<" SiStripHistoId::WrongInput "
72  <<" no such type of component accepted: "<<id_type
73  <<" id_type can be: fed, det, fec or layer ";
74  }
75  }else{
76  local_histo_id = description + "_dummy___" + path;
77  edm::LogWarning("SiStripHistoId") <<" SiStripHistoId::WrongInput "
78  <<" histogram description cannot contain: __ or: __"
79  <<" histogram description = "<<description;
80  }
81  return local_histo_id;
82 }
83 
84 std::string SiStripHistoId::getSubdetid(uint32_t id, const TrackerTopology* tTopo, bool flag_ring){
85  std::string rest1;
86 
87  const int buf_len = 50;
88  char temp_str[buf_len];
89 
90  StripSubdetector subdet(id);
91  if( subdet.subdetId() == StripSubdetector::TIB){
92  // --------------------------- TIB --------------------------- //
93 
94  snprintf(temp_str, buf_len, "TIB__layer__%i", tTopo->tibLayer(id));
95  }else if( subdet.subdetId() == StripSubdetector::TID){
96  // --------------------------- TID --------------------------- //
97 
98  std::string side = "";
99  if (tTopo->tidSide(id) == 1)
100  side = "MINUS";
101  else if (tTopo->tidSide(id) == 2)
102  side = "PLUS";
103 
104  if (flag_ring)
105  snprintf(temp_str, buf_len, "TID__%s__ring__%i", side.c_str(), tTopo->tidRing(id) );
106  else
107  snprintf(temp_str, buf_len, "TID__%s__wheel__%i", side.c_str(), tTopo->tidWheel(id));
108 
109  }else if(subdet.subdetId() == StripSubdetector::TOB){
110  // --------------------------- TOB --------------------------- //
111 
112  snprintf(temp_str, buf_len, "TOB__layer__%i",tTopo->tobLayer(id));
113  }else if(subdet.subdetId() == StripSubdetector::TEC){
114  // --------------------------- TEC --------------------------- //
115 
116  std::string side = "";
117  if (tTopo->tecSide(id) == 1)
118  side = "MINUS";
119  else if (tTopo->tecSide(id) == 2)
120  side = "PLUS";
121 
122  if (flag_ring)
123  snprintf(temp_str, buf_len, "TEC__%s__ring__%i", side.c_str(), tTopo->tecRing(id) );
124  else
125  snprintf(temp_str, buf_len, "TEC__%s__wheel__%i", side.c_str(), tTopo->tecWheel(id));
126  }else{
127  // --------------------------- ??? --------------------------- //
128  edm::LogError("SiStripTkDQM|WrongInput")<<"no such subdetector type :"<<subdet.subdetId()<<" no folder set!"<<std::endl;
129  snprintf(temp_str,0,"%s","");
130  }
131 
132  return std::string(temp_str);
133 }
134 
136  uint32_t local_component_id;
137  std::istringstream input(returnIdPart(histoid,3)); input >> local_component_id; // use std::istringstream for casting from std::string to uint32_t
138  return local_component_id;
139 }
140 
141 
143  return returnIdPart(histoid,2);
144 }
145 
146 
148  size_t length1=histoid.find("__",0);
149  if(length1==std::string::npos){ // no separator1 found
150  edm::LogWarning("SiStripTkDQM|UnregularInput")<<"no regular histoid. Returning 0";
151  return "0";
152  }
153  std::string part1 = histoid.substr(0,length1); // part of 'histoid' up to 'separator1'
154  if(whichpart==1) return part1;
155  std::string remain1 = histoid.substr(length1+2); // rest of 'histoid' starting at end of 'separator1'
156  size_t length2=remain1.find("__",0);
157  if(length2==std::string::npos){ // no separator2 found
158  edm::LogWarning("SiStripTkDQM|UnregularInput")<<"no regular histoid. Returning 0";
159  return "0";
160  }
161  std::string part2 = remain1.substr(0,length2); // part of 'remain1' up to 'separator2'
162  if(whichpart==2) return part2;
163  std::string part3 = remain1.substr(length2+2); // rest of remain1 starting at end of 'separator2'
164  if(whichpart==3) return part3;
165  edm::LogWarning("SiStripTkDQM|UnregularInput")<<"no such whichpart="<<whichpart<<" returning 0";
166  return "0";
167 }
168 
std::string getComponentType(std::string histoid)
unsigned int tibLayer(const DetId &id) const
unsigned int tidRing(const DetId &id) const
unsigned int tecRing(const DetId &id) const
ring id
std::string returnIdPart(std::string histoid, uint32_t whichpart)
unsigned int tidWheel(const DetId &id) const
static std::string const input
Definition: EdmProvDump.cc:44
uint32_t getComponentId(std::string histoid)
unsigned int tidSide(const DetId &id) const
tuple path
else: Piece not in the list, fine.
std::string getSubdetid(uint32_t id, const TrackerTopology *tTopo, bool flag_ring)
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
#define LogTrace(id)
tuple description
Definition: idDealer.py:66
std::string createHistoId(std::string description, std::string id_type, uint32_t component_id)
std::string createHistoLayer(std::string description, std::string id_type, std::string path, std::string flag)
unsigned int tecWheel(const DetId &id) const
virtual ~SiStripHistoId()
unsigned int tobLayer(const DetId &id) const
unsigned int tecSide(const DetId &id) const