CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
EcalSimRawData Class Reference

#include <EcalSimRawData.h>

Inheritance diagram for EcalSimRawData:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
 EcalSimRawData (const edm::ParameterSet &pset)
 
 ~EcalSimRawData () override=default
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

enum  tokenType { tcp = 0, tp = 1 }
 
enum  writeMode_t { littleEndian, bigEndian, ascii }
 

Private Member Functions

void checkGeometry (const edm::EventSetup &eventSetup)
 
void checkTriggerMap (const edm::EventSetup &eventSetup)
 
int cIndex2iTtEta (int iTtEta0) const
 
int cIndex2TtPhi (int iTtPhi0) const
 
void elec2GeomNum (int ittEta0, int ittPhi0, int strip1, int ch1, int &iEta0, int &iPhi0) const
 
void fwrite (std::ofstream &f, uint16_t data, int &iword, bool hpar=true) const
 
void genFeData (std::string &basename, int iEvent, const std::vector< uint16_t > adcCount[nEbEta][nEbPhi]) const
 
void genSrData (std::string &basename, int iEvent, int ttf[nEbTtEta][nTtPhi]) const
 
void genTccIn (std::string &basename, int iEvent, const int tps[nTtEta][nTtPhi]) const
 
void genTccOut (std::string &basename, int iEvent, const int tps[nTtEta][nTtPhi]) const
 
void getEbDigi (const edm::Event &event, std::vector< uint16_t > adc[nEbEta][nEbPhi]) const
 
std::string getExt () const
 
void getSrfs (const edm::Event &event, int ebSrf[nTtEta][nTtPhi], int eeSrf[nEndcaps][nScX][nScY]) const
 
void getTp (const edm::Event &event, tokenType type, int tp[nTtEta][nTtPhi]) const
 
int iEta2cIndex (int iEta) const
 
int iPhi2cIndex (int iPhi) const
 
int iTtEta2cIndex (int iTtEta) const
 
int iTtPhi2cIndex (int iTtPhi) const
 
void setHParity (uint16_t &a) const
 

Private Attributes

std::string basename_
 
int dccNum_
 
std::string digiProducer_
 
std::string ebDigiCollection_
 
edm::EDGetTokenT< EBDigiCollectionebDigisToken_
 
std::string ebSrFlagCollection_
 
edm::EDGetTokenT< EBSrFlagCollectionebSrFlagToken_
 
std::string eeDigiCollection_
 
std::string eeSrFlagCollection_
 
edm::EDGetTokenT< EESrFlagCollectioneeSrFlagToken_
 
std::unique_ptr< EcalSelectiveReadoutesr_
 
bool fe2dcc_
 
bool fe2tcc_
 
int iEvent
 
std::string srDigiProducer_
 
std::ofstream srfFile
 
bool srp2dcc_
 
bool tcc2dcc_
 
int tccInDefaultVal_
 
int tccNum_
 
std::string tcpDigiCollection_
 
const CaloGeometrytheGeometry
 
const EcalTrigTowerConstituentsMaptheTriggerTowerMap
 
std::string tpDigiCollection_
 
std::string tpProducer_
 
bool tpVerbose_
 
edm::EDGetTokenT< EcalTrigPrimDigiCollectiontrigPrimDigisToken_ [2]
 
std::ofstream ttfFile
 
writeMode_t writeMode_
 
bool xtalVerbose_
 

Static Private Attributes

static const int ebDccPhiEdge = 20
 
static const int ebTccPhiEdge = 20
 
static const int nDccEndcap = 9
 
static const int nDccInPhi = 18
 
static const int nEbEta = 170
 
static const int nEbPhi = 360
 
static const int nEbTtEta = nEbEta / ttEdge
 
static const int nEeTtEta = 11
 
static const int nEeX = 100
 
static const int nEeY = 100
 
static const int nEndcaps = 2
 
static const int nScX = 20
 
static const int nScY = 20
 
static const int nTccEndcap = 36
 
static const int nTccInPhi = 18
 
static const int nTtEta = nEbTtEta + 2 * nEeTtEta
 
static const int nTtPhi = nEbPhi / ttEdge
 
static const int nTtPhisPerEbDcc = 4
 
static const int nTtPhisPerEbTcc = 4
 
static const int nTtSmEta = 17
 
static const int nTtSmPhi = 4
 
static const int nTtTypes = 2
 
static const int scEdge = 5
 
static const int strip2Eta [nTtTypes][ttEdge]
 
static const int stripCh2Phi [nTtTypes][ttEdge][ttEdge]
 
static const int ttEdge = 5
 
static const int ttType [nEbTtEta]
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

The EcalSimRawData CMSSW module produces raw data from digis. The raw data are written into files which can be loaded into the TCC DCC and SRP boards in order to emulate the front-end. Only barrel is fully supported. The produced files for TCC assumes a special LUT in the TCC forged for FE emulation mode.

Module Parameters:

Definition at line 42 of file EcalSimRawData.h.

Member Enumeration Documentation

◆ tokenType

Enumerator
tcp 
tp 

Definition at line 59 of file EcalSimRawData.h.

◆ writeMode_t

Output format mode

littleEndian: little endian binary bigEndian: big endian binary ascii: ascii mode. The one accepted by the TCC, DCC and SRP board control software.

Enumerator
littleEndian 
bigEndian 
ascii 

Definition at line 187 of file EcalSimRawData.h.

Constructor & Destructor Documentation

◆ EcalSimRawData()

EcalSimRawData::EcalSimRawData ( const edm::ParameterSet pset)
explicit

Constructor

Parameters
psetCMSSW configuration

Definition at line 36 of file EcalSimRawData.cc.

References ascii, basename_, bigEndian, dccNum_, digiProducer_, ebDigiCollection_, ebDigisToken_, ebSrFlagCollection_, ebSrFlagToken_, eeDigiCollection_, eeSrFlagCollection_, eeSrFlagToken_, fe2dcc_, fe2tcc_, iEvent, ProducerED_cfi::InputTag, littleEndian, submitPVValidationJobs::params, srDigiProducer_, srp2dcc_, AlCaHLTBitMon_QueryRunRegistry::string, tcc2dcc_, tccInDefaultVal_, tccNum_, tcp, tcpDigiCollection_, tp, tpDigiCollection_, tpProducer_, tpVerbose_, trigPrimDigisToken_, EcalSimRawData_cfi::writeMode, writeMode_, and xtalVerbose_.

