CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
RctTextToRctDigi Class Reference

#include <RctTextToRctDigi.h>

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

Public Member Functions

 RctTextToRctDigi (const edm::ParameterSet &)
 
 ~RctTextToRctDigi () 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 bxSynchro (int &, int)
 Synchronize bunch crossing. More...
 
void produce (edm::Event &, const edm::EventSetup &) override
 
void putEmptyDigi (edm::Event &)
 Create empty digi collection. More...
 

Private Attributes

std::ifstream m_file [18]
 file handle More...
 
int m_fileEventOffset
 Number of events to be offset wrt input. More...
 
int m_nevt
 Event counter. 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/RctTextToRctDigi.cc

Description: Makes RCT digis from the file format specified by Pam Klabbers

L1Trigger/TextToDigi/src/RctTextToRctDigi.h

Description: Makes RCT digis from the file format specified by Pam Klabbers

Definition at line 39 of file RctTextToRctDigi.h.

Constructor & Destructor Documentation

◆ RctTextToRctDigi()

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

Definition at line 46 of file RctTextToRctDigi.cc.

References MillePedeFileConverter_cfg::fileName, caHitNtupletGeneratorKernels::good, mps_fire::i, recoMuon::in, LogDebug, m_file, m_textFileName, NUM_RCT_CRATES, and AlCaHLTBitMon_QueryRunRegistry::string.

