CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

EventWithHistoryProducerFromL1ABC Class Reference

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

Inheritance diagram for EventWithHistoryProducerFromL1ABC:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 EventWithHistoryProducerFromL1ABC (const edm::ParameterSet &)
 ~EventWithHistoryProducerFromL1ABC ()

Private Member Functions

virtual void beginJob ()
virtual void beginRun (edm::Run &, const edm::EventSetup &)
virtual void endJob ()
virtual void endRun (edm::Run &, const edm::EventSetup &)
virtual void produce (edm::Event &, const edm::EventSetup &)

Private Attributes

unsigned int _curroffevent
long long _curroffset
const bool _forceNoOffset
edm::InputTag _l1abccollection
std::map< unsigned int, long long > _offsets

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

References _forceNoOffset.

                                                                                                  :
  _l1abccollection(iConfig.getParameter<edm::InputTag>("l1ABCCollection")),
  _forceNoOffset(iConfig.getUntrackedParameter<bool>("forceNoOffset",false)),
  _offsets(), _curroffset(0), _curroffevent(0)
{

  if(_forceNoOffset) edm::LogWarning("NoOffsetComputation") << "Orbit and BX offset will NOT be computed: Be careful!";

  produces<EventWithHistory>();
   
   //now do what ever other initialization is needed
  
}
EventWithHistoryProducerFromL1ABC::~EventWithHistoryProducerFromL1ABC ( )

Definition at line 91 of file EventWithHistoryProducerFromL1ABC.cc.

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

}

Member Function Documentation

void EventWithHistoryProducerFromL1ABC::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 171 of file EventWithHistoryProducerFromL1ABC.cc.

{
}
void EventWithHistoryProducerFromL1ABC::beginRun ( edm::Run ,
const edm::EventSetup  
) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 176 of file EventWithHistoryProducerFromL1ABC.cc.

References _offsets.

{
  // reset offset vector

  _offsets.clear();
  edm::LogInfo("AbsoluteBXOffsetReset") << "Absolute BX offset map reset";

}
void EventWithHistoryProducerFromL1ABC::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 199 of file EventWithHistoryProducerFromL1ABC.cc.

                                          {
}
void EventWithHistoryProducerFromL1ABC::endRun ( edm::Run ,
const edm::EventSetup  
) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 186 of file EventWithHistoryProducerFromL1ABC.cc.

References _offsets, and evf::evtn::offset().

{
  // summary of absolute bx offset vector

  edm::LogInfo("AbsoluteBXOffsetSummary") << "Absolute BX offset summary:";
  for(std::map<unsigned int, long long>::const_iterator offset=_offsets.begin();offset!=_offsets.end();++offset) {
    edm::LogVerbatim("AbsoluteBXOffsetSummary") << offset->first << " " << offset->second;
  }

}
void EventWithHistoryProducerFromL1ABC::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 106 of file EventWithHistoryProducerFromL1ABC.cc.

References _curroffevent, _curroffset, _forceNoOffset, _l1abccollection, _offsets, edm::EventBase::bunchCrossing(), edm::EventID::event(), edm::Event::getByLabel(), edm::EventBase::id(), edm::EventBase::orbitNumber(), edm::Event::put(), and edm::Event::run().

{
   using namespace edm;

   if(iEvent.run() < 110878 ) {

     std::auto_ptr<EventWithHistory> pOut(new EventWithHistory(iEvent));
     iEvent.put(pOut);

   }
   else {

     Handle<L1AcceptBunchCrossingCollection > pIn;
     iEvent.getByLabel(_l1abccollection,pIn);
     
     // offset computation
     
     long long orbitoffset = 0;
     int bxoffset = 0;
     if(!_forceNoOffset) {
       for(L1AcceptBunchCrossingCollection::const_iterator l1abc=pIn->begin();l1abc!=pIn->end();++l1abc) {
         if(l1abc->l1AcceptOffset()==0) {
           orbitoffset = (long long)l1abc->orbitNumber() - (long long)iEvent.orbitNumber();
           bxoffset = l1abc->bunchCrossing() - iEvent.bunchCrossing();
         }
       }
     }
     
     
     std::auto_ptr<EventWithHistory> pOut(new EventWithHistory(iEvent,*pIn,orbitoffset,bxoffset));
     iEvent.put(pOut);
     
     // monitor offset
     
     long long absbxoffset = orbitoffset*3564 + bxoffset;
     
     if(_offsets.size()==0) {
       _curroffset = absbxoffset;
       _curroffevent = iEvent.id().event();
       _offsets[iEvent.id().event()] = absbxoffset;
     }
     else {
       if(_curroffset != absbxoffset || iEvent.id().event() < _curroffevent ) {

         if( _curroffset != absbxoffset) {
           edm::LogInfo("AbsoluteBXOffsetChanged") << "Absolute BX offset changed from " 
                                                   << _curroffset << " to "
                                                   << absbxoffset << " at orbit "
                                                   << iEvent.orbitNumber() << " and BX "
                                                   << iEvent.bunchCrossing();
           for(L1AcceptBunchCrossingCollection::const_iterator l1abc=pIn->begin();l1abc!=pIn->end();++l1abc) {
             edm::LogVerbatim("AbsoluteBXOffsetChanged") << *l1abc;
           }
         }

         _curroffset = absbxoffset;
         _curroffevent = iEvent.id().event();
         _offsets[iEvent.id().event()] = absbxoffset;
       }
     }
   }
}

Member Data Documentation

Definition at line 61 of file EventWithHistoryProducerFromL1ABC.cc.

Referenced by produce().

Definition at line 60 of file EventWithHistoryProducerFromL1ABC.cc.

Referenced by produce().

Definition at line 57 of file EventWithHistoryProducerFromL1ABC.cc.

Referenced by produce().

std::map<unsigned int, long long> EventWithHistoryProducerFromL1ABC::_offsets [private]

Definition at line 59 of file EventWithHistoryProducerFromL1ABC.cc.

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