CMS 3D CMS Logo

SiStripFedKey.cc
Go to the documentation of this file.
1 
8 #include <iomanip>
9 
10 // -----------------------------------------------------------------------------
11 //
12 SiStripFedKey::SiStripFedKey(const uint16_t& fed_id,
13  const uint16_t& fe_unit,
14  const uint16_t& fe_chan,
15  const uint16_t& fed_apv)
16  : SiStripKey(), fedId_(fed_id), feUnit_(fe_unit), feChan_(fe_chan), fedApv_(fed_apv) {
17  // order is important!
18  initFromValue();
19  initFromKey();
20  initFromPath();
22 }
23 
24 // -----------------------------------------------------------------------------
25 //
26 SiStripFedKey::SiStripFedKey(const uint32_t& fed_key)
27  : SiStripKey(fed_key),
28  fedId_(sistrip::invalid_),
32  // order is important!
33  initFromKey();
34  initFromValue();
35  initFromPath();
37 }
38 
39 // -----------------------------------------------------------------------------
40 //
42  : SiStripKey(path),
43  fedId_(sistrip::invalid_),
47  // order is important!
48  initFromPath();
49  initFromValue();
50  initFromKey();
52 }
53 
54 // -----------------------------------------------------------------------------
55 //
57  : SiStripKey(), fedId_(input.fedId()), feUnit_(input.feUnit()), feChan_(input.feChan()), fedApv_(input.fedApv()) {
58  key(input.key());
59  path(input.path());
60  granularity(input.granularity());
61 }
62 
63 // -----------------------------------------------------------------------------
64 //
66  : SiStripKey(),
67  fedId_(sistrip::invalid_),
71  const SiStripFedKey& fed_key = dynamic_cast<const SiStripFedKey&>(input);
72  key(fed_key.key());
73  path(fed_key.path());
74  granularity(fed_key.granularity());
75  fedId_ = fed_key.fedId();
76  feUnit_ = fed_key.feUnit();
77  feChan_ = fed_key.feChan();
78  fedApv_ = fed_key.fedApv();
79 }
80 
81 // -----------------------------------------------------------------------------
82 //
84  : SiStripKey(),
85  fedId_(sistrip::invalid_),
89  ;
90 }
91 
92 // -----------------------------------------------------------------------------
93 //
94 uint16_t SiStripFedKey::fedCh(const uint16_t& fe_unit, const uint16_t& fe_chan) {
95  if (fe_unit <= sistrip::FEUNITS_PER_FED && fe_chan <= sistrip::FEDCH_PER_FEUNIT) {
96  if (fe_unit != 0 && fe_chan != 0) {
97  return (95 - (12 * (fe_unit - 1) + (fe_chan - 1)));
98  }
99  }
100  return sistrip::invalid_;
101 }
102 
103 // -----------------------------------------------------------------------------
104 //
105 uint16_t SiStripFedKey::feUnit(const uint16_t& fed_ch) {
106  if (fed_ch < sistrip::FEDCH_PER_FED) {
107  return ((95 - fed_ch) / 12 + 1);
108  }
109  return sistrip::invalid_;
110 }
111 
112 // -----------------------------------------------------------------------------
113 //
114 uint16_t SiStripFedKey::feChan(const uint16_t& fed_ch) {
115  if (fed_ch < sistrip::FEDCH_PER_FED) {
116  return ((95 - fed_ch) % 12 + 1);
117  }
118  return sistrip::invalid_;
119 }
120 
121 // -----------------------------------------------------------------------------
122 //
123 uint32_t SiStripFedKey::fedIndex(const uint16_t& fed_id, const uint16_t& fed_ch) {
124  if (fed_id < sistrip::FED_ID_MIN || fed_id > sistrip::FED_ID_MAX || fed_ch >= sistrip::FEDCH_PER_FED) {
125  return sistrip::invalid32_;
126  }
127  return (fed_id * sistrip::FEDCH_PER_FED + fed_ch);
128 }
129 
130 // -----------------------------------------------------------------------------
131 //
133  const SiStripFedKey& input = dynamic_cast<const SiStripFedKey&>(key);
134  if (fedId_ == input.fedId() && feUnit_ == input.feUnit() && feChan_ == input.feChan() && fedApv_ == input.fedApv()) {
135  return true;
136  } else {
137  return false;
138  }
139 }
140 
141 // -----------------------------------------------------------------------------
142 //
144  const SiStripFedKey& input = dynamic_cast<const SiStripFedKey&>(key);
145  if (isEqual(input)) {
146  return true;
147  } else if ((fedId_ == 0 || input.fedId() == 0) && (feUnit_ == 0 || input.feUnit() == 0) &&
148  (feChan_ == 0 || input.feChan() == 0) && (fedApv_ == 0 || input.fedApv() == 0)) {
149  return true;
150  } else {
151  return false;
152  }
153 }
154 
155 // -----------------------------------------------------------------------------
156 //
158 
159 // -----------------------------------------------------------------------------
160 //
162  if (gran == sistrip::FED_SYSTEM) {
163  return true;
164  } else if (gran == sistrip::UNDEFINED_GRAN || gran == sistrip::UNKNOWN_GRAN) {
165  return false;
166  }
167 
168  if (fedId_ != sistrip::invalid_) {
169  if (gran == sistrip::FE_DRIVER) {
170  return true;
171  }
172  if (feUnit_ != sistrip::invalid_) {
173  if (gran == sistrip::FE_UNIT) {
174  return true;
175  }
176  if (feChan_ != sistrip::invalid_) {
177  if (gran == sistrip::FE_CHAN) {
178  return true;
179  }
180  if (fedApv_ != sistrip::invalid_) {
181  if (gran == sistrip::FED_APV) {
182  return true;
183  }
184  }
185  }
186  }
187  }
188  return false;
189 }
190 
191 // -----------------------------------------------------------------------------
192 //
194 
195 // -----------------------------------------------------------------------------
196 //
198  if (gran == sistrip::FED_SYSTEM) {
199  return false;
200  } else if (gran == sistrip::UNDEFINED_GRAN || gran == sistrip::UNKNOWN_GRAN) {
201  return false;
202  }
203 
204  if (fedId_ == sistrip::invalid_) {
205  if (gran == sistrip::FE_DRIVER) {
206  return true;
207  }
208  if (feUnit_ == sistrip::invalid_) {
209  if (gran == sistrip::FE_UNIT) {
210  return true;
211  }
212  if (feChan_ == sistrip::invalid_) {
213  if (gran == sistrip::FE_CHAN) {
214  return true;
215  }
216  if (fedApv_ == sistrip::invalid_) {
217  if (gran == sistrip::FED_APV) {
218  return true;
219  }
220  }
221  }
222  }
223  }
224  return false;
225 }
226 
227 // -----------------------------------------------------------------------------
228 //
230  if (not((fedId_ >= sistrip::FED_ID_MIN && fedId_ <= sistrip::FED_ID_MAX) || (fedId_ == 0))) {
232  }
233 
236  }
237 
240  }
241 
244  }
245 }
246 
247 // -----------------------------------------------------------------------------
248 //
250  if (key() == sistrip::invalid32_) {
251  // ---------- Set FedKey based on member data ----------
252 
253  // Initialise to null value
254  key(0);
255 
256  // Extract FED id
258  key(key() | (fedId_ << fedIdOffset_));
259  } else if (fedId_ == 0) {
260  key(key() | (fedId_ << fedIdOffset_));
261  } else {
262  key(key() | (fedIdMask_ << fedIdOffset_));
263  }
264 
265  // Extract FE unit
266  if (feUnit_ >= 1 && feUnit_ <= sistrip::FEUNITS_PER_FED) {
267  key(key() | (feUnit_ << feUnitOffset_));
268  } else if (feUnit_ == 0) {
269  key(key() | (feUnit_ << feUnitOffset_));
270  } else {
271  key(key() | (feUnitMask_ << feUnitOffset_));
272  }
273 
274  // Extract FE chan
275  if (feChan_ >= 1 && feChan_ <= sistrip::FEDCH_PER_FEUNIT) {
276  key(key() | (feChan_ << feChanOffset_));
277  } else if (feChan_ == 0) {
278  key(key() | (feChan_ << feChanOffset_));
279  } else {
280  key(key() | (feChanMask_ << feChanOffset_));
281  }
282 
283  // Extract FED APV
284  if (fedApv_ >= 1 && fedApv_ <= sistrip::APVS_PER_FEDCH) {
285  key(key() | (fedApv_ << fedApvOffset_));
286  } else if (fedApv_ == 0) {
287  key(key() | (fedApv_ << fedApvOffset_));
288  } else {
289  key(key() | (fedApvMask_ << fedApvOffset_));
290  }
291 
292  // Set invalid key if necessary
296  }
297 
298  } else {
299  // ---------- Set member data based on FED key ----------
300 
301  fedId_ = (key() >> fedIdOffset_) & fedIdMask_;
305 
306  if (fedId_ == fedIdMask_) {
308  }
309  if (feUnit_ == feUnitMask_) {
311  }
312  if (feChan_ == feChanMask_) {
314  }
315  if (fedApv_ == fedApvMask_) {
317  }
318  }
319 }
320 
321 // -----------------------------------------------------------------------------
322 //
324  if (path() == sistrip::null_) {
325  // ---------- Set directory path based on member data ----------
326 
327  std::stringstream dir;
328 
330 
331  // Add FED id
332  if (fedId_) {
334 
335  // Add FE unit
336  if (feUnit_) {
338 
339  // Add FE channel
340  if (feChan_) {
342 
343  // Add FED APV
344  if (fedApv_) {
346  }
347  }
348  }
349  }
350 
351  std::string temp(dir.str());
352  path(temp);
353 
354  } else {
355  // ---------- Set member data based on directory path ----------
356 
357  fedId_ = 0;
358  feUnit_ = 0;
359  feChan_ = 0;
360  fedApv_ = 0;
361 
362  // Check if root is found
363  if (path().find(sistrip::root_) == std::string::npos) {
364  std::string temp = path();
366  }
367 
368  size_t curr = 0; // current string position
369  size_t next = 0; // next string position
370  next = path().find(sistrip::readoutView_, curr);
371 
372  // Extract view
373  curr = next;
374  if (curr != std::string::npos) {
375  next = path().find(sistrip::feDriver_, curr);
376  std::string readout_view(
377  path(), curr + (sizeof(sistrip::readoutView_) - 1), (next - (sizeof(sistrip::dir_) - 1)) - curr);
378 
379  // Extract FED id
380  curr = next;
381  if (curr != std::string::npos) {
382  next = path().find(sistrip::feUnit_, curr);
383  std::string fed_id(
384  path(), curr + (sizeof(sistrip::feDriver_) - 1), (next - (sizeof(sistrip::dir_) - 1)) - curr);
385  fedId_ = atoi(fed_id.c_str());
386 
387  // Extract FE unit
388  curr = next;
389  if (curr != std::string::npos) {
390  next = path().find(sistrip::feChan_, curr);
391  std::string fe_unit(path(), curr + (sizeof(sistrip::feUnit_) - 1), next - curr);
392  feUnit_ = atoi(fe_unit.c_str());
393 
394  // Extract FE channel
395  curr = next;
396  if (curr != std::string::npos) {
397  next = path().find(sistrip::fedApv_, curr);
398  std::string fe_chan(path(), curr + (sizeof(sistrip::feChan_) - 1), next - curr);
399  feChan_ = atoi(fe_chan.c_str());
400 
401  // Extract FED APV
402  curr = next;
403  if (curr != std::string::npos) {
404  next = std::string::npos;
405  std::string fed_apv(path(), curr + (sizeof(sistrip::fedApv_) - 1), next - curr);
406  fedApv_ = atoi(fed_apv.c_str());
407  }
408  }
409  }
410  }
411  } else {
412  std::stringstream ss;
414  //ss << sistrip::root_ << sistrip::dir_
415  //<< sistrip::unknownView_ << sistrip::dir_;
416  std::string temp(ss.str());
417  path(temp);
418  }
419  }
420 }
421 
422 // -----------------------------------------------------------------------------
423 //
426  channel(0);
427  if (fedId_ && fedId_ != sistrip::invalid_) {
429  channel(fedId_);
430  if (feUnit_ && feUnit_ != sistrip::invalid_) {
432  channel(feUnit_);
433  if (feChan_ && feChan_ != sistrip::invalid_) {
435  channel(feChan_);
436  if (fedApv_ && fedApv_ != sistrip::invalid_) {
438  channel(fedApv_);
439  } else if (fedApv_ == sistrip::invalid_) {
442  }
443  } else if (feChan_ == sistrip::invalid_) {
446  }
447  } else if (feUnit_ == sistrip::invalid_) {
450  }
451  } else if (fedId_ == sistrip::invalid_) {
454  }
455 }
456 
457 // -----------------------------------------------------------------------------
458 //
459 void SiStripFedKey::terse(std::stringstream& ss) const {
460  ss << "FED:crate/slot/id/unit/chan/apv= "
461  << "-"
462  << "/"
463  << "-"
464  << "/" << fedId() << "/" << feUnit() << "/" << feChan() << "/" << fedApv();
465  // ss << " FedKey"
466  // //<<"=0x"
467  // //<< std::hex
468  // //<< std::setfill('0') << std::setw(8) << key() << std::setfill(' ')
469  // //<< std::dec
470  // //<< ", " << ( isValid() ? "Valid" : "Invalid" )
471  // //<< ", FedCrate=" << fedCrate()
472  // //<< ", FedSlot=" << fedSlot()
473  // << ", FedId=" << fedId()
474  // << ", FeUnit=" << feUnit()
475  // << ", FeChan=" << feChan()
476  // //<< ", FedChannel=" << fedChannel()
477  // << ", FedApv=" << fedApv();
478 }
479 
480 // -----------------------------------------------------------------------------
481 //
482 void SiStripFedKey::print(std::stringstream& ss) const {
483  ss << " [SiStripFedKey::print]" << std::endl
484  << std::hex << " FED key : 0x" << std::setfill('0') << std::setw(8) << key() << std::endl
485  << std::setfill(' ') << std::dec << " FED id : " << fedId() << std::endl
486  << " Front-End unit : " << feUnit() << std::endl
487  << " Front-End chan : " << feChan() << std::endl
488  << " (internal chan) : "
489  << "(" << fedChannel() << ")" << std::endl
490  << " FED APV : " << fedApv() << std::endl
491  << " Directory : " << path() << std::endl
492  << " Granularity : " << SiStripEnumsAndStrings::granularity(granularity()) << std::endl
493  << " Channel : " << channel() << std::endl
494  << " isValid : " << isValid();
495 }
496 
497 // -----------------------------------------------------------------------------
498 //
499 std::ostream& operator<<(std::ostream& os, const SiStripFedKey& input) {
500  std::stringstream ss;
501  input.print(ss);
502  os << ss.str();
503  return os;
504 }
sistrip::Granularity
Granularity
Definition: ConstantsForGranularity.h:60
Constants.h
Generic constants.
SiStripFedKey::fedIdMask_
static const uint16_t fedIdMask_
Definition: SiStripFedKey.h:180
SiStripFedKey::isEqual
bool isEqual(const SiStripKey &) const override
Definition: SiStripFedKey.cc:132
sistrip::null_
static const char null_[]
Definition: Constants.h:22
input
static const std::string input
Definition: EdmProvDump.cc:48
SiStripFedKey::fedId_
uint16_t fedId_
Definition: SiStripFedKey.h:158
SiStripFedKey::feUnit_
uint16_t feUnit_
Definition: SiStripFedKey.h:161
sistrip::invalid32_
static const uint32_t invalid32_
Definition: Constants.h:15
SiStripFedKey::isValid
bool isValid() const override
Definition: SiStripFedKey.cc:157
SiStripKey::key
const uint32_t & key() const
Definition: SiStripKey.h:120
sistrip::dir_
static const char dir_[]
Definition: ConstantsForDqm.h:17
SiStripFedKey::feChanMask_
static const uint16_t feChanMask_
Definition: SiStripFedKey.h:182
sistrip::FED_APV
Definition: ConstantsForGranularity.h:85
SiStripFedKey::feUnitMask_
static const uint16_t feUnitMask_
Definition: SiStripFedKey.h:181
sistrip::FE_UNIT
Definition: ConstantsForGranularity.h:83
sistrip::FED_ID_MIN
static const uint16_t FED_ID_MIN
Definition: ConstantsForHardwareSystems.h:21
SiStripFedKey::feChan_
uint16_t feChan_
Definition: SiStripFedKey.h:164
SiStripFedKey
A container class for generic run and event-related info, information required by the commissioning a...
Definition: SiStripFedKey.h:56
ConstantsForHardwareSystems.h
Constants and enumerated types for FED/FEC systems.
sistrip::UNKNOWN_GRAN
Definition: ConstantsForGranularity.h:62
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
SiStripFedKey::fedIdOffset_
static const uint16_t fedIdOffset_
Definition: SiStripFedKey.h:172
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
SiStripFedKey::fedApvOffset_
static const uint16_t fedApvOffset_
Definition: SiStripFedKey.h:175
SiStripKey::granularity
const sistrip::Granularity & granularity() const
Definition: SiStripKey.h:122
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
SiStripKey::channel
const uint16_t & channel() const
Definition: SiStripKey.h:123
SiStripFedKey::SiStripFedKey
SiStripFedKey()
Definition: SiStripFedKey.cc:83
operator<<
std::ostream & operator<<(std::ostream &os, const SiStripFedKey &input)
Definition: SiStripFedKey.cc:499
SiStripFedKey::initFromPath
void initFromPath() override
Definition: SiStripFedKey.cc:323
SiStripFedKey::isInvalid
bool isInvalid() const override
Definition: SiStripFedKey.cc:193
SiStripFedKey::initGranularity
void initGranularity() override
Definition: SiStripFedKey.cc:424
SiStripEnumsAndStrings::granularity
static std::string granularity(const sistrip::Granularity &)
Definition: SiStripEnumsAndStrings.cc:265
SiStripFedKey::terse
void terse(std::stringstream &ss) const override
Definition: SiStripFedKey.cc:459
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
sistrip::FEUNITS_PER_FED
static const uint16_t FEUNITS_PER_FED
Definition: ConstantsForHardwareSystems.h:29
SiStripFedKey::initFromKey
void initFromKey() override
Definition: SiStripFedKey.cc:249
SiStripFedKey.h
SiStripKey::path
const std::string & path() const
Definition: SiStripKey.h:121
SiStripFedKey::fedApv
const uint16_t & fedApv() const
Definition: SiStripFedKey.h:191
sistrip::fedApv_
static const char fedApv_[]
Definition: ConstantsForGranularity.h:47
SiStripFedKey::feUnit
const uint16_t & feUnit() const
Definition: SiStripFedKey.h:189
SiStripFedKey::fedIndex
static uint32_t fedIndex(const uint16_t &fed_id, const uint16_t &fed_ch)
Definition: SiStripFedKey.cc:123
sistrip::FED_SYSTEM
Definition: ConstantsForGranularity.h:81
SiStripFedKey::feUnitOffset_
static const uint16_t feUnitOffset_
Definition: SiStripFedKey.h:173
sistrip::root_
static const char root_[]
Definition: ConstantsForDqm.h:30
sistrip::invalid_
static const uint16_t invalid_
Definition: Constants.h:16
l1tstage2_dqm_sourceclient-live_cfg.fedId
fedId
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:88
sistrip::FED_ID_MAX
static const uint16_t FED_ID_MAX
Definition: ConstantsForHardwareSystems.h:22
ConstantsForView.h
Constants and enumerated types for sistrip::View.
SiStripFedKey::isConsistent
bool isConsistent(const SiStripKey &) const override
Definition: SiStripFedKey.cc:143
SiStripFedKey::fedApvMask_
static const uint16_t fedApvMask_
Definition: SiStripFedKey.h:183
SiStripFedKey::fedApv_
uint16_t fedApv_
Definition: SiStripFedKey.h:167
SiStripFedKey::fedCh
static uint16_t fedCh(const uint16_t &fe_unit, const uint16_t &fe_chan)
Definition: SiStripFedKey.cc:94
sistrip::feChan_
static const char feChan_[]
Definition: ConstantsForGranularity.h:46
SiStripFedKey::print
void print(std::stringstream &ss) const override
Definition: SiStripFedKey.cc:482
ConstantsForDqm.h
Various generic constants used by DQM.
SiStripFedKey::fedChannel
uint16_t fedChannel() const
Definition: SiStripFedKey.h:192
SiStripFedKey::initFromValue
void initFromValue() override
Definition: SiStripFedKey.cc:229
sistrip::APVS_PER_FEDCH
static const uint16_t APVS_PER_FEDCH
Definition: ConstantsForHardwareSystems.h:34
SiStripFedKey::feChanOffset_
static const uint16_t feChanOffset_
Definition: SiStripFedKey.h:174
SiStripEnumsAndStrings.h
sistrip::FEDCH_PER_FED
static const uint16_t FEDCH_PER_FED
Definition: ConstantsForHardwareSystems.h:30
sistrip::FEDCH_PER_FEUNIT
static const uint16_t FEDCH_PER_FEUNIT
Definition: ConstantsForHardwareSystems.h:28
sistrip::readoutView_
static const char readoutView_[]
Definition: ConstantsForView.h:20
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
sistrip::FE_DRIVER
Definition: ConstantsForGranularity.h:82
sistrip
sistrip classes
Definition: SiStripQualityHelpers.h:14
sistrip::UNDEFINED_GRAN
Definition: ConstantsForGranularity.h:61
crabWrapper.key
key
Definition: crabWrapper.py:19
SiStripKey
Base utility class that identifies a position within a logical structure of the strip tracker.
Definition: SiStripKey.h:23
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
sistrip::FE_CHAN
Definition: ConstantsForGranularity.h:84
SiStripFedKey::fedId
const uint16_t & fedId() const
Definition: SiStripFedKey.h:188
SiStripFedKey::feChan
const uint16_t & feChan() const
Definition: SiStripFedKey.h:190
sistrip::feDriver_
static const char feDriver_[]
Definition: ConstantsForGranularity.h:44
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
sistrip::feUnit_
static const char feUnit_[]
Definition: ConstantsForGranularity.h:45