CMS 3D CMS Logo

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

#include <L1Trigger/TextToDigi/src/RctTextToRctDigi.h>

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

Public Member Functions

 RctTextToRctDigi (const edm::ParameterSet &)
 
 ~RctTextToRctDigi ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

void bxSynchro (int &, int)
 Synchronize bunch crossing. More...
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
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
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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

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 41 of file RctTextToRctDigi.cc.

References convertXMLtoSQLite_cfg::fileName, i, recoMuon::in, LogDebug, m_file, m_textFileName, NUM_RCT_CRATES, and AlCaHLTBitMon_QueryRunRegistry::string.

41  :
42  m_textFileName(iConfig.getParameter<std::string>("TextFileName")),
43  m_fileEventOffset(iConfig.getParameter<int>("FileEventOffset")),
44  m_nevt(0)
45 {
46  // Produces collections
47  produces<L1CaloEmCollection>();
48  produces<L1CaloRegionCollection>();
49 
50  // Open the input files
51  for (unsigned i=0; i<NUM_RCT_CRATES; i++){
52  std::stringstream fileStream;
53  fileStream << m_textFileName << std::setw(2) << std::setfill('0') << i << ".txt";
54  std::string fileName(fileStream.str());
55  m_file[i].open(fileName.c_str(),std::ios::in);
56 
57  if(!m_file[i].good())
58  {
59  //throw cms::Exception("RctTextToRctDigiTextFileOpenError")
60  LogDebug("RctTextToRctDigi")
61  << "RctTextToRctDigi::RctTextToRctDigi : "
62  << " couldn't open the file " << fileName << "...skipping!" << std::endl;
63  }
64  }
65 }
#define LogDebug(id)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
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 ( )

Definition at line 67 of file RctTextToRctDigi.cc.

References i, m_file, and NUM_RCT_CRATES.

68 {
69  // Close the input files
70  for (unsigned i=0; i<NUM_RCT_CRATES; i++){
71  m_file[i].close();
72  }
73 }
int i
Definition: DBlmapReader.cc:9
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 94 of file RctTextToRctDigi.cc.

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

Referenced by produce().

94  {
96  // bypass bx input until correct bx is reached
97  while(bx<m_nevt+m_fileEventOffset) {
98  for (int j=0; j<6; j++){
99  getline(m_file[crate],tmp);
100  }
101  m_file[crate] >> tmp >> bx;
102  if(tmp!="Crossing")
103  throw cms::Exception("RctTextToRctDigiTextFileReadError")
104  << "RctTextToRctDigi::bxSynchro : "
105  << " something screwy happened Crossing!=" << tmp << std::endl;
106  }
107 }
int m_nevt
Event counter.
int j
Definition: DBlmapReader.cc:9
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 
)
privatevirtual

Synchronize bunch crossing

Implements edm::EDProducer.

Definition at line 110 of file RctTextToRctDigi.cc.

References bxSynchro(), edm::hlt::Exception, i, j, LogDebug, m_file, m_fileEventOffset, m_nevt, m_textFileName, NUM_RCT_CRATES, edm::Event::put(), putEmptyDigi(), AlCaHLTBitMon_QueryRunRegistry::string, and tmp.

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

Create empty digi collection.

Append empty digi collection/n.

Definition at line 76 of file RctTextToRctDigi.cc.

References i, j, NUM_RCT_CRATES, and edm::Event::put().

Referenced by produce().

76  {
77  std::auto_ptr<L1CaloEmCollection> em (new L1CaloEmCollection);
78  std::auto_ptr<L1CaloRegionCollection> rgn (new L1CaloRegionCollection);
79  for (unsigned i=0; i<NUM_RCT_CRATES; i++){
80  for (unsigned j=0; j<4; j++) {
81  em->push_back(L1CaloEmCand(0, i, true));
82  em->push_back(L1CaloEmCand(0, i, false));
83  }
84  for (unsigned j=0; j<14; j++)
85  rgn->push_back(L1CaloRegion(0,false,false,false,false,i,j/2,j%2));
86  for (unsigned j=0; j<8; j++)
87  rgn->push_back(L1CaloRegion(0,true,i,j));
88  }
89  iEvent.put(em);
90  iEvent.put(rgn);
91 }
int i
Definition: DBlmapReader.cc:9
std::vector< L1CaloEmCand > L1CaloEmCollection
Level-1 Region Calorimeter Trigger EM candidate.
Definition: L1CaloEmCand.h:18
static const unsigned NUM_RCT_CRATES
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
int j
Definition: DBlmapReader.cc:9
A calorimeter trigger region (sum of 4x4 trigger towers)
Definition: L1CaloRegion.h:22
std::vector< L1CaloRegion > L1CaloRegionCollection

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