CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
SourceCardTextToRctDigi Class Reference

#include <SourceCardTextToRctDigi.h>

Inheritance diagram for SourceCardTextToRctDigi:
edm::one::EDProducer<> edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 SourceCardTextToRctDigi (const edm::ParameterSet &)
 
 ~SourceCardTextToRctDigi () override
 
- Public Member Functions inherited from edm::one::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 
void putEmptyDigi (edm::Event &)
 Create empty digi collection. More...
 

Private Attributes

std::ifstream m_file
 file handle More...
 
int m_fileEventOffset
 Number of events to skip at the start of the file. More...
 
int m_nevt
 Event counter. More...
 
SourceCardRouting m_scRouting
 source card router More...
 
std::string m_textFileName
 Name out input file. More...
 

Additional Inherited Members

- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- 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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
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

L1Trigger/TextToDigi/src/SourceCardTextToRctDigi.cc

Description: Input text file to be loaded into the source cards and output RCT digis for pattern tests.

L1Trigger/TextToDigi/src/SourceCardTextToRctDigi.h

Description: Input text file to be loaded into the source cards and output RCT digis for pattern tests.

Implementation: <Notes on="" implementation>="">

Definition at line 44 of file SourceCardTextToRctDigi.h.

Constructor & Destructor Documentation

◆ SourceCardTextToRctDigi()

SourceCardTextToRctDigi::SourceCardTextToRctDigi ( const edm::ParameterSet iConfig)
explicit

Definition at line 30 of file SourceCardTextToRctDigi.cc.

References Exception, recoMuon::in, m_file, m_scRouting, and m_textFileName.