36  {
37  // sets up parameters:
38  digiProducer_ = params.getParameter<std::string>("unsuppressedDigiProducer");
39  ebDigiCollection_ = params.getParameter<std::string>("EBdigiCollection");
40  eeDigiCollection_ = params.getParameter<std::string>("EEdigiCollection");
41  srDigiProducer_ = params.getParameter<std::string>("srProducer");
42  ebSrFlagCollection_ = params.getParameter<std::string>("EBSrFlagCollection");
43  eeSrFlagCollection_ = params.getParameter<std::string>("EESrFlagCollection");
44  tpDigiCollection_ = params.getParameter<std::string>("trigPrimDigiCollection");
45  tcpDigiCollection_ = params.getParameter<std::string>("tcpDigiCollection");
46  tpProducer_ = params.getParameter<std::string>("trigPrimProducer");
47  xtalVerbose_ = params.getUntrackedParameter<bool>("xtalVerbose", false);
48  tpVerbose_ = params.getUntrackedParameter<bool>("tpVerbose", false);
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);
53  dccNum_ = params.getUntrackedParameter<int>("dccNum", -1);
54  tccNum_ = params.getUntrackedParameter<int>("tccNum", -1);
55  tccInDefaultVal_ = params.getUntrackedParameter<int>("tccInDefaultVal", 0xffff);
56  basename_ = params.getUntrackedParameter<std::string>("outputBaseName");
57 
58  iEvent = 0;
59 
60  std::string writeMode = params.getParameter<std::string>("writeMode");
61 
62  if (writeMode == std::string("littleEndian")) {
64  } else if (writeMode == std::string("bigEndian")) {
66  } else {
67  writeMode_ = ascii;
68  }
69 
70  eeSrFlagToken_ = consumes<EESrFlagCollection>(edm::InputTag(srDigiProducer_, eeSrFlagCollection_));
71  ebSrFlagToken_ = consumes<EBSrFlagCollection>(edm::InputTag(srDigiProducer_, ebSrFlagCollection_));
72  ebDigisToken_ = consumes<EBDigiCollection>(edm::InputTag(digiProducer_, ebDigiCollection_));
74  consumes<EcalTrigPrimDigiCollection>(edm::InputTag(tpProducer_, tcpDigiCollection_));
76  consumes<EcalTrigPrimDigiCollection>(edm::InputTag(tpProducer_, tpDigiCollection_));
77 }
std::string srDigiProducer_
writeMode_t writeMode_
edm::EDGetTokenT< EBSrFlagCollection > ebSrFlagToken_
edm::EDGetTokenT< EcalTrigPrimDigiCollection > trigPrimDigisToken_[2]
std::string digiProducer_
std::string eeSrFlagCollection_
edm::EDGetTokenT< EESrFlagCollection > eeSrFlagToken_
edm::EDGetTokenT< EBDigiCollection > ebDigisToken_
std::string ebDigiCollection_
std::string ebSrFlagCollection_
std::string tcpDigiCollection_
std::string basename_
std::string eeDigiCollection_
std::string tpDigiCollection_
std::string tpProducer_

◆ ~EcalSimRawData()

EcalSimRawData::~EcalSimRawData ( )
overridedefault

Destructor

Member Function Documentation

◆ analyze()

void EcalSimRawData::analyze ( const edm::Event event,
const edm::EventSetup es 
)
overridevirtual

Main method. Called back for each event. This method produced the raw data and write them to disk.

Implements edm::one::EDAnalyzerBase.

Definition at line 79 of file EcalSimRawData.cc.

References gpuClustering::adc, basename_, gather_cfg::cout, fe2dcc_, fe2tcc_, genFeData(), genSrData(), genTccIn(), genTccOut(), getEbDigi(), getSrfs(), getTp(), iEvent, nEbEta, nEbPhi, nEndcaps, nScX, nScY, nTtEta, nTtPhi, srp2dcc_, tcc2dcc_, tcp, tp, tpVerbose_, and xtalVerbose_.

79  {
80  // Event counter:
81  ++iEvent;
82 
83  if (xtalVerbose_ | tpVerbose_) {
84  std::cout << "=================================================================="
85  "====\n"
86  << " Event " << iEvent << "\n"
87  << "------------------------------------------------------------------"
88  << "----\n";
89  }
90 
91  if (fe2dcc_) {
92  std::vector<uint16_t> adc[nEbEta][nEbPhi];
95  }
96 
97  if (fe2tcc_) {
98  int tcp[nTtEta][nTtPhi] = {{0}};
101  }
102 
103  if (tcc2dcc_) {
104  int tp[nTtEta][nTtPhi] = {{0}};
107  }
108 
109  // SR flags:
110  int ebSrf[nTtEta][nTtPhi];
111  int eeSrf[nEndcaps][nScX][nScY];
112 
113  if (srp2dcc_) {
114  getSrfs(event, ebSrf, eeSrf);
115  genSrData(basename_, iEvent, ebSrf);
116  }
117 }
static const int nTtPhi
void genFeData(std::string &basename, int iEvent, const std::vector< uint16_t > adcCount[nEbEta][nEbPhi]) const
static const int nEbEta
static const int nScX
static const int nEbPhi
static const int nEndcaps
void getSrfs(const edm::Event &event, int ebSrf[nTtEta][nTtPhi], int eeSrf[nEndcaps][nScX][nScY]) const
void genSrData(std::string &basename, int iEvent, int ttf[nEbTtEta][nTtPhi]) const
static const int nScY
std::string basename_
void getTp(const edm::Event &event, tokenType type, int tp[nTtEta][nTtPhi]) const
static const int nTtEta
void genTccOut(std::string &basename, int iEvent, const int tps[nTtEta][nTtPhi]) const
void getEbDigi(const edm::Event &event, std::vector< uint16_t > adc[nEbEta][nEbPhi]) const
Definition: event.py:1
uint16_t *__restrict__ uint16_t const *__restrict__ adc
void genTccIn(std::string &basename, int iEvent, const int tps[nTtEta][nTtPhi]) const

◆ checkGeometry()

void EcalSimRawData::checkGeometry ( const edm::EventSetup eventSetup)
private

call these once an event, to make sure everything is up-to-date

◆ checkTriggerMap()

void EcalSimRawData::checkTriggerMap ( const edm::EventSetup eventSetup)
private

◆ cIndex2iTtEta()

int EcalSimRawData::cIndex2iTtEta ( int  iTtEta0) const
inlineprivate

Converse of iTtEta2cIndex

Parameters
iTtEta0c eta index of TT
stdCMSSW TT eta index

Definition at line 237 of file EcalSimRawData.h.

237 { return (iTtEta0 < 28) ? (iTtEta0 - 28) : (iTtEta0 - 27); }

◆ cIndex2TtPhi()

int EcalSimRawData::cIndex2TtPhi ( int  iTtPhi0) const
inlineprivate

Converse of iTtPhi2cIndex

Parameters
iTtPhi0phi index of TT
Returns
std CMSS TT index

Definition at line 243 of file EcalSimRawData.h.

243 { return iTtPhi0 + 1; }

◆ elec2GeomNum()

void EcalSimRawData::elec2GeomNum ( int  ittEta0,
int  ittPhi0,
int  strip1,
int  ch1,
int &  iEta0,
int &  iPhi0 
) const
private

Converts electronic number of an ECAL barrel channel to geometrical indices

Parameters
ittEta0trigger tower c index
ittPhi0trigger tower c index
strip1strip index within the TT. Runs from 1 to 5.
ch1channel electronics number within the VFE. Runs from 1 to 5.
[out]iEta0eta c index of the channel
[out]iPhi0eta c index of the channel

Definition at line 119 of file EcalSimRawData.cc.

References cms::cuda::assert(), nEbEta, nEbPhi, nEbTtEta, nTtPhi, strip2Eta, stripCh2Phi, ttEdge, and ttType.

Referenced by genFeData().

119  {
120  assert(0 <= ittEta0 && ittEta0 < nEbTtEta);
121  assert(0 <= ittPhi0 && ittPhi0 < nTtPhi);
122  assert(1 <= strip1 && strip1 <= ttEdge);
123  assert(1 <= ch1 && ch1 <= ttEdge);
124  const int type = ttType[ittEta0];
125  iEta0 = ittEta0 * ttEdge + strip2Eta[type][strip1 - 1];
126  iPhi0 = ittPhi0 * ttEdge + stripCh2Phi[type][strip1 - 1][ch1 - 1];
127  assert(0 <= iEta0 && iEta0 < nEbEta);
128  assert(0 <= iPhi0 && iPhi0 < nEbPhi);
129 }
static const int nTtPhi
static const int nEbEta
static const int nEbPhi
assert(be >=bs)
static const int strip2Eta[nTtTypes][ttEdge]
static const int nEbTtEta
static const int stripCh2Phi[nTtTypes][ttEdge][ttEdge]
static const int ttEdge
static const int ttType[nEbTtEta]

◆ fwrite()

