17 : useEcal_(iConfig.getParameter<
bool>(
"useEcal")),
18 useHcal_(iConfig.getParameter<
bool>(
"useHcal")),
19 ecalDigisLabel_(iConfig.getParameter<
edm::InputTag>(
"ecalDigisLabel")),
20 hcalDigisLabel_(iConfig.getParameter<
edm::InputTag>(
"hcalDigisLabel")),
21 maskFile_(iConfig.getParameter<
edm::FileInPath>(
"maskFile")) {
30 produces<EcalTrigPrimDigiCollection>();
31 produces<HcalTrigPrimDigiCollection>();
87 if (!maskFileStream.is_open()) {
89 <<
"RCT mask file not opened" << std::endl;
100 maskFileStream >> junk;
101 }
while (junk !=
"ECAL:");
106 std::vector<std::vector<std::vector<unsigned short>>> ecalMask(
107 2, std::vector<std::vector<unsigned short>>(
108 72, std::vector<unsigned short>(28, 1)));
109 std::vector<std::vector<std::vector<unsigned short>>> hcalMask(
110 2, std::vector<std::vector<unsigned short>>(
111 72, std::vector<unsigned short>(28, 1)));
112 std::vector<std::vector<std::vector<unsigned short>>> hfMask(
113 2, std::vector<std::vector<unsigned short>>(
114 18, std::vector<unsigned short>(8, 1)));
118 for (
int i = 1;
i <= 72;
i++) {
119 int phi_index = (72 + 18 -
i) % 72;
120 if (phi_index == 0) {
124 for (
int j = 28; j >= 1; j--) {
125 maskFileStream >> junk;
127 }
else if ((junk ==
"X") || (junk ==
"x")) {
128 ecalMask.at(0).at(phi_index - 1).at(j - 1) = 0;
130 std::cerr <<
"RCT mask producer: error -- unrecognized character" 134 for (
int j = 1; j <= 28; j++) {
135 maskFileStream >> junk;
137 }
else if ((junk ==
"X") || (junk ==
"x")) {
138 ecalMask.at(1).at(phi_index - 1).at(j - 1) = 0;
140 std::cerr <<
"RCT mask producer: error -- unrecognized character" 147 maskFileStream >> junk;
148 if (junk !=
"HCAL:") {
150 <<
"RCT mask producer: error reading ECAL mask" << std::endl;
158 for (
int i = 1;
i <= 72;
i++) {
159 int phi_index = (72 + 18 -
i) % 72;
160 if (phi_index == 0) {
164 for (
int j = 28; j >= 1; j--) {
165 maskFileStream >> junk;
167 }
else if ((junk ==
"X") || (junk ==
"x")) {
168 hcalMask.at(0).at(phi_index - 1).at(j - 1) = 0;
170 std::cerr <<
"RCT mask producer: error -- unrecognized character" 174 for (
int j = 1; j <= 28; j++) {
175 maskFileStream >> junk;
177 }
else if ((junk ==
"X") || (junk ==
"x")) {
178 hcalMask.at(1).at(phi_index - 1).at(j - 1) = 0;
180 std::cerr <<
"RCT mask producer: error -- unrecognized character" 186 maskFileStream >> junk;
189 <<
"RCT mask producer: error reading HCAL mask" << std::endl;
194 for (
int i = 0;
i < 18;
i++) {
196 for (
int j = 4; j >= 1; j--) {
197 if (maskFileStream >> junk) {
199 std::cerr <<
"RCT mask producer: error reading HF mask" << std::endl;
202 }
else if ((junk ==
"X") || (junk ==
"x")) {
203 hfMask.at(0).at(
i).at(j - 1) =
206 std::cerr <<
"RCT mask producer: error -- unrecognized character" 210 for (
int j = 1; j <= 4; j++) {
211 if (maskFileStream >> junk) {
213 std::cerr <<
"RCT mask producer: error reading HF mask" << std::endl;
216 }
else if ((junk ==
"X") || (junk ==
"x")) {
217 hfMask.at(1).at(
i).at(j - 1) = 0;
219 std::cerr <<
"RCT mask producer: error -- unrecognized character" 227 maskFileStream.close();
233 std::unique_ptr<EcalTrigPrimDigiCollection> maskedEcalTPs(
235 std::unique_ptr<HcalTrigPrimDigiCollection> maskedHcalTPs(
237 maskedEcalTPs->reserve(56 * 72);
238 maskedHcalTPs->reserve(56 * 72 + 18 * 8);
239 int nEcalSamples = 0;
240 int nHcalSamples = 0;
242 for (
unsigned int i = 0;
i < ecalColl.
size();
i++) {
243 nEcalSamples = ecalColl[
i].
size();
244 short ieta = (short)ecalColl[
i].
id().ieta();
245 unsigned short absIeta = (
unsigned short)
abs(ieta);
246 int sign = ieta / absIeta;
247 short iphi = (
unsigned short)ecalColl[
i].
id().iphi();
254 ecalDigi.
setSize(nEcalSamples);
256 for (
int nSample = 0; nSample < nEcalSamples; nSample++) {
259 bool fineGrain =
false;
264 energy = ecalMask.at(0).at(iphi - 1).at(absIeta - 1) *
265 ecalColl[
i].sample(nSample).compressedEt();
266 fineGrain = (ecalMask.at(0).at(iphi - 1).at(absIeta - 1) != 0) &&
267 ecalColl[
i].
sample(nSample).fineGrain();
268 }
else if (sign > 0) {
271 energy = ecalMask.at(1).at(iphi - 1).at(absIeta - 1) *
272 ecalColl[
i].sample(nSample).compressedEt();
273 fineGrain = (ecalMask.at(1).at(iphi - 1).at(absIeta - 1) != 0) &&
274 ecalColl[
i].
sample(nSample).fineGrain();
280 maskedEcalTPs->push_back(ecalDigi);
285 for (
unsigned int i = 0;
i < hcalColl.
size();
i++) {
286 nHcalSamples = hcalColl[
i].
size();
288 short ieta = (short)hcalColl[
i].
id().ieta();
289 unsigned short absIeta = (
unsigned short)
abs(ieta);
290 int sign = ieta / absIeta;
291 short iphi = (
unsigned short)hcalColl[
i].
id().iphi();
304 hcalDigi.
setSize(nHcalSamples);
307 for (
int nSample = 0; nSample < nHcalSamples; nSample++) {
310 bool fineGrain =
false;
314 energy = hcalMask.at(0).at(iphi - 1).at(absIeta - 1) *
315 hcalColl[
i].sample(nSample).compressedEt();
316 fineGrain = (hcalMask.at(0).at(iphi - 1).at(absIeta - 1) != 0) &&
317 hcalColl[
i].
sample(nSample).fineGrain();
318 }
else if (sign > 0) {
319 energy = hcalMask.at(1).at(iphi - 1).at(absIeta - 1) *
320 hcalColl[
i].sample(nSample).compressedEt();
321 fineGrain = (hcalMask.at(1).at(iphi - 1).at(absIeta - 1) != 0) &&
322 hcalColl[
i].
sample(nSample).fineGrain();
324 }
else if ((absIeta >= 29) && (absIeta <= 32)) {
326 short hf_phi_index = iphi / 4;
334 energy = hfMask.at(0).at(hf_phi_index).at(absIeta - 29) *
338 fineGrain = (hfMask.at(0).at(hf_phi_index).at(absIeta - 29) != 0) &&
339 hcalColl[
i].
sample(nSample).fineGrain();
340 }
else if (sign > 0) {
344 energy = hfMask.at(1).at(hf_phi_index).at(absIeta - 29) *
345 hcalColl[
i].sample(nSample).compressedEt();
346 fineGrain = (hfMask.at(1).at(hf_phi_index).at(absIeta - 29) != 0) &&
347 hcalColl[
i].
sample(nSample).fineGrain();
362 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