16 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1,
17 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1
29 {{0, 1, 2, 3, 4}, {4, 3, 2, 1, 0}, {0, 1, 2, 3, 4}, {4, 3, 2, 1, 0}, {0, 1, 2, 3, 4}}};
49 tcc2dcc_ =
params.getUntrackedParameter<
bool>(
"tcc2dccData",
true);
50 srp2dcc_ =
params.getUntrackedParameter<
bool>(
"srp2dccData",
true);
51 fe2dcc_ =
params.getUntrackedParameter<
bool>(
"fe2dccData",
true);
52 fe2tcc_ =
params.getUntrackedParameter<
bool>(
"fe2tccData",
true);
84 std::cout <<
"==================================================================" 86 <<
" Event " <<
iEvent <<
"\n" 87 <<
"------------------------------------------------------------------" 139 char c =
data & 0x00FF;
140 f.write(&
c,
sizeof(
c));
141 c = (
data >> 8) & 0x00FF;
142 f.write(&
c,
sizeof(
c));
145 char c = (
data >> 8) & 0x00FF;
146 f.write(&
c,
sizeof(
c));
148 f.write(&
c,
sizeof(
c));
151 f << ((iWord % 8 == 0 && iWord != 0) ?
"\n" :
"") <<
"0x" << std::setfill(
'0') << std::setw(4) << std::hex <<
data 152 <<
"\t" <<
std::dec << std::setfill(
' ');
173 const std::vector<uint16_t> adcCount[nEbEta][nEbPhi])
const {
178 int chFrameLen = adcCount[0][0].size() + 1;
182 for (
int iZ0 = 0; iZ0 < 2; ++iZ0) {
183 for (
int iDccPhi0 = 0; iDccPhi0 <
nDccInPhi; ++iDccPhi0) {
192 s << basename <<
"_fe2dcc" << std::setfill(
'0') << std::setw(2) << iDcc1 << std::setfill(
' ') <<
ext;
193 std::ofstream
f(
s.str().c_str(), (
iEvent == 1 ? std::ios::ate : std::ios::app));
199 f << (
iEvent == 1 ?
"" :
"\n") <<
"[Event:" <<
iEvent <<
"]\n";
202 for (
int iTtEtaInSm0 = 0; iTtEtaInSm0 <
nTtSmEta; ++iTtEtaInSm0) {
203 int iTtEta0 = iZ0 *
nTtSmEta + iTtEtaInSm0;
204 for (
int iTtPhiInSm0 = 0; iTtPhiInSm0 <
nTtSmPhi; ++iTtPhiInSm0) {
209 for (
int stripId1 = 1; stripId1 <=
ttEdge; ++stripId1) {
210 uint16_t stripHeader =
211 0xF << 11 | (nPendingEvt & 0x3F) << 5 | (gmf & 0
x1) << 4 | (smf & 0x1) << 3 | (stripId1 & 0x7);
215 for (
int xtalId1 = 1; xtalId1 <=
ttEdge; ++xtalId1) {
216 uint16_t crystalHeader = 1 << 14 | (chFrameLen & 0xFF) << 4 | (monitorFlag & 0
x1) << 3 | (xtalId1 & 0x7);
218 fwrite(
f, crystalHeader, iWord);
222 elec2GeomNum(iTtEta0, iTtPhi0, stripId1, xtalId1, iEta0, iPhi0);
225 <<
"iEbTtEta0 = " << iTtEta0 <<
"\t" 226 <<
"iEbTtPhi0 = " << iTtPhi0 <<
"\t" 227 <<
"stripId1 = " << stripId1 <<
"\t" 228 <<
"xtalId1 = " << xtalId1 <<
"\t" 229 <<
"iEta0 = " << iEta0 <<
"\t" 230 <<
"iPhi0 = " << iPhi0 <<
"\t" 231 <<
"adc[5] = 0x" << std::hex << adcCount[iEta0][iPhi0][5] <<
std::dec <<
"\n";
234 const std::vector<uint16_t> &
adc = adcCount[iEta0][iPhi0];
235 for (
unsigned iSample = 0; iSample <
adc.size(); ++iSample) {
236 uint16_t
data =
adc[iSample] & 0x3FFF;
249 for (
int iZ0 = 0; iZ0 < 2; ++iZ0) {
250 for (
int iDccPhi0 = 0; iDccPhi0 <
nDccInPhi; ++iDccPhi0) {
256 s << basename <<
"_ab2dcc" << std::setfill(
'0') << std::setw(2) << iDcc1 << std::setfill(
' ') <<
getExt();
257 std::ofstream
f(
s.str().c_str(), (
iEvent == 1 ? std::ios::ate : std::ios::app));
265 f << (
iEvent == 1 ?
"" :
"\n") <<
"[Event:" <<
iEvent <<
"]\n";
268 const uint16_t le1 = 0;
269 const uint16_t le0 = 0;
270 const uint16_t h1 = 1;
271 const uint16_t nFlags = 68;
272 uint16_t
data = (h1 & 0x1) << 14 | (le1 & 0
x1) << 12 | (le0 & 0x1) << 11 | (nFlags & 0x7F);
279 for (
int iTtEtaInSm0 = 0; iTtEtaInSm0 <
nTtSmEta; ++iTtEtaInSm0) {
282 for (
int iTtPhiInSm0 = 0; iTtPhiInSm0 <
nTtSmPhi; ++iTtPhiInSm0) {
291 const int field = iFlag % 4;
296 data |= srf[iTtEta0][iTtPhi0] << (field * 3);
312 for (
int iZ0 = 0; iZ0 < 2; ++iZ0) {
313 for (
int iTccPhi0 = 0; iTccPhi0 <
nTccInPhi; ++iTccPhi0) {
321 const char *
ext =
".txt";
323 s << basename <<
"_tcc" << std::setfill(
'0') << std::setw(2) << iTcc1 << std::setfill(
' ') <<
ext;
324 std::ofstream fe2tcc(
s.str().c_str(), (
iEvent == 1 ? std::ios::ate : std::ios::app));
331 for (
int iTtEtaInSm0 = 0; iTtEtaInSm0 <
nTtSmEta; ++iTtEtaInSm0) {
332 int iTtEta0 = (iZ0 == 0) ? 27 - iTtEtaInSm0 : 28 + iTtEtaInSm0;
333 for (
int iTtPhiInSm0 = 0; iTtPhiInSm0 <
nTtSmPhi; ++iTtPhiInSm0) {
339 uint16_t tp_fe2tcc = (
tcp[iTtEta0][iTtPhi0] & 0x7ff);
343 <<
"iTtEta0 = " << iTtEta0 <<
"\t" 344 <<
"iTtPhi0 = " << iTtPhi0 <<
"\t" 345 <<
"iCh1 = " << iCh1 <<
"\t" 346 <<
"memPos = " << memPos <<
"\t" 347 <<
"tp = 0x" << std::setfill(
'0') << std::hex << std::setw(3) << tp_fe2tcc <<
std::dec 348 << std::setfill(
' ') <<
"\n";
350 fe2tcc << iCh1 <<
"\t" << memPos <<
"\t" << std::setfill(
'0') << std::hex <<
"0x" << std::setw(4) << tp_fe2tcc
352 <<
"0" <<
std::dec << std::setfill(
' ') <<
"\n";
356 fe2tcc << std::flush;
365 for (
int iZ0 = 0; iZ0 < 2; ++iZ0) {
366 for (
int iTccPhi0 = 0; iTccPhi0 <
nTccInPhi; ++iTccPhi0) {
374 const char *
ext =
".txt";
376 s << basename <<
"_tcc" << std::setfill(
'0') << std::setw(2) << iTcc1 << std::setfill(
' ') <<
ext;
379 s << basename <<
"_tcc2dcc" << std::setfill(
'0') << std::setw(2) << iTcc1 << std::setfill(
' ') <<
getExt();
380 std::ofstream dccF(
s.str().c_str(), (
iEvent == 1 ? std::ios::ate : std::ios::app));
383 std::cout <<
"Warning: failed to create or open file " <<
s.str() <<
".\n";
387 const uint16_t h1 = 1;
388 const uint16_t le1 = 0;
389 const uint16_t le0 = 0;
391 const uint16_t nTts = 68;
392 const uint16_t
data =
393 (h1 & 0x1) << 14 | (le1 & 0
x1) << 12 | (le0 & 0x1) << 11 | (
nSamples & 0xF) << 7 | (nTts & 0x7F);
394 dccF << (
iEvent == 1 ?
"" :
"\n") <<
"[Event:" <<
iEvent <<
"]\n";
399 for (
int iTtEtaInSm0 = 0; iTtEtaInSm0 <
nTtSmEta; ++iTtEtaInSm0) {
401 for (
int iTtPhiInSm0 = 0; iTtPhiInSm0 <
nTtSmPhi; ++iTtPhiInSm0) {
409 <<
"iTtEta0 = " << iTtEta0 <<
"\t" 410 <<
"iTtPhi0 = " << iTtPhi0 <<
"\t" 411 <<
"iCh1 = " << iCh1 <<
"\t" 412 <<
"memPos = " << memPos <<
"\t" 413 <<
"tp = 0x" << std::hex << tps[iTtEta0][iTtPhi0] <<
std::dec <<
"\n";
415 fwrite(dccF, tps[iTtEta0][iTtPhi0], iDccWord,
false);
424 const int odd = 1 << 15;
429 const int p[16] = {even, odd, odd, even, odd, even, even, odd, odd, even, even, odd, even, odd, odd, even};
431 a ^=
p[
a & 0xF] ^
p[(
a >> 4) & 0xF] ^
p[(
a >> 8) & 0xF] ^
p[
a >> 12 & 0xF] ^ odd;
435 int ebSrf[nTtEta][nTtPhi],
436 int eeSrf[
nEndcaps][nScX][nScY])
const {
441 if (hEeSrFlags.isValid()) {
444 int iZ0 =
flag.id().zside() > 0 ? 1 : 0;
445 int iX0 =
flag.id().ix() - 1;
446 int iY0 =
flag.id().iy() - 1;
450 eeSrf[iZ0][iX0][iY0] =
flag.value();
461 if (hEbSrFlags.isValid()) {
467 int iPhi0 =
flag.id().iphi() - 1;
472 ebSrf[iEbEta0][iPhi0] =
flag.value();
484 if (hEbDigis.isValid() && !hEbDigis->empty()) {
485 nSamples = hEbDigis->begin()->size();
488 const uint16_t suppressed = 0xFFFF;
490 adc[0][0] = std::vector<uint16_t>(
nSamples, suppressed);
492 for (
int iEbEta = 0; iEbEta <
nEbEta; ++iEbEta) {
493 for (
int iEbPhi = 0; iEbPhi <
nEbPhi; ++iEbPhi) {
494 adc[iEbEta][iEbPhi] =
adc[0][0];
497 if (hEbDigis.isValid()) {
510 if (iEta0 < 0 || iEta0 >=
nEbEta) {
511 std::cout <<
"iEta0 (= " << iEta0 <<
") is out of range (" 512 <<
"[0," <<
nEbEta - 1 <<
"])\n";
514 if (iPhi0 < 0 || iPhi0 >=
nEbPhi) {
515 std::cout <<
"iPhi0 (= " << iPhi0 <<
") is out of range (" 516 <<
"[0," <<
nEbPhi - 1 <<
"])\n";
520 std::cout << iEta0 <<
"\t" << iPhi0 <<
":\t";
526 "Found EB digis with different sample count! This " 527 "is not supported by EcalSimRawData.");
530 for (
int iSample = 0; iSample <
nSamples; ++iSample) {
532 uint16_t encodedAdc =
sample.raw();
533 adc[iEta0][iPhi0][iSample] = encodedAdc;
535 std::cout << (iSample > 0 ?
" " :
"") <<
"0x" << std::setw(4) << encodedAdc;
548 if (hTpDigis.isValid() && !hTpDigis->empty()) {
552 for (
int iTtEta0 = 0; iTtEta0 <
nTtEta; ++iTtEta0) {
553 for (
int iTtPhi0 = 0; iTtPhi0 <
nTtPhi; ++iTtPhi0) {
564 if (iTtEta0 < 0 || iTtEta0 >=
nTtEta) {
565 std::cout <<
"iTtEta0 (= " << iTtEta0 <<
") is out of range (" 568 if (iTtPhi0 < 0 || iTtPhi0 >=
nTtPhi) {
569 std::cout <<
"iTtPhi0 (= " << iTtPhi0 <<
") is out of range (" 570 <<
"[0," <<
nTtPhi - 1 <<
"])\n";
573 tcp[iTtEta0][iTtPhi0] =
tp[
tp.sampleOfInterest()].raw();
576 if (
tcp[iTtEta0][iTtPhi0] != 0) {
580 <<
"0x" << std::setw(4) <<
tcp[iTtEta0][iTtPhi0] <<
"\tcmssw indices: " <<
tp.id().ieta() <<
" " 581 <<
tp.id().iphi() <<
"\n";
std::string srDigiProducer_
void analyze(const edm::Event &, const edm::EventSetup &) override
static const int nDccInPhi
static const int nTccInPhi
static const int nEeTtEta
void genFeData(std::string &basename, int iEvent, const std::vector< uint16_t > adcCount[nEbEta][nEbPhi]) const
static const int nTtSmPhi
edm::EDGetTokenT< EBSrFlagCollection > ebSrFlagToken_
void elec2GeomNum(int ittEta0, int ittPhi0, int strip1, int ch1, int &iEta0, int &iPhi0) const
static const int nDccEndcap
std::vector< T >::const_iterator const_iterator
edm::EDGetTokenT< EcalTrigPrimDigiCollection > trigPrimDigisToken_[2]
void setHParity(uint16_t &a) const
void fwrite(std::ofstream &f, uint16_t data, int &iword, bool hpar=true) const
std::string digiProducer_
std::string eeSrFlagCollection_
std::string getExt() const
static const int nEndcaps
edm::EDGetTokenT< EESrFlagCollection > eeSrFlagToken_
edm::EDGetTokenT< EBDigiCollection > ebDigisToken_
static const int strip2Eta[nTtTypes][ttEdge]
std::string ebDigiCollection_
void getSrfs(const edm::Event &event, int ebSrf[nTtEta][nTtPhi], int eeSrf[nEndcaps][nScX][nScY]) const
static const int nTtPhisPerEbDcc
static const int nTccEndcap
void genSrData(std::string &basename, int iEvent, int ttf[nEbTtEta][nTtPhi]) const
int iEta2cIndex(int iEta) const
std::string ebSrFlagCollection_
static const int nEbTtEta
const_iterator begin() const
EcalSimRawData(const edm::ParameterSet &pset)
std::string tcpDigiCollection_
static const int nTtPhisPerEbTcc
const_iterator end() const
int iTtPhi2cIndex(int iTtPhi) const
static const int nEndcaps
std::string eeDigiCollection_
std::string tpDigiCollection_
int iTtEta2cIndex(int iTtEta) const
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
void getTp(const edm::Event &event, tokenType type, int tp[nTtEta][nTtPhi]) const
void genTccOut(std::string &basename, int iEvent, const int tps[nTtEta][nTtPhi]) const
char data[epos_bytes_allocation]
int iPhi2cIndex(int iPhi) const
Log< level::Warning, false > LogWarning
static const int stripCh2Phi[nTtTypes][ttEdge][ttEdge]
void getEbDigi(const edm::Event &event, std::vector< uint16_t > adc[nEbEta][nEbPhi]) const
static const int nTtSmEta
uint16_t *__restrict__ uint16_t const *__restrict__ adc
static const int ttType[nEbTtEta]
void genTccIn(std::string &basename, int iEvent, const int tps[nTtEta][nTtPhi]) const