47  : m_textFileName(iConfig.getParameter<std::string>("TextFileName")),
48  m_fileEventOffset(iConfig.getParameter<int>("FileEventOffset")),
49  m_nevt(0) {
50  // Produces collections
51  produces<L1CaloEmCollection>();
52  produces<L1CaloRegionCollection>();
53 
54  // Open the input files
55  for (unsigned i = 0; i < NUM_RCT_CRATES; i++) {
56  std::stringstream fileStream;
57  fileStream << m_textFileName << std::setw(2) << std::setfill('0') << i << ".txt";
58  std::string fileName(fileStream.str());
59  m_file[i].open(fileName.c_str(), std::ios::in);
60 
61  if (!m_file[i].good()) {
62  // throw cms::Exception("RctTextToRctDigiTextFileOpenError")
63  LogDebug("RctTextToRctDigi") << "RctTextToRctDigi::RctTextToRctDigi : "
64  << " couldn't open the file " << fileName << "...skipping!" << std::endl;
65  }
66  }
67 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::string m_textFileName
Name out input file.
static const unsigned NUM_RCT_CRATES
int m_nevt
Event counter.
int m_fileEventOffset
Number of events to be offset wrt input.
std::ifstream m_file[18]
file handle
#define LogDebug(id)

◆ ~RctTextToRctDigi()

RctTextToRctDigi::~RctTextToRctDigi ( )
override

Definition at line 69 of file RctTextToRctDigi.cc.

References mps_fire::i, m_file, and NUM_RCT_CRATES.

69  {
70  // Close the input files
71  for (unsigned i = 0; i < NUM_RCT_CRATES; i++) {
72  m_file[i].close();
73  }
74 }
static const unsigned NUM_RCT_CRATES
std::ifstream m_file[18]
file handle

Member Function Documentation

◆ bxSynchro()

void RctTextToRctDigi::bxSynchro ( int &  bx,
int  crate 
)
private

Synchronize bunch crossing.

Syncronize bunch crossing number/n.

Definition at line 95 of file RctTextToRctDigi.cc.

References simKBmtfDigis_cfi::bx, Exception, dqmiolumiharvest::j, m_file, m_fileEventOffset, m_nevt, AlCaHLTBitMon_QueryRunRegistry::string, and createJobs::tmp.

Referenced by produce().

95  {
97  // bypass bx input until correct bx is reached
98  while (bx < m_nevt + m_fileEventOffset) {
99  for (int j = 0; j < 6; j++) {
100  getline(m_file[crate], tmp);
101  }
102  m_file[crate] >> tmp >> bx;
103  if (tmp != "Crossing")
104  throw cms::Exception("RctTextToRctDigiTextFileReadError")
105  << "RctTextToRctDigi::bxSynchro : "
106  << " something screwy happened Crossing!=" << tmp << std::endl;
107  }
108 }
int m_nevt
Event counter.
int m_fileEventOffset
Number of events to be offset wrt input.
std::ifstream m_file[18]
file handle
tmp
align.sh
Definition: createJobs.py:716

◆ produce()

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

Synchronize bunch crossing

Implements edm::one::EDProducerBase.

Definition at line 111 of file RctTextToRctDigi.cc.

References bxSynchro(), TauDecayModes::dec, EgHLTOffHistBins_cfi::et, Exception, caHitNtupletGeneratorKernels::good, mps_fire::i, iEvent, dqmiolumiharvest::j, LogDebug, m_file, m_fileEventOffset, m_nevt, m_textFileName, eostools::move(), NUM_RCT_CRATES, putEmptyDigi(), AlCaHLTBitMon_QueryRunRegistry::string, and createJobs::tmp.

111  {
112  // Skip event if required
113  if (m_nevt < m_fileEventOffset) {
114  // string tmp;
115  // for (int i=0; i<6; i++){
116  // getline(m_file[i],tmp);
117  //}
119  m_nevt++;
120  return;
121  }
122 
123  // New collections
124  std::unique_ptr<L1CaloEmCollection> em(new L1CaloEmCollection);
125  std::unique_ptr<L1CaloRegionCollection> rgn(new L1CaloRegionCollection);
126 
127  // Loop over RCT crates
128  for (unsigned i = 0; i < NUM_RCT_CRATES; i++) {
129  if (!m_file[i].good()) {
130  continue;
131  }
132 
133  // Check we're not at the end of the file
134  if (m_file[i].eof()) {
135  // throw cms::Exception("RctTextToRctDigiTextFileReadError")
136  LogDebug("RctTextToRctDigi") << "RctTextToRctDigi::produce : "
137  << " unexpected end of file " << m_textFileName << i
138  << " adding empty collection for event !" << std::endl;
140  continue;
141  }
142 
143  // Check we're at the start of an event
145  m_file[i] >> tmp;
146  if (tmp != "Crossing") {
147  throw cms::Exception("RctTextToRctDigiTextFileReadError")
148  << "RctTextToRctDigi::produce : "
149  << " something screwy happened Crossing!=" << tmp << std::endl;
150  }
151 
152  // Read BX number
153  dec(m_file[i]);
154  int BXNum;
155  m_file[i] >> BXNum;
156 
158  bxSynchro(BXNum, i);
159 
160  if (BXNum != m_nevt + m_fileEventOffset)
161  throw cms::Exception("RctTextToRctDigiTextSyncError")
162  << "RctTextToRctDigi::produce : "
163  << " something screwy happened "
164  << "evt:" << m_nevt << " != bx:" << BXNum << " + " << m_fileEventOffset << std::endl;
165 
166  // Buffers
167  unsigned long int uLongBuffer;
168  bool mipBitBuffer[14], qBitBuffer[14];
169 
170  // All in hex from now on
171  hex(m_file[i]);
172 
173  // Isolated electrons
174  for (unsigned j = 0; j < 4; j++) {
175  m_file[i] >> uLongBuffer;
176  em->push_back(L1CaloEmCand(uLongBuffer, i, true, j, BXNum, false));
177  }
178 
179  // Non-isolated electrons
180  for (unsigned j = 0; j < 4; j++) {
181  m_file[i] >> uLongBuffer;
182  em->push_back(L1CaloEmCand(uLongBuffer, i, false, j, BXNum, false));
183  }
184 
185  // MIP bits
186  for (unsigned j = 0; j < 14; j++) {
187  m_file[i] >> mipBitBuffer[j];
188  }
189 
190  // Quiet bits
191  for (unsigned j = 0; j < 14; j++) {
192  m_file[i] >> qBitBuffer[j];
193  }
194 
195  // Barrel and endcap regions
196  for (unsigned j = 0; j < 14; j++) {
197  m_file[i] >> uLongBuffer;
198 
199  unsigned et = uLongBuffer & 0x3ff; // put the first 10 bits of rawData into the Et
200  uLongBuffer >>= 10; // shift the remaining bits down to remove the 10 bits of Et
201 
202  bool overFlow = ((uLongBuffer & 0x1) != 0); // LSB is now overflow bit
203  bool tauVeto = (((uLongBuffer & 0x2) >> 1) != 0); // 2nd bit is tauveto
204 
205  rgn->push_back(L1CaloRegion(et, overFlow, tauVeto, mipBitBuffer[j], qBitBuffer[j], i, j / 2, j % 2));
206  }
207 
208  // HF
209  for (unsigned j = 0; j < 8; j++) {
210  m_file[i] >> uLongBuffer;
211 
212  unsigned et = uLongBuffer & 0xff; // put the first 8 bits into the Et
213 
214  rgn->push_back(L1CaloRegion(et, true, i, j));
215  }
216 
217  dec(m_file[i]);
218  }
219 
220  iEvent.put(std::move(em));
221  iEvent.put(std::move(rgn));
222 
223  m_nevt++;
224 }
std::vector< L1CaloEmCand > L1CaloEmCollection
void bxSynchro(int &, int)
Synchronize bunch crossing.
Level-1 Region Calorimeter Trigger EM candidate.
Definition: L1CaloEmCand.h:17
void putEmptyDigi(edm::Event &)
Create empty digi collection.
std::string m_textFileName
Name out input file.
int iEvent
Definition: GenABIO.cc:224
static const unsigned NUM_RCT_CRATES
int m_nevt
Event counter.
int m_fileEventOffset
Number of events to be offset wrt input.
A calorimeter trigger region (sum of 4x4 trigger towers)
Definition: L1CaloRegion.h:21
std::vector< L1CaloRegion > L1CaloRegionCollection
std::ifstream m_file[18]
file handle
tmp
align.sh
Definition: createJobs.py:716
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)

