CMS 3D CMS Logo

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(),
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(),
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),
61 {
62  // order is important!
63  initFromKey();
64  initFromValue();
65  initFromPath();
67 }
68 
69 // -----------------------------------------------------------------------------
70 //
72  SiStripKey(path),
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()),
91 {
92  key(input.key());
93  path(input.path());
94  granularity(input.granularity());
95 }
96 
97 // -----------------------------------------------------------------------------
98 //
100  SiStripKey(),
104 {
105  const SiStripDetKey& det_key = dynamic_cast<const SiStripDetKey&>(input);
106  key(det_key.key());
107  path(det_key.path());
108  granularity(det_key.granularity());
109  partition_ = det_key.partition();
110  apvPairNumber_ = det_key.apvPairNumber();
111  apvWithinPair_ = det_key.apvWithinPair();
112 }
113 
114 // -----------------------------------------------------------------------------
115 //
117  const sistrip::Granularity& gran ) :
118  SiStripKey(),
119  partition_(0),
120  apvPairNumber_(0),
121  apvWithinPair_(0)
122 {
123  const SiStripDetKey& det_key = dynamic_cast<const SiStripDetKey&>(input);
124  if ( gran == sistrip::PARTITION ) {
125  partition_ = det_key.partition();
126  }
127 
128  initFromValue();
129  initFromKey();
130  initFromPath();
131  initGranularity();
132 }
133 
134 // -----------------------------------------------------------------------------
135 //
137  SiStripKey(),
141 {;}
142 
143 // -----------------------------------------------------------------------------
144 //
145 bool SiStripDetKey::isEqual( const SiStripKey& key ) const {
146  const SiStripDetKey& input = dynamic_cast<const SiStripDetKey&>(key);
147  if ( partition_ == input.partition() &&
148  apvPairNumber_ == input.apvPairNumber() &&
149  apvWithinPair_ == input.apvWithinPair() ) {
150  return true;
151  } else { return false; }
152 }
153 
154 // -----------------------------------------------------------------------------
155 //
157  const SiStripDetKey& input = dynamic_cast<const SiStripDetKey&>(key);
158  if ( isEqual(input) ) { return false; }
159  else if ( ( partition_ == 0 || input.partition() == 0 ) &&
160  ( apvPairNumber_ == 0 || input.apvPairNumber() == 0 ) &&
161  ( apvWithinPair_ == 0 || input.apvWithinPair() == 0 ) ) {
162  return true;
163  } else { return false; }
164 }
165 
166 // -----------------------------------------------------------------------------
167 //
168 bool SiStripDetKey::isValid() const {
169  return isValid(sistrip::APV);
170 }
171 
172 // -----------------------------------------------------------------------------
173 //
174 bool SiStripDetKey::isValid( const sistrip::Granularity& gran ) const {
175  if ( gran == sistrip::TRACKER ) { return true; }
176  else if ( gran == sistrip::UNDEFINED_GRAN ||
177  gran == sistrip::UNKNOWN_GRAN ) { return false; }
178 
179  if ( partition_ != sistrip::invalid_ ) {
180  if ( gran == sistrip::PARTITION ) { return true; }
181  }
182  return false;
183 }
184 
185 // -----------------------------------------------------------------------------
186 //
188  return isInvalid(sistrip::APV);
189 }
190 
191 // -----------------------------------------------------------------------------
192 //
194  if ( gran == sistrip::TRACKER ) { return false; }
195  else if ( gran == sistrip::UNDEFINED_GRAN ||
196  gran == sistrip::UNKNOWN_GRAN ) { return false; }
197 
198  if ( partition_ == sistrip::invalid_ ) {
199  if ( gran == sistrip::PARTITION ) { return true; }
200  }
201  return false;
202 }
203 
204 // -----------------------------------------------------------------------------
205 //
207 
208  // partition
209  if ( partition_ >= 1 && //sistrip::PARTITION_MIN &&
210  partition_ <= 4 ) { //sistrip::PARTITION_MAX ) {
212  } else if ( partition_ == 0 ) {
213  partition_ = 0;
214  } else { partition_ = sistrip::invalid_; }
215 
216 }
217 
218 // -----------------------------------------------------------------------------
219 //
221 
222  if ( key() == sistrip::invalid32_ ) {
223 
224  // ---------- Set DetKey based on member data ----------
225 
226  // Initialise to null value
227  key(0);
228 
229  // Extract partition
230  if ( partition_ >= 1 && //sistrip::PARTITION_MIN &&
231  partition_ <= 4 ) { //sistrip::PARTITION_MAX ) {
233  } else if ( partition_ == 0 ) {
235  } else {
237  }
238 
239  } else {
240 
241  // ---------- Set member data based on Det key ----------
242 
244 
246 
247  }
248 
249 }
250 
251 // -----------------------------------------------------------------------------
252 //
254 
255  if ( path() == sistrip::null_ ) {
256 
257  // ---------- Set directory path based on member data ----------
258 
259  std::stringstream dir;
260 
261  dir << sistrip::root_ << sistrip::dir_
263 
264  // Add partition
265  if ( partition_ ) {
267  }
268 
269  std::string temp( dir.str() );
270  path( temp );
271 
272  } else {
273 
274  // ---------- Set member data based on directory path ----------
275 
276  partition_ = 0;
277 
278  // Check if root is found
279  if ( path().find( sistrip::root_ ) == std::string::npos ) {
280  std::string temp = path();
282  }
283 
284  size_t curr = 0; // current string position
285  size_t next = 0; // next string position
286  next = path().find( sistrip::detectorView_, curr );
287 
288  // Extract view
289  curr = next;
290  if ( curr != std::string::npos ) {
291  next = path().find( sistrip::partition_, curr );
292  std::string detector_view( path(),
293  curr+(sizeof(sistrip::detectorView_) - 1),
294  next-(sizeof(sistrip::dir_) - 1)-curr );
295  // Extract partition
296  curr = next;
297  if ( curr != std::string::npos ) {
298  next = std::string::npos;
300  curr+(sizeof(sistrip::partition_) - 1),
301  next-(sizeof(sistrip::dir_) - 1)-curr );
302  partition_ = std::atoi( partition.c_str() );
303  }
304  } else {
305  std::stringstream ss;
306  ss << sistrip::root_ << sistrip::dir_;
307  //ss << sistrip::root_ << sistrip::dir_
308  //<< sistrip::unknownView_ << sistrip::dir_;
309  std::string temp( ss.str() );
310  path( temp );
311  }
312 
313  }
314 
315 }
316 
317 // -----------------------------------------------------------------------------
318 //
320 
322  channel(0);
326  } else if ( partition_ == sistrip::invalid_ ) {
329  }
330 
331 }
332 
333 // -----------------------------------------------------------------------------
334 //
335 void SiStripDetKey::terse( std::stringstream& ss ) const {
336  ss << "DET:partition= "
337  << partition();
338 }
339 
340 // -----------------------------------------------------------------------------
341 //
342 void SiStripDetKey::print( std::stringstream& ss ) const {
343  ss << " [SiStripDetKey::print]" << std::endl
344  << std::hex
345  << " 32-bit Det key : 0x"
346  << std::setfill('0')
347  << std::setw(8) << key() << std::endl
348  << std::setfill(' ')
349  << std::dec
350  << " Partition : " << partition() << std::endl
351  << " Directory : " << path() << std::endl
352  << " Granularity : "
354  << " Channel : " << channel() << std::endl
355  << " isValid : " << isValid();
356 }
357 
358 // -----------------------------------------------------------------------------
359 //
360 std::ostream& operator<< ( std::ostream& os, const SiStripDetKey& input ) {
361  std::stringstream ss;
362  input.print(ss);
363  os << ss.str();
364  return os;
365 }
std::ostream & operator<<(std::ostream &os, const SiStripDetKey &input)
uint16_t apvPairNumber_
static const char dir_[]
bool isEqual(const SiStripKey &) const override
void initFromPath() override
static const uint32_t invalid32_
Definition: Constants.h:15
bool isValid() const override
static std::string granularity(const sistrip::Granularity &)
void initGranularity() override
static const uint16_t partitionOffset_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
static const char detectorView_[]
sistrip classes
static std::string const input
Definition: EdmProvDump.cc:44
void print(std::stringstream &ss) const override
const uint32_t & key() const
Definition: SiStripKey.h:125
const sistrip::Granularity & granularity() const
Definition: SiStripKey.h:127
static const char partition_[]
const uint16_t & partition() const
void initFromKey() override
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 override
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_
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
Definition: DetId.h:18
void initFromValue() override
const uint16_t & channel() const
Definition: SiStripKey.h:128
static const uint16_t invalid_
Definition: Constants.h:16
static const char root_[]
uint16_t apvWithinPair_
bool isConsistent(const SiStripKey &) const override
dbl *** dir
Definition: mlp_gen.cc:35
uint16_t partition_
void terse(std::stringstream &ss) const override
static const char null_[]
Definition: Constants.h:22