CMS 3D CMS Logo

EcalSampleMask.cc
Go to the documentation of this file.
1 
7 #include <cassert>
11 
12 using edm::LogError;
13 
15  // by default, all samples are set as active
18 }
19 
20 EcalSampleMask::EcalSampleMask(const unsigned int ebmask, const unsigned int eemask) {
21  sampleMaskEB_ = ebmask;
22  sampleMaskEE_ = eemask;
23 }
24 
25 EcalSampleMask::EcalSampleMask(const std::vector<unsigned int> &ebmask, const std::vector<unsigned int> &eemask) {
28 }
29 
31 
32 void EcalSampleMask::setEcalSampleMaskRecordEB(const std::vector<unsigned int> &ebmask) {
33  // check that size of the vector is adequate
34  if (ebmask.size() != static_cast<unsigned int>(EcalDataFrame::MAXSAMPLES)) {
35  LogError("DataMismatch") << " in EcalSampleMask::setEcalSampleMaskRecordEB size of ebmask (" << ebmask.size()
36  << ") need to be: " << EcalDataFrame::MAXSAMPLES << ". Bailing out." << std::endl;
37  assert(0);
38  }
39 
40  // check that values of vector are allowed
41  for (unsigned int s = 0; s < ebmask.size(); s++) {
42  if (ebmask.at(s) == 0 || ebmask.at(s) == 1) {
43  ;
44  } else {
45  LogError("DataMismatch")
46  << "in EcalSampleMask::setEcalSampleMaskRecordEB ebmask can only have values 0 or 1, while " << ebmask.at(s)
47  << " was found. Bailing out. " << std::endl;
48  assert(0);
49  }
50  }
51 
52  // ordering of bits:
53  // ebmask.at(0) refers to the first sample read out and is mapped into the _most_ significant bit of sampleMaskEB_
54  // ebmask.at(EcalDataFrame::MAXSAMPLES) refers to the last sample read out and is mapped into the _least_ significant bit of sampleMaskEB_
55  sampleMaskEB_ = 0;
56  for (unsigned int sampleId = 0; sampleId < ebmask.size(); sampleId++) {
57  sampleMaskEB_ |= (0x1 << (EcalDataFrame::MAXSAMPLES - (sampleId + 1)));
58  }
59 }
60 
61 void EcalSampleMask::setEcalSampleMaskRecordEE(const std::vector<unsigned int> &eemask) {
62  // check that size of the vector is adequate
63  if (eemask.size() != static_cast<unsigned int>(EcalDataFrame::MAXSAMPLES)) {
64  LogError("DataMismatch") << " in EcalSampleMask::setEcalSampleMaskRecordEE size of eemask (" << eemask.size()
65  << ") need to be: " << EcalDataFrame::MAXSAMPLES << ". Bailing out." << std::endl;
66  assert(0);
67  }
68 
69  // check that values of vector are allowed
70  for (unsigned int s = 0; s < eemask.size(); s++) {
71  if (eemask.at(s) == 0 || eemask.at(s) == 1) {
72  ;
73  } else {
74  LogError("DataMismatch")
75  << "in EcalSampleMask::setEcalSampleMaskRecordEE eemask can only have values 0 or 1, while " << eemask.at(s)
76  << " was found. Bailing out. " << std::endl;
77  assert(0);
78  }
79  }
80 
81  // ordering of bits:
82  // eemask.at(0) refers to the first sample read out and is mapped into the _most_ significant bit of sampleMaskEE_
83  // eemask.at(EcalDataFrame::MAXSAMPLES) refers to the last sample read out and is mapped into the _least_ significant bit of sampleMaskEE_
84  sampleMaskEE_ = 0;
85  for (unsigned int sampleId = 0; sampleId < eemask.size(); sampleId++) {
86  sampleMaskEE_ |= (0x1 << (EcalDataFrame::MAXSAMPLES - (sampleId + 1)));
87  }
88 }
89 
90 bool EcalSampleMask::useSampleEB(const int sampleId) const {
91  if (sampleId >= EcalDataFrame::MAXSAMPLES) {
92  LogError("DataMismatch") << "in EcalSampleMask::useSampleEB only sampleId up to: " << EcalDataFrame::MAXSAMPLES
93  << " can be used, while: " << sampleId << " was found. Bailing out." << std::endl;
94  assert(0);
95  }
96 
97  // ordering convention:
98  // ebmask.at(0) refers to the first sample read out and is mapped into the _most_ significant bit of sampleMaskEB_
99  // ebmask.at(EcalDataFrame::MAXSAMPLES) refers to the last sample read out and is mapped into the _least_ significant bit of sampleMaskEB_
100  return (sampleMaskEB_ & (0x1 << (EcalDataFrame::MAXSAMPLES - (sampleId + 1))));
101 }
102 
103 bool EcalSampleMask::useSampleEE(const int sampleId) const {
104  if (sampleId >= EcalDataFrame::MAXSAMPLES) {
105  LogError("DataMismatch") << "in EcalSampleMask::useSampleEE only sampleId up to: " << EcalDataFrame::MAXSAMPLES
106  << " can be used, while: " << sampleId << " was found. Bailing out." << std::endl;
107  assert(0);
108  }
109 
110  // ordering convention:
111  // ebmask.at(0) refers to the first sample read out and is mapped into the _most_ significant bit of sampleMaskEB_
112  // ebmask.at(EcalDataFrame::MAXSAMPLES) refers to the last sample read out and is mapped into the _least_ significant bit of sampleMaskEB_
113  return (sampleMaskEE_ & (0x1 << (EcalDataFrame::MAXSAMPLES - (sampleId + 1))));
114 }
115 
116 bool EcalSampleMask::useSample(const int sampleId, DetId &theCrystalId) const {
117  if (sampleId >= EcalDataFrame::MAXSAMPLES) {
118  LogError("DataMismatch") << "in EcalSampleMask::useSample only sampleId up to: " << EcalDataFrame::MAXSAMPLES
119  << " can be used, while: " << sampleId << " was found. Bailing out." << std::endl;
120  assert(0);
121  }
122 
123  if (theCrystalId.subdetId() == EcalBarrel) {
124  return useSampleEB(sampleId);
125  } else if (theCrystalId.subdetId() == EcalEndcap) {
126  return useSampleEE(sampleId);
127  } else {
128  LogError("DataMismatch")
129  << "EcalSampleMaskuseSample::useSample can only be called for EcalBarrel or EcalEndcap DetID" << std::endl;
130  assert(0);
131  }
132 }
133 
134 // LocalWords: eemask
EcalDataFrame::MAXSAMPLES
static constexpr int MAXSAMPLES
Definition: EcalDataFrame.h:48
MessageLogger.h
EcalSampleMask::setEcalSampleMaskRecordEB
void setEcalSampleMaskRecordEB(const unsigned int mask)
Definition: EcalSampleMask.h:27
cms::cuda::assert
assert(be >=bs)
EcalSampleMask::setEcalSampleMaskRecordEE
void setEcalSampleMaskRecordEE(const unsigned int mask)
Definition: EcalSampleMask.h:28
EcalDataFrame.h
EcalBarrel
Definition: EcalSubdetector.h:10
DetId
Definition: DetId.h:17
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
alignCSCRings.s
s
Definition: alignCSCRings.py:92
EcalSampleMask::useSampleEE
bool useSampleEE(const int sampleId) const
Definition: EcalSampleMask.cc:103
EcalSampleMask::sampleMaskEE_
unsigned int sampleMaskEE_
Definition: EcalSampleMask.h:42
EcalSampleMask::EcalSampleMask
EcalSampleMask()
Definition: EcalSampleMask.cc:14
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
EcalEndcap
Definition: EcalSubdetector.h:10
edm::LogError
Definition: MessageLogger.h:183
EcalSampleMask::useSample
bool useSample(const int sampleId, DetId &theCrystal) const
Definition: EcalSampleMask.cc:116
EcalSampleMask::~EcalSampleMask
~EcalSampleMask()
Definition: EcalSampleMask.cc:30
EcalSampleMask.h
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
EcalSampleMask::useSampleEB
bool useSampleEB(const int sampleId) const
Definition: EcalSampleMask.cc:90
EcalSampleMask::sampleMaskEB_
unsigned int sampleMaskEB_
Definition: EcalSampleMask.h:41