CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripHistoTitle.cc
Go to the documentation of this file.
1 // Last commit: $Id: SiStripHistoTitle.cc,v 1.8 2012/07/04 19:04:52 eulisse Exp $
2 
9 #include <iostream>
10 #include <iomanip>
11 
12 // -----------------------------------------------------------------------------
13 //
15  const sistrip::RunType& run_type,
16  const SiStripKey& key_object,
17  const std::string& extra_info )
18  : title_(""),
19  histoType_(histo_type),
20  runType_(run_type),
21  keyType_(sistrip::UNKNOWN_KEY),
22  keyValue_(sistrip::invalid32_),
23  granularity_(sistrip::UNKNOWN_GRAN),
24  channel_(sistrip::invalid_),
25  extraInfo_(extra_info)
26 {
27  if ( &dynamic_cast<const SiStripFedKey&>(key_object) ) {
29  } else if ( &dynamic_cast<const SiStripFecKey&>(key_object) ) {
31  } else {
33  }
34  if ( &key_object ) {
35  keyValue_ = key_object.key();
36  granularity_ = key_object.granularity();
37  channel_ = key_object.channel();
38  }
39  setTitle();
40 }
41 
42 // -----------------------------------------------------------------------------
43 //
45  const sistrip::RunType& run_type,
46  const sistrip::KeyType& key_type,
47  const uint32_t& key_value,
48  const sistrip::Granularity& gran,
49  const uint16_t& channel,
50  const std::string& extra_info )
51  : title_(""),
52  histoType_(histo_type),
53  runType_(run_type),
54  keyType_(key_type),
55  keyValue_(key_value),
56  granularity_(gran),
57  channel_(channel),
58  extraInfo_(extra_info)
59 {
60  setTitle();
61 }
62 
63 // -----------------------------------------------------------------------------
64 //
66  : title_(histo_title),
67  histoType_(sistrip::UNDEFINED_HISTO_TYPE),
68  runType_(sistrip::UNDEFINED_RUN_TYPE),
69  keyType_(sistrip::UNDEFINED_KEY),
70  keyValue_(sistrip::invalid32_),
71  granularity_(sistrip::UNDEFINED_GRAN),
72  channel_(sistrip::invalid_),
73  extraInfo_("")
74 {
75  extractTitle();
76 }
77 
78 // -----------------------------------------------------------------------------
79 //
81 
82  std::stringstream title;
83 
84  // Append HistoType, RunType, KeyType and KeyValue
86  << sistrip::sep_
88  << sistrip::sep_
90  << sistrip::hex_
91  << std::setfill('0') << std::setw(8) << std::hex << keyValue_ << std::dec
92  << sistrip::sep_;
93 
94  // Append Granularity and channel number
96  if ( channel_ ) { title << channel_; }
97 
98  // Append extra info
99  if ( extraInfo_ != "" ) {
100  title << sistrip::sep_ << extraInfo_;
101  }
102 
103  title_ = title.str();
104 
105 }
106 
107 // -----------------------------------------------------------------------------
108 //
110 
111  std::string::size_type length = title_.length();
114  std::string::size_type siz = 0;
115 
116  // Extract HistoType
117  siz = title_.find(sistrip::sep_,position) - position;
118  histoType_ = SiStripEnumsAndStrings::histoType( title_.substr(position,siz) );
120  position += title_.substr(position).find( histo_type ) + histo_type.size() + (sizeof(sistrip::sep_) - 1);
121  if ( histoType_ == sistrip::UNKNOWN_HISTO_TYPE ) { position = 0; }
122  else if ( position >= length ) { return; }
123 
124  // Extract RunType
125  siz = title_.find(sistrip::sep_,position) - position;
126  runType_ = SiStripEnumsAndStrings::runType( title_.substr(position,siz) );
128  position += title_.substr(position).find( run_type ) + run_type.size() + (sizeof(sistrip::sep_) - 1);
129  if ( position >= length ) { return; }
130 
131  // Extract KeyType
132  siz = title_.find(sistrip::sep_,position) - position;
133  keyType_ = SiStripEnumsAndStrings::keyType( title_.substr(position,siz) );
135  position += title_.substr(position).find( key_type ) + key_type.size() + (sizeof(sistrip::hex_) - 1);
136  if ( position >= length ) { return; }
137 
138  // Extract KeyValue
139  siz = 8;
140  std::stringstream key;
141  key << title_.substr(position,siz);
142  key >> std::hex >> keyValue_;
143  position += siz + (sizeof(sistrip::sep_) - 1);
144  if ( position >= length ) { return; }
145 
146  // Extract Granularity
147  pos = title_.find(sistrip::sep_,position);
148  if ( pos == std::string::npos || pos < position ) { siz = std::string::npos - position; }
149  else { siz = pos - position; }
150  granularity_ = SiStripEnumsAndStrings::granularity( title_.substr(position,siz) );
152  position += title_.substr(position).find( gran ) + gran.size();
153  if ( position > length ) { return; }
154 
155  // Extract Channel
156  pos = title_.find(sistrip::sep_,position);
157  if ( pos == std::string::npos || pos < position ) { siz = std::string::npos - position; }
158  else { siz = pos - position; }
159  if ( position == length || !siz ) {
162  } else {
163  std::stringstream chan;
164  chan << title_.substr(position,siz);
165  chan >> std::dec >> channel_;
166  }
167  position += siz + (sizeof(sistrip::sep_) - 1);
168  if ( position >= length ) { return; }
169 
170  // Extract ExtraInfo
171  extraInfo_ = title_.substr( position, std::string::npos - position );
172 
173 }
174 
175 // -----------------------------------------------------------------------------
176 //
177 std::ostream& operator<< ( std::ostream& os, const SiStripHistoTitle& title ) {
178  std::stringstream ss;
179  ss << "[SiStripHistoTitle::print]" << std::endl
180  << " Title : " << title.title() << std::endl
181  << " HistoType : " << SiStripEnumsAndStrings::histoType( title.histoType() ) << std::endl
182  << " RunType : " << SiStripEnumsAndStrings::runType( title.runType() ) << std::endl
183  << " KeyType : " << SiStripEnumsAndStrings::keyType( title.keyType() ) << std::endl
184  << " KeyValue (hex) : " << std::hex << std::setfill('0') << std::setw(8) << title.keyValue() << std::dec << std::endl
185  << " Granularity : " << SiStripEnumsAndStrings::granularity( title.granularity() ) << std::endl
186  << " Channel : " << title.channel() << std::endl
187  << " ExtraInfo : ";
188  if ( title.extraInfo() != "" ) { ss << "\"" << title.extraInfo() << "\""; }
189  else { ss << "(none)"; }
190  os << ss.str();
191  return os;
192 }
193 
Utility class that holds histogram title.
const std::string & title() const
static const uint32_t invalid32_
Definition: Constants.h:16
sistrip::Granularity granularity_
sistrip::RunType runType_
static std::string granularity(const sistrip::Granularity &)
const sistrip::Granularity & granularity() const
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
uint16_t size_type
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
const uint32_t & key() const
Definition: SiStripKey.h:126
const sistrip::Granularity & granularity() const
Definition: SiStripKey.h:128
static std::string runType(const sistrip::RunType &)
static const char sep_[]
const std::string & extraInfo() const
sistrip::HistoType histoType_
const sistrip::KeyType & keyType() const
const uint32_t & keyValue() const
static std::string histoType(const sistrip::HistoType &)
Base utility class that identifies a position within a logical structure of the strip tracker...
Definition: SiStripKey.h:24
const sistrip::RunType & runType() const
sistrip::KeyType keyType_
const uint16_t & channel() const
Definition: SiStripKey.h:129
static std::string keyType(const sistrip::KeyType &)
static const uint16_t invalid_
Definition: Constants.h:17
list key
Definition: combine.py:13
static const char hex_[]
const uint16_t & channel() const
const sistrip::HistoType & histoType() const