test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
APVCyclePhaseProducerFromL1ABC Class Reference

#include <DPGAnalysis/SiStripTools/plugins/APVCyclePhaseProducerFromL1ABC.cc>

Inheritance diagram for APVCyclePhaseProducerFromL1ABC:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 APVCyclePhaseProducerFromL1ABC (const edm::ParameterSet &)
 
 ~APVCyclePhaseProducerFromL1ABC ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

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

Private Attributes

edm::EventNumber_t _curroffevent
 
long long _curroffset
 
const std::vector< std::string > _defpartnames
 
const std::vector< int > _defphases
 
const unsigned int _firstgoodrun
 
TH1F ** _hbx
 
TH1F ** _hdbx
 
TH1F ** _hdorbit
 
edm::EDGetTokenT
< L1AcceptBunchCrossingCollection
_l1abccollectionToken
 
std::map< edm::EventNumber_t,
long long > 
_offsets
 
const int _orbitoffsetSOR
 
const bool _wantHistos
 
RunHistogramManager m_rhm
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: EDproducer for APVCyclePhaseCollection which uses the configuration file to assign a phase to the run

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

Definition at line 54 of file APVCyclePhaseProducerFromL1ABC.cc.

Constructor & Destructor Documentation

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

Definition at line 98 of file APVCyclePhaseProducerFromL1ABC.cc.

References _hbx, _hdbx, _hdorbit, _wantHistos, m_rhm, and RunHistogramManager::makeTH1F().

