CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
L1MuGMTHWFileReader Class Reference

#include <L1MuGMTHWFileReader.h>

Inheritance diagram for L1MuGMTHWFileReader:
edm::ProducerSourceFromFiles edm::ProducerSourceBase edm::FromFiles edm::IDGeneratorSourceBase< PuttableSourceBase > edm::PuttableSourceBase edm::InputSource edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 L1MuGMTHWFileReader (edm::ParameterSet const &, edm::InputSourceDescription const &)
 
void readNextEvent ()
 
 ~L1MuGMTHWFileReader () override
 
- Public Member Functions inherited from edm::ProducerSourceFromFiles
InputFileCatalogcatalog ()
 
std::vector< std::string > fileNames (unsigned iCatalog) const
 
std::vector< std::string > const & logicalFileNames () const
 
 ProducerSourceFromFiles (ParameterSet const &pset, InputSourceDescription const &desc, bool realData)
 
 ~ProducerSourceFromFiles () override
 
- Public Member Functions inherited from edm::ProducerSourceBase
 ProducerSourceBase (ParameterSet const &pset, InputSourceDescription const &desc, bool realData)
 
 ~ProducerSourceBase () noexcept(false) override
 
- Public Member Functions inherited from edm::IDGeneratorSourceBase< PuttableSourceBase >
EventNumber_t event () const
 
unsigned int eventCreationDelay () const
 
EventID const & eventID () const
 
 IDGeneratorSourceBase (ParameterSet const &pset, InputSourceDescription const &desc, bool realData)
 
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
 
 ~IDGeneratorSourceBase () noexcept(false) override
 
- Public Member Functions inherited from edm::PuttableSourceBase
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
PuttableSourceBaseoperator= (const PuttableSourceBase &)=delete
 
 PuttableSourceBase (ParameterSet const &, InputSourceDescription const &)
 
 PuttableSourceBase (const PuttableSourceBase &)=delete
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
void registerProducts () final
 Register any produced products. More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
- Public Member Functions inherited from edm::InputSource
std::shared_ptr< ActivityRegistryactReg () const
 Accessor for Activity Registry. More...
 
std::shared_ptr< BranchIDListHelper const > branchIDListHelper () const
 Accessors for branchIDListHelper. More...
 
std::shared_ptr< BranchIDListHelper > & branchIDListHelper ()
 
void closeFile (FileBlock *, bool cleaningUpAfterException)
 close current file More...
 
void doBeginJob ()
 Called by framework at beginning of job. More...
 
void doEndJob ()
 Called by framework at end of job. More...
 
void fillProcessBlockHelper ()
 Fill the ProcessBlockHelper with info for the current file. More...
 
ProcessingController::ForwardState forwardState () const
 
bool goToEvent (EventID const &eventID)
 
 InputSource (ParameterSet const &, InputSourceDescription const &)
 Constructor. More...
 
 InputSource (InputSource const &)=delete
 
void issueReports (EventID const &eventID, StreamID streamID)
 issue an event report More...
 
LuminosityBlockNumber_t luminosityBlock () const
 Accessor for current luminosity block number. More...
 
std::shared_ptr< LuminosityBlockAuxiliaryluminosityBlockAuxiliary () const
 Called by the framework to merge or insert lumi in principal cache. More...
 
int maxEvents () const
 
int maxLuminosityBlocks () const
 
ModuleDescription const & moduleDescription () const
 Accessor for 'module' description. More...
 
ItemType nextItemType ()
 Advances the source to the next item. More...
 
bool nextProcessBlock (ProcessBlockPrincipal &)
 Next process block, return false if there is none, sets the processName in the principal. More...
 
InputSourceoperator= (InputSource const &)=delete
 
std::shared_ptr< ProcessBlockHelper const > processBlockHelper () const
 Accessors for processBlockHelper. More...
 
std::shared_ptr< ProcessBlockHelper > & processBlockHelper ()
 
ProcessConfiguration const & processConfiguration () const
 Accessor for Process Configuration. More...
 
std::string const & processGUID () const
 Accessor for global process identifier. More...
 
