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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 SourceCardTextToRctDigi (const edm::ParameterSet &)
 
 ~SourceCardTextToRctDigi () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () 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
 
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)
 
 ~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
 
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::vector< ModuleDescription const * > &modules, 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
 
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::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
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::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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<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)
 

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 ( const edm::ParameterSet iConfig)
explicit

Definition at line 30 of file SourceCardTextToRctDigi.cc.

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

32  : m_textFileName(iConfig.getParameter<std::string>("TextFileName")),
33  m_fileEventOffset(iConfig.getParameter<int>("fileEventOffset")),
34  m_nevt(0) {
35  // Produces collections
36  produces<L1CaloEmCollection>();
37  produces<L1CaloRegionCollection>();
38 
39  // Open the input file
40  m_file.open(m_textFileName.c_str(), std::ios::in);
41 
42  if (!m_file.good()) {
43  throw cms::Exception("SourceCardTextToRctDigiTextFileOpenError")
44  << "SourceCardTextToRctDigi::SourceCardTextToRctDigi : "
45  << " couldn't open the file " << m_textFileName << " for reading"
46  << std::endl;
47  }
48 
49  // Make a SC routing object
51 }
T getParameter(std::string const &) const
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 ( )
override

Definition at line 53 of file SourceCardTextToRctDigi.cc.

References m_file.

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

Member Function Documentation

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

Definition at line 78 of file SourceCardTextToRctDigi.cc.

References funct::abs(), Exception, CaloTPGTranscoder_cfi::HF, mps_fire::i, 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, edm::Event::put(), putEmptyDigi(), AlCaHLTBitMon_QueryRunRegistry::string, SourceCardRouting::STRINGtoVHDCI(), tmp, SourceCardRouting::VHDCItoEMU(), SourceCardRouting::VHDCItoRC012(), SourceCardRouting::VHDCItoRC234(), and SourceCardRouting::VHDCItoRC56HF().

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

Create empty digi collection.

Append empty digi collection.

Definition at line 59 of file SourceCardTextToRctDigi.cc.

References mps_fire::i, eostools::move(), NUM_RCT_CRATES, and edm::Event::put().

Referenced by produce().

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

Member Data Documentation

std::ifstream SourceCardTextToRctDigi::m_file
private

file handle

Definition at line 65 of file SourceCardTextToRctDigi.h.

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

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().

int SourceCardTextToRctDigi::m_nevt
private

Event counter.

Definition at line 62 of file SourceCardTextToRctDigi.h.

Referenced by produce().

SourceCardRouting SourceCardTextToRctDigi::m_scRouting
private

source card router

Definition at line 68 of file SourceCardTextToRctDigi.h.

Referenced by produce(), and SourceCardTextToRctDigi().

std::string SourceCardTextToRctDigi::m_textFileName
private

Name out input file.

Definition at line 56 of file SourceCardTextToRctDigi.h.

Referenced by produce(), and SourceCardTextToRctDigi().