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"))
30 produces<EcalTrigPrimDigiCollection>();
31 produces<HcalTrigPrimDigiCollection>();
75 if (
ecal.isValid()) { ecalColl = *
ecal; }
76 if (
hcal.isValid()) { hcalColl = *
hcal; }
85 if (!maskFileStream.is_open())
88 <<
"RCT mask file not opened" << std::endl;;
98 maskFileStream >> junk;
100 while (junk.compare(
"ECAL:") != 0);
103 std::vector<std::vector<std::vector<unsigned short> > > ecalMask(2,std::vector<std::vector<unsigned short> >(72,std::vector<unsigned short>(28,1)));
104 std::vector<std::vector<std::vector<unsigned short> > > hcalMask(2,std::vector<std::vector<unsigned short> >(72,std::vector<unsigned short>(28,1)));
105 std::vector<std::vector<std::vector<unsigned short> > > hfMask(2,std::vector<std::vector<unsigned short> >(18,std::vector<unsigned short>(8,1)));
109 for (
int i = 1;
i <= 72;
i++)
111 int phi_index = (72 + 18 -
i) % 72;
112 if (phi_index == 0) {phi_index = 72;}
114 for (
int j = 28;
j >= 1;
j--)
116 maskFileStream >> junk;
117 if (junk.compare(
"-") == 0)
119 else if ((junk.compare(
"X") == 0) || (junk.compare(
"x") == 0))
121 ecalMask.at(0).at(phi_index-1).at(
j-1) = 0;
125 std::cerr <<
"RCT mask producer: error -- unrecognized character" << std::endl;
128 for (
int j = 1;
j <= 28;
j++)
130 maskFileStream >> junk;
131 if(junk.compare(
"-") == 0)
133 else if((junk.compare(
"X") == 0) || (junk.compare(
"x") == 0))
135 ecalMask.at(1).at(phi_index-1).at(
j-1) = 0;
139 std::cerr <<
"RCT mask producer: error -- unrecognized character" << std::endl;
145 maskFileStream >> junk;
146 if (junk.compare(
"HCAL:") != 0)
149 <<
"RCT mask producer: error reading ECAL mask" << std::endl;;
156 for (
int i = 1;
i <= 72;
i++)
158 int phi_index = (72 + 18 -
i) % 72;
159 if (phi_index == 0) {phi_index = 72;}
161 for (
int j = 28;
j >= 1;
j--)
163 maskFileStream >> junk;
164 if (junk.compare(
"-") == 0)
166 else if ((junk.compare(
"X") == 0) || (junk.compare(
"x") == 0))
168 hcalMask.at(0).at(phi_index-1).at(
j-1) = 0;
172 std::cerr <<
"RCT mask producer: error -- unrecognized character" << std::endl;
175 for (
int j = 1;
j <= 28;
j++)
177 maskFileStream >> junk;
178 if(junk.compare(
"-") == 0)
180 else if((junk.compare(
"X") == 0) || (junk.compare(
"x") == 0))
182 hcalMask.at(1).at(phi_index-1).at(
j-1) = 0;
186 std::cerr <<
"RCT mask producer: error -- unrecognized character" << std::endl;
191 maskFileStream >> junk;
192 if (junk.compare(
"HF:") != 0)
195 <<
"RCT mask producer: error reading HCAL mask" << std::endl;;
199 for(
int i = 0;
i < 18;
i++)
202 for (
int j = 4;
j >= 1;
j--)
204 if (maskFileStream >> junk) {}
205 else {
std::cerr <<
"RCT mask producer: error reading HF mask" << std::endl; }
206 if (junk.compare(
"-") == 0)
208 else if ((junk.compare(
"X") == 0) || (junk.compare(
"x") == 0))
210 hfMask.at(0).at(
i).at(
j-1) = 0;
214 std::cerr <<
"RCT mask producer: error -- unrecognized character" << std::endl;
217 for (
int j = 1;
j <= 4;
j++)
219 if (maskFileStream >> junk) {}
220 else {
std::cerr <<
"RCT mask producer: error reading HF mask" << std::endl; }
221 if (junk.compare(
"-") == 0)
223 else if ((junk.compare(
"X") == 0) || (junk.compare(
"x") == 0))
225 hfMask.at(1).at(
i).at(
j-1) = 0;
229 std::cerr <<
"RCT mask producer: error -- unrecognized character" << std::endl;
236 maskFileStream.close();
242 std::auto_ptr<EcalTrigPrimDigiCollection>
244 std::auto_ptr<HcalTrigPrimDigiCollection>
246 maskedEcalTPs->reserve(56*72);
247 maskedHcalTPs->reserve(56*72+18*8);
248 int nEcalSamples = 0;
249 int nHcalSamples = 0;
251 for (
unsigned int i = 0;
i < ecalColl.size();
i++)
253 nEcalSamples = ecalColl[
i].size();
254 short ieta = (short) ecalColl[
i].
id().ieta();
255 unsigned short absIeta = (
unsigned short)
abs(ieta);
256 int sign = ieta / absIeta;
257 short iphi = (
unsigned short) ecalColl[
i].
id().iphi();
263 ecalDigi.
setSize(nEcalSamples);
265 for (
int nSample = 0; nSample < nEcalSamples; nSample++)
269 bool fineGrain =
false;
274 energy = ecalMask.at(0).at(iphi-1).at(absIeta-1) * ecalColl[
i].sample(nSample).compressedEt();
275 fineGrain = ecalMask.at(0).at(iphi-1).at(absIeta-1) * ecalColl[
i].sample(nSample).fineGrain();
280 energy = ecalMask.at(1).at(iphi-1).at(absIeta-1) * ecalColl[
i].sample(nSample).compressedEt();
281 fineGrain = ecalMask.at(1).at(iphi-1).at(absIeta-1) * ecalColl[
i].sample(nSample).fineGrain();
288 maskedEcalTPs->push_back(ecalDigi);
293 for (
unsigned int i = 0;
i < hcalColl.size();
i++)
295 nHcalSamples = hcalColl[
i].size();
297 short ieta = (short) hcalColl[
i].
id().ieta();
298 unsigned short absIeta = (
unsigned short)
abs(ieta);
299 int sign = ieta / absIeta;
300 short iphi = (
unsigned short) hcalColl[
i].
id().iphi();
313 hcalDigi.
setSize(nHcalSamples);
316 for (
int nSample = 0; nSample < nHcalSamples; nSample++)
320 bool fineGrain =
false;
326 energy = hcalMask.at(0).at(iphi-1).at(absIeta-1) * hcalColl[
i].sample(nSample).compressedEt();
327 fineGrain = hcalMask.at(0).at(iphi-1).at(absIeta-1) * hcalColl[
i].sample(nSample).fineGrain();
331 energy = hcalMask.at(1).at(iphi-1).at(absIeta-1) * hcalColl[
i].sample(nSample).compressedEt();
332 fineGrain = hcalMask.at(1).at(iphi-1).at(absIeta-1) * hcalColl[
i].sample(nSample).fineGrain();
335 else if ((absIeta >= 29) && (absIeta <= 32))
338 short hf_phi_index = iphi/4;
345 energy = hfMask.at(0).at(hf_phi_index).at(absIeta-29) * hcalColl[
i].sample(nSample).compressedEt();
346 fineGrain = hfMask.at(0).at(hf_phi_index).at(absIeta-29) * hcalColl[
i].sample(nSample).fineGrain();
352 energy = hfMask.at(1).at(hf_phi_index).at(absIeta-29) * hcalColl[
i].sample(nSample).compressedEt();
353 fineGrain = hfMask.at(1).at(hf_phi_index).at(absIeta-29) * hcalColl[
i].sample(nSample).fineGrain();
369 maskedHcalTPs->push_back(hcalDigi);
375 iEvent.
put(maskedEcalTPs);
376 iEvent.
put(maskedHcalTPs);
void setSample(int i, const HcalTriggerPrimitiveSample &sam)
edm::SortedCollection< HcalTriggerPrimitiveDigi > HcalTrigPrimDigiCollection
#define DEFINE_FWK_MODULE(type)
void setSample(int i, const EcalTriggerPrimitiveSample &sam)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
edm::SortedCollection< EcalTriggerPrimitiveDigi > EcalTrigPrimDigiCollection
void setPresamples(int ps)
std::string fullPath() const