31  : m_textFileName(iConfig.getParameter<std::string>("TextFileName")),
32  m_fileEventOffset(iConfig.getParameter<int>("fileEventOffset")),
33  m_nevt(0) {
34  // Produces collections
35  produces<L1CaloEmCollection>();
36  produces<L1CaloRegionCollection>();
37 
38  // Open the input file
39  m_file.open(m_textFileName.c_str(), std::ios::in);
40 
41  if (!m_file.good()) {
42  throw cms::Exception("SourceCardTextToRctDigiTextFileOpenError")
43  << "SourceCardTextToRctDigi::SourceCardTextToRctDigi : "
44  << " couldn't open the file " << m_textFileName << " for reading" << std::endl;
45  }
46 
47  // Make a SC routing object
49 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::string m_textFileName
Name out input file.
std::ifstream m_file
file handle
int m_fileEventOffset
Number of events to skip at the start of the file.
SourceCardRouting m_scRouting
source card router

◆ ~SourceCardTextToRctDigi()

SourceCardTextToRctDigi::~SourceCardTextToRctDigi ( )
override

Definition at line 51 of file SourceCardTextToRctDigi.cc.

References m_file.

51  {
52  // Close the input file
53  m_file.close();
54 }
std::ifstream m_file
file handle

Member Function Documentation

◆ produce()

void SourceCardTextToRctDigi::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDProducerBase.

Definition at line 75 of file SourceCardTextToRctDigi.cc.

References funct::abs(), cms::cuda::assert(), Exception, DigiToRawDM_cff::HF, mps_fire::i, iEvent, dqmiolumiharvest::j, mps_splice::line, LogDebug, SourceCardRouting::LogicalCardIDtoRoutingMode(), m_file, m_fileEventOffset, m_nevt, m_scRouting, m_textFileName, L1CaloRegion::makeHBHERegion(), L1CaloRegion::makeHFRegion(), eostools::move(), NUM_LINES_PER_EVENT, NUM_RCT_CRATES, putEmptyDigi(), AlCaHLTBitMon_QueryRunRegistry::string, SourceCardRouting::STRINGtoVHDCI(), createJobs::tmp, SourceCardRouting::VHDCItoEMU(), SourceCardRouting::VHDCItoRC012(), SourceCardRouting::VHDCItoRC234(), and SourceCardRouting::VHDCItoRC56HF().

75  {
76  // Skip event if required
77  if (m_nevt < m_fileEventOffset) {
78  // std::string tmp;
79  // for (unsigned i=0;i<NUM_LINES_PER_EVENT;i++){
80  // getline(m_file,tmp);
81  //}
83  m_nevt++;
84  return;
85  } else if (m_nevt == 0 && m_fileEventOffset < 0) {
86  // skip first fileEventOffset input events
88  for (int i = 0; i < abs(m_fileEventOffset); i++)
89  for (unsigned line = 0; line < NUM_LINES_PER_EVENT; line++)
90  if (!getline(m_file, tmp)) {
91  throw cms::Exception("SourceCardTextToRctDigiTextFileReadError")
92  << "SourceCardTextToRctDigi::produce() : "
93  << " couldn't read from the file " << m_textFileName << std::endl;
94  }
95  }
96 
97  // New collections
98  std::unique_ptr<L1CaloEmCollection> em(new L1CaloEmCollection);
99  std::unique_ptr<L1CaloRegionCollection> rgn(new L1CaloRegionCollection);
100 
101  // General variables
102  unsigned long VHDCI[2][2];
103  int routingMode;
104  int crate;
105  std::string dataString;
106  unsigned short eventNumber;
107  unsigned short logicalCardID;
108 
109  // Arrays to hold electron variables
110  unsigned short eIsoRank[18][4];
111  unsigned short eIsoCardId[18][4];
112  unsigned short eIsoRegionId[18][4];
113  unsigned short eNonIsoRank[18][4];
114  unsigned short eNonIsoCardId[18][4];
115  unsigned short eNonIsoRegionId[18][4];
116 
117  // Arrays to hold region variables
118  unsigned short RC[18][7][2];
119  unsigned short RCof[18][7][2];
120  unsigned short RCtau[18][7][2];
121  unsigned short MIPbits[18][7][2];
122  unsigned short Qbits[18][7][2];
123  unsigned short HF[18][4][2];
124  unsigned short HFQ[18][4][2];
125 
126  // Check we're not at the end of the file
127  if (m_file.eof()) {
128  throw cms::Exception("SourceCardTextToRctDigiTextFileReadError")
129  << "SourceCardTextToRctDigi::produce : "
130  << " unexpected end of file " << m_textFileName << std::endl;
131  }
132 
133  int thisEventNumber = -1;
134  // Read in file one line at a time
135  for (unsigned line = 0; line < NUM_LINES_PER_EVENT; line++) {
136  if (!getline(m_file, dataString)) {
137  throw cms::Exception("SourceCardTextToRctDigiTextFileReadError")
138  << "SourceCardTextToRctDigi::SourceCardTextToRctDigi : "
139  << " couldn't read from the file " << m_textFileName << std::endl;
140  }
141 
142  // Convert the string to useful info
143  m_scRouting.STRINGtoVHDCI(logicalCardID, eventNumber, dataString, VHDCI);
144 
145  // Check crossing number
146  if (line != 0)
147  assert(eventNumber == thisEventNumber);
148  thisEventNumber = eventNumber;
149 
150  // Are we looking at electrons or regions
151  m_scRouting.LogicalCardIDtoRoutingMode(logicalCardID, routingMode, crate);
152 
153  if (routingMode == 0) {
154  // Electrons
155  m_scRouting.VHDCItoEMU(eIsoRank[crate],
156  eIsoCardId[crate],
157  eIsoRegionId[crate],
158  eNonIsoRank[crate],
159  eNonIsoCardId[crate],
160  eNonIsoRegionId[crate],
161  MIPbits[crate],
162  Qbits[crate],
163  VHDCI);
164 
165  } else if (routingMode == 1) {
166  // Regions
167  m_scRouting.VHDCItoRC56HF(RC[crate], RCof[crate], RCtau[crate], HF[crate], HFQ[crate], VHDCI);
168 
169  } else if (routingMode == 2) {
170  // Regions
171  m_scRouting.VHDCItoRC012(RC[crate], RCof[crate], RCtau[crate], VHDCI);
172 
173  } else if (routingMode == 3) {
174  // Regions
176  RC[crate], RCof[crate], RCtau[crate], RC[crate + 9], RCof[crate + 9], RCtau[crate + 9], VHDCI);
177 
178  } else {
179  // Something went wrong
180  throw cms::Exception("SourceCardtextToRctDigiError") << "SourceCardTextToRctDigi::produce : "
181  << " unknown routing mode=" << routingMode << std::endl;
182  }
183  }
184 
185  // Make RCT digis
186  for (crate = 0; crate < NUM_RCT_CRATES; crate++) {
187  // Make EM collections
188  for (int i = 0; i < 4; i++) {
189  em->push_back(L1CaloEmCand(eIsoRank[crate][i], eIsoRegionId[crate][i], eIsoCardId[crate][i], crate, true, i, 0));
190  em->push_back(
191  L1CaloEmCand(eNonIsoRank[crate][i], eNonIsoRegionId[crate][i], eNonIsoCardId[crate][i], crate, false, i, 0));
192  }
193 
194  // Make region collections
195  for (int i = 0; i < 7; i++) { // Receiver card
196  for (int j = 0; j < 2; j++) { // Region
197  rgn->push_back(L1CaloRegion::makeHBHERegion(RC[crate][i][j],
198  RCof[crate][i][j],
199  RCtau[crate][i][j],
200  MIPbits[crate][i][j],
201  Qbits[crate][i][j],
202  crate,
203  i,
204  j));
205  }
206  }
207 
208  // Make HF region collections
209  for (int i = 0; i < 4; i++) { // Eta bin
210  for (int j = 0; j < 2; j++) { // HF0, HF1
211  rgn->push_back(L1CaloRegion::makeHFRegion(HF[crate][i][j],
212  HFQ[crate][i][j],
213  crate,
214  i + (4 * j))); // region=eta+4*phi for eta 0-3
215  }
216  }
217  }
218 
219  // Debug info
220  for (L1CaloEmCollection::const_iterator iem = em->begin(); iem != em->end(); iem++) {
221  LogDebug("Electrons") << (*iem);
222  }
223 
224  for (L1CaloRegionCollection::const_iterator irgn = rgn->begin(); irgn != rgn->end(); irgn++) {
225  LogDebug("HFRegions") << (*irgn);
226  }
227 
228  iEvent.put(std::move(em));
229  iEvent.put(std::move(rgn));
230 
231  m_nevt++;
232 }
std::vector< L1CaloEmCand > L1CaloEmCollection
void VHDCItoRC234(unsigned short(&RC)[7][2], unsigned short(&RCof)[7][2], unsigned short(&RCtau)[7][2], unsigned short(&sisterRC)[7][2], unsigned short(&sisterRCof)[7][2], unsigned short(&sisterRCtau)[7][2], unsigned long(&VHDCI)[2][2]) const
void putEmptyDigi(edm::Event &)
Create empty digi collection.
void LogicalCardIDtoRoutingMode(unsigned short &logicalCardID, int &RoutingMode, int &RCTCrateNumber) const
std::string m_textFileName
Name out input file.
static L1CaloRegion makeHBHERegion(const unsigned et, const bool overFlow, const bool tauVeto, const bool mip, const bool quiet, const unsigned crate, const unsigned card, const unsigned rgn)
constructor HB/HE region from components
Definition: L1CaloRegion.cc:49
Level-1 Region Calorimeter Trigger EM candidate.
Definition: L1CaloEmCand.h:17
assert(be >=bs)
void VHDCItoRC56HF(unsigned short(&RC)[7][2], unsigned short(&RCof)[7][2], unsigned short(&RCtau)[7][2], unsigned short(&HF)[4][2], unsigned short(&HFQ)[4][2], unsigned long(&VHDCI)[2][2]) const
int iEvent
Definition: GenABIO.cc:224
std::ifstream m_file
file handle
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void VHDCItoRC012(unsigned short(&RC)[7][2], unsigned short(&RCof)[7][2], unsigned short(&RCtau)[7][2], unsigned long(&VHDCI)[2][2]) const
void STRINGtoVHDCI(unsigned short &logicalCardID, unsigned short &eventNumber, std::string &dataString, unsigned long(&VHDCI)[2][2]) const
int m_fileEventOffset
Number of events to skip at the start of the file.
static const int NUM_RCT_CRATES
SourceCardRouting m_scRouting
source card router
void VHDCItoEMU(unsigned short(&eIsoRank)[4], unsigned short(&eIsoCardId)[4], unsigned short(&eIsoRegionId)[4], unsigned short(&eNonIsoRank)[4], unsigned short(&eNonIsoCardId)[4], unsigned short(&eNonIsoRegionId)[4], unsigned short(&MIPbits)[7][2], unsigned short(&Qbits)[7][2], unsigned long(&VHDCI)[2][2]) const
static L1CaloRegion makeHFRegion(const unsigned et, const bool fineGrain, const unsigned crate, const unsigned rgn)
construct HF region from components
Definition: L1CaloRegion.cc:59
static const unsigned NUM_LINES_PER_EVENT
std::vector< L1CaloRegion > L1CaloRegionCollection
tmp
align.sh
Definition: createJobs.py:716
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)

