CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
APVCyclePhaseProducerFromL1TS Class Reference

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

Inheritance diagram for APVCyclePhaseProducerFromL1TS:
edm::stream::EDProducer<>

Public Member Functions

 APVCyclePhaseProducerFromL1TS (const edm::ParameterSet &)
 
 ~APVCyclePhaseProducerFromL1TS () 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
 
bool isBadRun (const unsigned int) const
 
void printConfiguration (std::stringstream &ss) const
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::vector< std::string > _defpartnames
 
std::vector< int > _defphases
 
edm::EDGetTokenT< Level1TriggerScalersCollection_l1tscollectionToken
 
long long _lastEventCounter0
 
long long _lastHardReset
 
long long _lastOrbitCounter0
 
long long _lastResync
 
long long _lastStart
 
long long _lastTestEnable
 
int _magicOffset
 
bool _useEC0
 
bool m_badRun
 
std::vector< std::pair< unsigned int, unsigned int > > m_badruns
 
edm::ESWatcher< SiStripConfObjectRcdm_eswatcher
 
const bool m_ignoreDB
 
const std::string m_rcdLabel
 

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: EDproducer for APVCyclePhaseCollection which uses the configuration file to assign a phase to the run

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

Definition at line 57 of file APVCyclePhaseProducerFromL1TS.cc.

Constructor & Destructor Documentation

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

Definition at line 102 of file APVCyclePhaseProducerFromL1TS.cc.

References m_badruns, printConfiguration(), and contentValuesCheck::ss.

