CMS 3D CMS Logo

SiStripHistoTitle.cc
Go to the documentation of this file.
1 
8 #include <iostream>
9 #include <iomanip>
10 
11 // -----------------------------------------------------------------------------
12 //
14  const sistrip::RunType& run_type,
15  const SiStripKey& key_object,
16  const std::string& extra_info)
17  : title_(""),
18  histoType_(histo_type),
19  runType_(run_type),
20  keyType_(sistrip::UNKNOWN_KEY),
21  keyValue_(sistrip::invalid32_),
22  granularity_(sistrip::UNKNOWN_GRAN),
23  channel_(sistrip::invalid_),
24  extraInfo_(extra_info) {
25  if (&dynamic_cast<const SiStripFedKey&>(key_object)) {
27  } else if (&dynamic_cast<const SiStripFecKey&>(key_object)) {
29  } else {
31  }
32  keyValue_ = key_object.key();
33  granularity_ = key_object.granularity();
34  channel_ = key_object.channel();
35  setTitle();
36 }
37 
38 // -----------------------------------------------------------------------------
39 //
41  const sistrip::RunType& run_type,
42  const sistrip::KeyType& key_type,
43  const uint32_t& key_value,
44  const sistrip::Granularity& gran,
45  const uint16_t& channel,
46  const std::string& extra_info)
47  : title_(""),
48  histoType_(histo_type),
49  runType_(run_type),
50  keyType_(key_type),
51  keyValue_(key_value),
52  granularity_(gran),
53  channel_(channel),
54  extraInfo_(extra_info) {
55  setTitle();
56 }
57 
58 // -----------------------------------------------------------------------------
59 //
61  : title_(histo_title),
62  histoType_(sistrip::UNDEFINED_HISTO_TYPE),
63  runType_(sistrip::UNDEFINED_RUN_TYPE),
64  keyType_(sistrip::UNDEFINED_KEY),
65  keyValue_(sistrip::invalid32_),
66  granularity_(sistrip::UNDEFINED_GRAN),
67  channel_(sistrip::invalid_),
68  extraInfo_("") {
69  extractTitle();
70 }
71 
72 // -----------------------------------------------------------------------------
73 //
75  std::stringstream title;
76 
77  // Append HistoType, RunType, KeyType and KeyValue
80  << std::setw(8) << std::hex << keyValue_ << std::dec << sistrip::sep_;
81 
82  // Append Granularity and channel number
84  if (channel_) {
85  title << channel_;
86  }
87 
88  // Append extra info
89  if (!extraInfo_.empty()) {
91  }
92 
93  title_ = title.str();
94 }
95 
96 // -----------------------------------------------------------------------------
97 //
99  std::string::size_type length = title_.length();
102  std::string::size_type siz = 0;
103 
104  // Extract HistoType
105  siz = title_.find(sistrip::sep_, position) - position;
108  position += title_.substr(position).find(histo_type) + histo_type.size() + (sizeof(sistrip::sep_) - 1);
110  position = 0;
111  } else if (position >= length) {
112  return;
113  }
114 
115  // Extract RunType
116  siz = title_.find(sistrip::sep_, position) - position;
119  position += title_.substr(position).find(run_type) + run_type.size() + (sizeof(sistrip::sep_) - 1);
120  if (position >= length) {
121  return;
122  }
123 
124  // Extract KeyType
125  siz = title_.find(sistrip::sep_, position) - position;
128  position += title_.substr(position).find(key_type) + key_type.size() + (sizeof(sistrip::hex_) - 1);
129  if (position >= length) {
130  return;
131  }
132 
133  // Extract KeyValue
134  siz = 8;
135  std::stringstream key;
136  key << title_.substr(position, siz);
137  key >> std::hex >> keyValue_;
138  position += siz + (sizeof(sistrip::sep_) - 1);
139  if (position >= length) {
140  return;
141  }
142 
143  // Extract Granularity
144  pos = title_.find(sistrip::sep_, position);
145  if (pos == std::string::npos || pos < position) {
146  siz = std::string::npos - position;
147  } else {
148  siz = pos - position;
149  }
152  position += title_.substr(position).find(gran) + gran.size();
153  if (position > length) {
154  return;
155  }
156 
157  // Extract Channel
158  pos = title_.find(sistrip::sep_, position);
159  if (pos == std::string::npos || pos < position) {
160  siz = std::string::npos - position;
161  } else {
162  siz = pos - position;
163  }
164  if (position == length || !siz) {
166  channel_ = 0;
167  } else if (granularity_ == sistrip::UNKNOWN_GRAN) {
169  }
170  } else {
171  std::stringstream chan;
172  chan << title_.substr(position, siz);
173  chan >> std::dec >> channel_;
174  }
175  position += siz + (sizeof(sistrip::sep_) - 1);
176  if (position >= length) {
177  return;
178  }
179 
180  // Extract ExtraInfo
181  extraInfo_ = title_.substr(position, std::string::npos - position);
182 }
183 
184 // -----------------------------------------------------------------------------
185 //
186 std::ostream& operator<<(std::ostream& os, const SiStripHistoTitle& title) {
187  std::stringstream ss;
188  ss << "[SiStripHistoTitle::print]" << std::endl
189  << " Title : " << title.title() << std::endl
190  << " HistoType : " << SiStripEnumsAndStrings::histoType(title.histoType()) << std::endl
191  << " RunType : " << SiStripEnumsAndStrings::runType(title.runType()) << std::endl
192  << " KeyType : " << SiStripEnumsAndStrings::keyType(title.keyType()) << std::endl
193  << " KeyValue (hex) : " << std::hex << std::setfill('0') << std::setw(8) << title.keyValue() << std::dec
194  << std::endl
195  << " Granularity : " << SiStripEnumsAndStrings::granularity(title.granularity()) << std::endl
196  << " Channel : " << title.channel() << std::endl
197  << " ExtraInfo : ";
198  if (!title.extraInfo().empty()) {
199  ss << "\"" << title.extraInfo() << "\"";
200  } else {
201  ss << "(none)";
202  }
203  os << ss.str();
204  return os;
205 }
const uint16_t & channel() const
Definition: SiStripKey.h:123
Utility class that holds histogram title.
static const uint32_t invalid32_
Definition: Constants.h:15
sistrip::Granularity granularity_
sistrip::RunType runType_
static std::string granularity(const sistrip::Granularity &)
uint16_t size_type
sistrip classes
static std::string runType(const sistrip::RunType &)
static const char sep_[]
sistrip::HistoType histoType_
static std::string histoType(const sistrip::HistoType &)
const uint32_t & key() const
Definition: SiStripKey.h:120
Base utility class that identifies a position within a logical structure of the strip tracker...
Definition: SiStripKey.h:23
std::ostream & operator<<(std::ostream &os, const SiStripHistoTitle &title)
sistrip::KeyType keyType_
static std::string keyType(const sistrip::KeyType &)
static const uint16_t invalid_
Definition: Constants.h:16
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
static int position[264][3]
Definition: ReadPGInfo.cc:289
static const char hex_[]
const std::string & title() const
const sistrip::Granularity & granularity() const
Definition: SiStripKey.h:122