ProcessHistoryRegistry const & processHistoryRegistry () const
 Accessors for process history registry. More...
 
ProcessHistoryRegistryprocessHistoryRegistry ()
 
ProcessingMode processingMode () const
 RunsLumisAndEvents (default), RunsAndLumis, or Runs. More...
 
std::shared_ptr< ProductRegistry const > productRegistry () const
 Accessors for product registry. More...
 
bool randomAccess () const
 
void readAndMergeLumi (LuminosityBlockPrincipal &lbp)
 Read next luminosity block (same as a prior lumi) More...
 
void readAndMergeRun (RunPrincipal &rp)
 Read next run (same as a prior run) More...
 
void readEvent (EventPrincipal &ep, StreamContext &)
 Read next event. More...
 
bool readEvent (EventPrincipal &ep, EventID const &, StreamContext &)
 Read a specific event. More...
 
std::shared_ptr< FileBlockreadFile ()
 Read next file. More...
 
void readLuminosityBlock (LuminosityBlockPrincipal &lumiPrincipal, HistoryAppender &historyAppender)
 Read next luminosity block (new lumi) More...
 
std::shared_ptr< LuminosityBlockAuxiliaryreadLuminosityBlockAuxiliary ()
 Read next luminosity block Auxilary. More...
 
void readProcessBlock (ProcessBlockPrincipal &)
 Read next process block. More...
 
void readRun (RunPrincipal &runPrincipal, HistoryAppender &historyAppender)
 Read next run (new run) More...
 
std::shared_ptr< RunAuxiliaryreadRunAuxiliary ()
 Read next run Auxiliary. More...
 
ProcessHistoryID const & reducedProcessHistoryID () const
 
int remainingEvents () const
 
int remainingLuminosityBlocks () const
 
void repeat ()
 Reset the remaining number of events/lumis to the maximum number. More...
 
std::pair< SharedResourcesAcquirer *, std::recursive_mutex * > resourceSharedWithDelayedReader ()
 Returns nullptr if no resource shared between the Source and a DelayedReader. More...
 
ProcessingController::ReverseState reverseState () const
 
void rewind ()
 Begin again at the first event. More...
 
RunNumber_t run () const
 Accessor for current run number. More...
 
std::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)
 
void switchTo (std::shared_ptr< ProductRegistry > iOther)
 switch to a different ProductRegistry. More...
 
std::shared_ptr< ThinnedAssociationsHelper const > thinnedAssociationsHelper () const
 Accessors for thinnedAssociationsHelper. More...
 
std::shared_ptr< ThinnedAssociationsHelper > & thinnedAssociationsHelper ()
 
Timestamp const & timestamp () const
 Accessor for the current time, as seen by the input source. More...
 
virtual ~InputSource () noexcept(false)
 Destructor. More...
 
- 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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 

Private Member Functions

void produce (edm::Event &) override
 
bool setRunAndEventInfo (edm::EventID &id, edm::TimeValue_t &time, edm::EventAuxiliary::ExperimentType &eType) override
 

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, IsSynchronize
}
 
enum  ProcessingMode { Runs, RunsAndLumis, RunsLumisAndEvents }
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Static Public Member Functions inherited from edm::ProducerSourceFromFiles
static void fillDescription (ParameterSetDescription &desc)
 
- Static Public Member Functions inherited from edm::IDGeneratorSourceBase< PuttableSourceBase >
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 &)
 
- Public Attributes inherited from edm::InputSource
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> postEventReadFromSourceSignal_
 
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> preEventReadFromSourceSignal_
 
- Protected Member Functions inherited from edm::ProducerSourceFromFiles
void incrementFileIndex ()
 
- Protected Member Functions inherited from edm::IDGeneratorSourceBase< PuttableSourceBase >
void doReadEvent (EventPrincipal &eventPrincipal, F &&f)
 
void doReadEventWithDelayedReader (EventPrincipal &eventPrincipal, ProcessHistoryID const &historyID, EventSelectionIDVector eventSelectionIDs, BranchListIndexes branchListIndexes, DelayedReader *reader)
 
- Protected Member Functions inherited from edm::InputSource
void decreaseRemainingEventsBy (int iSkipped)
 
