16 produces<EcalTrigPrimDigiCollection>();
17 produces<EcalTrigPrimDigiCollection>(
"formatTCP");
23 static int current_bx = -1;
30 std::cout <<
"[EcalFEtoDigi::produce] producing event " << current_bx << std::endl;
35 std::vector<TCCinput>::const_iterator it;
37 for (
int i = 0;
i <
N_SM;
i++) {
44 else if (
debug_ && (*it).input != 0)
46 <<
"\tsupermodule:" <<
sm_ <<
"\tevent: " << current_bx <<
"\tbx: " << (*it).bunchCrossing
47 <<
"\tvalue:0x" << std::setfill(
'0') << std::setw(4) << std::hex << (*it).input << std::setfill(
' ')
71 e_tpdigis->push_back(*e_digi);
78 e_tpdigisTcp->push_back(*e_digiTcp);
81 outfile << (*it).tower <<
'\t' << (*it).bunchCrossing <<
'\t' << std::setfill(
'0') << std::hex <<
"0x" 82 << std::setw(4) << (*it).input <<
'\t' <<
"0" <<
std::dec << std::setfill(
' ') << std::endl;
85 if (
debug_ && (*it).input != 0)
87 <<
"\tieta: " << e_digi->
id().
ieta() <<
"\tiphi: " << e_digi->
id().
iphi()
88 <<
"\tsize: " << e_digi->
size() <<
"\tfg: " << (e_digi->
fineGrain() ? 1 : 0) << std::hex <<
"\tEt: 0x" 89 << e_digi->
compressedEt() <<
" (0x" << (*it).get_energy() <<
")" 101 if (e_tpdigis->empty()) {
102 std::cout <<
"[EcalFEtoDigi] creating empty collection for the event!\n";
104 e_tpdigis->push_back(*e_digi);
114 std::cout <<
"\n[EcalFEtoDigi::readInput] Reading input data\n";
124 for (
int i = 0;
i <
N_SM;
i++) {
130 std::ifstream
f(s.str().c_str());
133 std::cout <<
" opening " << s.str().c_str() <<
"..." << std::endl;
155 f >> tt >> bx >> std::hex >> val >>
std::dec >> dummy;
158 if (!n_bx || (bx != (
inputdata_[
i].back()).bunchCrossing))
164 printf(
"\treading tower:%d bx:%d input:0x%x dummy:%2d\n", tt, bx, val, dummy);
174 std::cout <<
"[EcalFEtoDigi::readInput] Done reading." << std::endl;
182 static const int kTowersInPhi = 4;
184 int iTT = data.
tower;
188 int jtower = iTT - 1;
189 int etaTT = jtower / kTowersInPhi + 1;
192 phiTT = (SMid - 19) * kTowersInPhi + jtower % kTowersInPhi;
194 phiTT = (SMid - 1) * kTowersInPhi + kTowersInPhi - (jtower % kTowersInPhi) - 1;
206 "[EcalFEtoDigi] Creating EcalTrigTowerDetId " 207 "(SMid,itt)=(%d,%d)->(eta,phi)=(%d,%d) \n",
222 bool tt_fg = data.
get_fg();
228 unsigned int lut_[1024];
230 getLUT(lut_, tower, evtSetup);
232 for (
int i = 0;
i < 1024;
i++)
236 int lut_out = lut_[Et];
237 int ttFlag = (lut_out & 0x700) >> 8;
238 int cEt = (lut_out & 0xff);
243 "[EcalFEtoDigi] Creating sample; input:0x%X (Et:0x%x) cEt:0x%x " 244 "fg:%d ttflag:0x%x \n",
260 bool tt_fg = data.
get_fg();
263 unsigned int lut_[1024];
265 getLUT(lut_, tower, evtSetup);
267 for (
int i = 0;
i < 1024;
i++)
270 int lut_out = lut_[Et];
271 int ttFlag = (lut_out & 0x700) >> 8;
272 int tcpdata = ((ttFlag & 0x7) << 11) | ((tt_fg & 0x1) << 10) | (Et & 0x3ff);
283 if (
sm_ != -1 && (sm_ < 1 || sm_ > 36))
284 throw cms::Exception(
"EcalFEtoDigiInvalidDetId") <<
"EcalFEtoDigi: Adapt SM numbering convention.\n";
308 uint32_t lutGrp = 999;
309 if (itgrp != lutGrpMap.end())
310 lutGrp = itgrp->second;
316 if (itLut != lutMap.end()) {
317 const unsigned int *theLut = (itLut->second).getLut();
318 for (
unsigned int i = 0;
i < 1024;
i++)
void getLUT(unsigned int *lut, const int towerId, const edm::EventSetup &) const
return the LUT from eventSetup
T getUntrackedParameter(std::string const &, T const &) const
const EcalTPGGroupsMap & getMap() const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
EcalFEtoDigi(const edm::ParameterSet &)
std::map< uint32_t, uint32_t >::const_iterator EcalTPGGroupsMapItr
constexpr uint32_t rawId() const
get the raw id
void readInput()
open and read in input (flat) data file
TCCInputData inputdata_[N_SM]
void produce(edm::Event &, const edm::EventSetup &) override
method called to produce the data
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
int ieta() const
get the tower ieta
int compressedEt() const
get the encoded/compressed Et of interesting sample
int SMidToTCCid(const int) const
translate input supermodule id into TCC id (barrel)
void endJob() override
method called once each job just after ending the event loop
void setSample(int i, const EcalTriggerPrimitiveSample &sam)
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
int iphi() const
get the tower iphi
const EcalTrigTowerDetId & id() const
EcalTriggerPrimitiveSample create_TPSampleTcp(TCCinput, const edm::EventSetup &)
create EcalTriggerPrimitiveSample in tcp format (uncomrpessed energy)
std::map< uint32_t, EcalTPGLut > EcalTPGLutMap
char data[epos_bytes_allocation]
bool fineGrain() const
get the fine-grain bit of interesting sample
void beginJob() override
method called once each job just before starting event loop
EcalTriggerPrimitiveSample create_TPSample(TCCinput, const edm::EventSetup &)
create EcalTriggerPrimitiveSample from input data (line)
int ttFlag() const
get the Trigger tower Flag of interesting sample
T const * product() const
std::map< uint32_t, uint32_t > EcalTPGGroupsMap
std::map< uint32_t, EcalTPGLut >::const_iterator EcalTPGLutMapItr
EcalTrigTowerDetId create_TTDetId(TCCinput)
create EcalTrigTowerDetId from input data (line)