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
 
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 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 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

Definition at line 34 of file GtPsbTextToDigi.h.

Constructor & Destructor Documentation

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

Definition at line 15 of file GtPsbTextToDigi.cc.

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

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

Definition at line 53 of file GtPsbTextToDigi.cc.

References mps_fire::i, and m_file.

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

Member Function Documentation

void GtPsbTextToDigi::endJob ( void  )
overrideprivatevirtual

Check BC0 signals consistency

Reimplemented from edm::EDProducer.

Definition at line 230 of file GtPsbTextToDigi.cc.

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

230  {
232  int nmem = 4;
233  bool match = true;
234  for (int i = 0; i < nmem - 1; i++)
235  match &= (m_bc0[i] == m_bc0[i + 1]);
236  LogDebug("GtPsbTextToDigi") << "[GtPsbTextToDigi::endJob()] ";
237  if (!match)
238  LogDebug("GtPsbTextToDigi")
239  << "did not find matching BC0 in all input files: ";
240  else
241  LogDebug("GtPsbTextToDigi") << "detected common BC0 in all input files: ";
242  for (int i = 0; i < nmem; i++)
243  LogDebug("GtPsbTextToDigi") << " " << m_bc0[i];
244  LogDebug("GtPsbTextToDigi") << std::flush << std::endl;
245 }
#define LogDebug(id)
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
void GtPsbTextToDigi::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

buffer

Read in file

cycle debuging (temporary)

Fill in digi collections

Put collections

Definition at line 91 of file GtPsbTextToDigi.cc.

References funct::abs(), gather_cfg::cout, data, TauDecayModes::dec, Exception, mps_fire::i, compare_using_db::ifile, cuy::ii, LogDebug, m_bc0, m_file, m_fileEventOffset, m_nevt, m_textFileName, eostools::move(), edm::Event::put(), putEmptyDigi(), tmp, and globals_cff::x1.