void EcalSimRawData::fwrite ( std::ofstream &  f,
uint16_t  data,
int &  iword,
bool  hpar = true 
) const
private

Write a data 16-bit word into file according to selected format.

Parameters
fthe file stream to write to
datathe peace of data to write
[in,out]iwordpass zero when writing for the first time in a file, then the value returned by the previous call. Counts the number of words written into the file.
hparif true the horizontal odd word parity is set before writing the word into the file.

Definition at line 131 of file EcalSimRawData.cc.

References ascii, bigEndian, HltBtagPostValidation_cff::c, data, TauDecayModes::dec, f, littleEndian, setHParity(), and writeMode_.

Referenced by genFeData(), genSrData(), and genTccOut().

131  {
132  if (hpar) {
133  // set horizontal odd parity bit:
134  setHParity(data);
135  }
136 
137  switch (writeMode_) {
138  case littleEndian: {
139  char c = data & 0x00FF;
140  f.write(&c, sizeof(c));
141  c = (data >> 8) & 0x00FF;
142  f.write(&c, sizeof(c));
143  } break;
144  case bigEndian: {
145  char c = (data >> 8) & 0x00FF;
146  f.write(&c, sizeof(c));
147  c = data & 0x00FF;
148  f.write(&c, sizeof(c));
149  } break;
150  case ascii:
151  f << ((iWord % 8 == 0 && iWord != 0) ? "\n" : "") << "0x" << std::setfill('0') << std::setw(4) << std::hex << data
152  << "\t" << std::dec << std::setfill(' ');
153  break;
154  }
155  ++iWord;
156 }
writeMode_t writeMode_
void setHParity(uint16_t &a) const
double f[11][100]
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ genFeData()

void EcalSimRawData::genFeData ( std::string &  basename,
int  iEvent,
const std::vector< uint16_t >  adcCount[nEbEta][nEbPhi] 
) const
private

Generates FE crystal data

Parameters
basenamebase for the output file name. DCC number is appended to the name
iEventevent index
adcCountthe payload, the ADC count of the channels.

stripHeader |= parity(stripHeader) << 15;

Definition at line 171 of file EcalSimRawData.cc.

References gpuClustering::adc, ascii, gather_cfg::cout, data, dccNum_, TauDecayModes::dec, elec2GeomNum(), f, fwrite(), getExt(), iEvent, nDccEndcap, nDccInPhi, nTtPhi, nTtPhisPerEbDcc, nTtSmEta, nTtSmPhi, alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, ttEdge, writeMode_, testProducerWithPsetDescEmpty_cfi::x1, and xtalVerbose_.

Referenced by analyze().

173  {
174  int smf = 0;
175  int gmf = 0;
176  int nPendingEvt = 0;
177  int monitorFlag = 0;
178  int chFrameLen = adcCount[0][0].size() + 1;
179 
180  int iWord = 0;
181 
182  for (int iZ0 = 0; iZ0 < 2; ++iZ0) {
183  for (int iDccPhi0 = 0; iDccPhi0 < nDccInPhi; ++iDccPhi0) {
184  int iDcc1 = iDccPhi0 + iZ0 * nDccInPhi + nDccEndcap + 1;
185 
186  if (dccNum_ != -1 && dccNum_ != iDcc1)
187  continue;
188 
189  std::stringstream s;
190  s.str("");
191  const std::string &ext = getExt();
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));
194 
195  if (f.fail())
196  return;
197 
198  if (writeMode_ == ascii) {
199  f << (iEvent == 1 ? "" : "\n") << "[Event:" << iEvent << "]\n";
200  }
201 
202  for (int iTtEtaInSm0 = 0; iTtEtaInSm0 < nTtSmEta; ++iTtEtaInSm0) {
203  int iTtEta0 = iZ0 * nTtSmEta + iTtEtaInSm0;
204  for (int iTtPhiInSm0 = 0; iTtPhiInSm0 < nTtSmPhi; ++iTtPhiInSm0) {
205  // phi=0deg at middle of 1st barrel DCC:
206  int iTtPhi0 = -nTtPhisPerEbDcc / 2 + iDccPhi0 * nTtPhisPerEbDcc + iTtPhiInSm0;
207  if (iTtPhi0 < 0)
208  iTtPhi0 += nTtPhi;
209  for (int stripId1 = 1; stripId1 <= ttEdge; ++stripId1) {
210  uint16_t stripHeader =
211  0xF << 11 | (nPendingEvt & 0x3F) << 5 | (gmf & 0x1) << 4 | (smf & 0x1) << 3 | (stripId1 & 0x7);
213  fwrite(f, stripHeader, iWord);
214 
215  for (int xtalId1 = 1; xtalId1 <= ttEdge; ++xtalId1) {
216  uint16_t crystalHeader = 1 << 14 | (chFrameLen & 0xFF) << 4 | (monitorFlag & 0x1) << 3 | (xtalId1 & 0x7);
217  // crystalHeader |=parity(crystalHeader) << 15;
218  fwrite(f, crystalHeader, iWord);
219 
220  int iEta0;
221  int iPhi0;
222  elec2GeomNum(iTtEta0, iTtPhi0, stripId1, xtalId1, iEta0, iPhi0);
223  if (xtalVerbose_) {
224  std::cout << std::dec << "iDcc1 = " << iDcc1 << "\t"
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";
232  }
233 
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;
237  // data |= parity(data);
238  fwrite(f, data, iWord);
239  } // next time sample
240  } // next crystal in strip
241  } // next strip in TT
242  } // next TT along phi
243  } // next TT along eta
244  } // next DCC
245  } // next half-barrel
246 }
static const int nDccInPhi
writeMode_t writeMode_
static const int nTtPhi
static const int nTtSmPhi
void elec2GeomNum(int ittEta0, int ittPhi0, int strip1, int ch1, int &iEta0, int &iPhi0) const
static const int nDccEndcap
void fwrite(std::ofstream &f, uint16_t data, int &iword, bool hpar=true) const
std::string getExt() const
static const int nTtPhisPerEbDcc
double f[11][100]
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
Definition: memstream.h:15
static const int ttEdge
static const int nTtSmEta
uint16_t *__restrict__ uint16_t const *__restrict__ adc

◆ genSrData()

void EcalSimRawData::genSrData ( std::string &  basename,
int  iEvent,
int  ttf[nEbTtEta][nTtPhi] 
) const
private

Generates SR flags

Parameters
basenamebase for the output file name. DCC number is appended to the name
iEventevent index
thetrigger tower flags

Definition at line 248 of file EcalSimRawData.cc.

References ascii, data, dccNum_, f, fwrite(), getExt(), iEvent, nDccEndcap, nDccInPhi, nEeTtEta, nTtPhi, nTtPhisPerEbDcc, nTtSmEta, nTtSmPhi, alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, writeMode_, and testProducerWithPsetDescEmpty_cfi::x1.

Referenced by analyze().

