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.11 2009/12/10 08:44:16 elmer 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 //
72 SiStripDetKey::SiStripDetKey( const std::string& path ) :
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  SiStripKey& temp = const_cast<SiStripKey&>(input);
107  SiStripDetKey& det_key = dynamic_cast<SiStripDetKey&>(temp);
108  if ( (&det_key) ) {
109  key(det_key.key());
110  path(det_key.path());
111  granularity(det_key.granularity());
112  partition_ = det_key.partition();
113  apvPairNumber_ = det_key.apvPairNumber();
114  apvWithinPair_ = det_key.apvWithinPair();
115  }
116 }
117 
118 // -----------------------------------------------------------------------------
119 //
121  const sistrip::Granularity& gran ) :
122  SiStripKey(),
123  partition_(0),
124  apvPairNumber_(0),
125  apvWithinPair_(0)
126 {
127  SiStripKey& temp = const_cast<SiStripKey&>(input);
128  SiStripDetKey& det_key = dynamic_cast<SiStripDetKey&>(temp);
129  if ( (&det_key) ) {
130 
131  if ( gran == sistrip::PARTITION ) {
132  partition_ = det_key.partition();
133  }
134 
135  initFromValue();
136  initFromKey();
137  initFromPath();
138  initGranularity();
139 
140  }
141 
142 }
143 
144 // -----------------------------------------------------------------------------
145 //
147  SiStripKey(),
148  partition_(sistrip::invalid_),
149  apvPairNumber_(sistrip::invalid_),
150  apvWithinPair_(sistrip::invalid_)
151 {;}
152 
153 // -----------------------------------------------------------------------------
154 //
155 bool SiStripDetKey::isEqual( const SiStripKey& key ) const {
156  SiStripKey& temp = const_cast<SiStripKey&>(key);
157  SiStripDetKey& input = dynamic_cast<SiStripDetKey&>(temp);
158  if ( !(&input) ) { return false; }
159  if ( partition_ == input.partition() &&
160  apvPairNumber_ == input.apvPairNumber() &&
161  apvWithinPair_ == input.apvWithinPair() ) {
162  return true;
163  } else { return false; }
164 }
165 
166 // -----------------------------------------------------------------------------
167 //
169  SiStripKey& temp = const_cast<SiStripKey&>(key);
170  SiStripDetKey& input = dynamic_cast<SiStripDetKey&>(temp);
171  if ( !(&input) ) { return false; }
172  if ( isEqual(input) ) { return false; }
173  else if ( ( partition_ == 0 || input.partition() == 0 ) &&
174  ( apvPairNumber_ == 0 || input.apvPairNumber() == 0 ) &&
175  ( apvWithinPair_ == 0 || input.apvWithinPair() == 0 ) ) {
176  return true;
177  } else { return false; }
178 }
179 
180 // -----------------------------------------------------------------------------
181 //
182 bool SiStripDetKey::isValid() const {
183  return isValid(sistrip::APV);
184 }
185 
186 // -----------------------------------------------------------------------------
187 //
188 bool SiStripDetKey::isValid( const sistrip::Granularity& gran ) const {
189  if ( gran == sistrip::TRACKER ) { return true; }
190  else if ( gran == sistrip::UNDEFINED_GRAN ||
191  gran == sistrip::UNKNOWN_GRAN ) { return false; }
192 
193  if ( partition_ != sistrip::invalid_ ) {
194  if ( gran == sistrip::PARTITION ) { return true; }
195  }
196  return false;
197 }
198 
199 // -----------------------------------------------------------------------------
200 //
202  return isInvalid(sistrip::APV);
203 }
204 
205 // -----------------------------------------------------------------------------
206 //
208  if ( gran == sistrip::TRACKER ) { return false; }
209  else if ( gran == sistrip::UNDEFINED_GRAN ||
210  gran == sistrip::UNKNOWN_GRAN ) { return false; }
211 
212  if ( partition_ == sistrip::invalid_ ) {
213  if ( gran == sistrip::PARTITION ) { return true; }
214  }
215  return false;
216 }
217 
218 // -----------------------------------------------------------------------------
219 //
221 
222  // partition
223  if ( partition_ >= 1 && //sistrip::PARTITION_MIN &&
224  partition_ <= 4 ) { //sistrip::PARTITION_MAX ) {
226  } else if ( partition_ == 0 ) {
227  partition_ = 0;
228  } else { partition_ = sistrip::invalid_; }
229 
230 }
231 
232 // -----------------------------------------------------------------------------
233 //
235 
236  if ( key() == sistrip::invalid32_ ) {
237 
238  // ---------- Set DetKey based on member data ----------
239 
240  // Initialise to null value
241  key(0);
242 
243  // Extract partition
244  if ( partition_ >= 1 && //sistrip::PARTITION_MIN &&
245  partition_ <= 4 ) { //sistrip::PARTITION_MAX ) {
247  } else if ( partition_ == 0 ) {
249  } else {
251  }
252 
253  } else {
254 
255  // ---------- Set member data based on Det key ----------
256 
258 
260 
261  }
262 
263 }
264 
265 // -----------------------------------------------------------------------------
266 //
268 
269  if ( path() == sistrip::null_ ) {
270 
271  // ---------- Set directory path based on member data ----------
272 
273  std::stringstream dir;
274 
275  dir << sistrip::root_ << sistrip::dir_
277 
278  // Add partition
279  if ( partition_ ) {
281  }
282 
283  std::string temp( dir.str() );
284  path( temp );
285 
286  } else {
287 
288  // ---------- Set member data based on directory path ----------
289 
290  partition_ = 0;
291 
292  // Check if root is found
293  if ( path().find( sistrip::root_ ) == std::string::npos ) {
294  std::string temp = path();
295  path( std::string(sistrip::root_) + sistrip::dir_ + temp );
296  }
297 
298  size_t curr = 0; // current string position
299  size_t next = 0; // next string position
300  next = path().find( sistrip::detectorView_, curr );
301 
302  // Extract view
303  curr = next;
304  if ( curr != std::string::npos ) {
305  next = path().find( sistrip::partition_, curr );
306  std::string detector_view( path(),
307  curr+(sizeof(sistrip::detectorView_) - 1),
308  next-(sizeof(sistrip::dir_) - 1)-curr );
309  // Extract partition
310  curr = next;
311  if ( curr != std::string::npos ) {
312  next = std::string::npos;
313  std::string partition( path(),
314  curr+(sizeof(sistrip::partition_) - 1),
315  next-(sizeof(sistrip::dir_) - 1)-curr );
316  partition_ = std::atoi( partition.c_str() );
317  }
318  } else {
319  std::stringstream ss;
320  ss << sistrip::root_ << sistrip::dir_;
321  //ss << sistrip::root_ << sistrip::dir_
322  //<< sistrip::unknownView_ << sistrip::dir_;
323  std::string temp( ss.str() );
324  path( temp );
325  }
326 
327  }
328 
329 }
330 
331 // -----------------------------------------------------------------------------
332 //
334 
336  channel(0);
340  } else if ( partition_ == sistrip::invalid_ ) {
343  }
344 
345 }
346 
347 // -----------------------------------------------------------------------------
348 //
349 void SiStripDetKey::terse( std::stringstream& ss ) const {
350  ss << "DET:partition= "
351  << partition();
352 }
353 
354 // -----------------------------------------------------------------------------
355 //
356 void SiStripDetKey::print( std::stringstream& ss ) const {
357  ss << " [SiStripDetKey::print]" << std::endl
358  << std::hex
359  << " 32-bit Det key : 0x"
360  << std::setfill('0')
361  << std::setw(8) << key() << std::endl
362  << std::setfill(' ')
363  << std::dec
364  << " Partition : " << partition() << std::endl
365  << " Directory : " << path() << std::endl
366  << " Granularity : "
368  << " Channel : " << channel() << std::endl
369  << " isValid : " << isValid();
370 }
371 
372 // -----------------------------------------------------------------------------
373 //
374 std::ostream& operator<< ( std::ostream& os, const SiStripDetKey& input ) {
375  std::stringstream ss;
376  input.print(ss);
377  os << ss.str();
378  return os;
379 }
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
list path
Definition: scaleCards.py:51
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