6 basename_(iConfig.getUntrackedParameter<
std::
string>(
"FlatBaseName",
"ecal_tcc_")),
7 useIdentityLUT_(iConfig.getUntrackedParameter<
bool>(
"UseIdentityLUT",
false)),
8 sm_(iConfig.getUntrackedParameter<
int>(
"SuperModuleId", -1)),
9 fileEventOffset_(iConfig.getUntrackedParameter<
int>(
"FileEventOffset", 0)),
10 debug_(iConfig.getUntrackedParameter<
bool>(
"debugPrintFlag",
false)) {
13 produces<EcalTrigPrimDigiCollection>();
14 produces<EcalTrigPrimDigiCollection>(
"formatTCP");
20 static int current_bx = -1;
27 std::cout <<
"[EcalFEtoDigi::produce] producing event " << current_bx << std::endl;
32 std::vector<TCCinput>::const_iterator
it;
34 for (
int i = 0;
i <
N_SM;
i++) {
41 else if (
debug_ && (*it).input != 0)
43 <<
"\tsupermodule:" <<
sm_ <<
"\tevent: " << current_bx <<
"\tbx: " << (*it).bunchCrossing
44 <<
"\tvalue:0x" << std::setfill(
'0') << std::setw(4) << std::hex << (*it).input << std::setfill(
' ')
68 e_tpdigis->push_back(*e_digi);
75 e_tpdigisTcp->push_back(*e_digiTcp);
78 outfile << (*it).tower <<
'\t' << (*it).bunchCrossing <<
'\t' << std::setfill(
'0') << std::hex <<
"0x" 79 << std::setw(4) << (*it).input <<
'\t' <<
"0" <<
std::dec << std::setfill(
' ') << std::endl;
82 if (
debug_ && (*it).input != 0)
84 <<
"\tieta: " << e_digi->
id().
ieta() <<
"\tiphi: " << e_digi->
id().
iphi()
85 <<
"\tsize: " << e_digi->
size() <<
"\tfg: " << (e_digi->
fineGrain() ? 1 : 0) << std::hex <<
"\tEt: 0x" 86 << e_digi->
compressedEt() <<
" (0x" << (*it).get_energy() <<
")" 98 if (e_tpdigis->empty()) {
99 std::cout <<
"[EcalFEtoDigi] creating empty collection for the event!\n";
101 e_tpdigis->push_back(*e_digi);
111 std::cout <<
"\n[EcalFEtoDigi::readInput] Reading input data\n";
121 for (
int i = 0;
i <
N_SM;
i++) {
127 std::ifstream
f(
s.str().c_str());
130 std::cout <<
" opening " <<
s.str().c_str() <<
"..." << std::endl;
161 printf(
"\treading tower:%d bx:%d input:0x%x dummy:%2d\n",
tt,
bx,
val,
dummy);
171 std::cout <<
"[EcalFEtoDigi::readInput] Done reading." << std::endl;
179 static const int kTowersInPhi = 4;
181 int iTT =
data.tower;
185 int jtower = iTT - 1;
186 int etaTT = jtower / kTowersInPhi + 1;
189 phiTT = (SMid - 19) * kTowersInPhi + jtower % kTowersInPhi;
191 phiTT = (SMid - 1) * kTowersInPhi + kTowersInPhi - (jtower % kTowersInPhi) - 1;
203 "[EcalFEtoDigi] Creating EcalTrigTowerDetId " 204 "(SMid,itt)=(%d,%d)->(eta,phi)=(%d,%d) \n",
218 int Et =
data.get_energy();
219 bool tt_fg =
data.get_fg();
225 unsigned int lut_[1024];
229 for (
int i = 0;
i < 1024;
i++)
233 int lut_out = lut_[Et];
234 int ttFlag = (lut_out & 0x700) >> 8;
235 int cEt = (lut_out & 0xff);
240 "[EcalFEtoDigi] Creating sample; input:0x%X (Et:0x%x) cEt:0x%x " 241 "fg:%d ttflag:0x%x \n",
256 int Et =
data.get_energy();
257 bool tt_fg =
data.get_fg();
260 unsigned int lut_[1024];
264 for (
int i = 0;
i < 1024;
i++)
267 int lut_out = lut_[Et];
268 int ttFlag = (lut_out & 0x700) >> 8;
269 int tcpdata = ((ttFlag & 0x7) << 11) | ((tt_fg & 0x1) << 10) | (Et & 0x3ff);
280 if (
sm_ != -1 && (sm_ < 1 || sm_ > 36))
281 throw cms::Exception(
"EcalFEtoDigiInvalidDetId") <<
"EcalFEtoDigi: Adapt SM numbering convention.\n";
303 uint32_t lutGrp = 999;
304 if (itgrp != lutGrpMap.end())
305 lutGrp = itgrp->second;
309 if (itLut != lutMap.end()) {
310 const unsigned int *theLut = (itLut->second).getLut();
311 for (
unsigned int i = 0;
i < 1024;
i++)
bool fineGrain() const
get the fine-grain bit of interesting sample
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
int ieta() const
get the tower ieta
const edm::ESGetToken< EcalTPGLutGroup, EcalTPGLutGroupRcd > tpgLutGroupToken_
EcalFEtoDigi(const edm::ParameterSet &)
std::map< uint32_t, uint32_t >::const_iterator EcalTPGGroupsMapItr
const EcalTrigTowerDetId & id() const
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
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
unsigned towerId(DetId const &, EcalElectronicsMapping const *)
void setSample(int i, const EcalTriggerPrimitiveSample &sam)
const bool useIdentityLUT_
int compressedEt() const
get the encoded/compressed Et of interesting sample
constexpr uint32_t rawId() const
get the raw id
EcalTriggerPrimitiveSample create_TPSampleTcp(TCCinput, const edm::EventSetup &)
create EcalTriggerPrimitiveSample in tcp format (uncomrpessed energy)
const int fileEventOffset_
const std::string basename_
std::map< uint32_t, EcalTPGLut > EcalTPGLutMap
char data[epos_bytes_allocation]
int ttFlag() const
get the Trigger tower Flag of interesting sample
void getLUT(unsigned int *lut, const int towerId, const edm::EventSetup &) const
return the LUT from eventSetup
const edm::ESGetToken< EcalTPGLutIdMap, EcalTPGLutIdMapRcd > tpgLutIdMapToken_
void beginJob() override
method called once each job just before starting event loop
int iphi() const
get the tower iphi
EcalTriggerPrimitiveSample create_TPSample(TCCinput, const edm::EventSetup &)
create EcalTriggerPrimitiveSample from input data (line)
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)