CMS 3D CMS Logo

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

#include <GtPsbTextToDigi.h>

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

Public Member Functions

 GtPsbTextToDigi (const edm::ParameterSet &)
 
 ~GtPsbTextToDigi () 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
 
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 endJob () override
 
void produce (edm::Event &, const edm::EventSetup &) override
 
void putEmptyDigi (edm::Event &)
 Create empty digi collection. More...
 

Private Attributes

int m_bc0 [4]
 Hold detected BC0 signal position per file. More...
 
std::ifstream m_file [4]
 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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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

Definition at line 34 of file GtPsbTextToDigi.h.

Constructor & Destructor Documentation

◆ GtPsbTextToDigi()

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

Definition at line 15 of file GtPsbTextToDigi.cc.

References Exception, MillePedeFileConverter_cfg::fileName, good, mps_fire::i, compare_using_db::ifile, cuy::ii, recoMuon::in, m_bc0, m_file, m_textFileName, and AlCaHLTBitMon_QueryRunRegistry::string.

16  : m_fileEventOffset(iConfig.getUntrackedParameter<int>("FileEventOffset", 0)),
17  m_textFileName(iConfig.getParameter<std::string>("TextFileName")),
18  m_nevt(0) {
19  // Produces collections
20  produces<L1GctEmCandCollection>("isoEm");
21  produces<L1GctEmCandCollection>("nonIsoEm");
22  produces<L1GctJetCandCollection>("cenJets");
23  produces<L1GctJetCandCollection>("forJets");
24  produces<L1GctJetCandCollection>("tauJets");
25  // produces<L1GctEtTotal>();
26 
27  // Open the input files
28  for (int ifile = 0; ifile < 4; ifile++) {
29  // gct em cand coll: (noiso) 0<->0, 1<->1, (iso) 6<->2, 7<->3
30  int ii = (ifile < 2) ? ifile : ifile + 4;
31  std::stringstream fileStream;
32  fileStream << m_textFileName << ii << ".txt";
33  std::string fileName(fileStream.str());
34  m_file[ifile].open(fileName.c_str(), std::ios::in);
35  if (!m_file[ifile].good()) {
36  throw cms::Exception("GtPsbTextToDigiTextFileOpenError")
37  // LogDebug("GtPsbTextToDigi")
38  << "GtPsbTextToDigi::GtPsbTextToDigi : "
39  << " couldn't open the file "
40  << fileName
41  //<< "...skipping!"
42  << std::endl;
43  }
44  std::hex(m_file[ifile]);
45  }
46 
47  // Initialize bc0 position holder
48  for (int i = 0; i < 4; i++)
49  m_bc0[i] = -1;
50 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::string m_textFileName
Name out input file.
T getUntrackedParameter(std::string const &, T const &) const
int m_fileEventOffset
Number of events to be offset wrt input.
std::ifstream m_file[4]
File handle.
int m_nevt
Event counter.
ii
Definition: cuy.py:589
auto const good
min quality of good
int m_bc0[4]
Hold detected BC0 signal position per file.

◆ ~GtPsbTextToDigi()

GtPsbTextToDigi::~GtPsbTextToDigi ( )
override

Definition at line 52 of file GtPsbTextToDigi.cc.

References mps_fire::i, and m_file.

52  {
53  // Close the input files
54  for (unsigned i = 0; i < 4; i++) {
55  m_file[i].close();
56  }
57 }
std::ifstream m_file[4]
File handle.

Member Function Documentation

◆ endJob()

void GtPsbTextToDigi::endJob ( void  )
overrideprivatevirtual

Check BC0 signals consistency

Reimplemented from edm::EDProducer.

Definition at line 206 of file GtPsbTextToDigi.cc.

References mps_fire::i, LogDebug, m_bc0, and match().

206  {
208  int nmem = 4;
209  bool match = true;
210  for (int i = 0; i < nmem - 1; i++)
211  match &= (m_bc0[i] == m_bc0[i + 1]);
212  LogDebug("GtPsbTextToDigi") << "[GtPsbTextToDigi::endJob()] ";
213  if (!match)
214  LogDebug("GtPsbTextToDigi") << "did not find matching BC0 in all input files: ";
215  else
216  LogDebug("GtPsbTextToDigi") << "detected common BC0 in all input files: ";
217  for (int i = 0; i < nmem; i++)
218  LogDebug("GtPsbTextToDigi") << " " << m_bc0[i];
219  LogDebug("GtPsbTextToDigi") << std::flush << std::endl;
220 }
int m_bc0[4]
Hold detected BC0 signal position per file.
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
#define LogDebug(id)

◆ produce()

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

buffer

Read in file

cycle debuging (temporary)

Fill in digi collections

Put collections

Implements edm::EDProducer.

Definition at line 85 of file GtPsbTextToDigi.cc.

References funct::abs(), gather_cfg::cout, data, TauDecayModes::dec, Exception, good, mps_fire::i, iEvent, compare_using_db::ifile, cuy::ii, dqmiolumiharvest::j, LogDebug, m_bc0, m_file, m_fileEventOffset, m_nevt, m_textFileName, eostools::move(), putEmptyDigi(), createJobs::tmp, and testProducerWithPsetDescEmpty_cfi::x1.

85  {
86  // specify clock cycle bit sequence 1 0 1 0... or 0 1 0 1...
87  unsigned short cbs[2] = {1, 0};
88 
89  // Skip event if required
90  if (m_nevt < m_fileEventOffset) {
92  LogDebug("GtPsbTextToDigi") << "[GtPsbTextToDigi::produce()] skipping event " << m_nevt << std::endl;
93  m_nevt++;
94  return;
95  } else if (m_nevt == 0 && m_fileEventOffset < 0) {
96  // skip first fileEventOffset input events
97  unsigned long int buff;
98  for (int ievt = 0; ievt < abs(m_fileEventOffset); ievt++) {
99  for (int ifile = 0; ifile < 4; ifile++) {
100  for (int cycle = 0; cycle < 2; cycle++) {
101  std::hex(m_file[ifile]);
102  m_file[ifile] >> buff;
103  unsigned tmp = (buff >> 15) & 0x1;
104  if (tmp != cbs[cycle]) {
105  if (m_bc0[ifile] == -1 && cycle == 1 && tmp == 1)
106  m_bc0[ifile] = ievt;
107  else
108  throw cms::Exception("GtPsbTextToDigiTextFileFormatError")
109  // std::cout << "GtPsbTextToDigiTextFileFormatError"
110  << "GtPsbTextToDigi::produce : "
111  << " found format inconsistency in file #" << ifile << "\n in skipped line:" << ievt * 2 + 1
112  << " cycle:" << tmp << " is different from " << cbs[cycle] << std::endl;
113  }
114  }
115  }
116  LogDebug("GtPsbTextToDigi") << "[GtPsbTextToDigi::produce()] skipping input " << ievt << std::endl;
117  }
118  }
119  m_nevt++;
120 
121  // New collections
122  std::unique_ptr<L1GctEmCandCollection> gctIsolaEm(new L1GctEmCandCollection());
123  std::unique_ptr<L1GctEmCandCollection> gctNoIsoEm(new L1GctEmCandCollection());
124  std::unique_ptr<L1GctJetCandCollection> gctCenJets(new L1GctJetCandCollection());
125  std::unique_ptr<L1GctJetCandCollection> gctForJets(new L1GctJetCandCollection());
126  std::unique_ptr<L1GctJetCandCollection> gctTauJets(new L1GctJetCandCollection());
127  // std::unique_ptr<L1GctEtTotal> gctEtTotal( new L1GctEtTotal () );
128 
130  uint16_t data[4][2] = {{0}};
131  for (int i = 0; i < 4; i++)
132  for (int j = 0; j < 2; j++)
133  data[i][j] = 0;
134 
135  // Loop over files
136  for (int ifile = 0; ifile < 4; ifile++) {
137  int ii = (ifile < 2) ? ifile : ifile + 4;
138 
139  // Check we're not at the end of the file
140  if (m_file[ifile].eof()) {
141  LogDebug("GtPsbTextToDigi") << "GtPsbTextToDigi::produce : "
142  << " unexpected end of file " << m_textFileName << ii << ".txt" << std::endl;
144  continue;
145  }
146 
147  if (!m_file[ifile].good()) {
148  LogDebug("GtPsbTextToDigi") << "GtPsbTextToDigi::produce : "
149  << " problem reading file " << m_textFileName << ii << ".txt" << std::endl;
151  continue;
152  }
153 
155  unsigned long int uLongBuffer;
156 
157  for (unsigned cycle = 0; cycle < 2; cycle++) {
158  m_file[ifile] >> uLongBuffer;
159  unsigned tmp = (uLongBuffer >> 15) & 0x1;
160 
162  if (false && tmp != cbs[cycle])
163  std::cout << "[GtPsbTextToDigi::produce()] asserting "
164  << " evt:" << m_nevt << " ifile:" << ifile << " cycle:" << cbs[cycle] << std::hex
165  << " buffer:" << uLongBuffer << " tmp: " << tmp << std::dec << "\n\n"
166  << std::flush;
167 
168  if (tmp != cbs[cycle]) {
169  if (m_bc0[ifile] == -1 && cycle == 1 && tmp == 1) {
171  } else {
172  throw cms::Exception("GtPsbTextToDigiTextFileFormatError")
173  // std::cout << "GtPsbTextToDigiTextFileFormatError "
174  << "GtPsbTextToDigi::produce : "
175  << " found format inconsistency in file #" << ifile
176  << "\n in line:" << (m_nevt - m_fileEventOffset) * 2 - 1 << " cycle:" << tmp << " is different from "
177  << cbs[cycle] << std::endl;
178  }
179  }
180  data[ifile][cycle] = (uLongBuffer & 0x7fff);
181  } // cycle loop
182  } // ifile loop
183 
185  unsigned iIsola, iNoIso;
186  for (unsigned cycle = 0; cycle < 2; cycle++) {
187  for (unsigned i = 0; i < 2; i++) {
188  iIsola = i + 2;
189  iNoIso = i;
190  gctIsolaEm->push_back(L1GctEmCand(data[iIsola][cycle] & 0x7fff, true));
191  gctNoIsoEm->push_back(L1GctEmCand(data[iNoIso][cycle] & 0x7fff, false));
192  L1GctEmCand candI(data[iIsola][cycle], true);
193  L1GctEmCand candN(data[iNoIso][cycle], false);
194  }
195  }
196 
198  iEvent.put(std::move(gctIsolaEm), "isoEm");
199  iEvent.put(std::move(gctNoIsoEm), "nonIsoEm");
200  iEvent.put(std::move(gctCenJets), "cenJets");
201  iEvent.put(std::move(gctForJets), "forJets");
202  iEvent.put(std::move(gctTauJets), "tauJets");
203  // iEvent.put(std::move(gctEtTotal));
204 }
std::string m_textFileName
Name out input file.
Level-1 Trigger EM candidate at output of GCT.
Definition: L1GctEmCand.h:21
std::vector< L1GctJetCand > L1GctJetCandCollection
int iEvent
Definition: GenABIO.cc:224
int m_fileEventOffset
Number of events to be offset wrt input.
std::ifstream m_file[4]
File handle.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void putEmptyDigi(edm::Event &)
Create empty digi collection.
int m_nevt
Event counter.
ii
Definition: cuy.py:589
auto const good
min quality of good
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
int m_bc0[4]
Hold detected BC0 signal position per file.
tmp
align.sh
Definition: createJobs.py:716
def move(src, dest)
Definition: eostools.py:511
std::vector< L1GctEmCand > L1GctEmCandCollection
#define LogDebug(id)

◆ putEmptyDigi()

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

Create empty digi collection.

Append empty digi collection.

Definition at line 60 of file GtPsbTextToDigi.cc.

References mps_fire::i, iEvent, LogDebug, m_nevt, and eostools::move().

Referenced by produce().

60  {
61  std::unique_ptr<L1GctEmCandCollection> gctIsolaEm(new L1GctEmCandCollection());
62  std::unique_ptr<L1GctEmCandCollection> gctNoIsoEm(new L1GctEmCandCollection());
63  std::unique_ptr<L1GctJetCandCollection> gctCenJets(new L1GctJetCandCollection());
64  std::unique_ptr<L1GctJetCandCollection> gctForJets(new L1GctJetCandCollection());
65  std::unique_ptr<L1GctJetCandCollection> gctTauJets(new L1GctJetCandCollection());
66  // std::unique_ptr<L1GctEtTotal> gctEtTotal( new L1GctEtTotal () );
67  for (int i = 0; i < 4; i++) {
68  gctIsolaEm->push_back(L1GctEmCand(0, true));
69  gctNoIsoEm->push_back(L1GctEmCand(0, false));
70  gctCenJets->push_back(L1GctJetCand(0, false, false));
71  gctForJets->push_back(L1GctJetCand(0, false, true));
72  gctTauJets->push_back(L1GctJetCand(0, true, false));
73  // gctEtTotal->push_back(());
74  }
75  iEvent.put(std::move(gctIsolaEm), "isoEm");
76  iEvent.put(std::move(gctNoIsoEm), "nonIsoEm");
77  iEvent.put(std::move(gctCenJets), "cenJets");
78  iEvent.put(std::move(gctForJets), "forJets");
79  iEvent.put(std::move(gctTauJets), "tauJets");
80  // iEvent.put(std::move(gctEtTotal));
81 
82  LogDebug("GtPsbTextToDigi") << "putting empty digi (evt:" << m_nevt << ")\n";
83 }
Level-1 Trigger jet candidate.
Definition: L1GctJetCand.h:17
Level-1 Trigger EM candidate at output of GCT.
Definition: L1GctEmCand.h:21
std::vector< L1GctJetCand > L1GctJetCandCollection
int iEvent
Definition: GenABIO.cc:224
int m_nevt
Event counter.
def move(src, dest)
Definition: eostools.py:511
std::vector< L1GctEmCand > L1GctEmCandCollection
#define LogDebug(id)

Member Data Documentation

◆ m_bc0

int GtPsbTextToDigi::m_bc0[4]
private

Hold detected BC0 signal position per file.

Definition at line 60 of file GtPsbTextToDigi.h.

Referenced by endJob(), GtPsbTextToDigi(), and produce().

◆ m_file

std::ifstream GtPsbTextToDigi::m_file[4]
private

File handle.

Definition at line 57 of file GtPsbTextToDigi.h.

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

◆ m_fileEventOffset

int GtPsbTextToDigi::m_fileEventOffset
private

Number of events to be offset wrt input.

Definition at line 48 of file GtPsbTextToDigi.h.

Referenced by produce().

◆ m_nevt

int GtPsbTextToDigi::m_nevt
private

Event counter.

Definition at line 54 of file GtPsbTextToDigi.h.

Referenced by produce(), and putEmptyDigi().

◆ m_textFileName

std::string GtPsbTextToDigi::m_textFileName
private

Name out input file.

Definition at line 51 of file GtPsbTextToDigi.h.

Referenced by GtPsbTextToDigi(), and produce().