CMS 3D CMS Logo

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 () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void beginJob () override
 
void beginRun (const edm::Run &, const edm::EventSetup &) override
 
void endJob () 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 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
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
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)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 53 of file APVCyclePhaseProducerFromL1ABC.cc.

Constructor & Destructor Documentation

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

Definition at line 95 of file APVCyclePhaseProducerFromL1ABC.cc.

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

97  mayConsume<L1AcceptBunchCrossingCollection>(iConfig.getParameter<edm::InputTag>("l1ABCCollection"))),
98  _defpartnames(iConfig.getParameter<std::vector<std::string> >("defaultPartitionNames")),
99  _defphases(iConfig.getParameter<std::vector<int> >("defaultPhases")),
100  _orbitoffsetSOR(iConfig.getParameter<int>("StartOfRunOrbitOffset")),
101  _wantHistos(iConfig.getUntrackedParameter<bool>("wantHistos", false)),
103  _hbx(nullptr),
104  _hdbx(nullptr),
105  _hdorbit(nullptr),
106  _firstgoodrun(110878),
107  _offsets(),
108  _curroffset(0),
109  _curroffevent(0) {
110  produces<APVCyclePhaseCollection, edm::InEvent>();
111 
112  //now do what ever other initialization is needed
113 
114  if (_wantHistos) {
115  _hbx = m_rhm.makeTH1F("l1abcbx", "BX number from L1ABC", 4096, -0.5, 4095.5);
116  _hdbx = m_rhm.makeTH1F("dbx", "BX number difference", 4096 * 2 - 1, -4095.5, 4095.5);
117  _hdorbit = m_rhm.makeTH1F("dorbit", "Orbit Number difference", 9999, -4999.5, 4999.5);
118  }
119 }
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 ( )
override

Definition at line 121 of file APVCyclePhaseProducerFromL1ABC.cc.

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

Member Function Documentation

void APVCyclePhaseProducerFromL1ABC::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 261 of file APVCyclePhaseProducerFromL1ABC.cc.

261 {}
void APVCyclePhaseProducerFromL1ABC::beginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 131 of file APVCyclePhaseProducerFromL1ABC.cc.

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

133 {
134  // reset offset vector
135 
136  _offsets.clear();
137  edm::LogInfo("AbsoluteBXOffsetReset") << "Absolute BX offset map reset";
138 
139  if (_wantHistos) {
140  m_rhm.beginRun(iRun);
141 
142  if (_hbx && *_hbx) {
143  (*_hbx)->GetXaxis()->SetTitle("BX");
144  (*_hbx)->GetYaxis()->SetTitle("Events");
145  }
146 
147  if (_hdbx && *_hdbx) {
148  (*_hdbx)->GetXaxis()->SetTitle("#DeltaBX");
149  (*_hdbx)->GetYaxis()->SetTitle("Events");
150  }
151 
152  if (_hdorbit && *_hdorbit) {
153  (*_hdorbit)->GetXaxis()->SetTitle("#Deltaorbit");
154  (*_hdorbit)->GetYaxis()->SetTitle("Events");
155  }
156  }
157 
158  if (iRun.run() < _firstgoodrun) {
159  edm::LogInfo("UnreliableMissingL1AcceptBunchCrossingCollection")
160  << "In this run L1AcceptBunchCrossingCollection is missing or unreliable: default phases will be used";
161  }
162 }
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 264 of file APVCyclePhaseProducerFromL1ABC.cc.

References DEFINE_FWK_MODULE.

264 {}
void APVCyclePhaseProducerFromL1ABC::endRun ( const edm::Run ,
const edm::EventSetup  
)
overrideprivate

Definition at line 164 of file APVCyclePhaseProducerFromL1ABC.cc.

References _offsets, and hltrates_dqm_sourceclient-live_cfg::offset.

164  {
165  // summary of absolute bx offset vector
166 
167  edm::LogInfo("L1AcceptBunchCrossingAbsoluteBXOffsetSummary") << "Absolute BX offset summary:";
168  for (std::map<edm::EventNumber_t, long long>::const_iterator offset = _offsets.begin(); offset != _offsets.end();
169  ++offset) {
170  edm::LogVerbatim("L1AcceptBunchCrossingAbsoluteBXOffsetSummary") << offset->first << " " << offset->second;
171  }
172 }
std::map< edm::EventNumber_t, long long > _offsets
void APVCyclePhaseProducerFromL1ABC::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 174 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(), eostools::move(), edm::EventBase::orbitNumber(), phases, edm::Event::put(), and edm::Event::run().

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

