CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripDetKey.cc
Go to the documentation of this file.
1 
5 #include <iomanip>
6 
7 // -----------------------------------------------------------------------------
8 //
9 SiStripDetKey::SiStripDetKey( const uint16_t& partition ) :
10  SiStripKey(),
11  partition_(partition),
12  apvPairNumber_(sistrip::invalid_),
13  apvWithinPair_(sistrip::invalid_)
14 {
15  // order is important!
16  initFromValue();
17  initFromKey();
18  initFromPath();
20 }
21 
22 // -----------------------------------------------------------------------------
23 //
25  const uint16_t& apv_pair_number,
26  const uint16_t& apv_within_pair ) :
27  SiStripKey(),
28  partition_(sistrip::invalid_),
29  apvPairNumber_(apv_pair_number),
30  apvWithinPair_(apv_within_pair)
31 {
32  // order is important!
33  initFromValue();
34  initFromKey();
35  initFromPath();
37 }
38 
39 // -----------------------------------------------------------------------------
40 //
42  SiStripKey(),
43  partition_(sistrip::invalid_),
44  apvPairNumber_(sistrip::invalid_),
45  apvWithinPair_(sistrip::invalid_)
46 {
47  // order is important!
48  initFromValue();
49  initFromKey();
50  initFromPath();
52 }
53 
54 // -----------------------------------------------------------------------------
55 //
56 SiStripDetKey::SiStripDetKey( const uint32_t& det_key ) :
57  SiStripKey(det_key),
58  partition_(sistrip::invalid_),
59  apvPairNumber_(sistrip::invalid_),
60  apvWithinPair_(sistrip::invalid_)
61 {
62  // order is important!
63  initFromKey();
64  initFromValue();
65  initFromPath();
67 }
68 
69 // -----------------------------------------------------------------------------
70 //
72  SiStripKey(path),
73  partition_(sistrip::invalid_),
74  apvPairNumber_(sistrip::invalid_),
75  apvWithinPair_(sistrip::invalid_)
76 {
77  // order is important!
78  initFromPath();
79  initFromValue();
80  initFromKey();
82 }
83 
84 // -----------------------------------------------------------------------------
85 //
87  SiStripKey(),
88  partition_(input.partition()),
89  apvPairNumber_(input.apvPairNumber()),
90  apvWithinPair_(input.apvWithinPair())
91 {
92  key(input.key());
93  path(input.path());
94  granularity(input.granularity());
95 }
96 
97 // -----------------------------------------------------------------------------
98 //
100  SiStripKey(),
101  partition_(sistrip::invalid_),
102  apvPairNumber_(sistrip::invalid_),
103  apvWithinPair_(sistrip::invalid_)
104 {
105  const SiStripDetKey& det_key = dynamic_cast<const SiStripDetKey&>(input);
106  if ( (&det_key) ) {
107  key(det_key.key());
108  path(det_key.path());
109  granularity(det_key.granularity());
110  partition_ = det_key.partition();
111  apvPairNumber_ = det_key.apvPairNumber();
112  apvWithinPair_ = det_key.apvWithinPair();
113  }
114 }
115 
116 // -----------------------------------------------------------------------------
117 //
119  const sistrip::Granularity& gran ) :
120  SiStripKey(),
121  partition_(0),
122  apvPairNumber_(0),
123  apvWithinPair_(0)
124 {
125  const SiStripDetKey& det_key = dynamic_cast<const SiStripDetKey&>(input);
126  if ( (&det_key) ) {
127 
128  if ( gran == sistrip::PARTITION ) {
129  partition_ = det_key.partition();
130  }
131 
132  initFromValue();
133  initFromKey();
134  initFromPath();
135  initGranularity();
136 
137  }
138 
139 }
140 
141 // -----------------------------------------------------------------------------
142 //
144  SiStripKey(),
145  partition_(sistrip::invalid_),
146  apvPairNumber_(sistrip::invalid_),
147  apvWithinPair_(sistrip::invalid_)
148 {;}
149 
150 // -----------------------------------------------------------------------------
151 //
152 bool SiStripDetKey::isEqual( const SiStripKey& key ) const {
153  const SiStripDetKey& input = dynamic_cast<const SiStripDetKey&>(key);
154  if ( !(&input) ) { return false; }
155  if ( partition_ == input.partition() &&
156  apvPairNumber_ == input.apvPairNumber() &&
157  apvWithinPair_ == input.apvWithinPair() ) {
158  return true;
159  } else { return false; }
160 }
161 
162 // -----------------------------------------------------------------------------
163 //
165  const SiStripDetKey& input = dynamic_cast<const SiStripDetKey&>(key);
166  if ( !(&input) ) { return false; }
167  if ( isEqual(input) ) { return false; }
168  else if ( ( partition_ == 0 || input.partition() == 0 ) &&
169  ( apvPairNumber_ == 0 || input.apvPairNumber() == 0 ) &&
170  ( apvWithinPair_ == 0 || input.apvWithinPair() == 0 ) ) {
171  return true;
172  } else { return false; }
173 }
174 
175 // -----------------------------------------------------------------------------
176 //
177 bool SiStripDetKey::isValid() const {
178  return isValid(sistrip::APV);
179 }
180 
181 // -----------------------------------------------------------------------------
182 //
183 bool SiStripDetKey::isValid( const sistrip::Granularity& gran ) const {
184  if ( gran == sistrip::TRACKER ) { return true; }
185  else if ( gran == sistrip::UNDEFINED_GRAN ||
186  gran == sistrip::UNKNOWN_GRAN ) { return false; }
187 
188  if ( partition_ != sistrip::invalid_ ) {
189  if ( gran == sistrip::PARTITION ) { return true; }
190  }
191  return false;
192 }
193 
194 // -----------------------------------------------------------------------------
195 //
197  return isInvalid(sistrip::APV);
198 }
199 
200 // -----------------------------------------------------------------------------
201 //
203  if ( gran == sistrip::TRACKER ) { return false; }
204  else if ( gran == sistrip::UNDEFINED_GRAN ||
205  gran == sistrip::UNKNOWN_GRAN ) { return false; }
206 
207  if ( partition_ == sistrip::invalid_ ) {
208  if ( gran == sistrip::PARTITION ) { return true; }
209  }
210  return false;
211 }
212 
213 // -----------------------------------------------------------------------------
214 //
216 
217  // partition
218  if ( partition_ >= 1 && //sistrip::PARTITION_MIN &&
219  partition_ <= 4 ) { //sistrip::PARTITION_MAX ) {
221  } else if ( partition_ == 0 ) {
222  partition_ = 0;
223  } else { partition_ = sistrip::invalid_; }
224 
225 }
226 
227 // -----------------------------------------------------------------------------
228 //
230 
231  if ( key() == sistrip::invalid32_ ) {
232 
233  // ---------- Set DetKey based on member data ----------
234 
235  // Initialise to null value
236  key(0);
237 
238  // Extract partition
239  if ( partition_ >= 1 && //sistrip::PARTITION_MIN &&
240  partition_ <= 4 ) { //sistrip::PARTITION_MAX ) {
242  } else if ( partition_ == 0 ) {
244  } else {
246  }
247 
248  } else {
249 
250  // ---------- Set member data based on Det key ----------
251 
253 
255 
256  }
257 
258 }
259 
260 // -----------------------------------------------------------------------------
261 //
263 
264  if ( path() == sistrip::null_ ) {
265 
266  // ---------- Set directory path based on member data ----------
267 
268  std::stringstream dir;
269 
270  dir << sistrip::root_ << sistrip::dir_
272 
273  // Add partition
274  if ( partition_ ) {
276  }
277 
278  std::string temp( dir.str() );
279  path( temp );
280 
281  } else {
282 
283  // ---------- Set member data based on directory path ----------
284 
285  partition_ = 0;
286 
287  // Check if root is found
288  if ( path().find( sistrip::root_ ) == std::string::npos ) {
289  std::string temp = path();
291  }
292 
293  size_t curr = 0; // current string position
294  size_t next = 0; // next string position
295  next = path().find( sistrip::detectorView_, curr );
296 
297  // Extract view
298  curr = next;
299  if ( curr != std::string::npos ) {
300  next = path().find( sistrip::partition_, curr );
301  std::string detector_view( path(),
302  curr+(sizeof(sistrip::detectorView_) - 1),
303  next-(sizeof(sistrip::dir_) - 1)-curr );
304  // Extract partition
305  curr = next;
306  if ( curr != std::string::npos ) {
307  next = std::string::npos;
309  curr+(sizeof(sistrip::partition_) - 1),
310  next-(sizeof(sistrip::dir_) - 1)-curr );
311  partition_ = std::atoi( partition.c_str() );
312  }
313  } else {
314  std::stringstream ss;
315  ss << sistrip::root_ << sistrip::dir_;
316  //ss << sistrip::root_ << sistrip::dir_
317  //<< sistrip::unknownView_ << sistrip::dir_;
318  std::string temp( ss.str() );
319  path( temp );
320  }
321 
322  }
323 
324 }
325 
326 // -----------------------------------------------------------------------------
327 //
329 
331  channel(0);
335  } else if ( partition_ == sistrip::invalid_ ) {
338  }
339 
340 }
341 
342 // -----------------------------------------------------------------------------
343 //
344 void SiStripDetKey::terse( std::stringstream& ss ) const {
345  ss << "DET:partition= "
346  << partition();
347 }
348 
349 // -----------------------------------------------------------------------------
350 //
351 void SiStripDetKey::print( std::stringstream& ss ) const {
352  ss << " [SiStripDetKey::print]" << std::endl
353  << std::hex
354  << " 32-bit Det key : 0x"
355  << std::setfill('0')
356  << std::setw(8) << key() << std::endl
357  << std::setfill(' ')
358  << std::dec
359  << " Partition : " << partition() << std::endl
360  << " Directory : " << path() << std::endl
361  << " Granularity : "
363  << " Channel : " << channel() << std::endl
364  << " isValid : " << isValid();
365 }
366 
367 // -----------------------------------------------------------------------------
368 //
369 std::ostream& operator<< ( std::ostream& os, const SiStripDetKey& input ) {
370  std::stringstream ss;
371  input.print(ss);
372  os << ss.str();
373  return os;
374 }
uint16_t apvPairNumber_
static const char dir_[]
static const uint32_t invalid32_
Definition: Constants.h:15
static std::string granularity(const sistrip::Granularity &)
static const uint16_t partitionOffset_
virtual void print(std::stringstream &ss) const
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
static const char detectorView_[]
static std::string const input
Definition: EdmProvDump.cc:44
const uint32_t & key() const
Definition: SiStripKey.h:125
const sistrip::Granularity & granularity() const
Definition: SiStripKey.h:127
static const char partition_[]
tuple path
else: Piece not in the list, fine.
void initFromValue()
const uint16_t & partition() const
const uint16_t & apvWithinPair() const
Base utility class that identifies a position within a logical structure of the strip tracker...
Definition: SiStripKey.h:23
const std::string & path() const
Definition: SiStripKey.h:126
const uint16_t & apvPairNumber() const
bool isInvalid() const
Utility class that identifies a position within the strip tracker geometrical structure, down to the level of an APV25 chip.
Definition: SiStripDetKey.h:28
static const uint16_t partitionMask_
bool isEqual(const SiStripKey &) const
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
Definition: DetId.h:18
bool isConsistent(const SiStripKey &) const
const uint16_t & channel() const
Definition: SiStripKey.h:128
static const uint16_t invalid_
Definition: Constants.h:16
list key
Definition: combine.py:13
static const char root_[]
uint16_t apvWithinPair_
dbl *** dir
Definition: mlp_gen.cc:35
void initGranularity()
bool isValid() const
uint16_t partition_
static const char null_[]
Definition: Constants.h:22
virtual void terse(std::stringstream &ss) const