248  {
249  for (int iZ0 = 0; iZ0 < 2; ++iZ0) {
250  for (int iDccPhi0 = 0; iDccPhi0 < nDccInPhi; ++iDccPhi0) {
251  int iDcc1 = iDccPhi0 + iZ0 * nDccInPhi + nDccEndcap + 1;
252  if (dccNum_ != -1 && dccNum_ != iDcc1)
253  continue;
254  std::stringstream s;
255  s.str("");
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));
258 
259  if (f.fail())
260  throw cms::Exception(std::string("Cannot create/open file ") + s.str() + ".");
261 
262  int iWord = 0;
263 
264  if (writeMode_ == ascii) {
265  f << (iEvent == 1 ? "" : "\n") << "[Event:" << iEvent << "]\n";
266  }
267 
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 & 0x1) << 12 | (le0 & 0x1) << 11 | (nFlags & 0x7F);
273 
274  fwrite(f, data, iWord, true);
275 
276  int iFlag = 0;
277  data = 0;
278 
279  for (int iTtEtaInSm0 = 0; iTtEtaInSm0 < nTtSmEta; ++iTtEtaInSm0) {
280  // int iTtEbEta0 = iZ0*nTtSmEta + iTtEtaInSm0;
281  int iTtEta0 = nEeTtEta + iZ0 * nTtSmEta + iTtEtaInSm0;
282  for (int iTtPhiInSm0 = 0; iTtPhiInSm0 < nTtSmPhi; ++iTtPhiInSm0) {
283  // phi=0deg at middle of 1st barrel DCC:
284  int iTtPhi0 = -nTtPhisPerEbDcc / 2 + iDccPhi0 * nTtPhisPerEbDcc + iTtPhiInSm0;
285  if (iTtPhi0 < 0)
286  iTtPhi0 += nTtPhi;
287  // flags are packed by four:
288  //|15 |14 |13-12 |11 9|8 6|5 3|2 0|
289  //| P | 0 | X X | srf i+3| srf i+2| srf i+1| srf i |
290  //| | | | field 3 |field 2 | field 1| field 0|
291  const int field = iFlag % 4;
292  // std::cout << "TtEta0: " << iTtEta0 << "\tTtPhi0: " << iTtPhi0 << "\n";
293  // std::cout << "#" << oct << (int)srf[iTtEta0][iTtPhi0] << "o ****> #" <<
294  // oct << (srf[iTtEta0][iTtPhi0] << (field*3)) << "o\n" << std::dec;
295 
296  data |= srf[iTtEta0][iTtPhi0] << (field * 3);
297 
298  if (field == 3) {
299  // std::cout << srf[iTtEta0][iTtPhi0] << "----> 0x" << std::hex << data <<
300  // "\n";
301  fwrite(f, data, iWord, true);
302  data = 0;
303  }
304  ++iFlag;
305  } // next TT along phi
306  } // next TT along eta
307  } // next DCC
308  } // next half-barrel
309 }
static const int nDccInPhi
writeMode_t writeMode_
static const int nTtPhi
static const int nEeTtEta
static const int nTtSmPhi
static const int nDccEndcap
void fwrite(std::ofstream &f, uint16_t data, int &iword, bool hpar=true) const
std::string getExt() const
static const int nTtPhisPerEbDcc
double f[11][100]
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
static const int nTtSmEta

◆ genTccIn()

void EcalSimRawData::genTccIn ( std::string &  basename,
int  iEvent,
const int  tps[nTtEta][nTtPhi] 
) const
private

Generates FE trigger primitives data

Parameters
basenamebase for the output file name. DCC number is appended to the name
iEventevent index
tpsthe payload, the trigger primitives

Definition at line 311 of file EcalSimRawData.cc.

References gather_cfg::cout, TauDecayModes::dec, iEvent, nTccEndcap, nTccInPhi, nTtPhi, nTtPhisPerEbTcc, nTtSmEta, nTtSmPhi, alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, tccNum_, tcp, and tpVerbose_.

Referenced by analyze().

311  {
312  for (int iZ0 = 0; iZ0 < 2; ++iZ0) {
313  for (int iTccPhi0 = 0; iTccPhi0 < nTccInPhi; ++iTccPhi0) {
314  int iTcc1 = iTccPhi0 + iZ0 * nTccInPhi + nTccEndcap + 1;
315 
316  if (tccNum_ != -1 && tccNum_ != iTcc1)
317  continue;
318 
319  std::stringstream s;
320  s.str("");
321  const char *ext = ".txt"; // only ascii mode supported for TCP
322 
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));
325 
326  if (fe2tcc.fail())
327  throw cms::Exception(std::string("Failed to create file ") + s.str() + ".");
328 
329  int memPos = iEvent - 1;
330  int iCh1 = 1;
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) {
334  // phi=0deg at middle of 1st barrel DCC:
335  int iTtPhi0 = -nTtPhisPerEbTcc / 2 + iTccPhi0 * nTtPhisPerEbTcc + iTtPhiInSm0;
336  iTtPhi0 += nTtPhisPerEbTcc * iTccPhi0;
337  if (iTtPhi0 < 0)
338  iTtPhi0 += nTtPhi;
339  uint16_t tp_fe2tcc = (tcp[iTtEta0][iTtPhi0] & 0x7ff); // keep only Et (9:0) and FineGrain (10)
340 
341  if (tpVerbose_ && tp_fe2tcc != 0) {
342  std::cout << std::dec << "iTcc1 = " << iTcc1 << "\t"
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";
349  }
350  fe2tcc << iCh1 << "\t" << memPos << "\t" << std::setfill('0') << std::hex << "0x" << std::setw(4) << tp_fe2tcc
351  << "\t"
352  << "0" << std::dec << std::setfill(' ') << "\n";
353  ++iCh1;
354  } // next TT along phi
355  } // next TT along eta
356  fe2tcc << std::flush;
357  fe2tcc.close();
358  } // next TCC
359  } // next half-barrel
360 }
static const int nTtPhi
static const int nTccInPhi
static const int nTtSmPhi
static const int nTccEndcap
static const int nTtPhisPerEbTcc
Definition: memstream.h:15
static const int nTtSmEta

◆ genTccOut()

void EcalSimRawData::genTccOut ( std::string &  basename,
int  iEvent,
const int  tps[nTtEta][nTtPhi] 
) const
private

Generates TCC->DCC data

Parameters
basenamebase for the output file name. DCC number is appended to the name
iEventevent index
tpsthe payload, the trigger primitives

Definition at line 362 of file EcalSimRawData.cc.

References gather_cfg::cout, data, TauDecayModes::dec, fwrite(), getExt(), iEvent, nEeTtEta, PresampleTask_cfi::nSamples, nTccEndcap, nTccInPhi, nTtPhi, nTtPhisPerEbTcc, nTtSmEta, nTtSmPhi, alignCSCRings::s, tccNum_, tpVerbose_, and testProducerWithPsetDescEmpty_cfi::x1.

Referenced by analyze().

362  {
363  int iDccWord = 0;
364 
365  for (int iZ0 = 0; iZ0 < 2; ++iZ0) {
366  for (int iTccPhi0 = 0; iTccPhi0 < nTccInPhi; ++iTccPhi0) {
367  int iTcc1 = iTccPhi0 + iZ0 * nTccInPhi + nTccEndcap + 1;
368 
369  if (tccNum_ != -1 && tccNum_ != iTcc1)
370  continue;
371 
372  std::stringstream s;
373  s.str("");
374  const char *ext = ".txt"; // only ascii mode supported for TCP
375 
376  s << basename << "_tcc" << std::setfill('0') << std::setw(2) << iTcc1 << std::setfill(' ') << ext;
377 
378  s.str("");
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));
381 
382  if (dccF.fail()) {
383  std::cout << "Warning: failed to create or open file " << s.str() << ".\n";
384  return;
385  }
386 
387  const uint16_t h1 = 1;
388  const uint16_t le1 = 0;
389  const uint16_t le0 = 0;
390  const uint16_t nSamples = 1;
391  const uint16_t nTts = 68;
392  const uint16_t data =
393  (h1 & 0x1) << 14 | (le1 & 0x1) << 12 | (le0 & 0x1) << 11 | (nSamples & 0xF) << 7 | (nTts & 0x7F);
394  dccF << (iEvent == 1 ? "" : "\n") << "[Event:" << iEvent << "]\n";
395  fwrite(dccF, data, iDccWord, false);
396 
397  int memPos = iEvent - 1;
398  int iCh1 = 1;
399  for (int iTtEtaInSm0 = 0; iTtEtaInSm0 < nTtSmEta; ++iTtEtaInSm0) {
400  int iTtEta0 = nEeTtEta + iZ0 * nTtSmEta + iTtEtaInSm0;
401  for (int iTtPhiInSm0 = 0; iTtPhiInSm0 < nTtSmPhi; ++iTtPhiInSm0) {
402  // phi=0deg at middle of 1st barrel DCC:
403  int iTtPhi0 = -nTtPhisPerEbTcc / 2 + iTccPhi0 * nTtPhisPerEbTcc + iTtPhiInSm0;
404  if (iTtPhi0 < 0)
405  iTtPhi0 += nTtPhi;
406 
407  if (tpVerbose_) {
408  std::cout << std::dec << "iTcc1 = " << iTcc1 << "\t"
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";
414  }
415  fwrite(dccF, tps[iTtEta0][iTtPhi0], iDccWord, false);
416  ++iCh1;
417  } // next TT along phi
418  } // next TT along eta
419  } // next TCC
420  } // next half-barrel
421 }
static const int nTtPhi
static const int nTccInPhi
static const int nEeTtEta
static const int nTtSmPhi
void fwrite(std::ofstream &f, uint16_t data, int &iword, bool hpar=true) const
std::string getExt() const
static const int nTccEndcap
static const int nTtPhisPerEbTcc
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
Definition: memstream.h:15
static const int nTtSmEta

