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
 
edm::EDGetTokenT< L1AcceptBunchCrossingCollection_l1abccollectionToken
 
std::map< edm::EventNumber_t, long long > _offsets
 

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 42 of file EventWithHistoryProducerFromL1ABC.cc.

Constructor & Destructor Documentation

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

Definition at line 72 of file EventWithHistoryProducerFromL1ABC.cc.

References _forceNoOffset.

74  mayConsume<L1AcceptBunchCrossingCollection>(iConfig.getParameter<edm::InputTag>("l1ABCCollection"))),
75  _forceNoOffset(iConfig.getUntrackedParameter<bool>("forceNoOffset", false)),
76  _offsets(),
77  _curroffset(0),
78  _curroffevent(0) {
79  if (_forceNoOffset)
80  edm::LogWarning("NoOffsetComputation") << "Orbit and BX offset will NOT be computed: Be careful!";
81 
82  produces<EventWithHistory>();
83 
84  //now do what ever other initialization is needed
85 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::map< edm::EventNumber_t, long long > _offsets
edm::EDGetTokenT< L1AcceptBunchCrossingCollection > _l1abccollectionToken
EventWithHistoryProducerFromL1ABC::~EventWithHistoryProducerFromL1ABC ( )
override

Definition at line 87 of file EventWithHistoryProducerFromL1ABC.cc.

87  {
88  // do anything here that needs to be done at desctruction time
89  // (e.g. close files, deallocate resources etc.)
90 }

Member Function Documentation

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

Definition at line 151 of file EventWithHistoryProducerFromL1ABC.cc.

References _offsets.

151  {
152  // reset offset vector
153 
154  _offsets.clear();
155  edm::LogInfo("AbsoluteBXOffsetReset") << "Absolute BX offset map reset";
156 }
std::map< edm::EventNumber_t, long long > _offsets
void EventWithHistoryProducerFromL1ABC::endRun ( const edm::Run ,
const edm::EventSetup  
)
overrideprivate

Definition at line 158 of file EventWithHistoryProducerFromL1ABC.cc.

References _offsets, DEFINE_FWK_MODULE, and hltrates_dqm_sourceclient-live_cfg::offset.

158  {
159  // summary of absolute bx offset vector
160 
161  edm::LogInfo("AbsoluteBXOffsetSummary") << "Absolute BX offset summary:";
162  for (std::map<edm::EventNumber_t, long long>::const_iterator offset = _offsets.begin(); offset != _offsets.end();
163  ++offset) {
164  edm::LogVerbatim("AbsoluteBXOffsetSummary") << offset->first << " " << offset->second;
165  }
166 }
std::map< edm::EventNumber_t, long long > _offsets
void EventWithHistoryProducerFromL1ABC::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 97 of file EventWithHistoryProducerFromL1ABC.cc.

References _curroffevent, _curroffset, _forceNoOffset, _l1abccollectionToken, _offsets, edm::EventBase::bunchCrossing(), edm::EventID::event(), edm::Event::getByToken(), edm::EventBase::id(), eostools::move(), edm::EventBase::orbitNumber(), edm::Event::put(), and edm::Event::run().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

97  {
98  using namespace edm;
99 
100  if (iEvent.run() < 110878) {
101  std::unique_ptr<EventWithHistory> pOut(new EventWithHistory(iEvent));
102  iEvent.put(std::move(pOut));
103 
104  } else {
106  iEvent.getByToken(_l1abccollectionToken, pIn);
107 
108  // offset computation
109 
110  long long orbitoffset = 0;
111  int bxoffset = 0;
112  if (!_forceNoOffset) {
113  for (L1AcceptBunchCrossingCollection::const_iterator l1abc = pIn->begin(); l1abc != pIn->end(); ++l1abc) {
114  if (l1abc->l1AcceptOffset() == 0) {
115  orbitoffset = (long long)l1abc->orbitNumber() - (long long)iEvent.orbitNumber();
116  bxoffset = l1abc->bunchCrossing() - iEvent.bunchCrossing();
117  }
118  }
119  }
120 
121  std::unique_ptr<EventWithHistory> pOut(new EventWithHistory(iEvent, *pIn, orbitoffset, bxoffset));
122  iEvent.put(std::move(pOut));
123 
124  // monitor offset
125 
126  long long absbxoffset = orbitoffset * 3564 + bxoffset;
127 
128  if (_offsets.empty()) {
129  _curroffset = absbxoffset;
130  _curroffevent = iEvent.id().event();
131  _offsets[iEvent.id().event()] = absbxoffset;
132  } else {
133  if (_curroffset != absbxoffset || iEvent.id().event() < _curroffevent) {
134  if (_curroffset != absbxoffset) {
135  edm::LogInfo("AbsoluteBXOffsetChanged")
136  << "Absolute BX offset changed from " << _curroffset << " to " << absbxoffset << " at orbit "
137  << iEvent.orbitNumber() << " and BX " << iEvent.bunchCrossing();
138  for (L1AcceptBunchCrossingCollection::const_iterator l1abc = pIn->begin(); l1abc != pIn->end(); ++l1abc) {
139  edm::LogVerbatim("AbsoluteBXOffsetChanged") << *l1abc;
140  }
141  }
142 
143  _curroffset = absbxoffset;
144  _curroffevent = iEvent.id().event();
145  _offsets[iEvent.id().event()] = absbxoffset;
146  }
147  }
148  }
149 }
EventNumber_t event() const
Definition: EventID.h:40
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
int bunchCrossing() const
Definition: EventBase.h:64
std::map< edm::EventNumber_t, long long > _offsets
RunNumber_t run() const
Definition: Event.h:107
int orbitNumber() const
Definition: EventBase.h:65
edm::EDGetTokenT< L1AcceptBunchCrossingCollection > _l1abccollectionToken
edm::EventID id() const
Definition: EventBase.h:59
HLT enums.
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

edm::EventNumber_t EventWithHistoryProducerFromL1ABC::_curroffevent
private

Definition at line 58 of file EventWithHistoryProducerFromL1ABC.cc.

Referenced by produce().

long long EventWithHistoryProducerFromL1ABC::_curroffset
private

Definition at line 57 of file EventWithHistoryProducerFromL1ABC.cc.

Referenced by produce().

const bool EventWithHistoryProducerFromL1ABC::_forceNoOffset
private
edm::EDGetTokenT<L1AcceptBunchCrossingCollection> EventWithHistoryProducerFromL1ABC::_l1abccollectionToken
private

Definition at line 54 of file EventWithHistoryProducerFromL1ABC.cc.

Referenced by produce().

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

Definition at line 56 of file EventWithHistoryProducerFromL1ABC.cc.

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