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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 43 of file EventWithHistoryProducerFromL1ABC.cc.

Constructor & Destructor Documentation

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

Definition at line 74 of file EventWithHistoryProducerFromL1ABC.cc.

References _forceNoOffset.

74  :
75  _l1abccollectionToken(mayConsume<L1AcceptBunchCrossingCollection>(iConfig.getParameter<edm::InputTag>("l1ABCCollection"))),
76  _forceNoOffset(iConfig.getUntrackedParameter<bool>("forceNoOffset",false)),
78 {
79 
80  if(_forceNoOffset) 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 
86 }
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 89 of file EventWithHistoryProducerFromL1ABC.cc.

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

Member Function Documentation

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

Definition at line 168 of file EventWithHistoryProducerFromL1ABC.cc.

References _offsets.

169 {
170  // reset offset vector
171 
172  _offsets.clear();
173  edm::LogInfo("AbsoluteBXOffsetReset") << "Absolute BX offset map reset";
174 
175 }
std::map< edm::EventNumber_t, long long > _offsets
void EventWithHistoryProducerFromL1ABC::endRun ( const edm::Run ,
const edm::EventSetup  
)
overrideprivate

Definition at line 178 of file EventWithHistoryProducerFromL1ABC.cc.

References _offsets, DEFINE_FWK_MODULE, and PFRecoTauDiscriminationByIsolation_cfi::offset.

179 {
180  // summary of absolute bx offset vector
181 
182  edm::LogInfo("AbsoluteBXOffsetSummary") << "Absolute BX offset summary:";
183  for(std::map<edm::EventNumber_t, long long>::const_iterator offset=_offsets.begin();offset!=_offsets.end();++offset) {
184  edm::LogVerbatim("AbsoluteBXOffsetSummary") << offset->first << " " << offset->second;
185  }
186 
187 }
std::map< edm::EventNumber_t, long long > _offsets
void EventWithHistoryProducerFromL1ABC::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 104 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().

105 {
106  using namespace edm;
107 
108  if(iEvent.run() < 110878 ) {
109 
110  std::unique_ptr<EventWithHistory> pOut(new EventWithHistory(iEvent));
111  iEvent.put(std::move(pOut));
112 
113  }
114  else {
115 
117  iEvent.getByToken(_l1abccollectionToken,pIn);
118 
119  // offset computation
120 
121  long long orbitoffset = 0;
122  int bxoffset = 0;
123  if(!_forceNoOffset) {
124  for(L1AcceptBunchCrossingCollection::const_iterator l1abc=pIn->begin();l1abc!=pIn->end();++l1abc) {
125  if(l1abc->l1AcceptOffset()==0) {
126  orbitoffset = (long long)l1abc->orbitNumber() - (long long)iEvent.orbitNumber();
127  bxoffset = l1abc->bunchCrossing() - iEvent.bunchCrossing();
128  }
129  }
130  }
131 
132 
133  std::unique_ptr<EventWithHistory> pOut(new EventWithHistory(iEvent,*pIn,orbitoffset,bxoffset));
134  iEvent.put(std::move(pOut));
135 
136  // monitor offset
137 
138  long long absbxoffset = orbitoffset*3564 + bxoffset;
139 
140  if(_offsets.empty()) {
141  _curroffset = absbxoffset;
142  _curroffevent = iEvent.id().event();
143  _offsets[iEvent.id().event()] = absbxoffset;
144  }
145  else {
146  if(_curroffset != absbxoffset || iEvent.id().event() < _curroffevent ) {
147 
148  if( _curroffset != absbxoffset) {
149  edm::LogInfo("AbsoluteBXOffsetChanged") << "Absolute BX offset changed from "
150  << _curroffset << " to "
151  << absbxoffset << " at orbit "
152  << iEvent.orbitNumber() << " and BX "
153  << iEvent.bunchCrossing();
154  for(L1AcceptBunchCrossingCollection::const_iterator l1abc=pIn->begin();l1abc!=pIn->end();++l1abc) {
155  edm::LogVerbatim("AbsoluteBXOffsetChanged") << *l1abc;
156  }
157  }
158 
159  _curroffset = absbxoffset;
160  _curroffevent = iEvent.id().event();
161  _offsets[iEvent.id().event()] = absbxoffset;
162  }
163  }
164  }
165 }
EventNumber_t event() const
Definition: EventID.h:41
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
int bunchCrossing() const
Definition: EventBase.h:64
std::map< edm::EventNumber_t, long long > _offsets
RunNumber_t run() const
Definition: Event.h:101
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 59 of file EventWithHistoryProducerFromL1ABC.cc.

Referenced by produce().

long long EventWithHistoryProducerFromL1ABC::_curroffset
private

Definition at line 58 of file EventWithHistoryProducerFromL1ABC.cc.

Referenced by produce().

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

Definition at line 55 of file EventWithHistoryProducerFromL1ABC.cc.

Referenced by produce().

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

Definition at line 57 of file EventWithHistoryProducerFromL1ABC.cc.

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