103  : m_eswatcher(),
105  consumes<Level1TriggerScalersCollection>(iConfig.getParameter<edm::InputTag>("l1TSCollection"))),
106  m_ignoreDB(iConfig.getUntrackedParameter<bool>("ignoreDB", false)),
107  m_rcdLabel(iConfig.getUntrackedParameter<std::string>("recordLabel", "apvphaseoffsets")),
108  _defpartnames(iConfig.getParameter<std::vector<std::string> >("defaultPartitionNames")),
109  _defphases(iConfig.getParameter<std::vector<int> >("defaultPhases")),
110  _useEC0(iConfig.getUntrackedParameter<bool>("useEC0", false)),
111  _magicOffset(iConfig.getUntrackedParameter<int>("magicOffset", 8)),
112  m_badRun(false),
113  m_badruns(),
114  _lastResync(-1),
115  _lastHardReset(-1),
116  _lastStart(-1),
117  _lastEventCounter0(-1),
118  _lastOrbitCounter0(-1),
119  _lastTestEnable(-1) {
120  std::stringstream ss;
121  printConfiguration(ss);
122  edm::LogInfo("ConfigurationAtConstruction") << ss.str();
123 
124  produces<APVCyclePhaseCollection, edm::InEvent>();
125 
126  m_badruns.push_back(std::pair<unsigned int, unsigned int>(0, 131767));
127  m_badruns.push_back(std::pair<unsigned int, unsigned int>(193150, 193733));
128 
129  //now do what ever other initialization is needed
130 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::ESWatcher< SiStripConfObjectRcd > m_eswatcher
void printConfiguration(std::stringstream &ss) const
std::vector< std::pair< unsigned int, unsigned int > > m_badruns
edm::EDGetTokenT< Level1TriggerScalersCollection > _l1tscollectionToken
APVCyclePhaseProducerFromL1TS::~APVCyclePhaseProducerFromL1TS ( )
override

Definition at line 132 of file APVCyclePhaseProducerFromL1TS.cc.

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

Member Function Documentation

void APVCyclePhaseProducerFromL1TS::beginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 142 of file APVCyclePhaseProducerFromL1TS.cc.

References _defpartnames, _defphases, _magicOffset, _useEC0, edm::ESWatcher< T >::check(), SiStripConfObject::get(), edm::EventSetup::get(), isBadRun(), LogDebug, m_badRun, m_eswatcher, m_ignoreDB, m_rcdLabel, printConfiguration(), SiStripConfObject::printDebug(), edm::ESHandle< T >::product(), edm::RunBase::run(), contentValuesCheck::ss, and edmLumisInFiles::summary.

144 {
145  // update the parameters from DB
146 
147  if (!m_ignoreDB && m_eswatcher.check(iSetup)) {
149  iSetup.get<SiStripConfObjectRcd>().get(m_rcdLabel, confObj);
150 
152  iSetup.get<TrackerTopologyRcd>().get(tTopo);
153 
154  std::stringstream summary;
155  confObj->printDebug(summary, tTopo.product());
156  LogDebug("SiStripConfObjectSummary") << summary.str();
157 
158  _defpartnames = confObj->get<std::vector<std::string> >("defaultPartitionNames");
159  _defphases = confObj->get<std::vector<int> >("defaultPhases");
160  _useEC0 = confObj->get<bool>("useEC0");
161  m_badRun = confObj->get<bool>("badRun");
162  _magicOffset = confObj->get<int>("magicOffset");
163 
164  std::stringstream ss;
165  printConfiguration(ss);
166  edm::LogInfo("UpdatedConfiguration") << ss.str();
167  }
168 
169  if (isBadRun(iRun.run())) {
170  LogDebug("UnreliableMissingL1TriggerScalers") << "In this run L1TriggerScalers is missing or unreliable for phase "
171  "determination: invlid phase will be returned";
172  }
173 }
#define LogDebug(id)
void printDebug(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Prints the full list of parameters.
RunNumber_t run() const
Definition: RunBase.h:40
edm::ESWatcher< SiStripConfObjectRcd > m_eswatcher
void printConfiguration(std::stringstream &ss) const
bool isBadRun(const unsigned int) const
valueType get(const std::string &name) const
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
T get() const
Definition: EventSetup.h:73
T const * product() const
Definition: ESHandle.h:86
bool APVCyclePhaseProducerFromL1TS::isBadRun ( const unsigned int  run) const
private

Definition at line 249 of file APVCyclePhaseProducerFromL1TS.cc.

References m_badRun, m_badruns, and edm::second().

Referenced by beginRun(), and produce().

249  {
250  for (std::vector<std::pair<unsigned int, unsigned int> >::const_iterator runpair = m_badruns.begin();
251  runpair != m_badruns.end();
252  ++runpair) {
253  if (run >= runpair->first && run <= runpair->second)
254  return true;
255  }
256 
257  return m_badRun;
258 }
U second(std::pair< T, U > const &p)
std::vector< std::pair< unsigned int, unsigned int > > m_badruns
void APVCyclePhaseProducerFromL1TS::printConfiguration ( std::stringstream &  ss) const
private

Definition at line 260 of file APVCyclePhaseProducerFromL1TS.cc.

References _defpartnames, _defphases, _magicOffset, _useEC0, DEFINE_FWK_MODULE, m_badRun, and HLT_2018_cff::phase.

Referenced by APVCyclePhaseProducerFromL1TS(), and beginRun().

260  {
261  ss << _defpartnames.size() << " default partition names: ";
262  for (std::vector<std::string>::const_iterator part = _defpartnames.begin(); part != _defpartnames.end(); ++part) {
263  ss << *part << " ";
264  }
265  ss << std::endl;
266  ss << _defphases.size() << " default phases: ";
267  for (std::vector<int>::const_iterator phase = _defphases.begin(); phase != _defphases.end(); ++phase) {
268  ss << *phase << " ";
269  }
270  ss << std::endl;
271  ss << " Magic offset: " << _magicOffset << std::endl;
272  ss << " use ECO: " << _useEC0 << std::endl;
273  ss << " bad run: " << m_badRun << std::endl;
274 }
part
Definition: HCALResponse.h:20
void APVCyclePhaseProducerFromL1TS::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 175 of file APVCyclePhaseProducerFromL1TS.cc.

References _defpartnames, _defphases, _l1tscollectionToken, _lastEventCounter0, _lastHardReset, _lastOrbitCounter0, _lastResync, _lastStart, _lastTestEnable, _magicOffset, _useEC0, Exception, edm::Event::getByToken(), APVCyclePhaseCollection::invalid, isBadRun(), LogDebug, eostools::move(), phases, edm::Event::put(), and edm::Event::run().

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

175  {
176  using namespace edm;
177 
178  std::unique_ptr<APVCyclePhaseCollection> apvphases(new APVCyclePhaseCollection());
179 
180  std::vector<int> phases(_defphases.size(), APVCyclePhaseCollection::invalid);
181 
182  const std::vector<std::string>& partnames = _defpartnames;
183 
184  int phasechange = 0;
185 
187  iEvent.getByToken(_l1tscollectionToken, l1ts);
188 
189  // offset computation
190 
191  long long orbitoffset = 0;
192 
193  if (!l1ts->empty()) {
194  if ((*l1ts)[0].lastResync() != 0) {
195  orbitoffset = _useEC0 ? (*l1ts)[0].lastEventCounter0() + _magicOffset : (*l1ts)[0].lastResync() + _magicOffset;
196  }
197 
198  if (_lastResync != (*l1ts)[0].lastResync()) {
199  _lastResync = (*l1ts)[0].lastResync();
200  LogDebug("TTCSignalReceived") << "New Resync at orbit " << _lastResync;
201  }
202  if (_lastHardReset != (*l1ts)[0].lastHardReset()) {
203  _lastHardReset = (*l1ts)[0].lastHardReset();
204  LogDebug("TTCSignalReceived") << "New HardReset at orbit " << _lastHardReset;
205  }
206  if (_lastTestEnable != (*l1ts)[0].lastTestEnable()) {
207  _lastTestEnable = (*l1ts)[0].lastTestEnable();
208  // LogDebug("TTCSignalReceived") << "New TestEnable at orbit " << _lastTestEnable ;
209  }
210  if (_lastOrbitCounter0 != (*l1ts)[0].lastOrbitCounter0()) {
211  _lastOrbitCounter0 = (*l1ts)[0].lastOrbitCounter0();
212  LogDebug("TTCSignalReceived") << "New OrbitCounter0 at orbit " << _lastOrbitCounter0;
213  }
214  if (_lastEventCounter0 != (*l1ts)[0].lastEventCounter0()) {
215  _lastEventCounter0 = (*l1ts)[0].lastEventCounter0();
216  LogDebug("TTCSignalReceived") << "New EventCounter0 at orbit " << _lastEventCounter0;
217  }
218  if (_lastStart != (*l1ts)[0].lastStart()) {
219  _lastStart = (*l1ts)[0].lastStart();
220  LogDebug("TTCSignalReceived") << "New Start at orbit " << _lastStart;
221  }
222 
223  if (!isBadRun(iEvent.run())) {
224  phasechange = ((long long)(orbitoffset * 3564)) % 70;
225 
226  for (unsigned int ipart = 0; ipart < phases.size(); ++ipart) {
227  phases[ipart] = (_defphases[ipart] + phasechange) % 70;
228  }
229  }
230  }
231 
232  if (phases.size() < partnames.size()) {
233  // throw exception
234  throw cms::Exception("InvalidAPVCyclePhases")
235  << " Inconsistent phases/partitions vector sizes: " << phases.size() << " " << partnames.size();
236  }
237 
238  for (unsigned int ipart = 0; ipart < partnames.size(); ++ipart) {
239  // if(phases[ipart]>=0) {
240  // apvphases->get()[partnames[ipart]] = (phases[ipart]+phasechange)%70;
241  apvphases->get()[partnames[ipart]] = phases[ipart];
242 
243  // }
244  }
245 
246  iEvent.put(std::move(apvphases));
247 }
#define LogDebug(id)
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
RunNumber_t run() const
Definition: Event.h:107
bool isBadRun(const unsigned int) const
std::vector< int > phases
HLT enums.
edm::EDGetTokenT< Level1TriggerScalersCollection > _l1tscollectionToken
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

std::vector<std::string> APVCyclePhaseProducerFromL1TS::_defpartnames
private

Definition at line 75 of file APVCyclePhaseProducerFromL1TS.cc.

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

std::vector<int> APVCyclePhaseProducerFromL1TS::_defphases
private

Definition at line 76 of file APVCyclePhaseProducerFromL1TS.cc.

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

edm::EDGetTokenT<Level1TriggerScalersCollection> APVCyclePhaseProducerFromL1TS::_l1tscollectionToken
private

Definition at line 72 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastEventCounter0
private

Definition at line 86 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastHardReset
private

Definition at line 84 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastOrbitCounter0
private

Definition at line 87 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastResync
private

Definition at line 83 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastStart
private

Definition at line 85 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastTestEnable
private

Definition at line 88 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

int APVCyclePhaseProducerFromL1TS::_magicOffset
private

Definition at line 78 of file APVCyclePhaseProducerFromL1TS.cc.

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

bool APVCyclePhaseProducerFromL1TS::_useEC0
private

Definition at line 77 of file APVCyclePhaseProducerFromL1TS.cc.

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

bool APVCyclePhaseProducerFromL1TS::m_badRun
private

Definition at line 79 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by beginRun(), isBadRun(), and printConfiguration().

std::vector<std::pair<unsigned int, unsigned int> > APVCyclePhaseProducerFromL1TS::m_badruns
private

Definition at line 81 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by APVCyclePhaseProducerFromL1TS(), and isBadRun().

edm::ESWatcher<SiStripConfObjectRcd> APVCyclePhaseProducerFromL1TS::m_eswatcher
private

Definition at line 71 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by beginRun().

const bool APVCyclePhaseProducerFromL1TS::m_ignoreDB
private

Definition at line 73 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by beginRun().

const std::string APVCyclePhaseProducerFromL1TS::m_rcdLabel
private

Definition at line 74 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by beginRun().