◆ getEbDigi()

void EcalSimRawData::getEbDigi ( const edm::Event event,
std::vector< uint16_t >  adc[nEbEta][nEbPhi] 
) const
private

Retrieves barrel digis (APD ADC count).

Parameters
eventCMS event
adc[out] the adc counts: adc[iEta0][iPhi0][iTimeSample0]

Definition at line 480 of file EcalSimRawData.cc.

References gpuClustering::adc, gather_cfg::cout, TauDecayModes::dec, ebDigisToken_, Exception, hcalRecHitTable_cff::ieta, iEta2cIndex(), hcalRecHitTable_cff::iphi, iPhi2cIndex(), nEbEta, nEbPhi, PresampleTask_cfi::nSamples, ecalGpuTask_cfi::sample, and xtalVerbose_.

Referenced by analyze().

480  {
481  const auto &hEbDigis = event.getHandle(ebDigisToken_);
482 
483  int nSamples = 0;
484  if (hEbDigis.isValid() && !hEbDigis->empty()) { // there is at least one digi
485  nSamples = hEbDigis->begin()->size(); // gets the sample count from 1st digi
486  }
487 
488  const uint16_t suppressed = 0xFFFF;
489 
490  adc[0][0] = std::vector<uint16_t>(nSamples, suppressed);
491 
492  for (int iEbEta = 0; iEbEta < nEbEta; ++iEbEta) {
493  for (int iEbPhi = 0; iEbPhi < nEbPhi; ++iEbPhi) {
494  adc[iEbEta][iEbPhi] = adc[0][0];
495  }
496  }
497  if (hEbDigis.isValid()) {
498  if (xtalVerbose_)
499  std::cout << std::setfill('0');
500  for (EBDigiCollection::const_iterator it = hEbDigis->begin(); it != hEbDigis->end(); ++it) {
501  const EBDataFrame &frame = *it;
502 
503  int iEta0 = iEta2cIndex((frame.id()).ieta());
504  int iPhi0 = iPhi2cIndex((frame.id()).iphi());
505 
506  // std::cout << "xtl indices conv: (" << frame.id().ieta() << ","
507  // << frame.id().iphi() << ") -> ("
508  // << iEta0 << "," << iPhi0 << ")\n";
509 
510  if (iEta0 < 0 || iEta0 >= nEbEta) {
511  std::cout << "iEta0 (= " << iEta0 << ") is out of range ("
512  << "[0," << nEbEta - 1 << "])\n";
513  }
514  if (iPhi0 < 0 || iPhi0 >= nEbPhi) {
515  std::cout << "iPhi0 (= " << iPhi0 << ") is out of range ("
516  << "[0," << nEbPhi - 1 << "])\n";
517  }
518 
519  if (xtalVerbose_) {
520  std::cout << iEta0 << "\t" << iPhi0 << ":\t";
521  std::cout << std::hex;
522  }
523 
524  if (nSamples != frame.size()) {
525  throw cms::Exception("EcalSimRawData",
526  "Found EB digis with different sample count! This "
527  "is not supported by EcalSimRawData.");
528  }
529 
530  for (int iSample = 0; iSample < nSamples; ++iSample) {
531  const EcalMGPASample &sample = frame.sample(iSample);
532  uint16_t encodedAdc = sample.raw();
533  adc[iEta0][iPhi0][iSample] = encodedAdc;
534  if (xtalVerbose_) {
535  std::cout << (iSample > 0 ? " " : "") << "0x" << std::setw(4) << encodedAdc;
536  }
537  }
538  if (xtalVerbose_)
539  std::cout << "\n" << std::dec;
540  }
541  if (xtalVerbose_)
542  std::cout << std::setfill(' ');
543  }
544 }
static const int nEbEta
static const int nEbPhi
edm::EDGetTokenT< EBDigiCollection > ebDigisToken_
int iEta2cIndex(int iEta) const
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
int iPhi2cIndex(int iPhi) const
uint16_t *__restrict__ uint16_t const *__restrict__ adc

◆ getExt()

std::string EcalSimRawData::getExt ( ) const
private

Help function to get the file extension which depends on the output formats.

Definition at line 158 of file EcalSimRawData.cc.

References ascii, bigEndian, littleEndian, and writeMode_.

Referenced by genFeData(), genSrData(), and genTccOut().

158  {
159  switch (writeMode_) {
160  case littleEndian:
161  return ".le";
162  case bigEndian:
163  return ".be";
164  case ascii:
165  return ".txt";
166  default:
167  return ".?";
168  }
169 }
writeMode_t writeMode_

◆ getSrfs()

void EcalSimRawData::getSrfs ( const edm::Event event,
int  ebSrf[nTtEta][nTtPhi],
int  eeSrf[nEndcaps][nScX][nScY] 
) const
private

Computes the selective readout flags.

Parameters
[in]eventCMS event
[out]ebSrfthe computed SR flags for barrel
[out]eeSrfthe computed SR flags for endcaps

Definition at line 434 of file EcalSimRawData.cc.

References cms::cuda::assert(), ebSrFlagCollection_, ebSrFlagToken_, eeSrFlagCollection_, eeSrFlagToken_, RemoveAddSevLevel::flag, mps_fire::i, l1tTowerCalibrationProducer_cfi::iEta, nEbTtEta, nEeTtEta, nEndcaps, nScX, nScY, nTtEta, nTtPhi, and srDigiProducer_.

Referenced by analyze().