92  {
93 
94  // specify clock cycle bit sequence 1 0 1 0... or 0 1 0 1...
95  unsigned short cbs[2] = {1, 0};
96 
97  // Skip event if required
98  if (m_nevt < m_fileEventOffset) {
99  putEmptyDigi(iEvent);
100  LogDebug("GtPsbTextToDigi")
101  << "[GtPsbTextToDigi::produce()] skipping event " << m_nevt
102  << std::endl;
103  m_nevt++;
104  return;
105  } else if (m_nevt == 0 && m_fileEventOffset < 0) {
106  // skip first fileEventOffset input events
107  unsigned long int buff;
108  for (int ievt = 0; ievt < abs(m_fileEventOffset); ievt++) {
109  for (int ifile = 0; ifile < 4; ifile++) {
110  for (int cycle = 0; cycle < 2; cycle++) {
111  std::hex(m_file[ifile]);
112  m_file[ifile] >> buff;
113  unsigned tmp = (buff >> 15) & 0x1;
114  if (tmp != cbs[cycle]) {
115  if (m_bc0[ifile] == -1 && cycle == 1 && tmp == 1)
116  m_bc0[ifile] = ievt;
117  else
118  throw cms::Exception("GtPsbTextToDigiTextFileFormatError")
119  // std::cout << "GtPsbTextToDigiTextFileFormatError"
120  << "GtPsbTextToDigi::produce : "
121  << " found format inconsistency in file #" << ifile
122  << "\n in skipped line:" << ievt * 2 + 1 << " cycle:" << tmp
123  << " is different from " << cbs[cycle] << std::endl;
124  }
125  }
126  }
127  LogDebug("GtPsbTextToDigi")
128  << "[GtPsbTextToDigi::produce()] skipping input " << ievt
129  << std::endl;
130  }
131  }
132  m_nevt++;
133 
134  // New collections
135  std::unique_ptr<L1GctEmCandCollection> gctIsolaEm(
136  new L1GctEmCandCollection());
137  std::unique_ptr<L1GctEmCandCollection> gctNoIsoEm(
138  new L1GctEmCandCollection());
139  std::unique_ptr<L1GctJetCandCollection> gctCenJets(
140  new L1GctJetCandCollection());
141  std::unique_ptr<L1GctJetCandCollection> gctForJets(
142  new L1GctJetCandCollection());
143  std::unique_ptr<L1GctJetCandCollection> gctTauJets(
144  new L1GctJetCandCollection());
145  // std::unique_ptr<L1GctEtTotal> gctEtTotal( new L1GctEtTotal () );
146 
148  uint16_t data[4][2] = {{0}};
149  for (int i = 0; i < 4; i++)
150  for (int j = 0; j < 2; j++)
151  data[i][j] = 0;
152 
153  // Loop over files
154  for (int ifile = 0; ifile < 4; ifile++) {
155  int ii = (ifile < 2) ? ifile : ifile + 4;
156 
157  // Check we're not at the end of the file
158  if (m_file[ifile].eof()) {
159  LogDebug("GtPsbTextToDigi")
160  << "GtPsbTextToDigi::produce : "
161  << " unexpected end of file " << m_textFileName << ii << ".txt"
162  << std::endl;
163  putEmptyDigi(iEvent);
164  continue;
165  }
166 
167  if (!m_file[ifile].good()) {
168  LogDebug("GtPsbTextToDigi") << "GtPsbTextToDigi::produce : "
169  << " problem reading file " << m_textFileName
170  << ii << ".txt" << std::endl;
171  putEmptyDigi(iEvent);
172  continue;
173  }
174 
176  unsigned long int uLongBuffer;
177 
178  for (unsigned cycle = 0; cycle < 2; cycle++) {
179  m_file[ifile] >> uLongBuffer;
180  unsigned tmp = (uLongBuffer >> 15) & 0x1;
181 
183  if (false && tmp != cbs[cycle])
184  std::cout << "[GtPsbTextToDigi::produce()] asserting "
185  << " evt:" << m_nevt << " ifile:" << ifile
186  << " cycle:" << cbs[cycle] << std::hex
187  << " buffer:" << uLongBuffer << " tmp: " << tmp << std::dec
188  << "\n\n"
189  << std::flush;
190 
191  if (tmp != cbs[cycle]) {
192  if (m_bc0[ifile] == -1 && cycle == 1 && tmp == 1) {
194  } else {
195  throw cms::Exception("GtPsbTextToDigiTextFileFormatError")
196  // std::cout << "GtPsbTextToDigiTextFileFormatError "
197  << "GtPsbTextToDigi::produce : "
198  << " found format inconsistency in file #" << ifile
199  << "\n in line:" << (m_nevt - m_fileEventOffset) * 2 - 1
200  << " cycle:" << tmp << " is different from " << cbs[cycle]
201  << std::endl;
202  }
203  }
204  data[ifile][cycle] = (uLongBuffer & 0x7fff);
205  } // cycle loop
206  } // ifile loop
207 
209  unsigned iIsola, iNoIso;
210  for (unsigned cycle = 0; cycle < 2; cycle++) {
211  for (unsigned i = 0; i < 2; i++) {
212  iIsola = i + 2;
213  iNoIso = i;
214  gctIsolaEm->push_back(L1GctEmCand(data[iIsola][cycle] & 0x7fff, true));
215  gctNoIsoEm->push_back(L1GctEmCand(data[iNoIso][cycle] & 0x7fff, false));
216  L1GctEmCand candI(data[iIsola][cycle], true);
217  L1GctEmCand candN(data[iNoIso][cycle], false);
218  }
219  }
220 
222  iEvent.put(std::move(gctIsolaEm), "isoEm");
223  iEvent.put(std::move(gctNoIsoEm), "nonIsoEm");
224  iEvent.put(std::move(gctCenJets), "cenJets");
225  iEvent.put(std::move(gctForJets), "forJets");
226  iEvent.put(std::move(gctTauJets), "tauJets");
227  // iEvent.put(std::move(gctEtTotal));
228 }
#define LogDebug(id)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
std::string m_textFileName
Name out input file.
Level-1 Trigger EM candidate at output of GCT.
Definition: L1GctEmCand.h:22
std::vector< L1GctJetCand > L1GctJetCandCollection
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:590
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
int m_bc0[4]
Hold detected BC0 signal position per file.
def move(src, dest)
Definition: eostools.py:511
std::vector< L1GctEmCand > L1GctEmCandCollection
void GtPsbTextToDigi::putEmptyDigi ( edm::Event iEvent)
private

Create empty digi collection.

Append empty digi collection.

Definition at line 61 of file GtPsbTextToDigi.cc.

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

Referenced by produce().

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

Member Data Documentation

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

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

File handle.

Definition at line 57 of file GtPsbTextToDigi.h.

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

int GtPsbTextToDigi::m_fileEventOffset
private

Number of events to be offset wrt input.

Definition at line 48 of file GtPsbTextToDigi.h.

Referenced by produce().

int GtPsbTextToDigi::m_nevt
private

Event counter.

Definition at line 54 of file GtPsbTextToDigi.h.

Referenced by produce(), and putEmptyDigi().

std::string GtPsbTextToDigi::m_textFileName
private

Name out input file.

Definition at line 51 of file GtPsbTextToDigi.h.

Referenced by GtPsbTextToDigi(), and produce().