◆ putEmptyDigi()

void SourceCardTextToRctDigi::putEmptyDigi ( edm::Event iEvent)
private

Create empty digi collection.

Append empty digi collection.

Definition at line 57 of file SourceCardTextToRctDigi.cc.

References mps_fire::i, iEvent, dqmiolumiharvest::j, eostools::move(), and NUM_RCT_CRATES.

Referenced by produce().

57  {
58  std::unique_ptr<L1CaloEmCollection> em(new L1CaloEmCollection);
59  std::unique_ptr<L1CaloRegionCollection> rgn(new L1CaloRegionCollection);
60  for (int i = 0; i < NUM_RCT_CRATES; i++) {
61  for (int j = 0; j < 4; j++) {
62  em->push_back(L1CaloEmCand(0, i, true));
63  em->push_back(L1CaloEmCand(0, i, false));
64  }
65  for (int j = 0; j < 14; j++)
66  rgn->push_back(L1CaloRegion(0, false, false, false, false, i, j / 2, j % 2));
67  for (unsigned j = 0; j < 8; j++)
68  rgn->push_back(L1CaloRegion(0, true, i, j));
69  }
70  iEvent.put(std::move(em));
71  iEvent.put(std::move(rgn));
72 }
std::vector< L1CaloEmCand > L1CaloEmCollection
Level-1 Region Calorimeter Trigger EM candidate.
Definition: L1CaloEmCand.h:17
int iEvent
Definition: GenABIO.cc:224
static const int NUM_RCT_CRATES
A calorimeter trigger region (sum of 4x4 trigger towers)
Definition: L1CaloRegion.h:21
std::vector< L1CaloRegion > L1CaloRegionCollection
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ m_file

std::ifstream SourceCardTextToRctDigi::m_file
private

file handle

Definition at line 65 of file SourceCardTextToRctDigi.h.

Referenced by produce(), SourceCardTextToRctDigi(), and ~SourceCardTextToRctDigi().

◆ m_fileEventOffset

int SourceCardTextToRctDigi::m_fileEventOffset
private

Number of events to skip at the start of the file.

Definition at line 59 of file SourceCardTextToRctDigi.h.

Referenced by produce().

◆ m_nevt

int SourceCardTextToRctDigi::m_nevt
private

Event counter.

Definition at line 62 of file SourceCardTextToRctDigi.h.

Referenced by produce().

◆ m_scRouting

SourceCardRouting SourceCardTextToRctDigi::m_scRouting
private

source card router

Definition at line 68 of file SourceCardTextToRctDigi.h.

Referenced by produce(), and SourceCardTextToRctDigi().

◆ m_textFileName

std::string SourceCardTextToRctDigi::m_textFileName
private

Name out input file.

Definition at line 56 of file SourceCardTextToRctDigi.h.

Referenced by produce(), and SourceCardTextToRctDigi().