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 Attributes
L1MuGMTHWFileReader Class Reference

#include <L1MuGMTHWFileReader.h>

Inheritance diagram for L1MuGMTHWFileReader:
edm::ExternalInputSource edm::ConfigurableInputSource edm::InputSource edm::ProductRegistryHelper

Public Member Functions

 L1MuGMTHWFileReader (edm::ParameterSet const &, edm::InputSourceDescription const &)
 
virtual bool produce (edm::Event &)
 
void readNextEvent ()
 
virtual void setRunAndEventInfo ()
 
 ~L1MuGMTHWFileReader ()
 
- Public Member Functions inherited from edm::ExternalInputSource
InputFileCatalogcatalog ()
 
 ExternalInputSource (ParameterSet const &pset, InputSourceDescription const &desc, bool realData=true)
 
std::vector< std::string > const & fileNames () const
 
std::vector< std::string > const & logicalFileNames () const
 
virtual ~ExternalInputSource ()
 
- Public Member Functions inherited from edm::ConfigurableInputSource
 ConfigurableInputSource (ParameterSet const &pset, InputSourceDescription const &desc, bool realData=true)
 
EventNumber_t event () const
 
unsigned int eventCreationDelay () const
 
LuminosityBlockNumber_t luminosityBlock () const
 
unsigned int numberEventsInLumi () const
 
unsigned int numberEventsInRun () const
 
unsigned int numberEventsInThisLumi () const
 
unsigned int numberEventsInThisRun () const
 
TimeValue_t presentTime () const
 
RunNumber_t run () const
 
unsigned int timeBetweenEvents () const
 
virtual ~ConfigurableInputSource ()
 
- Public Member Functions inherited from edm::InputSource
boost::shared_ptr
< ActivityRegistry
actReg () const
 Accessor for Activity Registry. More...
 
void closeFile (boost::shared_ptr< FileBlock >, bool cleaningUpAfterException)
 close current file More...
 
void doBeginJob ()
 Called by framework at beginning of job. More...
 
void doBeginLumi (LuminosityBlockPrincipal &lbp)
 Called by framework at beginning of lumi block. More...
 
void doBeginRun (RunPrincipal &rp)
 Called by framework at beginning of run. More...
 
void doEndJob ()
 Called by framework at end of job. More...
 
void doEndLumi (LuminosityBlockPrincipal &lbp, bool cleaningUpAfterException)
 Called by framework at end of lumi block. More...
 
void doEndRun (RunPrincipal &rp, bool cleaningUpAfterException)
 Called by framework at end of run. More...
 
void doPostForkReacquireResources (boost::shared_ptr< multicore::MessageReceiverForSource >)
 
void doPreForkReleaseResources ()
 Called by the framework before forking the process. More...
 
ProcessingController::ForwardState forwardState () const
 
bool goToEvent (EventID const &eventID)
 
 InputSource (ParameterSet const &, InputSourceDescription const &)
 Constructor. More...
 
void issueReports (EventID const &eventID)
 issue an event report More...
 
LuminosityBlockNumber_t luminosityBlock () const
 Accessor for current luminosity block number. More...
 
boost::shared_ptr
< LuminosityBlockAuxiliary
luminosityBlockAuxiliary () const
 Called by the framework to merge or insert lumi in principal cache. More...
 
int markLumi ()
 Mark lumi as read. More...
 
int markRun ()
 Mark run as read. More...
 
int maxEvents () const
 
int maxLuminosityBlocks () const
 
ModuleDescription const & moduleDescription () const
 Accessor for 'module' description. More...
 
ItemType nextItemType ()
 
bool primary () const
 Accessor for primary input source flag. More...
 
ProcessConfiguration const & processConfiguration () const
 Accessor for Process Configuration. More...
 
std::string const & processGUID () const
 Accessor for global process identifier. More...
 
ProcessingMode processingMode () const
 RunsLumisAndEvents (default), RunsAndLumis, or Runs. More...
 
boost::shared_ptr
< ProductRegistry const > 
productRegistry () const
 Accessor for product registry. More...
 
bool randomAccess () const
 
void readAndCacheLumi (bool merge, HistoryAppender &historyAppender)
 Read next luminosity block. More...
 
void readAndCacheRun (bool merge, HistoryAppender &historyAppender)
 Read next run. More...
 
EventPrincipalreadEvent (boost::shared_ptr< LuminosityBlockPrincipal > lbCache)
 
EventPrincipalreadEvent (EventID const &)
 Read a specific event. More...
 
boost::shared_ptr< FileBlockreadFile ()
 Read next file. More...
 
