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

15  :
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 " << fileName
40  //<< "...skipping!"
41  << std::endl;
42  }
43  std::hex(m_file[ifile]);
44  }
45 
46  // Initialize bc0 position holder
47  for(int i=0; i<4; i++)
48  m_bc0[i]=-1;
49 }
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:589
int m_bc0[4]
Hold detected BC0 signal position per file.
GtPsbTextToDigi::~GtPsbTextToDigi ( )
override

Definition at line 51 of file GtPsbTextToDigi.cc.

References mps_fire::i, and m_file.

51  {
52  // Close the input files
53  for (unsigned i=0; i<4; i++){
54  m_file[i].close();
55  }
56 }
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 223 of file GtPsbTextToDigi.cc.

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

223  {
225  int nmem = 4;
226  bool match = true;
227  for(int i=0; i<nmem-1; i++)
228  match &= (m_bc0[i]==m_bc0[i+1]);
229  LogDebug("GtPsbTextToDigi") << "[GtPsbTextToDigi::endJob()] ";
230  if(!match)
231  LogDebug("GtPsbTextToDigi") << "did not find matching BC0 in all input files: ";
232  else
233  LogDebug("GtPsbTextToDigi") << "detected common BC0 in all input files: ";
234  for(int i=0; i<nmem; i++)
235  LogDebug("GtPsbTextToDigi") << " " << m_bc0[i];
236  LogDebug("GtPsbTextToDigi") << std::flush << std::endl;
237 
238 }
#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 84 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.

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

Create empty digi collection.

Append empty digi collection.

Definition at line 59 of file GtPsbTextToDigi.cc.

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

Referenced by produce().

59  {
60  std::unique_ptr<L1GctEmCandCollection> gctIsolaEm( new L1GctEmCandCollection () );
61  std::unique_ptr<L1GctEmCandCollection> gctNoIsoEm( new L1GctEmCandCollection () );
62  std::unique_ptr<L1GctJetCandCollection> gctCenJets( new L1GctJetCandCollection() );
63  std::unique_ptr<L1GctJetCandCollection> gctForJets( new L1GctJetCandCollection() );
64  std::unique_ptr<L1GctJetCandCollection> gctTauJets( new L1GctJetCandCollection() );
65  //std::unique_ptr<L1GctEtTotal> gctEtTotal( new L1GctEtTotal () );
66  for (int i=0; i<4; i++){
67  gctIsolaEm->push_back(L1GctEmCand (0,true));
68  gctNoIsoEm->push_back(L1GctEmCand (0,false));
69  gctCenJets->push_back(L1GctJetCand(0,false,false));
70  gctForJets->push_back(L1GctJetCand(0,false,true));
71  gctTauJets->push_back(L1GctJetCand(0,true,false));
72  //gctEtTotal->push_back(());
73  }
74  iEvent.put(std::move(gctIsolaEm), "isoEm");
75  iEvent.put(std::move(gctNoIsoEm), "nonIsoEm");
76  iEvent.put(std::move(gctCenJets), "cenJets");
77  iEvent.put(std::move(gctForJets), "forJets");
78  iEvent.put(std::move(gctTauJets), "tauJets");
79  //iEvent.put(std::move(gctEtTotal));
80 
81  LogDebug("GtPsbTextToDigi") << "putting empty digi (evt:" << m_nevt << ")\n";
82 }
#define LogDebug(id)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
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:510
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().