test
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 
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 {
26  if ( &dynamic_cast<const SiStripFedKey&>(key_object) ) {
28  } else if ( &dynamic_cast<const SiStripFecKey&>(key_object) ) {
30  } else {
32  }
33  if ( &key_object ) {
34  keyValue_ = key_object.key();
35  granularity_ = key_object.granularity();
36  channel_ = key_object.channel();
37  }
38  setTitle();
39 }
40 
41 // -----------------------------------------------------------------------------
42 //
44  const sistrip::RunType& run_type,
45  const sistrip::KeyType& key_type,
46  const uint32_t& key_value,
47  const sistrip::Granularity& gran,
48  const uint16_t& channel,
49  const std::string& extra_info )
50  : title_(""),
51  histoType_(histo_type),
52  runType_(run_type),
53  keyType_(key_type),
54  keyValue_(key_value),
55  granularity_(gran),
56  channel_(channel),
57  extraInfo_(extra_info)
58 {
59  setTitle();
60 }
61 
62 // -----------------------------------------------------------------------------
63 //
65  : title_(histo_title),
66  histoType_(sistrip::UNDEFINED_HISTO_TYPE),
67  runType_(sistrip::UNDEFINED_RUN_TYPE),
68  keyType_(sistrip::UNDEFINED_KEY),
69  keyValue_(sistrip::invalid32_),
70  granularity_(sistrip::UNDEFINED_GRAN),
71  channel_(sistrip::invalid_),
72  extraInfo_("")
73 {
74  extractTitle();
75 }
76 
77 // -----------------------------------------------------------------------------
78 //
80 
81  std::stringstream title;
82 
83  // Append HistoType, RunType, KeyType and KeyValue
85  << sistrip::sep_
87  << sistrip::sep_
89  << sistrip::hex_
90  << std::setfill('0') << std::setw(8) << std::hex << keyValue_ << std::dec
91  << sistrip::sep_;
92 
93  // Append Granularity and channel number
95  if ( channel_ ) { title << channel_; }
96 
97  // Append extra info
98  if ( extraInfo_ != "" ) {
99  title << sistrip::sep_ << extraInfo_;
100  }
101 
102  title_ = title.str();
103 
104 }
105 
106 // -----------------------------------------------------------------------------
107 //
109 
110  std::string::size_type length = title_.length();
112  std::string::size_type pos = 0;
113  std::string::size_type siz = 0;
114 
115  // Extract HistoType
116  siz = title_.find(sistrip::sep_,position) - position;
117  histoType_ = SiStripEnumsAndStrings::histoType( title_.substr(position,siz) );
119  position += title_.substr(position).find( histo_type ) + histo_type.size() + (sizeof(sistrip::sep_) - 1);
120  if ( histoType_ == sistrip::UNKNOWN_HISTO_TYPE ) { position = 0; }
121  else if ( position >= length ) { return; }
122 
123  // Extract RunType
124  siz = title_.find(sistrip::sep_,position) - position;
125  runType_ = SiStripEnumsAndStrings::runType( title_.substr(position,siz) );
127  position += title_.substr(position).find( run_type ) + run_type.size() + (sizeof(sistrip::sep_) - 1);
128  if ( position >= length ) { return; }
129 
130  // Extract KeyType
131  siz = title_.find(sistrip::sep_,position) - position;
132  keyType_ = SiStripEnumsAndStrings::keyType( title_.substr(position,siz) );
134  position += title_.substr(position).find( key_type ) + key_type.size() + (sizeof(sistrip::hex_) - 1);
135  if ( position >= length ) { return; }
136 
137  // Extract KeyValue
138  siz = 8;
139  std::stringstream key;
140  key << title_.substr(position,siz);
141  key >> std::hex >> keyValue_;
142  position += siz + (sizeof(sistrip::sep_) - 1);
143  if ( position >= length ) { return; }
144 
145  // Extract Granularity
146  pos = title_.find(sistrip::sep_,position);
147  if ( pos == std::string::npos || pos < position ) { siz = std::string::npos - position; }
148  else { siz = pos - position; }
149  granularity_ = SiStripEnumsAndStrings::granularity( title_.substr(position,siz) );
151  position += title_.substr(position).find( gran ) + gran.size();
152  if ( position > length ) { return; }
153 
154  // Extract Channel
155  pos = title_.find(sistrip::sep_,position);
156  if ( pos == std::string::npos || pos < position ) { siz = std::string::npos - position; }
157  else { siz = pos - position; }
158  if ( position == length || !siz ) {
161  } else {
162  std::stringstream chan;
163  chan << title_.substr(position,siz);
164  chan >> std::dec >> channel_;
165  }
166  position += siz + (sizeof(sistrip::sep_) - 1);
167  if ( position >= length ) { return; }
168 
169  // Extract ExtraInfo
170  extraInfo_ = title_.substr( position, std::string::npos - position );
171 
172 }
173 
174 // -----------------------------------------------------------------------------
175 //
176 std::ostream& operator<< ( std::ostream& os, const SiStripHistoTitle& title ) {
177  std::stringstream ss;
178  ss << "[SiStripHistoTitle::print]" << std::endl
179  << " Title : " << title.title() << std::endl
180  << " HistoType : " << SiStripEnumsAndStrings::histoType( title.histoType() ) << std::endl
181  << " RunType : " << SiStripEnumsAndStrings::runType( title.runType() ) << std::endl
182  << " KeyType : " << SiStripEnumsAndStrings::keyType( title.keyType() ) << std::endl
183  << " KeyValue (hex) : " << std::hex << std::setfill('0') << std::setw(8) << title.keyValue() << std::dec << std::endl
184  << " Granularity : " << SiStripEnumsAndStrings::granularity( title.granularity() ) << std::endl
185  << " Channel : " << title.channel() << std::endl
186  << " ExtraInfo : ";
187  if ( title.extraInfo() != "" ) { ss << "\"" << title.extraInfo() << "\""; }
188  else { ss << "(none)"; }
189  os << ss.str();
190  return os;
191 }
192 
Utility class that holds histogram title.
const std::string & title() const
static const uint32_t invalid32_
Definition: Constants.h:15
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
const uint32_t & key() const
Definition: SiStripKey.h:125
const sistrip::Granularity & granularity() const
Definition: SiStripKey.h:127
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:23
const sistrip::RunType & runType() const
sistrip::KeyType keyType_
const uint16_t & channel() const
Definition: SiStripKey.h:128
static std::string keyType(const sistrip::KeyType &)
static const uint16_t invalid_
Definition: Constants.h:16
list key
Definition: combine.py:13
static int position[264][3]
Definition: ReadPGInfo.cc:509
static const char hex_[]
const uint16_t & channel() const
const sistrip::HistoType & histoType() const