436  {
437  // EE
438  const auto &hEeSrFlags = event.getHandle(eeSrFlagToken_);
439  for (size_t i = 0; i < (nEndcaps * nScX * nScY); ((int *)eeSrf)[i++] = -1) {
440  };
441  if (hEeSrFlags.isValid()) {
442  for (EESrFlagCollection::const_iterator it = hEeSrFlags->begin(); it != hEeSrFlags->end(); ++it) {
443  const EESrFlag &flag = *it;
444  int iZ0 = flag.id().zside() > 0 ? 1 : 0;
445  int iX0 = flag.id().ix() - 1;
446  int iY0 = flag.id().iy() - 1;
447  assert(iZ0 >= 0 && iZ0 < nEndcaps);
448  assert(iX0 >= 0 && iX0 < nScX);
449  assert(iY0 >= 0 && iY0 < nScY);
450  eeSrf[iZ0][iX0][iY0] = flag.value();
451  }
452  } else {
453  edm::LogWarning("EcalSimRawData") << "EE SR flag not found (Product label: " << srDigiProducer_
454  << "Producet instance: " << eeSrFlagCollection_ << ")";
455  }
456 
457  // EB
458  const auto &hEbSrFlags = event.getHandle(ebSrFlagToken_);
459  for (size_t i = 0; i < (nTtEta * nTtPhi); ((int *)ebSrf)[i++] = -1) {
460  };
461  if (hEbSrFlags.isValid()) {
462  for (EBSrFlagCollection::const_iterator it = hEbSrFlags->begin(); it != hEbSrFlags->end(); ++it) {
463  const EBSrFlag &flag = *it;
464  int iEta = flag.id().ieta();
465  int iEta0 = iEta + nTtEta / 2 - (iEta >= 0 ? 1 : 0); // 0->55 from eta=-3 to eta=3
466  int iEbEta0 = iEta0 - nEeTtEta; // 0->33 from eta=-1.48 to eta=1.48
467  int iPhi0 = flag.id().iphi() - 1;
468 
469  assert(iEbEta0 >= 0 && iEbEta0 < nEbTtEta);
470  assert(iPhi0 >= 0 && iPhi0 < nTtPhi);
471 
472  ebSrf[iEbEta0][iPhi0] = flag.value();
473  }
474  } else {
475  edm::LogWarning("EcalSimRawData") << "EB SR flag not found (Product label: " << srDigiProducer_
476  << "Producet instance: " << ebSrFlagCollection_ << ")";
477  }
478 }
std::string srDigiProducer_
static const int nTtPhi
static const int nEeTtEta
static const int nScX
edm::EDGetTokenT< EBSrFlagCollection > ebSrFlagToken_
std::vector< T >::const_iterator const_iterator
std::string eeSrFlagCollection_
assert(be >=bs)
static const int nEndcaps
edm::EDGetTokenT< EESrFlagCollection > eeSrFlagToken_
std::string ebSrFlagCollection_
static const int nEbTtEta
static const int nScY
static const int nTtEta
Log< level::Warning, false > LogWarning

◆ getTp()

void EcalSimRawData::getTp ( const edm::Event event,
EcalSimRawData::tokenType  type,
int  tp[nTtEta][nTtPhi] 
) const
private

Extracts the trigger primitive (TP). The collection name parameter permits to select either the TCP Fenix output or the TCC output. Note: TCP output is only valid for the barrel.

Parameters
eventCMS event
collNamelabel of the EDM collection containing the TP.
tp[out] the trigger primitives

Definition at line 546 of file EcalSimRawData.cc.

References edm::SortedCollection< T, SORT >::begin(), trigObjTnPSource_cfi::collName, gather_cfg::cout, edm::SortedCollection< T, SORT >::end(), iTtEta2cIndex(), iTtPhi2cIndex(), nEbTtEta, nTtEta, nTtPhi, AlCaHLTBitMon_QueryRunRegistry::string, tccInDefaultVal_, tcp, tcpDigiCollection_, tp, tpDigiCollection_, tpVerbose_, and trigPrimDigisToken_.

Referenced by analyze().

546  {
547  const auto &hTpDigis = event.getHandle(trigPrimDigisToken_[type]);
548  if (hTpDigis.isValid() && !hTpDigis->empty()) {
549  const EcalTrigPrimDigiCollection &tpDigis = *hTpDigis.product();
550 
551  // EcalSelectiveReadout::ttFlag_t ttf[nTtEta][nTtPhi];
552  for (int iTtEta0 = 0; iTtEta0 < nTtEta; ++iTtEta0) {
553  for (int iTtPhi0 = 0; iTtPhi0 < nTtPhi; ++iTtPhi0) {
554  tcp[iTtEta0][iTtPhi0] = tccInDefaultVal_;
555  }
556  }
557  if (tpVerbose_) {
558  std::cout << std::setfill('0');
559  }
560  for (EcalTrigPrimDigiCollection::const_iterator it = tpDigis.begin(); it != tpDigis.end(); ++it) {
561  const EcalTriggerPrimitiveDigi &tp = *it;
562  int iTtEta0 = iTtEta2cIndex(tp.id().ieta());
563  int iTtPhi0 = iTtPhi2cIndex(tp.id().iphi());
564  if (iTtEta0 < 0 || iTtEta0 >= nTtEta) {
565  std::cout << "iTtEta0 (= " << iTtEta0 << ") is out of range ("
566  << "[0," << nEbTtEta - 1 << "])\n";
567  }
568  if (iTtPhi0 < 0 || iTtPhi0 >= nTtPhi) {
569  std::cout << "iTtPhi0 (= " << iTtPhi0 << ") is out of range ("
570  << "[0," << nTtPhi - 1 << "])\n";
571  }
572 
573  tcp[iTtEta0][iTtPhi0] = tp[tp.sampleOfInterest()].raw();
574 
575  if (tpVerbose_) {
576  if (tcp[iTtEta0][iTtPhi0] != 0) { // print non-zero values only
578  std::cout << collName << (collName.empty() ? "" : " ") << "TP(" << std::setw(2) << iTtEta0 << "," << iTtPhi0
579  << ") = "
580  << "0x" << std::setw(4) << tcp[iTtEta0][iTtPhi0] << "\tcmssw indices: " << tp.id().ieta() << " "
581  << tp.id().iphi() << "\n";
582  }
583  }
584  } // next TP
585  if (tpVerbose_)
586  std::cout << std::setfill(' ');
587  }
588 }
static const int nTtPhi
std::vector< T >::const_iterator const_iterator
edm::EDGetTokenT< EcalTrigPrimDigiCollection > trigPrimDigisToken_[2]
static const int nEbTtEta
const_iterator begin() const
std::string tcpDigiCollection_
const_iterator end() const
int iTtPhi2cIndex(int iTtPhi) const
std::string tpDigiCollection_
int iTtEta2cIndex(int iTtEta) const
static const int nTtEta

◆ iEta2cIndex()

int EcalSimRawData::iEta2cIndex ( int  iEta) const
inlineprivate

Converts std CMSSW crystal eta index into a c-index (contiguous integer starting from 0 and increasing with pseudo-rapidity).

Parameters
iEtastd CMSSW crystal eta index
Returns
the c-array index

Definition at line 211 of file EcalSimRawData.h.

References l1tTowerCalibrationProducer_cfi::iEta.

Referenced by getEbDigi().

211 { return (iEta < 0) ? iEta + 85 : iEta + 84; }

◆ iPhi2cIndex()

int EcalSimRawData::iPhi2cIndex ( int  iPhi) const
inlineprivate

Converts std CMSSW crystal phi index into a c-index (contiguous integer starting from 0 at phi=0deg and increasing with phi).

Parameters
iPhistd CMSSW crystal phi index
Returns
the c-array index

Definition at line 218 of file EcalSimRawData.h.

References nEbPhi.

Referenced by getEbDigi().

218  {
219  int iPhi0 = iPhi - 11;
220  if (iPhi0 < 0)
221  iPhi0 += nEbPhi;
222  return iPhi0;
223  }
static const int nEbPhi

◆ iTtEta2cIndex()

int EcalSimRawData::iTtEta2cIndex ( int  iTtEta) const
inlineprivate

Converts std CMSSW ECAL trigger tower eta index into a c-index (contiguous integer starting from 0 and increasing with pseudo-rapidity).

Parameters
iEtastd CMSSW trigger tower eta index
Returns
the c-array index

Definition at line 231 of file EcalSimRawData.h.

Referenced by getTp().

231 { return (iTtEta < 0) ? (iTtEta + 28) : (iTtEta + 27); }

◆ iTtPhi2cIndex()

int EcalSimRawData::iTtPhi2cIndex ( int  iTtPhi) const
inlineprivate