boost::shared_ptr
< LuminosityBlockAuxiliary
readLuminosityBlockAuxiliary ()
 Read next luminosity block Auxilary. More...
 
boost::shared_ptr< RunAuxiliaryreadRunAuxiliary ()
 Read next run Auxiliary. More...
 
ProcessHistoryID const & reducedProcessHistoryID () const
 
void registerProducts ()
 Register any produced products. More...
 
int remainingEvents () const
 
int remainingLuminosityBlocks () const
 
void repeat ()
 Reset the remaining number of events/lumis to the maximum number. More...
 
ProcessingController::ReverseState reverseState () const
 
void rewind ()
 Begin again at the first event. More...
 
RunNumber_t run () const
 Accessor for current run number. More...
 
boost::shared_ptr< RunAuxiliaryrunAuxiliary () const
 Called by the framework to merge or insert run in principal cache. More...
 
void setLuminosityBlockNumber_t (LuminosityBlockNumber_t lb)
 Set the luminosity block ID. More...
 
void setRunNumber (RunNumber_t r)
 Set the run number. More...
 
void skipEvents (int offset)
 
Timestamp const & timestamp () const
 Accessor for the current time, as seen by the input source. More...
 
virtual ~InputSource ()
 Destructor. More...
 

Private Attributes

L1MuGMTInputEvent m_evt
 
std::ifstream m_in
 

Additional Inherited Members

- Public Types inherited from edm::InputSource
enum  ItemType {
  IsInvalid, IsStop, IsFile, IsRun,
  IsLumi, IsEvent, IsRepeat
}
 
enum  ProcessingMode { Runs, RunsAndLumis, RunsLumisAndEvents }
 
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::ExternalInputSource
static void fillDescription (ParameterSetDescription &desc)
 
- Static Public Member Functions inherited from edm::ConfigurableInputSource
static void fillDescription (ParameterSetDescription &desc)
 
- Static Public Member Functions inherited from edm::InputSource
static const std::string & baseType ()
 
static void fillDescription (ParameterSetDescription &desc)
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::ExternalInputSource
void incrementFileIndex ()
 
- Protected Member Functions inherited from edm::ConfigurableInputSource
void reallyReadEvent ()
 
void setEventNumber (EventNumber_t e)
 
void setTime (TimeValue_t t)
 
- Protected Member Functions inherited from edm::InputSource
void decreaseRemainingEventsBy (int iSkipped)
 
EventPrincipaleventPrincipalCache ()
 
boost::shared_ptr
< LuminosityBlockPrincipal >
const 
luminosityBlockPrincipal () const
 
PrincipalCache const & principalCache () const
 
PrincipalCacheprincipalCache ()
 
ProductRegistryproductRegistryUpdate () const
 
void reset () const
 
void resetLuminosityBlockAuxiliary () const
 
void resetRunAuxiliary () const
 
boost::shared_ptr
< RunPrincipal > const 
runPrincipal () const
 
void setLuminosityBlockAuxiliary (LuminosityBlockAuxiliary *lbp)
 
void setRunAuxiliary (RunAuxiliary *rp)
 
void setTimestamp (Timestamp const &theTime)
 To set the current time, as seen by the input source. More...
 
ItemType state () const
 

Detailed Description

Definition at line 41 of file L1MuGMTHWFileReader.h.

Constructor & Destructor Documentation

L1MuGMTHWFileReader::L1MuGMTHWFileReader ( edm::ParameterSet const &  ps,
edm::InputSourceDescription const &  desc 
)
explicit

Definition at line 39 of file L1MuGMTHWFileReader.cc.

References edm::ExternalInputSource::fileNames(), spr::find(), and m_in.

