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  keyValue_ = key_object.key();
34  granularity_ = key_object.granularity();
35  channel_ = key_object.channel();
36  setTitle();
37 }
38 
39 // -----------------------------------------------------------------------------
40 //
42  const sistrip::RunType& run_type,
43  const sistrip::KeyType& key_type,
44  const uint32_t& key_value,
45  const sistrip::Granularity& gran,
46  const uint16_t& channel,
47  const std::string& extra_info )
48  : title_(""),
49  histoType_(histo_type),
50  runType_(run_type),
51  keyType_(key_type),
52  keyValue_(key_value),
53  granularity_(gran),
54  channel_(channel),
55  extraInfo_(extra_info)
56 {
57  setTitle();
58 }
59 
60 // -----------------------------------------------------------------------------
61 //
63  : title_(histo_title),
64  histoType_(sistrip::UNDEFINED_HISTO_TYPE),
65  runType_(sistrip::UNDEFINED_RUN_TYPE),
66  keyType_(sistrip::UNDEFINED_KEY),
67  keyValue_(sistrip::invalid32_),
68  granularity_(sistrip::UNDEFINED_GRAN),
69  channel_(sistrip::invalid_),
70  extraInfo_("")
71 {
72  extractTitle();
73 }
74 
75 // -----------------------------------------------------------------------------
76 //
78 
79  std::stringstream title;
80 
81  // Append HistoType, RunType, KeyType and KeyValue
83  << sistrip::sep_
85  << sistrip::sep_
87  << sistrip::hex_
88  << std::setfill('0') << std::setw(8) << std::hex << keyValue_ << std::dec
89  << sistrip::sep_;
90 
91  // Append Granularity and channel number
93  if ( channel_ ) { title << channel_; }
94 
95  // Append extra info
96  if ( extraInfo_ != "" ) {
97  title << sistrip::sep_ << extraInfo_;
98  }
99 
100  title_ = title.str();
101 
102 }
103 
104 // -----------------------------------------------------------------------------
105 //
107 
108  std::string::size_type length = title_.length();
110  std::string::size_type pos = 0;
111  std::string::size_type siz = 0;
112 
113  // Extract HistoType
114  siz = title_.find(sistrip::sep_,position) - position;
115  histoType_ = SiStripEnumsAndStrings::histoType( title_.substr(position,siz) );
117  position += title_.substr(position).find( histo_type ) + histo_type.size() + (sizeof(sistrip::sep_) - 1);
118  if ( histoType_ == sistrip::UNKNOWN_HISTO_TYPE ) { position = 0; }
119  else if ( position >= length ) { return; }
120 
121  // Extract RunType
122  siz = title_.find(sistrip::sep_,position) - position;
123  runType_ = SiStripEnumsAndStrings::runType( title_.substr(position,siz) );
125  position += title_.substr(position).find( run_type ) + run_type.size() + (sizeof(sistrip::sep_) - 1);
126  if ( position >= length ) { return; }
127 
128  // Extract KeyType
129  siz = title_.find(sistrip::sep_,position) - position;
130  keyType_ = SiStripEnumsAndStrings::keyType( title_.substr(position,siz) );
132  position += title_.substr(position).find( key_type ) + key_type.size() + (sizeof(sistrip::hex_) - 1);
133  if ( position >= length ) { return; }
134 
135  // Extract KeyValue
136  siz = 8;
137  std::stringstream key;
138  key << title_.substr(position,siz);
139  key >> std::hex >> keyValue_;
140  position += siz + (sizeof(sistrip::sep_) - 1);
141  if ( position >= length ) { return; }
142 
143  // Extract Granularity
144  pos = title_.find(sistrip::sep_,position);
145  if ( pos == std::string::npos || pos < position ) { siz = std::string::npos - position; }
146  else { siz = pos - position; }
147  granularity_ = SiStripEnumsAndStrings::granularity( title_.substr(position,siz) );
149  position += title_.substr(position).find( gran ) + gran.size();
150  if ( position > length ) { return; }
151 
152  // Extract Channel
153  pos = title_.find(sistrip::sep_,position);
154  if ( pos == std::string::npos || pos < position ) { siz = std::string::npos - position; }
155  else { siz = pos - position; }
156  if ( position == length || !siz ) {
159  } else {
160  std::stringstream chan;
161  chan << title_.substr(position,siz);
162  chan >> std::dec >> channel_;
163  }
164  position += siz + (sizeof(sistrip::sep_) - 1);
165  if ( position >= length ) { return; }
166 
167  // Extract ExtraInfo
168  extraInfo_ = title_.substr( position, std::string::npos - position );
169 
170 }
171 
172 // -----------------------------------------------------------------------------
173 //
174 std::ostream& operator<< ( std::ostream& os, const SiStripHistoTitle& title ) {
175  std::stringstream ss;
176  ss << "[SiStripHistoTitle::print]" << std::endl
177  << " Title : " << title.title() << std::endl
178  << " HistoType : " << SiStripEnumsAndStrings::histoType( title.histoType() ) << std::endl
179  << " RunType : " << SiStripEnumsAndStrings::runType( title.runType() ) << std::endl
180  << " KeyType : " << SiStripEnumsAndStrings::keyType( title.keyType() ) << std::endl
181  << " KeyValue (hex) : " << std::hex << std::setfill('0') << std::setw(8) << title.keyValue() << std::dec << std::endl
182  << " Granularity : " << SiStripEnumsAndStrings::granularity( title.granularity() ) << std::endl
183  << " Channel : " << title.channel() << std::endl
184  << " ExtraInfo : ";
185  if ( title.extraInfo() != "" ) { ss << "\"" << title.extraInfo() << "\""; }
186  else { ss << "(none)"; }
187  os << ss.str();
188  return os;
189 }
190 
Utility class that holds histogram title.
const std::string & title() const
static const uint32_t invalid32_
Definition: Constants.h:15
tuple chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, &quot;NDC&quot;) lumi.SetBorderSize( 0 ) lumi...
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:188
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
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
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
static int position[264][3]
Definition: ReadPGInfo.cc:509
static const char hex_[]
const uint16_t & channel() const
const sistrip::HistoType & histoType() const