16 : useEcal_(iConfig.getParameter<
bool>(
"useEcal")),
17 useHcal_(iConfig.getParameter<
bool>(
"useHcal")),
18 maskFile_(iConfig.getParameter<
edm::FileInPath>(
"maskFile")) {
33 produces<EcalTrigPrimDigiCollection>();
34 produces<HcalTrigPrimDigiCollection>();
72 if (!maskFileStream.is_open()) {
73 throw cms::Exception(
"FileInPathError") <<
"RCT mask file not opened" << std::endl;
84 maskFileStream >> junk;
85 }
while (junk !=
"ECAL:");
90 std::vector<std::vector<std::vector<unsigned short>>> ecalMask(
91 2,
std::vector<std::vector<unsigned short>>(72, std::vector<unsigned short>(28, 1)));
92 std::vector<std::vector<std::vector<unsigned short>>> hcalMask(
93 2,
std::vector<std::vector<unsigned short>>(72, std::vector<unsigned short>(28, 1)));
94 std::vector<std::vector<std::vector<unsigned short>>> hfMask(
95 2,
std::vector<std::vector<unsigned short>>(18, std::vector<unsigned short>(8, 1)));
99 for (
int i = 1;
i <= 72;
i++) {
100 int phi_index = (72 + 18 -
i) % 72;
101 if (phi_index == 0) {
105 for (
int j = 28;
j >= 1;
j--) {
106 maskFileStream >> junk;
108 }
else if ((junk ==
"X") || (junk ==
"x")) {
109 ecalMask.at(0).at(phi_index - 1).at(
j - 1) = 0;
111 std::cerr <<
"RCT mask producer: error -- unrecognized character" << std::endl;
114 for (
int j = 1;
j <= 28;
j++) {
115 maskFileStream >> junk;
117 }
else if ((junk ==
"X") || (junk ==
"x")) {
118 ecalMask.at(1).at(phi_index - 1).at(
j - 1) = 0;
120 std::cerr <<
"RCT mask producer: error -- unrecognized character" << std::endl;
126 maskFileStream >> junk;
127 if (junk !=
"HCAL:") {
128 throw cms::Exception(
"FileInPathError") <<
"RCT mask producer: error reading ECAL mask" << std::endl;
136 for (
int i = 1;
i <= 72;
i++) {
137 int phi_index = (72 + 18 -
i) % 72;
138 if (phi_index == 0) {
142 for (
int j = 28;
j >= 1;
j--) {
143 maskFileStream >> junk;
145 }
else if ((junk ==
"X") || (junk ==
"x")) {
146 hcalMask.at(0).at(phi_index - 1).at(
j - 1) = 0;
148 std::cerr <<
"RCT mask producer: error -- unrecognized character" << std::endl;
151 for (
int j = 1;
j <= 28;
j++) {
152 maskFileStream >> junk;
154 }
else if ((junk ==
"X") || (junk ==
"x")) {
155 hcalMask.at(1).at(phi_index - 1).at(
j - 1) = 0;
157 std::cerr <<
"RCT mask producer: error -- unrecognized character" << std::endl;
162 maskFileStream >> junk;
164 throw cms::Exception(
"FileInPathError") <<
"RCT mask producer: error reading HCAL mask" << std::endl;
169 for (
int i = 0;
i < 18;
i++) {
171 for (
int j = 4;
j >= 1;
j--) {
172 if (maskFileStream >> junk) {
174 std::cerr <<
"RCT mask producer: error reading HF mask" << std::endl;
177 }
else if ((junk ==
"X") || (junk ==
"x")) {
178 hfMask.at(0).at(
i).at(
j - 1) = 0;
180 std::cerr <<
"RCT mask producer: error -- unrecognized character" << std::endl;
183 for (
int j = 1;
j <= 4;
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(1).at(
i).at(
j - 1) = 0;
192 std::cerr <<
"RCT mask producer: error -- unrecognized character" << std::endl;
199 maskFileStream.close();
207 maskedEcalTPs->reserve(56 * 72);
208 maskedHcalTPs->reserve(56 * 72 + 18 * 8);
209 int nEcalSamples = 0;
210 int nHcalSamples = 0;
212 for (
unsigned int i = 0;
i < ecalColl.
size();
i++) {
213 nEcalSamples = ecalColl[
i].
size();
214 short ieta = (short)ecalColl[
i].
id().ieta();
215 unsigned short absIeta = (
unsigned short)
abs(
ieta);
217 short iphi = (
unsigned short)ecalColl[
i].
id().iphi();
223 ecalDigi.
setSize(nEcalSamples);
225 for (
int nSample = 0; nSample < nEcalSamples; nSample++) {
227 bool fineGrain =
false;
232 energy = ecalMask.at(0).at(
iphi - 1).at(absIeta - 1) * ecalColl[
i].sample(nSample).compressedEt();
233 fineGrain = (ecalMask.at(0).at(
iphi - 1).at(absIeta - 1) != 0) && ecalColl[
i].
sample(nSample).fineGrain();
234 }
else if (
sign > 0) {
237 energy = ecalMask.at(1).at(
iphi - 1).at(absIeta - 1) * ecalColl[
i].sample(nSample).compressedEt();
238 fineGrain = (ecalMask.at(1).at(
iphi - 1).at(absIeta - 1) != 0) && ecalColl[
i].
sample(nSample).fineGrain();
243 maskedEcalTPs->push_back(ecalDigi);
248 for (
unsigned int i = 0;
i < hcalColl.
size();
i++) {
249 nHcalSamples = hcalColl[
i].
size();
251 short ieta = (short)hcalColl[
i].
id().ieta();
252 unsigned short absIeta = (
unsigned short)
abs(
ieta);
254 short iphi = (
unsigned short)hcalColl[
i].
id().iphi();
267 hcalDigi.
setSize(nHcalSamples);
270 for (
int nSample = 0; nSample < nHcalSamples; nSample++) {
272 bool fineGrain =
false;
276 energy = hcalMask.at(0).at(
iphi - 1).at(absIeta - 1) * hcalColl[
i].sample(nSample).compressedEt();
277 fineGrain = (hcalMask.at(0).at(
iphi - 1).at(absIeta - 1) != 0) && hcalColl[
i].
sample(nSample).fineGrain();
278 }
else if (
sign > 0) {
279 energy = hcalMask.at(1).at(
iphi - 1).at(absIeta - 1) * hcalColl[
i].sample(nSample).compressedEt();
280 fineGrain = (hcalMask.at(1).at(
iphi - 1).at(absIeta - 1) != 0) && hcalColl[
i].
sample(nSample).fineGrain();
282 }
else if ((absIeta >= 29) && (absIeta <= 32)) {
284 short hf_phi_index =
iphi / 4;
292 energy = hfMask.at(0).at(hf_phi_index).at(absIeta - 29) *
293 hcalColl[
i].sample(nSample).compressedEt();
294 fineGrain = (hfMask.at(0).at(hf_phi_index).at(absIeta - 29) != 0) && hcalColl[
i].
sample(nSample).fineGrain();
295 }
else if (
sign > 0) {
299 energy = hfMask.at(1).at(hf_phi_index).at(absIeta - 29) * hcalColl[
i].sample(nSample).compressedEt();
300 fineGrain = (hfMask.at(1).at(hf_phi_index).at(absIeta - 29) != 0) && hcalColl[
i].
sample(nSample).fineGrain();
314 maskedHcalTPs->push_back(hcalDigi);
T getParameter(std::string const &) const
void setSample(int i, const HcalTriggerPrimitiveSample &sam)
edm::SortedCollection< HcalTriggerPrimitiveDigi > HcalTrigPrimDigiCollection
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void setSample(int i, const EcalTriggerPrimitiveSample &sam)
Abs< T >::type abs(const T &t)
#define DEFINE_FWK_MODULE(type)
edm::SortedCollection< EcalTriggerPrimitiveDigi > EcalTrigPrimDigiCollection
void setPresamples(int ps)
const std::string & fullPath() const