98  :
99  _l1abccollectionToken(mayConsume<L1AcceptBunchCrossingCollection>(iConfig.getParameter<edm::InputTag>("l1ABCCollection"))),
100  _defpartnames(iConfig.getParameter<std::vector<std::string> >("defaultPartitionNames")),
101  _defphases(iConfig.getParameter<std::vector<int> >("defaultPhases")),
102  _orbitoffsetSOR(iConfig.getParameter<int>("StartOfRunOrbitOffset")),
103  _wantHistos(iConfig.getUntrackedParameter<bool>("wantHistos",false)),
105  _hbx(0),_hdbx(0),_hdorbit(0),_firstgoodrun(110878),
107 {
108 
109  produces<APVCyclePhaseCollection,edm::InEvent>();
110 
111  //now do what ever other initialization is needed
112 
113  if(_wantHistos) {
114  _hbx = m_rhm.makeTH1F("l1abcbx","BX number from L1ABC",4096,-0.5,4095.5);
115  _hdbx = m_rhm.makeTH1F("dbx","BX number difference",4096*2-1,-4095.5,4095.5);
116  _hdorbit = m_rhm.makeTH1F("dorbit","Orbit Number difference",9999,-4999.5,4999.5);
117  }
118 
119 
120 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::map< edm::EventNumber_t, long long > _offsets
const std::vector< std::string > _defpartnames
edm::EDGetTokenT< L1AcceptBunchCrossingCollection > _l1abccollectionToken
TH1F ** makeTH1F(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
APVCyclePhaseProducerFromL1ABC::~APVCyclePhaseProducerFromL1ABC ( )

Definition at line 123 of file APVCyclePhaseProducerFromL1ABC.cc.

124 {
125 
126  // do anything here that needs to be done at desctruction time
127  // (e.g. close files, deallocate resources etc.)
128 
129 }

Member Function Documentation

void APVCyclePhaseProducerFromL1ABC::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 287 of file APVCyclePhaseProducerFromL1ABC.cc.

288 {
289 }
void APVCyclePhaseProducerFromL1ABC::beginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 138 of file APVCyclePhaseProducerFromL1ABC.cc.

References _firstgoodrun, _hbx, _hdbx, _hdorbit, _offsets, _wantHistos, RunHistogramManager::beginRun(), m_rhm, and edm::RunBase::run().

140 {
141 
142  // reset offset vector
143 
144  _offsets.clear();
145  edm::LogInfo("AbsoluteBXOffsetReset") << "Absolute BX offset map reset";
146 
147 
148  if(_wantHistos) {
149 
150  m_rhm.beginRun(iRun);
151 
152  if(_hbx && *_hbx) {
153  (*_hbx)->GetXaxis()->SetTitle("BX"); (*_hbx)->GetYaxis()->SetTitle("Events");
154  }
155 
156  if(_hdbx && *_hdbx) {
157  (*_hdbx)->GetXaxis()->SetTitle("#DeltaBX"); (*_hdbx)->GetYaxis()->SetTitle("Events");
158  }
159 
160  if(_hdorbit && *_hdorbit) {
161  (*_hdorbit)->GetXaxis()->SetTitle("#Deltaorbit"); (*_hdorbit)->GetYaxis()->SetTitle("Events");
162  }
163 
164  }
165 
166  if(iRun.run() < _firstgoodrun) {
167  edm::LogInfo("UnreliableMissingL1AcceptBunchCrossingCollection") <<
168  "In this run L1AcceptBunchCrossingCollection is missing or unreliable: default phases will be used";
169  }
170 
171 }
std::map< edm::EventNumber_t, long long > _offsets
RunNumber_t run() const
Definition: RunBase.h:40
void beginRun(const edm::Run &iRun)
void APVCyclePhaseProducerFromL1ABC::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 293 of file APVCyclePhaseProducerFromL1ABC.cc.

293  {
294 }
void APVCyclePhaseProducerFromL1ABC::endRun ( const edm::Run ,
const edm::EventSetup  
)
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 174 of file APVCyclePhaseProducerFromL1ABC.cc.

References _offsets, and hltrates_dqm_sourceclient-live_cfg::offset.

175 {
176  // summary of absolute bx offset vector
177 
178  edm::LogInfo("L1AcceptBunchCrossingAbsoluteBXOffsetSummary") << "Absolute BX offset summary:";
179  for(std::map<edm::EventNumber_t, long long>::const_iterator offset=_offsets.begin();offset!=_offsets.end();++offset) {
180  edm::LogVerbatim("L1AcceptBunchCrossingAbsoluteBXOffsetSummary") << offset->first << " " << offset->second;
181  }
182 
183 }
std::map< edm::EventNumber_t, long long > _offsets
void APVCyclePhaseProducerFromL1ABC::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 187 of file APVCyclePhaseProducerFromL1ABC.cc.

References _curroffevent, _curroffset, _defpartnames, _defphases, _firstgoodrun, _hbx, _hdbx, _hdorbit, _l1abccollectionToken, _offsets, _orbitoffsetSOR, _wantHistos, edm::EventBase::bunchCrossing(), edm::EventID::event(), Exception, edm::Event::getByToken(), edm::EventBase::id(), edm::EventBase::orbitNumber(), edm::Event::put(), and edm::Event::run().

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

187  {
188 
189  using namespace edm;
190 
191  std::auto_ptr<APVCyclePhaseCollection> apvphases(new APVCyclePhaseCollection() );
192 
193 
194  const std::vector<int>& phases = _defphases;
195  const std::vector<std::string>& partnames = _defpartnames;
196 
197  // Look for the L1AcceptBunchCrossingCollection
198 
199  int phasechange = 0;
200 
201  if(iEvent.run() >= _firstgoodrun ) {
202 
204  iEvent.getByToken(_l1abccollectionToken,pIn);
205 
206  // offset computation
207 
208  long long orbitoffset = _orbitoffsetSOR;
209  int bxoffset = 0;
210 
211  for(L1AcceptBunchCrossingCollection::const_iterator l1abc=pIn->begin();l1abc!=pIn->end();++l1abc) {
212  if(l1abc->l1AcceptOffset()==0) {
213  if(l1abc->eventType()!=0) {
214  orbitoffset = (long long)iEvent.orbitNumber() - (long long)l1abc->orbitNumber() ;
215  bxoffset = iEvent.bunchCrossing() - l1abc->bunchCrossing();
216 
217  if(_wantHistos) {
218  if(_hbx && *_hbx) (*_hbx)->Fill(l1abc->bunchCrossing());
219  if(_hdbx && *_hdbx) (*_hdbx)->Fill(bxoffset);
220  if(_hdorbit && *_hdorbit) (*_hdorbit)->Fill(orbitoffset);
221  }
222  }
223  else {
224  edm::LogWarning("L1AcceptBunchCrossingNoType") << "L1AcceptBunchCrossing with no type found: ";
225  for(L1AcceptBunchCrossingCollection::const_iterator debu=pIn->begin();debu!=pIn->end();++debu) {
226  edm::LogPrint("L1AcceptBunchCrossingNoType") << *debu;
227  }
228  }
229  }
230  }
231 
232  long long absbxoffset = orbitoffset*3564 + bxoffset;
233 
234  if(orbitoffset != _orbitoffsetSOR) phasechange = (orbitoffset*3564)%70;
235 
236  if(_offsets.size()==0) {
237  _curroffset = absbxoffset;
238  _curroffevent = iEvent.id().event();
239  _offsets[iEvent.id().event()] = absbxoffset;
240  }
241  else {
242  if(_curroffset != absbxoffset || iEvent.id().event() < _curroffevent ) {
243 
244  if( _curroffset != absbxoffset) {
245  edm::LogInfo("L1AcceptBunchCrossingAbsoluteBXOffsetChanged") << "Absolute BX offset changed from "
246  << _curroffset << " to "
247  << absbxoffset << " at orbit "
248  << iEvent.orbitNumber() << " and BX "
249  << iEvent.bunchCrossing();
250  for(L1AcceptBunchCrossingCollection::const_iterator l1abc=pIn->begin();l1abc!=pIn->end();++l1abc) {
251  edm::LogVerbatim("L1AcceptBunchCrossingAbsoluteBXOffsetChanged") << *l1abc;
252  }
253  }
254 
255  _curroffset = absbxoffset;
256  _curroffevent = iEvent.id().event();
257  _offsets[iEvent.id().event()] = absbxoffset;
258  }
259  }
260 
261 
262  }
263 
264 
265 
266  if(phases.size() < partnames.size() ) {
267  // throw exception
268  throw cms::Exception("InvalidAPVCyclePhases") << " Inconsistent phases/partitions vector sizes: "
269  << phases.size() << " "
270  << partnames.size();
271  }
272 
273  for(unsigned int ipart=0;ipart<partnames.size();++ipart) {
274  if(phases[ipart]>=0) {
275  apvphases->get()[partnames[ipart]] = (phases[ipart]+phasechange)%70;
276 
277  }
278  }
279 
280 
281  iEvent.put(apvphases);
282 
283 }
EventNumber_t event() const
Definition: EventID.h:41
std::map< edm::EventNumber_t, long long > _offsets
const std::vector< std::string > _defpartnames
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
int bunchCrossing() const
Definition: EventBase.h:65
edm::EDGetTokenT< L1AcceptBunchCrossingCollection > _l1abccollectionToken
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
RunNumber_t run() const
Definition: Event.h:93
int orbitNumber() const
Definition: EventBase.h:66
edm::EventID id() const
Definition: EventBase.h:59

Member Data Documentation

edm::EventNumber_t APVCyclePhaseProducerFromL1ABC::_curroffevent
private

Definition at line 82 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1ABC::_curroffset
private

Definition at line 81 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

const std::vector<std::string> APVCyclePhaseProducerFromL1ABC::_defpartnames
private

Definition at line 69 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

const std::vector<int> APVCyclePhaseProducerFromL1ABC::_defphases
private

Definition at line 70 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

const unsigned int APVCyclePhaseProducerFromL1ABC::_firstgoodrun
private

Definition at line 79 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by beginRun(), and produce().

TH1F** APVCyclePhaseProducerFromL1ABC::_hbx
private
TH1F** APVCyclePhaseProducerFromL1ABC::_hdbx
private
TH1F** APVCyclePhaseProducerFromL1ABC::_hdorbit
private
edm::EDGetTokenT<L1AcceptBunchCrossingCollection> APVCyclePhaseProducerFromL1ABC::_l1abccollectionToken
private

Definition at line 68 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

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

Definition at line 80 of file APVCyclePhaseProducerFromL1ABC.cc.

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

const int APVCyclePhaseProducerFromL1ABC::_orbitoffsetSOR
private

Definition at line 71 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

const bool APVCyclePhaseProducerFromL1ABC::_wantHistos
private
RunHistogramManager APVCyclePhaseProducerFromL1ABC::m_rhm
private

Definition at line 74 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by APVCyclePhaseProducerFromL1ABC(), and beginRun().