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

Public Member Functions

 RctTextToRctDigi (const edm::ParameterSet &)
 
 ~RctTextToRctDigi ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

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
 
typedef WorkerT< EDProducerWorkerType
 
- 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::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Description: Makes RCT digis from the file format specified by Pam Klabbers

Definition at line 40 of file RctTextToRctDigi.h.

Constructor & Destructor Documentation

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

Definition at line 42 of file RctTextToRctDigi.cc.

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

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

References i, m_file, and NUM_RCT_CRATES.

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

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

Referenced by produce().

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

112 {
113 
114  // Skip event if required
115  if (m_nevt < m_fileEventOffset){
116  //string tmp;
117  //for (int i=0; i<6; i++){
118  // getline(m_file[i],tmp);
119  //}
120  putEmptyDigi(iEvent);
121  m_nevt++;
122  return;
123  }
124 
125  // New collections
126  std::auto_ptr<L1CaloEmCollection> em (new L1CaloEmCollection);
127  std::auto_ptr<L1CaloRegionCollection> rgn (new L1CaloRegionCollection);
128 
129  // Loop over RCT crates
130  for (unsigned i=0; i<NUM_RCT_CRATES; i++){
131 
132  if(!m_file[i].good()) {
133  continue;
134  }
135 
136  // Check we're not at the end of the file
137  if(m_file[i].eof())
138  {
139  //throw cms::Exception("RctTextToRctDigiTextFileReadError")
140  LogDebug("RctTextToRctDigi")
141  << "RctTextToRctDigi::produce : "
142  << " unexpected end of file " << m_textFileName << i
143  << " adding empty collection for event !"
144  << std::endl;
145  putEmptyDigi(iEvent);
146  continue;
147  }
148 
149  // Check we're at the start of an event
150  std::string tmp;
151  m_file[i]>> tmp;
152  if(tmp!="Crossing")
153  {
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 << " + " << m_fileEventOffset
172  << 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,0));
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,0));
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 = uLongBuffer & 0x3ff; // put the first 10 bits of rawData into the Et
208  uLongBuffer >>= 10; // shift the remaining bits down to remove the 10 bits of Et
209 
210  bool overFlow = ((uLongBuffer & 0x1) != 0); //LSB is now overflow bit
211  bool tauVeto = (((uLongBuffer & 0x2) >> 1) != 0); //2nd bit is tauveto
212 
213  rgn->push_back(L1CaloRegion(et,overFlow,tauVeto,mipBitBuffer[j],qBitBuffer[j],i,j/2,j%2));
214  }
215 
216  // HF
217  for (unsigned j=0; j<8; j++){
218  m_file[i] >> uLongBuffer;
219 
220  unsigned et = uLongBuffer & 0xff; // put the first 8 bits into the Et
221 
222  rgn->push_back(L1CaloRegion(et,true,i,j));
223  }
224 
225  dec(m_file[i]);
226  }
227 
228  iEvent.put(em);
229  iEvent.put(rgn);
230 
231  m_nevt++;
232 }
#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:85
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 77 of file RctTextToRctDigi.cc.

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

Referenced by produce().

77  {
78  std::auto_ptr<L1CaloEmCollection> em (new L1CaloEmCollection);
79  std::auto_ptr<L1CaloRegionCollection> rgn (new L1CaloRegionCollection);
80  for (unsigned i=0; i<NUM_RCT_CRATES; i++){
81  for (unsigned j=0; j<4; j++) {
82  em->push_back(L1CaloEmCand(0, i, true));
83  em->push_back(L1CaloEmCand(0, i, false));
84  }
85  for (unsigned j=0; j<14; j++)
86  rgn->push_back(L1CaloRegion(0,false,false,false,false,i,j/2,j%2));
87  for (unsigned j=0; j<8; j++)
88  rgn->push_back(L1CaloRegion(0,true,i,j));
89  }
90  iEvent.put(em);
91  iEvent.put(rgn);
92 }
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:85
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 64 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 58 of file RctTextToRctDigi.h.

Referenced by bxSynchro(), and produce().

int RctTextToRctDigi::m_nevt
private

Event counter.

Definition at line 61 of file RctTextToRctDigi.h.

Referenced by bxSynchro(), and produce().

std::string RctTextToRctDigi::m_textFileName
private

Name out input file.

Definition at line 55 of file RctTextToRctDigi.h.

Referenced by produce(), and RctTextToRctDigi().