16 produces<EcalTrigPrimDigiCollection>();
17 produces<EcalTrigPrimDigiCollection >(
"formatTCP");
27 static int current_bx = -1;
34 std::cout <<
"[EcalFEtoDigi::produce] producing event " << current_bx << std::endl;
36 std::auto_ptr<EcalTrigPrimDigiCollection>
38 std::auto_ptr<EcalTrigPrimDigiCollection>
41 std::vector<TCCinput>::const_iterator it;
53 if(
debug_ && (*it).input!=0 )
55 <<
"\tsupermodule:" <<
sm_
56 <<
"\tevent: " << current_bx
57 <<
"\tbx: " << (*it).bunchCrossing
58 <<
"\tvalue:0x" << std::setfill(
'0') << std::setw(4)
59 << std::hex << (*it).input << std::setfill(
' ') <<
std::dec
84 e_tpdigis->push_back(*e_digi);
91 e_tpdigisTcp->push_back(*e_digiTcp);
95 << (*it).bunchCrossing <<
'\t'<< std::setfill(
'0') << std::hex
96 <<
"0x" << std::setw(4) << (*it).input <<
'\t'
97 <<
"0" <<
std::dec << std::setfill(
' ')
101 if(
debug_ && (*it).input!=0 )
102 std::cout <<
"[EcalFEtoDigi] debug id: " << e_digi->
id() <<
"\n\t"
104 <<
"\tieta: " << e_digi->
id().
ieta()
105 <<
"\tiphi: " << e_digi->
id().
iphi()
106 <<
"\tsize: " << e_digi->
size()
110 <<
" (0x" << (*it).get_energy() <<
")"
111 <<
"\tttflag: 0x" << e_digi->
ttFlag()
125 if(e_tpdigis->size()==0) {
126 std::cout <<
"[EcalFEtoDigi] creating empty collection for the event!\n";
128 e_tpdigis->push_back(*e_digi);
131 iEvent.
put(e_tpdigis);
132 iEvent.
put(e_tpdigisTcp,
"formatTCP");
142 std::cout <<
"\n[EcalFEtoDigi::readInput] Reading input data\n";
159 std::ifstream
f(s.str().c_str());
162 std::cout <<
" opening " << s.str().c_str() <<
"..." << std::endl;
172 int tt;
int bx;
unsigned val;
int dummy;
176 tt=0; bx=-1; val=0x0; dummy=0;
177 f >> tt >> bx >> std::hex >> val >>
std::dec >> dummy;
179 if( !n_bx || (bx!=(
inputdata_[
i].back()).bunchCrossing) )
185 printf(
"\treading tower:%d bx:%d input:0x%x dummy:%2d\n",
196 std::cout <<
"[EcalFEtoDigi::readInput] Done reading." << std::endl;
206 static const int kTowersInPhi = 4;
208 int iTT = data.
tower;
213 int etaTT = jtower / kTowersInPhi +1;
216 phiTT = (SMid-19) * kTowersInPhi + jtower % kTowersInPhi;
218 phiTT = (SMid- 1) * kTowersInPhi + kTowersInPhi-(jtower % kTowersInPhi)-1;
223 if (phiTT <= 0) phiTT = 72+phiTT;
227 printf(
"[EcalFEtoDigi] Creating EcalTrigTowerDetId (SMid,itt)=(%d,%d)->(eta,phi)=(%d,%d) \n", SMid, iTT, etaTT, phiTT);
241 bool tt_fg = data.
get_fg();
247 unsigned int lut_[1024] ;
249 getLUT(lut_, tower, evtSetup) ;
251 for(
int i=0;
i<1024;
i++) lut_[
i] =
i ;
254 int lut_out = lut_[Et];
255 int ttFlag = (lut_out & 0x700) >> 8;
256 int cEt = (lut_out & 0xff );
260 printf(
"[EcalFEtoDigi] Creating sample; input:0x%X (Et:0x%x) cEt:0x%x fg:%d ttflag:0x%x \n",
261 data.
input, Et, cEt, tt_fg, ttFlag);
274 bool tt_fg = data.
get_fg();
277 unsigned int lut_[1024] ;
279 getLUT(lut_, tower, evtSetup) ;
281 for(
int i=0;
i<1024;
i++) lut_[
i] =
i ;
283 int lut_out = lut_[Et];
284 int ttFlag = (lut_out & 0x700) >> 8;
285 int tcpdata = ((ttFlag&0x7)<<11) | ((tt_fg & 0x1)<<10) | (Et & 0x3ff) ;
299 if(
sm_!=-1 && (sm_<1 || sm_>36))
301 <<
"EcalFEtoDigi: Adapt SM numbering convention.\n";
323 return (smid<=18) ? smid+55-1 : smid+37-19;
334 uint32_t lutGrp = 999 ;
335 if (itgrp != lutGrpMap.end()) lutGrp = itgrp->second ;
341 if (itLut != lutMap.end()) {
342 const unsigned int * theLut = (itLut->second).getLut() ;
343 for (
unsigned int i=0 ;
i<1024 ;
i++) lut[
i] = theLut[
i] ;
void getLUT(unsigned int *lut, const int towerId, const edm::EventSetup &) const
return the LUT from eventSetup
virtual void produce(edm::Event &, const edm::EventSetup &)
method called to produce the data
T getUntrackedParameter(std::string const &, T const &) const
EcalFEtoDigi(const edm::ParameterSet &)
std::map< uint32_t, uint32_t >::const_iterator EcalTPGGroupsMapItr
void readInput()
open and read in input (flat) data file
TCCInputData inputdata_[N_SM]
virtual void beginJob()
method called once each job just before starting event loop
int ieta() const
get the tower ieta
uint32_t rawId() const
get the raw id
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 setSample(int i, const EcalTriggerPrimitiveSample &sam)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
void get(HolderT &iHolder) const
virtual void endJob()
method called once each job just after ending the event loop
unsigned towerId(DetId const &)
int iphi() const
get the tower iphi
const EcalTrigTowerDetId & id() const
T const * product() 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
EcalTriggerPrimitiveSample create_TPSample(TCCinput, const edm::EventSetup &)
create EcalTriggerPrimitiveSample from input data (line)
int ttFlag() const
get the Trigger tower Flag of interesting sample
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)