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 // Last commit: $Id: SiStripDetKey.cc,v 1.12 2012/07/04 19:04:49 eulisse Exp $
2 
6 #include <iomanip>
7 
8 // -----------------------------------------------------------------------------
9 //
10 SiStripDetKey::SiStripDetKey( const uint16_t& partition ) :
11  SiStripKey(),
12  partition_(partition),
13  apvPairNumber_(sistrip::invalid_),
14  apvWithinPair_(sistrip::invalid_)
15 {
16  // order is important!
17  initFromValue();
18  initFromKey();
19  initFromPath();
21 }
22 
23 // -----------------------------------------------------------------------------
24 //
26  const uint16_t& apv_pair_number,
27  const uint16_t& apv_within_pair ) :
28  SiStripKey(),
29  partition_(sistrip::invalid_),
30  apvPairNumber_(apv_pair_number),
31  apvWithinPair_(apv_within_pair)
32 {
33  // order is important!
34  initFromValue();
35  initFromKey();
36  initFromPath();
38 }
39 
40 // -----------------------------------------------------------------------------
41 //
43  SiStripKey(),
44  partition_(sistrip::invalid_),
45  apvPairNumber_(sistrip::invalid_),
46  apvWithinPair_(sistrip::invalid_)
47 {
48  // order is important!
49  initFromValue();
50  initFromKey();
51  initFromPath();
53 }
54 
55 // -----------------------------------------------------------------------------
56 //
57 SiStripDetKey::SiStripDetKey( const uint32_t& det_key ) :
58  SiStripKey(det_key),
59  partition_(sistrip::invalid_),
60  apvPairNumber_(sistrip::invalid_),
61  apvWithinPair_(sistrip::invalid_)
62 {
63  // order is important!
64  initFromKey();
65  initFromValue();
66  initFromPath();
68 }
69 
70 // -----------------------------------------------------------------------------
71 //
73  SiStripKey(path),
74  partition_(sistrip::invalid_),
75  apvPairNumber_(sistrip::invalid_),
76  apvWithinPair_(sistrip::invalid_)
77 {
78  // order is important!
79  initFromPath();
80  initFromValue();
81  initFromKey();
83 }
84 
85 // -----------------------------------------------------------------------------
86 //
88  SiStripKey(),
89  partition_(input.partition()),
90  apvPairNumber_(input.apvPairNumber()),
91  apvWithinPair_(input.apvWithinPair())
92 {
93  key(input.key());
94  path(input.path());
95  granularity(input.granularity());
96 }
97 
98 // -----------------------------------------------------------------------------
99 //
101  SiStripKey(),
102  partition_(sistrip::invalid_),
103  apvPairNumber_(sistrip::invalid_),
104  apvWithinPair_(sistrip::invalid_)
105 {
106  const SiStripDetKey& det_key = dynamic_cast<const SiStripDetKey&>(input);
107  if ( (&det_key) ) {
108  key(det_key.key());
109  path(det_key.path());
110  granularity(det_key.granularity());
111  partition_ = det_key.partition();
112  apvPairNumber_ = det_key.apvPairNumber();
113  apvWithinPair_ = det_key.apvWithinPair();
114  }
115 }
116 
117 // -----------------------------------------------------------------------------
118 //
120  const sistrip::Granularity& gran ) :
121  SiStripKey(),
122  partition_(0),
123  apvPairNumber_(0),
124  apvWithinPair_(0)
125 {
126  const SiStripDetKey& det_key = dynamic_cast<const SiStripDetKey&>(input);
127  if ( (&det_key) ) {
128 
129  if ( gran == sistrip::PARTITION ) {
130  partition_ = det_key.partition();
131  }
132 
133  initFromValue();
134  initFromKey();
135  initFromPath();
136  initGranularity();
137 
138  }
139 
140 }
141 
142 // -----------------------------------------------------------------------------
143 //
145  SiStripKey(),
146  partition_(sistrip::invalid_),
147  apvPairNumber_(sistrip::invalid_),
148  apvWithinPair_(sistrip::invalid_)
149 {;}
150 
151 // -----------------------------------------------------------------------------
152 //
153 bool SiStripDetKey::isEqual( const SiStripKey& key ) const {
154  const SiStripDetKey& input = dynamic_cast<const SiStripDetKey&>(key);
155  if ( !(&input) ) { return false; }
156  if ( partition_ == input.partition() &&
157  apvPairNumber_ == input.apvPairNumber() &&
158  apvWithinPair_ == input.apvWithinPair() ) {
159  return true;
160  } else { return false; }
161 }
162 
163 // -----------------------------------------------------------------------------
164 //
166  const SiStripDetKey& input = dynamic_cast<const SiStripDetKey&>(key);
167  if ( !(&input) ) { return false; }
168  if ( isEqual(input) ) { return false; }
169  else if ( ( partition_ == 0 || input.partition() == 0 ) &&
170  ( apvPairNumber_ == 0 || input.apvPairNumber() == 0 ) &&
171  ( apvWithinPair_ == 0 || input.apvWithinPair() == 0 ) ) {
172  return true;
173  } else { return false; }
174 }
175 
176 // -----------------------------------------------------------------------------
177 //
178 bool SiStripDetKey::isValid() const {
179  return isValid(sistrip::APV);
180 }
181 
182 // -----------------------------------------------------------------------------
183 //
184 bool SiStripDetKey::isValid( const sistrip::Granularity& gran ) const {
185  if ( gran == sistrip::TRACKER ) { return true; }
186  else if ( gran == sistrip::UNDEFINED_GRAN ||
187  gran == sistrip::UNKNOWN_GRAN ) { return false; }
188 
189  if ( partition_ != sistrip::invalid_ ) {
190  if ( gran == sistrip::PARTITION ) { return true; }
191  }
192  return false;
193 }
194 
195 // -----------------------------------------------------------------------------
196 //
198  return isInvalid(sistrip::APV);
199 }
200 
201 // -----------------------------------------------------------------------------
202 //
204  if ( gran == sistrip::TRACKER ) { return false; }
205  else if ( gran == sistrip::UNDEFINED_GRAN ||
206  gran == sistrip::UNKNOWN_GRAN ) { return false; }
207 
208  if ( partition_ == sistrip::invalid_ ) {
209  if ( gran == sistrip::PARTITION ) { return true; }
210  }
211  return false;
212 }
213 
214 // -----------------------------------------------------------------------------
215 //
217 
218  // partition
219  if ( partition_ >= 1 && //sistrip::PARTITION_MIN &&
220  partition_ <= 4 ) { //sistrip::PARTITION_MAX ) {
222  } else if ( partition_ == 0 ) {
223  partition_ = 0;
224  } else { partition_ = sistrip::invalid_; }
225 
226 }
227 
228 // -----------------------------------------------------------------------------
229 //
231 
232  if ( key() == sistrip::invalid32_ ) {
233 
234  // ---------- Set DetKey based on member data ----------
235 
236  // Initialise to null value
237  key(0);
238 
239  // Extract partition
240  if ( partition_ >= 1 && //sistrip::PARTITION_MIN &&
241  partition_ <= 4 ) { //sistrip::PARTITION_MAX ) {
243  } else if ( partition_ == 0 ) {
245  } else {
247  }
248 
249  } else {
250 
251  // ---------- Set member data based on Det key ----------
252 
254 
256 
257  }
258 
259 }
260 
261 // -----------------------------------------------------------------------------
262 //
264 
265  if ( path() == sistrip::null_ ) {
266 
267  // ---------- Set directory path based on member data ----------
268 
269  std::stringstream dir;
270 
271  dir << sistrip::root_ << sistrip::dir_
273 
274  // Add partition
275  if ( partition_ ) {
277  }
278 
279  std::string temp( dir.str() );
280  path( temp );
281 
282  } else {
283 
284  // ---------- Set member data based on directory path ----------
285 
286  partition_ = 0;
287 
288  // Check if root is found
289  if ( path().find( sistrip::root_ ) == std::string::npos ) {
290  std::string temp = path();
292  }
293 
294  size_t curr = 0; // current string position
295  size_t next = 0; // next string position
296  next = path().find( sistrip::detectorView_, curr );
297 
298  // Extract view
299  curr = next;
300  if ( curr != std::string::npos ) {
301  next = path().find( sistrip::partition_, curr );
302  std::string detector_view( path(),
303  curr+(sizeof(sistrip::detectorView_) - 1),
304  next-(sizeof(sistrip::dir_) - 1)-curr );
305  // Extract partition
306  curr = next;
307  if ( curr != std::string::npos ) {
308  next = std::string::npos;
310  curr+(sizeof(sistrip::partition_) - 1),
311  next-(sizeof(sistrip::dir_) - 1)-curr );
312  partition_ = std::atoi( partition.c_str() );
313  }
314  } else {
315  std::stringstream ss;
316  ss << sistrip::root_ << sistrip::dir_;
317  //ss << sistrip::root_ << sistrip::dir_
318  //<< sistrip::unknownView_ << sistrip::dir_;
319  std::string temp( ss.str() );
320  path( temp );
321  }
322 
323  }
324 
325 }
326 
327 // -----------------------------------------------------------------------------
328 //
330 
332  channel(0);
336  } else if ( partition_ == sistrip::invalid_ ) {
339  }
340 
341 }
342 
343 // -----------------------------------------------------------------------------
344 //
345 void SiStripDetKey::terse( std::stringstream& ss ) const {
346  ss << "DET:partition= "
347  << partition();
348 }
349 
350 // -----------------------------------------------------------------------------
351 //
352 void SiStripDetKey::print( std::stringstream& ss ) const {
353  ss << " [SiStripDetKey::print]" << std::endl
354  << std::hex
355  << " 32-bit Det key : 0x"
356  << std::setfill('0')
357  << std::setw(8) << key() << std::endl
358  << std::setfill(' ')
359  << std::dec
360  << " Partition : " << partition() << std::endl
361  << " Directory : " << path() << std::endl
362  << " Granularity : "
364  << " Channel : " << channel() << std::endl
365  << " isValid : " << isValid();
366 }
367 
368 // -----------------------------------------------------------------------------
369 //
370 std::ostream& operator<< ( std::ostream& os, const SiStripDetKey& input ) {
371  std::stringstream ss;
372  input.print(ss);
373  os << ss.str();
374  return os;
375 }
uint16_t apvPairNumber_
static const char dir_[]
static const uint32_t invalid32_
Definition: Constants.h:16
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_[]
const uint32_t & key() const
Definition: SiStripKey.h:126
const sistrip::Granularity & granularity() const
Definition: SiStripKey.h:128
static const char partition_[]
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:24
const std::string & path() const
Definition: SiStripKey.h:127
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:29
static const uint16_t partitionMask_
bool isEqual(const SiStripKey &) const
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
Definition: DetId.h:20
bool isConsistent(const SiStripKey &) const
const uint16_t & channel() const
Definition: SiStripKey.h:129
static const uint16_t invalid_
Definition: Constants.h:17
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:23
virtual void terse(std::stringstream &ss) const