40  :
41  ExternalInputSource(ps, desc) {
42 
43  produces<std::vector<L1MuRegionalCand> >("DT");
44  produces<std::vector<L1MuRegionalCand> >("CSC");
45  produces<std::vector<L1MuRegionalCand> >("RPCb");
46  produces<std::vector<L1MuRegionalCand> >("RPCf");
47 
48  produces<L1CaloRegionCollection>();
49 
50  if(!fileNames().size()) {
51  throw std::runtime_error("L1MuGMTHWFileReader: no input file");
52  }
53  edm::LogInfo("GMT_HWFileReader_info") << "opening file " << fileNames()[0];
54  m_in.open((fileNames()[0].substr(fileNames()[0].find(":")+1)).c_str());
55  if(!m_in) {
56  throw std::runtime_error("L1MuGMTHWFileReader: file " + fileNames()[0]
57  + " could not be openned");
58  }
59 
60 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
ExternalInputSource(ParameterSet const &pset, InputSourceDescription const &desc, bool realData=true)
std::vector< std::string > const & fileNames() const
L1MuGMTHWFileReader::~L1MuGMTHWFileReader ( )

Definition at line 65 of file L1MuGMTHWFileReader.cc.

References m_in.

65  {
66  m_in.close();
67 }

Member Function Documentation

bool L1MuGMTHWFileReader::produce ( edm::Event e)
virtual

Implements edm::ConfigurableInputSource.

Definition at line 81 of file L1MuGMTHWFileReader.cc.

References L1MuGMTInputEvent::getEventNumber(), L1MuGMTInputEvent::getInputMuon(), L1MuGMTInputEvent::getIsoBit(), L1MuGMTInputEvent::getMipBit(), L1MuGMTInputEvent::getRunNumber(), i, m_evt, RPCpg::mu, and edm::Event::put().

81  {
82  L1MuRegionalCand empty_mu;
83 
84  if(!m_evt.getRunNumber() && !m_evt.getEventNumber()) return false;
85 
86  std::auto_ptr<std::vector<L1MuRegionalCand> > DTCands(new std::vector<L1MuRegionalCand>);
87  for (unsigned i = 0; i < 4; i++) {
88  const L1MuRegionalCand *mu = m_evt.getInputMuon("IND", i);
89  if (!mu) mu = &empty_mu;
90  DTCands->push_back(*mu);
91  }
92  e.put(DTCands,"DT");
93 
94  std::auto_ptr<std::vector<L1MuRegionalCand> > CSCCands(new std::vector<L1MuRegionalCand>);
95  for (unsigned i = 0; i < 4; i++) {
96  const L1MuRegionalCand *mu = m_evt.getInputMuon("INC", i);
97  if (!mu) mu = &empty_mu;
98  CSCCands->push_back(*mu);
99  }
100  e.put(CSCCands,"CSC");
101 
102  std::auto_ptr<std::vector<L1MuRegionalCand> > RPCbCands(new std::vector<L1MuRegionalCand>);
103  for (unsigned i = 0; i < 4; i++) {
104  const L1MuRegionalCand *mu = m_evt.getInputMuon("INB", i);
105  if (!mu) mu = &empty_mu;
106  RPCbCands->push_back(*mu);
107  }
108  e.put(RPCbCands,"RPCb");
109 
110  std::auto_ptr<std::vector<L1MuRegionalCand> > RPCfCands(new std::vector<L1MuRegionalCand>);
111  for (unsigned i = 0; i < 4; i++) {
112  const L1MuRegionalCand *mu = m_evt.getInputMuon("INF", i);
113  if (!mu) mu = &empty_mu;
114  RPCfCands->push_back(*mu);
115  }
116  e.put(RPCfCands,"RPCf");
117 
118  std::auto_ptr<L1CaloRegionCollection> rctRegions (new L1CaloRegionCollection);
119  for(int ieta = 4; ieta < 18; ieta++) {
120  for(int iphi = 0; iphi < 18; iphi++) {
121  rctRegions->push_back(L1CaloRegion(0,false,true,m_evt.getMipBit(ieta-4,iphi),m_evt.getIsoBit(ieta-4,iphi),ieta,iphi));
122  }
123  }
124 
125  e.put(rctRegions);
126 
127  return true;
128 }
int i
Definition: DBlmapReader.cc:9
unsigned long getRunNumber() const
get the Run number
unsigned long getEventNumber() const
get the Event number
L1MuGMTInputEvent m_evt
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
const int mu
Definition: Constants.h:23
const L1MuRegionalCand * getInputMuon(std::string chipid, unsigned index) const
const bool & getMipBit(unsigned etaIndex, unsigned phiIndex)
const bool & getIsoBit(unsigned etaIndex, unsigned phiIndex)
A calorimeter trigger region (sum of 4x4 trigger towers)
Definition: L1CaloRegion.h:22
std::vector< L1CaloRegion > L1CaloRegionCollection
void L1MuGMTHWFileReader::readNextEvent ( )

Definition at line 130 of file L1MuGMTHWFileReader.cc.

References L1MuGMTInputEvent::addInputMuon(), eta(), i, m_evt, m_in, phi, L1MuGMTInputEvent::reset(), L1MuRegionalCand::setBx(), L1MuGMTInputEvent::setEventNumber(), L1MuGMTInputEvent::setIsoBit(), L1MuGMTInputEvent::setMipBit(), L1MuGMTInputEvent::setRunNumber(), and L1MuRegionalCand::setType().

Referenced by setRunAndEventInfo().

130  {
131  m_evt.reset();
132 
133  std::string line_id;
134  do {
135  int bx = 0;
136 
137  m_in >> line_id;
138  if (line_id == "--") continue;
139 
140  if (line_id == "RUN") {
141  unsigned long runnr;
142  m_in >> runnr;
143  m_evt.setRunNumber(runnr);
144  }
145 
146  if (line_id == "EVT") {
147  unsigned long evtnr;
148  m_in >> evtnr;
149  m_evt.setEventNumber(evtnr);
150  }
151 
152 
153  if (line_id == "DT" || line_id == "CSC" || line_id == "BRPC" || line_id == "FRPC")
154  {
155 
156  // decode input muon
157 
158  unsigned inpmu = 0;
159  unsigned val;
160  m_in >> val; inpmu |= (val & 0x01) << 24; // valid charge
161  m_in >> val; inpmu |= (val & 0x01) << 23; // charge
162  m_in >> val; inpmu |= (val & 0x01) << 22; // halo / fine
163  m_in >> val; inpmu |= (val & 0x3f) << 16; // eta
164  m_in >> val; inpmu |= (val & 0x07) << 13; // quality
165  m_in >> val; inpmu |= (val & 0x1f) << 8; // pt
166  m_in >> val; inpmu |= (val & 0xff) ; // phi
167 
168  std::string chipid("IN");
169  chipid += line_id[0];
170 
171  int type=0;
172  if (line_id == "DT") type = 0;
173  if (line_id == "CSC") type = 2;
174  if (line_id == "BRPC") type = 1;
175  if (line_id == "FRPC") type = 3;
176 
177 
178  L1MuRegionalCand cand(inpmu);
179  cand.setType(type);
180  cand.setBx(bx);
181  m_evt.addInputMuon(chipid, cand);
182  }
183 
184  if (line_id == "MIP") {
185  int nPairs;
186  m_in >> nPairs;
187  for (int i=0; i<nPairs; i++) {
188  unsigned eta;
189  unsigned phi;
190  m_in >> eta;
191  m_in >> phi;
192  if (phi >= 9) phi-=9;
193  else phi+=9;
194  m_evt.setMipBit(eta, phi, true);
195  }
196  }
197 
198  if (line_id == "NQ") {
199  int nPairs;
200  m_in >> nPairs;
201  for (int i=0; i<nPairs; i++) {
202  unsigned eta;
203  unsigned phi;
204  m_in >> eta;
205  m_in >> phi;
206  if (phi >= 9) phi-=9;
207  else phi+=9;
208  m_evt.setIsoBit(eta, phi, false);
209  }
210  }
211 
212  //read the rest of the line
213  const int sz=4000; char buf[sz];
214  m_in.getline(buf, sz);
215 
216  } while (line_id != "NQ" && !m_in.eof());
217 
218 }
type
Definition: HCALResponse.h:22
int i
Definition: DBlmapReader.cc:9
T eta() const
void setRunNumber(unsigned long runnr)
L1MuGMTInputEvent m_evt
void addInputMuon(std::string chipid, const L1MuRegionalCand &inMu)
void setIsoBit(unsigned etaIndex, unsigned phiIndex, bool val)
void setEventNumber(unsigned long eventnr)
void setMipBit(unsigned etaIndex, unsigned phiIndex, bool val)
Definition: DDAxes.h:10
void L1MuGMTHWFileReader::setRunAndEventInfo ( )
virtual

Reimplemented from edm::ConfigurableInputSource.

Definition at line 72 of file L1MuGMTHWFileReader.cc.

References L1MuGMTInputEvent::getEventNumber(), L1MuGMTInputEvent::getRunNumber(), m_evt, readNextEvent(), edm::ConfigurableInputSource::setEventNumber(), and edm::InputSource::setRunNumber().

72  {
73  readNextEvent();
76 
77  edm::LogInfo("GMT_HWFileReader_info") << "run: " << m_evt.getRunNumber() <<
78  " evt: " << m_evt.getEventNumber();
79 }
unsigned long getRunNumber() const
get the Run number
unsigned long getEventNumber() const
get the Event number
L1MuGMTInputEvent m_evt
void setRunNumber(RunNumber_t r)
Set the run number.
Definition: InputSource.h:143
void setEventNumber(EventNumber_t e)

Member Data Documentation

L1MuGMTInputEvent L1MuGMTHWFileReader::m_evt
private

Definition at line 58 of file L1MuGMTHWFileReader.h.

Referenced by produce(), readNextEvent(), and setRunAndEventInfo().

std::ifstream L1MuGMTHWFileReader::m_in
private

Definition at line 57 of file L1MuGMTHWFileReader.h.

Referenced by L1MuGMTHWFileReader(), readNextEvent(), and ~L1MuGMTHWFileReader().