174  {
175  using namespace edm;
176 
177  std::unique_ptr<APVCyclePhaseCollection> apvphases(new APVCyclePhaseCollection());
178 
179  const std::vector<int>& phases = _defphases;
180  const std::vector<std::string>& partnames = _defpartnames;
181 
182  // Look for the L1AcceptBunchCrossingCollection
183 
184  int phasechange = 0;
185 
186  if (iEvent.run() >= _firstgoodrun) {
188  iEvent.getByToken(_l1abccollectionToken, pIn);
189 
190  // offset computation
191 
192  long long orbitoffset = _orbitoffsetSOR;
193  int bxoffset = 0;
194 
195  for (L1AcceptBunchCrossingCollection::const_iterator l1abc = pIn->begin(); l1abc != pIn->end(); ++l1abc) {
196  if (l1abc->l1AcceptOffset() == 0) {
197  if (l1abc->eventType() != 0) {
198  orbitoffset = (long long)iEvent.orbitNumber() - (long long)l1abc->orbitNumber();
199  bxoffset = iEvent.bunchCrossing() - l1abc->bunchCrossing();
200 
201  if (_wantHistos) {
202  if (_hbx && *_hbx)
203  (*_hbx)->Fill(l1abc->bunchCrossing());
204  if (_hdbx && *_hdbx)
205  (*_hdbx)->Fill(bxoffset);
206  if (_hdorbit && *_hdorbit)
207  (*_hdorbit)->Fill(orbitoffset);
208  }
209  } else {
210  edm::LogWarning("L1AcceptBunchCrossingNoType") << "L1AcceptBunchCrossing with no type found: ";
211  for (L1AcceptBunchCrossingCollection::const_iterator debu = pIn->begin(); debu != pIn->end(); ++debu) {
212  edm::LogPrint("L1AcceptBunchCrossingNoType") << *debu;
213  }
214  }
215  }
216  }
217 
218  long long absbxoffset = orbitoffset * 3564 + bxoffset;
219 
220  if (orbitoffset != _orbitoffsetSOR)
221  phasechange = (orbitoffset * 3564) % 70;
222 
223  if (_offsets.empty()) {
224  _curroffset = absbxoffset;
225  _curroffevent = iEvent.id().event();
226  _offsets[iEvent.id().event()] = absbxoffset;
227  } else {
228  if (_curroffset != absbxoffset || iEvent.id().event() < _curroffevent) {
229  if (_curroffset != absbxoffset) {
230  edm::LogInfo("L1AcceptBunchCrossingAbsoluteBXOffsetChanged")
231  << "Absolute BX offset changed from " << _curroffset << " to " << absbxoffset << " at orbit "
232  << iEvent.orbitNumber() << " and BX " << iEvent.bunchCrossing();
233  for (L1AcceptBunchCrossingCollection::const_iterator l1abc = pIn->begin(); l1abc != pIn->end(); ++l1abc) {
234  edm::LogVerbatim("L1AcceptBunchCrossingAbsoluteBXOffsetChanged") << *l1abc;
235  }
236  }
237 
238  _curroffset = absbxoffset;
239  _curroffevent = iEvent.id().event();
240  _offsets[iEvent.id().event()] = absbxoffset;
241  }
242  }
243  }
244 
245  if (phases.size() < partnames.size()) {
246  // throw exception
247  throw cms::Exception("InvalidAPVCyclePhases")
248  << " Inconsistent phases/partitions vector sizes: " << phases.size() << " " << partnames.size();
249  }
250 
251  for (unsigned int ipart = 0; ipart < partnames.size(); ++ipart) {
252  if (phases[ipart] >= 0) {
253  apvphases->get()[partnames[ipart]] = (phases[ipart] + phasechange) % 70;
254  }
255  }
256 
257  iEvent.put(std::move(apvphases));
258 }
EventNumber_t event() const
Definition: EventID.h:40
std::map< edm::EventNumber_t, long long > _offsets
const std::vector< std::string > _defpartnames
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
edm::EDGetTokenT< L1AcceptBunchCrossingCollection > _l1abccollectionToken
RunNumber_t run() const
Definition: Event.h:107
int orbitNumber() const
Definition: EventBase.h:65
std::vector< int > phases
edm::EventID id() const
Definition: EventBase.h:59
HLT enums.
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

edm::EventNumber_t APVCyclePhaseProducerFromL1ABC::_curroffevent
private

Definition at line 81 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1ABC::_curroffset
private

Definition at line 80 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

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

Definition at line 68 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

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

Definition at line 69 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

const unsigned int APVCyclePhaseProducerFromL1ABC::_firstgoodrun
private

Definition at line 78 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 67 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

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

Definition at line 79 of file APVCyclePhaseProducerFromL1ABC.cc.

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

const int APVCyclePhaseProducerFromL1ABC::_orbitoffsetSOR
private

Definition at line 70 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

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

Definition at line 73 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by APVCyclePhaseProducerFromL1ABC(), and beginRun().