◆ putEmptyDigi()

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

Create empty digi collection.

Append empty digi collection/n.

Definition at line 77 of file RctTextToRctDigi.cc.

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

Referenced by produce().

77  {
78  std::unique_ptr<L1CaloEmCollection> em(new L1CaloEmCollection);
79  std::unique_ptr<L1CaloRegionCollection> rgn(new L1CaloRegionCollection);
80  for (unsigned i = 0; i < NUM_RCT_CRATES; i++) {
81  for (unsigned j = 0; j < 4; j++) {
82  em->push_back(L1CaloEmCand(0, i, true));
83  em->push_back(L1CaloEmCand(0, i, false));
84  }
85  for (unsigned j = 0; j < 14; j++)
86  rgn->push_back(L1CaloRegion(0, false, false, false, false, i, j / 2, j % 2));
87  for (unsigned j = 0; j < 8; j++)
88  rgn->push_back(L1CaloRegion(0, true, i, j));
89  }
90  iEvent.put(std::move(em));
91  iEvent.put(std::move(rgn));
92 }
std::vector< L1CaloEmCand > L1CaloEmCollection
Level-1 Region Calorimeter Trigger EM candidate.
Definition: L1CaloEmCand.h:17
int iEvent
Definition: GenABIO.cc:224
static const unsigned 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 RctTextToRctDigi::m_file[18]
private

file handle

Definition at line 63 of file RctTextToRctDigi.h.

Referenced by bxSynchro(), produce(), RctTextToRctDigi(), and ~RctTextToRctDigi().

◆ m_fileEventOffset

int RctTextToRctDigi::m_fileEventOffset
private

Number of events to be offset wrt input.

Definition at line 57 of file RctTextToRctDigi.h.

Referenced by bxSynchro(), and produce().

◆ m_nevt

int RctTextToRctDigi::m_nevt
private

Event counter.

Definition at line 60 of file RctTextToRctDigi.h.

Referenced by bxSynchro(), and produce().

◆ m_textFileName

std::string RctTextToRctDigi::m_textFileName
private

Name out input file.

Definition at line 54 of file RctTextToRctDigi.h.

Referenced by produce(), and RctTextToRctDigi().