Converts std CMSSW ECAL trigger tower phi index into a c-index (contiguous integer starting from 0 at phi=0deg and increasing with phi).

Parameters
iPhistd CMSSW ECAL trigger tower phi index
Returns
the c-array index

Definition at line 250 of file EcalSimRawData.h.

Referenced by getTp().

250 { return iTtPhi - 1; }

◆ setHParity()

void EcalSimRawData::setHParity ( uint16_t &  a) const
private

Definition at line 423 of file EcalSimRawData.cc.

References a, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by fwrite().

423  {
424  const int odd = 1 << 15;
425  const int even = 0;
426  // parity bit of numbers from 0x0 to 0xF:
427  // 0 1 2 3 4 5 6 7 8 9 A B C
428  // D E F
429  const int p[16] = {even, odd, odd, even, odd, even, even, odd, odd, even, even, odd, even, odd, odd, even};
430  // inverts parity bit (LSB) of 'a' in case of even parity:
431  a ^= p[a & 0xF] ^ p[(a >> 4) & 0xF] ^ p[(a >> 8) & 0xF] ^ p[a >> 12 & 0xF] ^ odd;
432 }
double a
Definition: hdecay.h:121

Member Data Documentation

◆ basename_

std::string EcalSimRawData::basename_
private

basename for output files

Definition at line 444 of file EcalSimRawData.h.

Referenced by analyze(), and EcalSimRawData().

◆ dccNum_

int EcalSimRawData::dccNum_
private

Index of the DCC, FE data must be produced for. -1 for all TTCs

Definition at line 436 of file EcalSimRawData.h.

Referenced by EcalSimRawData(), genFeData(), and genSrData().

◆ digiProducer_

std::string EcalSimRawData::digiProducer_
private

Name of module/plugin/producer making digis

Definition at line 348 of file EcalSimRawData.h.

Referenced by EcalSimRawData().

◆ ebDccPhiEdge

const int EcalSimRawData::ebDccPhiEdge = 20
staticprivate

Number of barrel crystals along phi covered by a DCC

Definition at line 145 of file EcalSimRawData.h.

◆ ebDigiCollection_

std::string EcalSimRawData::ebDigiCollection_
private

EB digi product instance name

Definition at line 352 of file EcalSimRawData.h.

Referenced by EcalSimRawData().

◆ ebDigisToken_

edm::EDGetTokenT<EBDigiCollection> EcalSimRawData::ebDigisToken_
private

Definition at line 448 of file EcalSimRawData.h.

Referenced by EcalSimRawData(), and getEbDigi().

◆ ebSrFlagCollection_

std::string EcalSimRawData::ebSrFlagCollection_
private

EB SRP flag digi product instance name

Definition at line 364 of file EcalSimRawData.h.

Referenced by EcalSimRawData(), and getSrfs().

◆ ebSrFlagToken_

edm::EDGetTokenT<EBSrFlagCollection> EcalSimRawData::ebSrFlagToken_
private

Definition at line 447 of file EcalSimRawData.h.

Referenced by EcalSimRawData(), and getSrfs().

◆ ebTccPhiEdge

const int EcalSimRawData::ebTccPhiEdge = 20
staticprivate

number of TTs along phi of a TCC sector

Definition at line 133 of file EcalSimRawData.h.

◆ eeDigiCollection_

std::string EcalSimRawData::eeDigiCollection_
private

EE digi product instance name

Definition at line 356 of file EcalSimRawData.h.

Referenced by EcalSimRawData().

◆ eeSrFlagCollection_

std::string EcalSimRawData::eeSrFlagCollection_
private

EE SRP flag digi product instancename

Definition at line 368 of file EcalSimRawData.h.

Referenced by EcalSimRawData(), and getSrfs().

◆ eeSrFlagToken_

edm::EDGetTokenT<EESrFlagCollection> EcalSimRawData::eeSrFlagToken_
private

Definition at line 446 of file EcalSimRawData.h.

Referenced by EcalSimRawData(), and getSrfs().

◆ esr_

std::unique_ptr<EcalSelectiveReadout> EcalSimRawData::esr_
private

Selective readout simulator

Definition at line 420 of file EcalSimRawData.h.

◆ fe2dcc_

bool EcalSimRawData::fe2dcc_
private

Switch for data of FE->DCC link

Definition at line 408 of file EcalSimRawData.h.

Referenced by analyze(), and EcalSimRawData().

◆ fe2tcc_

bool EcalSimRawData::fe2tcc_
private

Switch for data of FE->TCC link

Definition at line 412 of file EcalSimRawData.h.

Referenced by analyze(), and EcalSimRawData().

◆ iEvent

int EcalSimRawData::iEvent
private

Definition at line 61 of file EcalSimRawData.h.

Referenced by analyze(), EcalSimRawData(), genFeData(), genSrData(), genTccIn(), and genTccOut().

◆ nDccEndcap

const int EcalSimRawData::nDccEndcap = 9
staticprivate

Number of DCCs for a single endcap

Definition at line 129 of file EcalSimRawData.h.

Referenced by genFeData(), and genSrData().

◆ nDccInPhi

const int EcalSimRawData::nDccInPhi = 18
staticprivate

Number of barrel DCCs along Phi

Definition at line 125 of file EcalSimRawData.h.

Referenced by genFeData(), and genSrData().

◆ nEbEta

const int EcalSimRawData::nEbEta = 170
staticprivate

Number of crystals in ECAL barrel along eta

Definition at line 65 of file EcalSimRawData.h.

Referenced by analyze(), elec2GeomNum(), and getEbDigi().

◆ nEbPhi

const int EcalSimRawData::nEbPhi = 360
staticprivate

Number of crystals in ECAL barrel along phi

Definition at line 69 of file EcalSimRawData.h.

Referenced by analyze(), elec2GeomNum(), getEbDigi(), and iPhi2cIndex().

◆ nEbTtEta

const int EcalSimRawData::nEbTtEta = nEbEta / ttEdge
staticprivate

Number of TTs along Ecal barrel eta

Definition at line 113 of file EcalSimRawData.h.

Referenced by elec2GeomNum(), getSrfs(), and getTp().

◆ nEeTtEta

const int EcalSimRawData::nEeTtEta = 11
staticprivate

Number of TTs along eta for one endcap.

Definition at line 117 of file EcalSimRawData.h.

Referenced by genSrData(), genTccOut(), and getSrfs().

◆ nEeX

const int EcalSimRawData::nEeX = 100
staticprivate

X-edge of endcap (x,y)- crystal grid

Definition at line 73 of file EcalSimRawData.h.

◆ nEeY

const int EcalSimRawData::nEeY = 100
staticprivate

Y-edge of endcap (x,y)- crystal grid

Definition at line 77 of file EcalSimRawData.h.

◆ nEndcaps

const int EcalSimRawData::nEndcaps = 2
staticprivate

Number of endcaps

Definition at line 81 of file EcalSimRawData.h.

Referenced by analyze(), and getSrfs().

◆ nScX

const int EcalSimRawData::nScX = 20
staticprivate

Maximum number of supercrystal along x axis

Definition at line 89 of file EcalSimRawData.h.

Referenced by analyze(), and getSrfs().

◆ nScY

const int EcalSimRawData::nScY = 20
staticprivate

Maximum number of supercrystal along y axis

Definition at line 93 of file EcalSimRawData.h.

Referenced by analyze(), and getSrfs().

◆ nTccEndcap

const int EcalSimRawData::nTccEndcap = 36
staticprivate

Number of TCCs for a single endcap

Definition at line 141 of file EcalSimRawData.h.

Referenced by genTccIn(), and genTccOut().

◆ nTccInPhi

const int EcalSimRawData::nTccInPhi = 18
staticprivate

