16 : useEcal_(iConfig.getParameter<
bool>(
"useEcal")),
17 useHcal_(iConfig.getParameter<
bool>(
"useHcal")),
18 ecalDigisLabel_(iConfig.getParameter<
edm::
InputTag>(
"ecalDigisLabel")),
19 hcalDigisLabel_(iConfig.getParameter<
edm::
InputTag>(
"hcalDigisLabel")),
20 maskFile_(iConfig.getParameter<
edm::FileInPath>(
"maskFile")) {
29 produces<EcalTrigPrimDigiCollection>();
30 produces<HcalTrigPrimDigiCollection>();
84 if (!maskFileStream.is_open()) {
85 throw cms::Exception(
"FileInPathError") <<
"RCT mask file not opened" << std::endl;
96 maskFileStream >> junk;
97 }
while (junk !=
"ECAL:");
102 std::vector<std::vector<std::vector<unsigned short>>> ecalMask(
103 2, std::vector<std::vector<unsigned short>>(72, std::vector<unsigned short>(28, 1)));
104 std::vector<std::vector<std::vector<unsigned short>>> hcalMask(
105 2, std::vector<std::vector<unsigned short>>(72, std::vector<unsigned short>(28, 1)));
106 std::vector<std::vector<std::vector<unsigned short>>> hfMask(
107 2, std::vector<std::vector<unsigned short>>(18, std::vector<unsigned short>(8, 1)));
111 for (
int i = 1;
i <= 72;
i++) {
112 int phi_index = (72 + 18 -
i) % 72;
113 if (phi_index == 0) {
117 for (
int j = 28;
j >= 1;
j--) {
118 maskFileStream >> junk;
120 }
else if ((junk ==
"X") || (junk ==
"x")) {
121 ecalMask.at(0).at(phi_index - 1).at(
j - 1) = 0;
123 std::cerr <<
"RCT mask producer: error -- unrecognized character" << std::endl;
126 for (
int j = 1;
j <= 28;
j++) {
127 maskFileStream >> junk;
129 }
else if ((junk ==
"X") || (junk ==
"x")) {
130 ecalMask.at(1).at(phi_index - 1).at(
j - 1) = 0;
132 std::cerr <<
"RCT mask producer: error -- unrecognized character" << std::endl;
138 maskFileStream >> junk;
139 if (junk !=
"HCAL:") {
140 throw cms::Exception(
"FileInPathError") <<
"RCT mask producer: error reading ECAL mask" << std::endl;
148 for (
int i = 1;
i <= 72;
i++) {
149 int phi_index = (72 + 18 -
i) % 72;
150 if (phi_index == 0) {
154 for (
int j = 28;
j >= 1;
j--) {
155 maskFileStream >> junk;
157 }
else if ((junk ==
"X") || (junk ==
"x")) {
158 hcalMask.at(0).at(phi_index - 1).at(
j - 1) = 0;
160 std::cerr <<
"RCT mask producer: error -- unrecognized character" << std::endl;
163 for (
int j = 1;
j <= 28;
j++) {
164 maskFileStream >> junk;
166 }
else if ((junk ==
"X") || (junk ==
"x")) {
167 hcalMask.at(1).at(phi_index - 1).at(
j - 1) = 0;
169 std::cerr <<
"RCT mask producer: error -- unrecognized character" << std::endl;
174 maskFileStream >> junk;
176 throw cms::Exception(
"FileInPathError") <<
"RCT mask producer: error reading HCAL mask" << std::endl;
181 for (
int i = 0;
i < 18;
i++) {
183 for (
int j = 4;
j >= 1;
j--) {
184 if (maskFileStream >> junk) {
186 std::cerr <<
"RCT mask producer: error reading HF mask" << std::endl;
189 }
else if ((junk ==
"X") || (junk ==
"x")) {
190 hfMask.at(0).at(
i).at(
j - 1) = 0;
192 std::cerr <<
"RCT mask producer: error -- unrecognized character" << std::endl;
195 for (
int j = 1;
j <= 4;
j++) {
196 if (maskFileStream >> junk) {
198 std::cerr <<
"RCT mask producer: error reading HF mask" << std::endl;
201 }
else if ((junk ==
"X") || (junk ==
"x")) {
202 hfMask.at(1).at(
i).at(
j - 1) = 0;
204 std::cerr <<
"RCT mask producer: error -- unrecognized character" << std::endl;
211 maskFileStream.close();
219 maskedEcalTPs->reserve(56 * 72);
220 maskedHcalTPs->reserve(56 * 72 + 18 * 8);
221 int nEcalSamples = 0;
222 int nHcalSamples = 0;
224 for (
unsigned int i = 0;
i < ecalColl.
size();
i++) {
225 nEcalSamples = ecalColl[
i].
size();
226 short ieta = (short)ecalColl[
i].
id().ieta();
227 unsigned short absIeta = (
unsigned short)
abs(ieta);
228 int sign = ieta / absIeta;
229 short iphi = (
unsigned short)ecalColl[
i].
id().iphi();
235 ecalDigi.
setSize(nEcalSamples);
237 for (
int nSample = 0; nSample < nEcalSamples; nSample++) {
239 bool fineGrain =
false;
244 energy = ecalMask.at(0).at(iphi - 1).at(absIeta - 1) * ecalColl[
i].sample(nSample).compressedEt();
245 fineGrain = (ecalMask.at(0).at(iphi - 1).at(absIeta - 1) != 0) && ecalColl[
i].
sample(nSample).fineGrain();
246 }
else if (sign > 0) {
249 energy = ecalMask.at(1).at(iphi - 1).at(absIeta - 1) * ecalColl[
i].sample(nSample).compressedEt();
250 fineGrain = (ecalMask.at(1).at(iphi - 1).at(absIeta - 1) != 0) && ecalColl[
i].
sample(nSample).fineGrain();
255 maskedEcalTPs->push_back(ecalDigi);
260 for (
unsigned int i = 0;
i < hcalColl.
size();
i++) {
261 nHcalSamples = hcalColl[
i].
size();
263 short ieta = (short)hcalColl[
i].
id().ieta();
264 unsigned short absIeta = (
unsigned short)
abs(ieta);
265 int sign = ieta / absIeta;
266 short iphi = (
unsigned short)hcalColl[
i].
id().iphi();
279 hcalDigi.
setSize(nHcalSamples);
282 for (
int nSample = 0; nSample < nHcalSamples; nSample++) {
284 bool fineGrain =
false;
288 energy = hcalMask.at(0).at(iphi - 1).at(absIeta - 1) * hcalColl[
i].sample(nSample).compressedEt();
289 fineGrain = (hcalMask.at(0).at(iphi - 1).at(absIeta - 1) != 0) && hcalColl[
i].
sample(nSample).fineGrain();
290 }
else if (sign > 0) {
291 energy = hcalMask.at(1).at(iphi - 1).at(absIeta - 1) * hcalColl[
i].sample(nSample).compressedEt();
292 fineGrain = (hcalMask.at(1).at(iphi - 1).at(absIeta - 1) != 0) && hcalColl[
i].
sample(nSample).fineGrain();
294 }
else if ((absIeta >= 29) && (absIeta <= 32)) {
296 short hf_phi_index = iphi / 4;
304 energy = hfMask.at(0).at(hf_phi_index).at(absIeta - 29) *
305 hcalColl[
i].sample(nSample).compressedEt();
306 fineGrain = (hfMask.at(0).at(hf_phi_index).at(absIeta - 29) != 0) && hcalColl[
i].
sample(nSample).fineGrain();
307 }
else if (sign > 0) {
311 energy = hfMask.at(1).at(hf_phi_index).at(absIeta - 29) * hcalColl[
i].sample(nSample).compressedEt();
312 fineGrain = (hfMask.at(1).at(hf_phi_index).at(absIeta - 29) != 0) && hcalColl[
i].
sample(nSample).fineGrain();
326 maskedHcalTPs->push_back(hcalDigi);
void setSample(int i, const HcalTriggerPrimitiveSample &sam)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::SortedCollection< HcalTriggerPrimitiveDigi > HcalTrigPrimDigiCollection
#define DEFINE_FWK_MODULE(type)
void setSample(int i, const EcalTriggerPrimitiveSample &sam)
Abs< T >::type abs(const T &t)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
edm::SortedCollection< EcalTriggerPrimitiveDigi > EcalTrigPrimDigiCollection
void setPresamples(int ps)
std::string fullPath() const