CMS 3D CMS Logo

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

#include <DPGAnalysis/SiStripTools/src/EventWithHistoryProducerFromL1ABC.cc>

Inheritance diagram for EventWithHistoryProducerFromL1ABC:
edm::stream::EDProducer<>

Public Member Functions

 EventWithHistoryProducerFromL1ABC (const edm::ParameterSet &)
 
 ~EventWithHistoryProducerFromL1ABC () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

void beginRun (const edm::Run &, const edm::EventSetup &) override
 
void endRun (const edm::Run &, const edm::EventSetup &) override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::EventNumber_t _curroffevent
 
long long _curroffset
 
const bool _forceNoOffset
 
const bool _forceSCAL
 
edm::EDGetTokenT< L1AcceptBunchCrossingCollection_l1abccollectionToken
 
std::map< edm::EventNumber_t, long long > _offsets
 
edm::EDGetTokenT< TCDSRecord_tcdsRecordToken
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 43 of file EventWithHistoryProducerFromL1ABC.cc.

Constructor & Destructor Documentation

◆ EventWithHistoryProducerFromL1ABC()

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

Definition at line 75 of file EventWithHistoryProducerFromL1ABC.cc.

References _forceNoOffset.

77  mayConsume<L1AcceptBunchCrossingCollection>(iConfig.getParameter<edm::InputTag>("l1ABCCollection"))),
78  _tcdsRecordToken(mayConsume<TCDSRecord>(iConfig.getParameter<edm::InputTag>("tcdsRecordLabel"))),
79  _forceNoOffset(iConfig.getUntrackedParameter<bool>("forceNoOffset", false)),
80  _forceSCAL(iConfig.getParameter<bool>("forceSCAL")),
81  _offsets(),
82  _curroffset(0),
83  _curroffevent(0) {
84  if (_forceNoOffset)
85  edm::LogWarning("NoOffsetComputation") << "Orbit and BX offset will NOT be computed: Be careful!";
86 
87  produces<EventWithHistory>();
88 
89  //now do what ever other initialization is needed
90 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
T getUntrackedParameter(std::string const &, T const &) const
std::map< edm::EventNumber_t, long long > _offsets
edm::EDGetTokenT< L1AcceptBunchCrossingCollection > _l1abccollectionToken
Log< level::Warning, false > LogWarning

◆ ~EventWithHistoryProducerFromL1ABC()

EventWithHistoryProducerFromL1ABC::~EventWithHistoryProducerFromL1ABC ( )
override

Definition at line 92 of file EventWithHistoryProducerFromL1ABC.cc.

92  {
93  // do anything here that needs to be done at desctruction time
94  // (e.g. close files, deallocate resources etc.)
95 }

Member Function Documentation

◆ beginRun()

void EventWithHistoryProducerFromL1ABC::beginRun ( const edm::Run ,
const edm::EventSetup  
)
overrideprivate

Definition at line 175 of file EventWithHistoryProducerFromL1ABC.cc.

References _offsets.

175  {
176  // reset offset vector
177 
178  _offsets.clear();
179  edm::LogInfo("AbsoluteBXOffsetReset") << "Absolute BX offset map reset";
180 }
std::map< edm::EventNumber_t, long long > _offsets
Log< level::Info, false > LogInfo

◆ endRun()

void EventWithHistoryProducerFromL1ABC::endRun ( const edm::Run ,
const edm::EventSetup  
)
overrideprivate

Definition at line 182 of file EventWithHistoryProducerFromL1ABC.cc.

References _offsets, and hltrates_dqm_sourceclient-live_cfg::offset.

182  {
183  // summary of absolute bx offset vector
184 
185  edm::LogInfo("AbsoluteBXOffsetSummary") << "Absolute BX offset summary:";
186  for (std::map<edm::EventNumber_t, long long>::const_iterator offset = _offsets.begin(); offset != _offsets.end();
187  ++offset) {
188  edm::LogVerbatim("AbsoluteBXOffsetSummary") << offset->first << " " << offset->second;
189  }
190 }
Log< level::Info, true > LogVerbatim
std::map< edm::EventNumber_t, long long > _offsets
Log< level::Info, false > LogInfo

◆ produce()

void EventWithHistoryProducerFromL1ABC::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 102 of file EventWithHistoryProducerFromL1ABC.cc.

References _curroffevent, _curroffset, _forceNoOffset, _forceSCAL, _l1abccollectionToken, _offsets, _tcdsRecordToken, iEvent, edm::HandleBase::isValid(), eostools::move(), edm::Handle< T >::product(), and BeamMonitor_cff::tcdsRecord.

102  {
103  using namespace edm;
104 
105  if (iEvent.run() < 110878) {
106  std::unique_ptr<EventWithHistory> pOut(new EventWithHistory(iEvent));
107  iEvent.put(std::move(pOut));
108 
109  } else {
111  iEvent.getByToken(_l1abccollectionToken, pIn);
112  Handle<TCDSRecord> tcds_pIn;
113  iEvent.getByToken(_tcdsRecordToken, tcds_pIn);
114  bool useTCDS(tcds_pIn.isValid() && !_forceSCAL);
115 
116  const auto* tcdsRecord = useTCDS ? tcds_pIn.product() : nullptr;
117  // offset computation
118 
119  long long orbitoffset = 0;
120  int bxoffset = 0;
121 
122  if (useTCDS) {
123  if (!_forceNoOffset) {
124  if (tcdsRecord->getL1aHistoryEntry(0).getIndex() == 0) {
125  orbitoffset = (long long)tcdsRecord->getOrbitNr() - (long long)iEvent.orbitNumber();
126  bxoffset = tcdsRecord->getBXID() - iEvent.bunchCrossing();
127  }
128  }
129  } else {
130  if (!_forceNoOffset) {
131  for (L1AcceptBunchCrossingCollection::const_iterator l1abc = pIn->begin(); l1abc != pIn->end(); ++l1abc) {
132  if (l1abc->l1AcceptOffset() == 0) {
133  orbitoffset = (long long)l1abc->orbitNumber() - (long long)iEvent.orbitNumber();
134  bxoffset = l1abc->bunchCrossing() - iEvent.bunchCrossing();
135  }
136  }
137  }
138  }
139 
140  std::unique_ptr<EventWithHistory> pOut(useTCDS ? new EventWithHistory(iEvent, *tcdsRecord, orbitoffset, bxoffset)
141  : new EventWithHistory(iEvent, *pIn, orbitoffset, bxoffset));
142  iEvent.put(std::move(pOut));
143 
144  // monitor offset
145 
146  long long absbxoffset = orbitoffset * 3564 + bxoffset;
147 
148  if (_offsets.empty()) {
149  _curroffset = absbxoffset;
150  _curroffevent = iEvent.id().event();
151  _offsets[iEvent.id().event()] = absbxoffset;
152  } else {
153  if (_curroffset != absbxoffset || iEvent.id().event() < _curroffevent) {
154  if (_curroffset != absbxoffset) {
155  edm::LogInfo("AbsoluteBXOffsetChanged")
156  << "Absolute BX offset changed from " << _curroffset << " to " << absbxoffset << " at orbit "
157  << iEvent.orbitNumber() << " and BX " << iEvent.bunchCrossing();
158  if (useTCDS) {
159  edm::LogVerbatim("AbsoluteBXOffsetChanged") << *tcdsRecord; // Not sure about this
160  } else {
161  for (L1AcceptBunchCrossingCollection::const_iterator l1abc = pIn->begin(); l1abc != pIn->end(); ++l1abc) {
162  edm::LogVerbatim("AbsoluteBXOffsetChanged") << *l1abc;
163  }
164  }
165  }
166 
167  _curroffset = absbxoffset;
168  _curroffevent = iEvent.id().event();
169  _offsets[iEvent.id().event()] = absbxoffset;
170  }
171  }
172  }
173 }
Log< level::Info, true > LogVerbatim
T const * product() const
Definition: Handle.h:70
std::map< edm::EventNumber_t, long long > _offsets
int iEvent
Definition: GenABIO.cc:224
Log< level::Info, false > LogInfo
bool isValid() const
Definition: HandleBase.h:70
edm::EDGetTokenT< L1AcceptBunchCrossingCollection > _l1abccollectionToken
HLT enums.
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ _curroffevent

edm::EventNumber_t EventWithHistoryProducerFromL1ABC::_curroffevent
private

Definition at line 61 of file EventWithHistoryProducerFromL1ABC.cc.

Referenced by produce().

◆ _curroffset

long long EventWithHistoryProducerFromL1ABC::_curroffset
private

Definition at line 60 of file EventWithHistoryProducerFromL1ABC.cc.

Referenced by produce().

◆ _forceNoOffset

const bool EventWithHistoryProducerFromL1ABC::_forceNoOffset
private

◆ _forceSCAL

const bool EventWithHistoryProducerFromL1ABC::_forceSCAL
private

Definition at line 58 of file EventWithHistoryProducerFromL1ABC.cc.

Referenced by produce().

◆ _l1abccollectionToken

edm::EDGetTokenT<L1AcceptBunchCrossingCollection> EventWithHistoryProducerFromL1ABC::_l1abccollectionToken
private

Definition at line 55 of file EventWithHistoryProducerFromL1ABC.cc.

Referenced by produce().

◆ _offsets

std::map<edm::EventNumber_t, long long> EventWithHistoryProducerFromL1ABC::_offsets
private

Definition at line 59 of file EventWithHistoryProducerFromL1ABC.cc.

Referenced by beginRun(), endRun(), and produce().

◆ _tcdsRecordToken

edm::EDGetTokenT<TCDSRecord> EventWithHistoryProducerFromL1ABC::_tcdsRecordToken
private

Definition at line 56 of file EventWithHistoryProducerFromL1ABC.cc.

Referenced by produce().