bool eventCached () const
 
bool newLumi () const
 
bool newRun () const
 
ProcessHistoryRegistryprocessHistoryRegistryForUpdate ()
 
ProductRegistryproductRegistryUpdate ()
 
void reset () const
 
void resetEventCached ()
 
void resetLuminosityBlockAuxiliary (bool isNewLumi=true) const
 
void resetNewLumi ()
 
void resetNewRun ()
 
void resetRunAuxiliary (bool isNewRun=true) const
 
void setEventCached ()
 Called by the framework to merge or ached() const {return eventCached_;}. More...
 
void setLuminosityBlockAuxiliary (LuminosityBlockAuxiliary *lbp)
 
void setNewLumi ()
 
void setNewRun ()
 
void setRunAuxiliary (RunAuxiliary *rp)
 
void setTimestamp (Timestamp const &theTime)
 To set the current time, as seen by the input source. More...
 
ItemType state () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 

Detailed Description

Definition at line 39 of file L1MuGMTHWFileReader.h.

Constructor & Destructor Documentation

◆ L1MuGMTHWFileReader()

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

Definition at line 37 of file L1MuGMTHWFileReader.cc.

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

38  : ProducerSourceFromFiles(ps, desc, true) {
39  produces<std::vector<L1MuRegionalCand> >("DT");
40  produces<std::vector<L1MuRegionalCand> >("CSC");
41  produces<std::vector<L1MuRegionalCand> >("RPCb");
42  produces<std::vector<L1MuRegionalCand> >("RPCf");
43 
44  produces<L1CaloRegionCollection>();
45 
46  if (fileNames(0).empty()) {
47  throw std::runtime_error("L1MuGMTHWFileReader: no input file");
48  }
49  edm::LogInfo("GMT_HWFileReader_info") << "opening file " << fileNames(0)[0];
50  m_in.open((fileNames(0)[0].substr(fileNames(0)[0].find(':') + 1)).c_str());
51  if (!m_in) {
52  throw std::runtime_error("L1MuGMTHWFileReader: file " + fileNames(0)[0] + " could not be openned");
53  }
54 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
ProducerSourceFromFiles(ParameterSet const &pset, InputSourceDescription const &desc, bool realData)
Log< level::Info, false > LogInfo
std::vector< std::string > fileNames(unsigned iCatalog) const
Definition: FromFiles.h:22

◆ ~L1MuGMTHWFileReader()

L1MuGMTHWFileReader::~L1MuGMTHWFileReader ( )
override

Definition at line 59 of file L1MuGMTHWFileReader.cc.

References m_in.

59 { m_in.close(); }

Member Function Documentation

◆ produce()

void L1MuGMTHWFileReader::produce ( edm::Event e)
overrideprivatevirtual

Implements edm::ProducerSourceBase.

Definition at line 76 of file L1MuGMTHWFileReader.cc.

References MillePedeFileConverter_cfg::e, L1MuGMTInputEvent::getInputMuon(), L1MuGMTInputEvent::getIsoBit(), L1MuGMTInputEvent::getMipBit(), mps_fire::i, hcalRecHitTable_cff::ieta, hcalRecHitTable_cff::iphi, m_evt, eostools::move(), and amptDefaultParameters_cff::mu.

76  {
77  L1MuRegionalCand empty_mu;
78 
79  std::unique_ptr<std::vector<L1MuRegionalCand> > DTCands(new std::vector<L1MuRegionalCand>);
80  for (unsigned i = 0; i < 4; i++) {
81  const L1MuRegionalCand* mu = m_evt.getInputMuon("IND", i);
82  if (!mu)
83  mu = &empty_mu;
84  DTCands->push_back(*mu);
85  }
86  e.put(std::move(DTCands), "DT");
87 
88  std::unique_ptr<std::vector<L1MuRegionalCand> > CSCCands(new std::vector<L1MuRegionalCand>);
89  for (unsigned i = 0; i < 4; i++) {
90  const L1MuRegionalCand* mu = m_evt.getInputMuon("INC", i);
91  if (!mu)
92  mu = &empty_mu;
93  CSCCands->push_back(*mu);
94  }
95  e.put(std::move(CSCCands), "CSC");
96 
97  std::unique_ptr<std::vector<L1MuRegionalCand> > RPCbCands(new std::vector<L1MuRegionalCand>);
98  for (unsigned i = 0; i < 4; i++) {
99  const L1MuRegionalCand* mu = m_evt.getInputMuon("INB", i);
100  if (!mu)
101  mu = &empty_mu;
102  RPCbCands->push_back(*mu);
103  }
104  e.put(std::move(RPCbCands), "RPCb");
105 
106  std::unique_ptr<std::vector<L1MuRegionalCand> > RPCfCands(new std::vector<L1MuRegionalCand>);
107  for (unsigned i = 0; i < 4; i++) {
108  const L1MuRegionalCand* mu = m_evt.getInputMuon("INF", i);
109  if (!mu)
110  mu = &empty_mu;
111  RPCfCands->push_back(*mu);
112  }
113  e.put(std::move(RPCfCands), "RPCf");
114 
115  std::unique_ptr<L1CaloRegionCollection> rctRegions(new L1CaloRegionCollection);
116  for (int ieta = 4; ieta < 18; ieta++) {
117  for (int iphi = 0; iphi < 18; iphi++) {
118  rctRegions->push_back(
119  L1CaloRegion(0, false, true, m_evt.getMipBit(ieta - 4, iphi), m_evt.getIsoBit(ieta - 4, iphi), ieta, iphi));
120  }
121  }
122 
123  e.put(std::move(rctRegions));
124 }
const L1MuRegionalCand * getInputMuon(std::string chipid, unsigned index) const
L1MuGMTInputEvent m_evt
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:21
std::vector< L1CaloRegion > L1CaloRegionCollection
def move(src, dest)
Definition: eostools.py:511

◆ readNextEvent()

void L1MuGMTHWFileReader::readNextEvent ( )

Definition at line 126 of file L1MuGMTHWFileReader.cc.

References L1MuGMTInputEvent::addInputMuon(), visDQMUpload::buf, nano_mu_digi_cff::bx, PVValHelper::eta, mps_fire::i, m_evt, m_in, phase1PixelTopology::nPairs, phi, L1MuGMTInputEvent::reset(), fileCollector::runnr, L1MuGMTInputEvent::setEventNumber(), L1MuGMTInputEvent::setIsoBit(), L1MuGMTInputEvent::setMipBit(), L1MuGMTInputEvent::setRunNumber(), AlCaHLTBitMon_QueryRunRegistry::string, and heppy_batch::val.

Referenced by setRunAndEventInfo().

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

◆ setRunAndEventInfo()

bool L1MuGMTHWFileReader::setRunAndEventInfo ( edm::EventID id,
edm::TimeValue_t time,
edm::EventAuxiliary::ExperimentType eType 
)
overrideprivatevirtual

Implements edm::IDGeneratorSourceBase< PuttableSourceBase >.

Definition at line 64 of file L1MuGMTHWFileReader.cc.

References L1MuGMTInputEvent::getEventNumber(), L1MuGMTInputEvent::getRunNumber(), m_evt, and readNextEvent().

66  {
67  readNextEvent();
69  return false;
70  id = edm::EventID(m_evt.getRunNumber(), id.luminosityBlock(), m_evt.getEventNumber());
71 
72  edm::LogInfo("GMT_HWFileReader_info") << "run: " << m_evt.getRunNumber() << " evt: " << m_evt.getEventNumber();
73  return true;
74 }
L1MuGMTInputEvent m_evt
unsigned long getEventNumber() const
get the Event number
Log< level::Info, false > LogInfo
unsigned long getRunNumber() const
get the Run number

Member Data Documentation

◆ m_evt

L1MuGMTInputEvent L1MuGMTHWFileReader::m_evt
private

Definition at line 56 of file L1MuGMTHWFileReader.h.

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

◆ m_in

std::ifstream L1MuGMTHWFileReader::m_in
private

Definition at line 55 of file L1MuGMTHWFileReader.h.

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