Number of Barrel TTCs along phi

Definition at line 137 of file EcalSimRawData.h.

Referenced by genTccIn(), and genTccOut().

◆ nTtEta

const int EcalSimRawData::nTtEta = nEbTtEta + 2 * nEeTtEta
staticprivate

Number of TTs along ECAL eta

Definition at line 121 of file EcalSimRawData.h.

Referenced by analyze(), getSrfs(), and getTp().

◆ nTtPhi

const int EcalSimRawData::nTtPhi = nEbPhi / ttEdge
staticprivate

Number of TTs along Ecal Phi

Definition at line 109 of file EcalSimRawData.h.

Referenced by analyze(), elec2GeomNum(), genFeData(), genSrData(), genTccIn(), genTccOut(), getSrfs(), and getTp().

◆ nTtPhisPerEbDcc

const int EcalSimRawData::nTtPhisPerEbDcc = 4
staticprivate

Number of trigger towers alng phi covered by a DCC

Definition at line 149 of file EcalSimRawData.h.

Referenced by genFeData(), and genSrData().

◆ nTtPhisPerEbTcc

const int EcalSimRawData::nTtPhisPerEbTcc = 4
staticprivate

Number of trigger towers alng phi covered by a TCC

Definition at line 153 of file EcalSimRawData.h.

Referenced by genTccIn(), and genTccOut().

◆ nTtSmEta

const int EcalSimRawData::nTtSmEta = 17
staticprivate

Number of TTs along SM eta

Definition at line 105 of file EcalSimRawData.h.

Referenced by genFeData(), genSrData(), genTccIn(), and genTccOut().

◆ nTtSmPhi

const int EcalSimRawData::nTtSmPhi = 4
staticprivate

Number of TTs along SM phi

Definition at line 101 of file EcalSimRawData.h.

Referenced by genFeData(), genSrData(), genTccIn(), and genTccOut().

◆ nTtTypes

const int EcalSimRawData::nTtTypes = 2
staticprivate

Number of barrel trigger tower types (in term of VFE card orientation)

Definition at line 157 of file EcalSimRawData.h.

◆ scEdge

const int EcalSimRawData::scEdge = 5
staticprivate

Supercrystal edge in number of crystals

Definition at line 85 of file EcalSimRawData.h.

◆ srDigiProducer_

std::string EcalSimRawData::srDigiProducer_
private

Label of SR flags and suppressed digis

Definition at line 360 of file EcalSimRawData.h.

Referenced by EcalSimRawData(), and getSrfs().

◆ srfFile

std::ofstream EcalSimRawData::srfFile
private

Output file for selective readout flags

Definition at line 428 of file EcalSimRawData.h.

◆ srp2dcc_

bool EcalSimRawData::srp2dcc_
private

Switch for data of SRP->DCC link

Definition at line 400 of file EcalSimRawData.h.

Referenced by analyze(), and EcalSimRawData().

◆ strip2Eta

const int EcalSimRawData::strip2Eta
staticprivate
Initial value:
= {
{4, 3, 2, 1, 0},
{0, 1, 2, 3, 4}
}

Maps strip_id to eta index within a TT. strip2Eta[iTtType][strip_id-1] will be the eta index of channels with strip_id 'strip_id'. The eta index runs from 0 to 4 and increasing with the eta of the std CMS coordinates.

Definition at line 178 of file EcalSimRawData.h.

Referenced by elec2GeomNum().

◆ stripCh2Phi

const int EcalSimRawData::stripCh2Phi
staticprivate
Initial value:
= {
{{4, 3, 2, 1, 0},
{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}, {4, 3, 2, 1, 0}, {0, 1, 2, 3, 4}, {4, 3, 2, 1, 0}, {0, 1, 2, 3, 4}}}

Maps (strip_id, channel_id) to phi index within a TT. stripCh2Phi[iTtType][strip_id-1][ch_id-1] will be the phi index of the TT of type iTtType with strip ID 'strip_id' and channel VFE id 'ch_id'. The phi runs from 0 to 4 and increases with the phi of std CMS coordinates.

Definition at line 171 of file EcalSimRawData.h.

Referenced by elec2GeomNum().

◆ tcc2dcc_

bool EcalSimRawData::tcc2dcc_
private

Switch for data of TCC->DCC link

Definition at line 404 of file EcalSimRawData.h.

Referenced by analyze(), and EcalSimRawData().

◆ tccInDefaultVal_

int EcalSimRawData::tccInDefaultVal_
private

default TriggerPrimitive values if the trigger tower is abscent

Definition at line 440 of file EcalSimRawData.h.

Referenced by EcalSimRawData(), and getTp().

◆ tccNum_

int EcalSimRawData::tccNum_
private

Index of the TCC, FE data must be produced for. -1 for all TTCs

Definition at line 432 of file EcalSimRawData.h.

Referenced by EcalSimRawData(), genTccIn(), and genTccOut().

◆ tcpDigiCollection_

std::string EcalSimRawData::tcpDigiCollection_
private

TCP Fenix output digi product instance name

Definition at line 376 of file EcalSimRawData.h.

Referenced by EcalSimRawData(), and getTp().

◆ theGeometry

const CaloGeometry* EcalSimRawData::theGeometry
private

Calorimeter geometry

Definition at line 380 of file EcalSimRawData.h.

◆ theTriggerTowerMap

const EcalTrigTowerConstituentsMap* EcalSimRawData::theTriggerTowerMap
private

ECAL endcap trigger tower map

Definition at line 416 of file EcalSimRawData.h.

◆ tpDigiCollection_

std::string EcalSimRawData::tpDigiCollection_
private

Trigger primitive digi product instance name

Definition at line 372 of file EcalSimRawData.h.

Referenced by EcalSimRawData(), and getTp().

◆ tpProducer_

std::string EcalSimRawData::tpProducer_
private

Name of the trigger primitive label

Definition at line 384 of file EcalSimRawData.h.

Referenced by EcalSimRawData().

◆ tpVerbose_

bool EcalSimRawData::tpVerbose_
private

Verbosity switch for crystal data

Definition at line 396 of file EcalSimRawData.h.

Referenced by analyze(), EcalSimRawData(), genTccIn(), genTccOut(), and getTp().

◆ trigPrimDigisToken_

edm::EDGetTokenT<EcalTrigPrimDigiCollection> EcalSimRawData::trigPrimDigisToken_[2]
private

Definition at line 449 of file EcalSimRawData.h.

Referenced by EcalSimRawData(), and getTp().

◆ ttEdge

const int EcalSimRawData::ttEdge = 5
staticprivate

Definition at line 97 of file EcalSimRawData.h.

Referenced by elec2GeomNum(), and genFeData().

◆ ttfFile

std::ofstream EcalSimRawData::ttfFile
private

Output file for trigger tower flags

Definition at line 424 of file EcalSimRawData.h.

◆ ttType

const int EcalSimRawData::ttType
staticprivate
Initial value:
= {
0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1,
0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1
}

Map of trigger tower types (in term of VFE card orientation). ttType[iTtEta0]: trigger tower type of TTs with eta 'c-arrary' index iTtEta0

Definition at line 163 of file EcalSimRawData.h.

Referenced by elec2GeomNum().

◆ writeMode_

writeMode_t EcalSimRawData::writeMode_
private

output format

Definition at line 388 of file EcalSimRawData.h.

Referenced by EcalSimRawData(), fwrite(), genFeData(), genSrData(), and getExt().

◆ xtalVerbose_

bool EcalSimRawData::xtalVerbose_
private

Verbosity switch for crystal data

Definition at line 392 of file EcalSimRawData.h.

Referenced by analyze(), EcalSimRawData(), genFeData(), and getEbDigi().