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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache 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.

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 }

References _forceNoOffset.

◆ ~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.

175  {
176  // reset offset vector
177 
178  _offsets.clear();
179  edm::LogInfo("AbsoluteBXOffsetReset") << "Absolute BX offset map reset";
180 }

References _offsets.

◆ endRun()

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

Definition at line 182 of file EventWithHistoryProducerFromL1ABC.cc.

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 }

References _offsets, and hltrates_dqm_sourceclient-live_cfg::offset.

◆ produce()

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

Definition at line 102 of file EventWithHistoryProducerFromL1ABC.cc.

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 }

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

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

EventWithHistoryProducerFromL1ABC::_l1abccollectionToken
edm::EDGetTokenT< L1AcceptBunchCrossingCollection > _l1abccollectionToken
Definition: EventWithHistoryProducerFromL1ABC.cc:55
edm::Handle::product
T const * product() const
Definition: Handle.h:70
EventWithHistoryProducerFromL1ABC::_forceNoOffset
const bool _forceNoOffset
Definition: EventWithHistoryProducerFromL1ABC.cc:57
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::LogInfo
Definition: MessageLogger.h:254
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::Handle
Definition: AssociativeIterator.h:50
TCDSRecord::getOrbitNr
uint64_t getOrbitNr() const
Definition: TCDSRecord.h:88
EventWithHistoryProducerFromL1ABC::_tcdsRecordToken
edm::EDGetTokenT< TCDSRecord > _tcdsRecordToken
Definition: EventWithHistoryProducerFromL1ABC.cc:56
EventWithHistoryProducerFromL1ABC::_curroffset
long long _curroffset
Definition: EventWithHistoryProducerFromL1ABC.cc:60
EventWithHistoryProducerFromL1ABC::_curroffevent
edm::EventNumber_t _curroffevent
Definition: EventWithHistoryProducerFromL1ABC.cc:61
edm::LogWarning
Definition: MessageLogger.h:141
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::LogVerbatim
Definition: MessageLogger.h:297
EventWithHistory
Definition: EventWithHistory.h:17
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
EventWithHistoryProducerFromL1ABC::_offsets
std::map< edm::EventNumber_t, long long > _offsets
Definition: EventWithHistoryProducerFromL1ABC.cc:59
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
EventWithHistoryProducerFromL1ABC::_forceSCAL
const bool _forceSCAL
Definition: EventWithHistoryProducerFromL1ABC.cc:58
edm::InputTag
Definition: InputTag.h:15