CMS 3D CMS Logo

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

#include <RctTextToRctDigi.h>

Inheritance diagram for RctTextToRctDigi:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

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

Definition at line 46 of file RctTextToRctDigi.cc.

References MillePedeFileConverter_cfg::fileName, 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
58  << ".txt";
59  std::string fileName(fileStream.str());
60  m_file[i].open(fileName.c_str(), std::ios::in);
61 
62  if (!m_file[i].good()) {
63  // throw cms::Exception("RctTextToRctDigiTextFileOpenError")
64  LogDebug("RctTextToRctDigi") << "RctTextToRctDigi::RctTextToRctDigi : "
65  << " couldn't open the file " << fileName
66  << "...skipping!" << std::endl;
67  }
68  }
69 }
#define LogDebug(id)
T getParameter(std::string const &) const
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
RctTextToRctDigi::~RctTextToRctDigi ( )
override

Definition at line 71 of file RctTextToRctDigi.cc.

References mps_fire::i, m_file, and NUM_RCT_CRATES.

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

Member Function Documentation

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

Synchronize bunch crossing.

Syncronize bunch crossing number/n.

Definition at line 98 of file RctTextToRctDigi.cc.

References Exception, m_file, m_fileEventOffset, m_nevt, AlCaHLTBitMon_QueryRunRegistry::string, and tmp.

Referenced by produce().

98  {
100  // bypass bx input until correct bx is reached
101  while (bx < m_nevt + m_fileEventOffset) {
102  for (int j = 0; j < 6; j++) {
103  getline(m_file[crate], tmp);
104  }
105  m_file[crate] >> tmp >> bx;
106  if (tmp != "Crossing")
107  throw cms::Exception("RctTextToRctDigiTextFileReadError")
108  << "RctTextToRctDigi::bxSynchro : "
109  << " something screwy happened Crossing!=" << tmp << std::endl;
110  }
111 }
int m_nevt
Event counter.
int m_fileEventOffset
Number of events to be offset wrt input.
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
std::ifstream m_file[18]
file handle
void RctTextToRctDigi::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Synchronize bunch crossing

Definition at line 114 of file RctTextToRctDigi.cc.

References bxSynchro(), TauDecayModes::dec, stringResolutionProvider_cfi::et, Exception, mps_fire::i, LogDebug, m_file, m_fileEventOffset, m_nevt, m_textFileName, eostools::move(), NUM_RCT_CRATES, edm::Event::put(), putEmptyDigi(), AlCaHLTBitMon_QueryRunRegistry::string, and tmp.

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

Create empty digi collection.

Append empty digi collection/n.

Definition at line 79 of file RctTextToRctDigi.cc.

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

Referenced by produce().

79  {
80  std::unique_ptr<L1CaloEmCollection> em(new L1CaloEmCollection);
81  std::unique_ptr<L1CaloRegionCollection> rgn(new L1CaloRegionCollection);
82  for (unsigned i = 0; i < NUM_RCT_CRATES; i++) {
83  for (unsigned j = 0; j < 4; j++) {
84  em->push_back(L1CaloEmCand(0, i, true));
85  em->push_back(L1CaloEmCand(0, i, false));
86  }
87  for (unsigned j = 0; j < 14; j++)
88  rgn->push_back(
89  L1CaloRegion(0, false, false, false, false, i, j / 2, j % 2));
90  for (unsigned j = 0; j < 8; j++)
91  rgn->push_back(L1CaloRegion(0, true, i, j));
92  }
93  iEvent.put(std::move(em));
94  iEvent.put(std::move(rgn));
95 }
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 unsigned 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 RctTextToRctDigi::m_file[18]
private

file handle

Definition at line 63 of file RctTextToRctDigi.h.

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

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

int RctTextToRctDigi::m_nevt
private

Event counter.

Definition at line 60 of file RctTextToRctDigi.h.

Referenced by bxSynchro(), and produce().

std::string RctTextToRctDigi::m_textFileName
private

Name out input file.

Definition at line 54 of file RctTextToRctDigi.h.

Referenced by produce(), and RctTextToRctDigi().