CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

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

edm::ESGetToken
< SiStripConfObject,
SiStripConfObjectRcd
_confObjectToken
 
std::vector< std::string > _defpartnames
 
std::vector< int > _defphases
 
const bool _forceSCAL
 
edm::EDGetTokenT
< Level1TriggerScalersCollection
_l1tscollectionToken
 
long long _lastEventCounter0
 
long long _lastHardReset
 
long long _lastOrbitCounter0
 
long long _lastResync
 
long long _lastStart
 
long long _lastTestEnable
 
int _magicOffset
 
edm::EDGetTokenT< TCDSRecord_tcdsRecordToken
 
edm::ESGetToken
< TrackerTopology,
TrackerTopologyRcd
_tTopoToken
 
bool _useEC0
 
bool m_badRun
 
std::vector< std::pair
< unsigned int, unsigned int > > 
m_badruns
 
edm::ESWatcher
< SiStripConfObjectRcd
m_eswatcher
 
const bool m_ignoreDB
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::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 58 of file APVCyclePhaseProducerFromL1TS.cc.

Constructor & Destructor Documentation

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

Definition at line 106 of file APVCyclePhaseProducerFromL1TS.cc.

References edm::ParameterSet::getUntrackedParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

107  : m_ignoreDB(iConfig.getUntrackedParameter<bool>("ignoreDB", false)),
108  m_eswatcher(),
110  consumes<Level1TriggerScalersCollection>(iConfig.getParameter<edm::InputTag>("l1TSCollection"))),
111  _tcdsRecordToken(consumes<TCDSRecord>(iConfig.getParameter<edm::InputTag>("tcdsRecordLabel"))),
113  ? decltype(_confObjectToken){esConsumes<edm::Transition::BeginRun>(edm::ESInputTag{
114  "", iConfig.getUntrackedParameter<std::string>("recordLabel", "apvphaseoffsets")})}
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< TCDSRecord > _tcdsRecordToken
edm::ESWatcher< SiStripConfObjectRcd > m_eswatcher
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ESGetToken< SiStripConfObject, SiStripConfObjectRcd > _confObjectToken
edm::EDGetTokenT< Level1TriggerScalersCollection > _l1tscollectionToken
APVCyclePhaseProducerFromL1TS::~APVCyclePhaseProducerFromL1TS ( )
override

Definition at line 143 of file APVCyclePhaseProducerFromL1TS.cc.

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

Member Function Documentation

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

Definition at line 153 of file APVCyclePhaseProducerFromL1TS.cc.

References _confObjectToken, _defpartnames, _defphases, _magicOffset, _tTopoToken, _useEC0, edm::ESWatcher< T >::check(), edm::EventSetup::getData(), isBadRun(), LogDebug, m_badRun, m_eswatcher, m_ignoreDB, printConfiguration(), edm::RunBase::run(), contentValuesCheck::ss, and edmLumisInFiles::summary.

155 {
156  // update the parameters from DB
157 
158  if (!m_ignoreDB && m_eswatcher.check(iSetup)) {
159  const auto& confObj = iSetup.getData(_confObjectToken);
160 
161  std::stringstream summary;
162  confObj.printDebug(summary, &iSetup.getData(_tTopoToken));
163  LogDebug("SiStripConfObjectSummary") << summary.str();
164 
165  _defpartnames = confObj.get<std::vector<std::string> >("defaultPartitionNames");
166  _defphases = confObj.get<std::vector<int> >("defaultPhases");
167  _useEC0 = confObj.get<bool>("useEC0");
168  m_badRun = confObj.get<bool>("badRun");
169  _magicOffset = confObj.get<int>("magicOffset");
170 
171  std::stringstream ss;
172  printConfiguration(ss);
173  edm::LogInfo("UpdatedConfiguration") << ss.str();
174  }
175 
176  if (isBadRun(iRun.run())) {
177  LogDebug("UnreliableMissingL1TriggerScalers") << "In this run L1TriggerScalers is missing or unreliable for phase "
178  "determination: invlid phase will be returned";
179  }
180 }
RunNumber_t run() const
Definition: RunBase.h:40
edm::ESWatcher< SiStripConfObjectRcd > m_eswatcher
bool getData(T &iHolder) const
Definition: EventSetup.h:128
void printConfiguration(std::stringstream &ss) const
bool isBadRun(const unsigned int) const
Log< level::Info, false > LogInfo
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > _tTopoToken
edm::ESGetToken< SiStripConfObject, SiStripConfObjectRcd > _confObjectToken
#define LogDebug(id)
bool APVCyclePhaseProducerFromL1TS::isBadRun ( const unsigned int  run) const
private

Definition at line 301 of file APVCyclePhaseProducerFromL1TS.cc.

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

Referenced by beginRun(), and produce().

301  {
302  for (std::vector<std::pair<unsigned int, unsigned int> >::const_iterator runpair = m_badruns.begin();
303  runpair != m_badruns.end();
304  ++runpair) {
305  if (run >= runpair->first && run <= runpair->second)
306  return true;
307  }
308 
309  return m_badRun;
310 }
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 312 of file APVCyclePhaseProducerFromL1TS.cc.

References _defpartnames, _defphases, _magicOffset, _useEC0, and m_badRun.

Referenced by _lastTestEnable(), and beginRun().

312  {
313  ss << _defpartnames.size() << " default partition names: ";
314  for (std::vector<std::string>::const_iterator part = _defpartnames.begin(); part != _defpartnames.end(); ++part) {
315  ss << *part << " ";
316  }
317  ss << std::endl;
318  ss << _defphases.size() << " default phases: ";
319  for (std::vector<int>::const_iterator phase = _defphases.begin(); phase != _defphases.end(); ++phase) {
320  ss << *phase << " ";
321  }
322  ss << std::endl;
323  ss << " Magic offset: " << _magicOffset << std::endl;
324  ss << " use ECO: " << _useEC0 << std::endl;
325  ss << " bad run: " << m_badRun << std::endl;
326 }
part
Definition: HCALResponse.h:20
void APVCyclePhaseProducerFromL1TS::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 182 of file APVCyclePhaseProducerFromL1TS.cc.

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

182  {
183  using namespace edm;
184 
185  std::unique_ptr<APVCyclePhaseCollection> apvphases(new APVCyclePhaseCollection());
186 
187  std::vector<int> phases(_defphases.size(), APVCyclePhaseCollection::invalid);
188 
189  const std::vector<std::string>& partnames = _defpartnames;
190 
191  int phasechange = 0;
192 
194  iEvent.getByToken(_l1tscollectionToken, l1ts);
195  Handle<TCDSRecord> tcds_pIn;
196  iEvent.getByToken(_tcdsRecordToken, tcds_pIn);
197  bool useTCDS(tcds_pIn.isValid() && !_forceSCAL);
198  const auto* tcdsRecord = useTCDS ? tcds_pIn.product() : nullptr;
199  // offset computation
200 
201  long long orbitoffset = 0;
202 
203  if (useTCDS && iEvent.eventAuxiliary().isRealData()) {
204  // l1ts->empty() always retuns false (last commit as of today: https://github.com/cms-sw/cmssw/commit/f4694d795d4b268d541c633dfb68283d889264b0 ), so the check is likely not necessary---and TCDSRecord hasn't anything similar
205  if (tcdsRecord->getLastResync() != 0) {
206  orbitoffset =
207  _useEC0 ? tcdsRecord->getLastEventCounter0() + _magicOffset : tcdsRecord->getLastResync() + _magicOffset;
208  }
209 
210  if (_lastResync != tcdsRecord->getLastResync()) {
211  _lastResync = tcdsRecord->getLastResync();
212  LogDebug("TTCSignalReceived") << "New Resync at orbit " << _lastResync;
213  }
214  if (_lastHardReset != tcdsRecord->getLastHardReset()) {
215  _lastHardReset = tcdsRecord->getLastHardReset();
216  LogDebug("TTCSignalReceived") << "New HardReset at orbit " << _lastHardReset;
217  }
218  if (_lastTestEnable != tcdsRecord->getLastTestEnable()) {
219  _lastTestEnable = tcdsRecord->getLastTestEnable();
220  // LogDebug("TTCSignalReceived") << "New TestEnable at orbit " << _lastTestEnable ;
221  }
222  if (_lastOrbitCounter0 != tcdsRecord->getLastOrbitCounter0()) {
223  _lastOrbitCounter0 = tcdsRecord->getLastOrbitCounter0();
224  LogDebug("TTCSignalReceived") << "New OrbitCounter0 at orbit " << _lastOrbitCounter0;
225  }
226  if (_lastEventCounter0 != tcdsRecord->getLastEventCounter0()) {
227  _lastEventCounter0 = tcdsRecord->getLastEventCounter0();
228  LogDebug("TTCSignalReceived") << "New EventCounter0 at orbit " << _lastEventCounter0;
229  }
230  if (_lastStart != tcdsRecord->getLastStart()) {
231  _lastStart = tcdsRecord->getLastStart();
232  LogDebug("TTCSignalReceived") << "New Start at orbit " << _lastStart;
233  }
234 
235  if (!isBadRun(iEvent.run())) {
236  phasechange = ((long long)(orbitoffset * 3564)) % 70;
237 
238  for (unsigned int ipart = 0; ipart < phases.size(); ++ipart) {
239  phases[ipart] = (_defphases[ipart] + phasechange) % 70;
240  }
241  }
242 
243  } else {
244  if (!l1ts->empty()) {
245  if ((*l1ts)[0].lastResync() != 0) {
246  orbitoffset = _useEC0 ? (*l1ts)[0].lastEventCounter0() + _magicOffset : (*l1ts)[0].lastResync() + _magicOffset;
247  }
248 
249  if (_lastResync != (*l1ts)[0].lastResync()) {
250  _lastResync = (*l1ts)[0].lastResync();
251  LogDebug("TTCSignalReceived") << "New Resync at orbit " << _lastResync;
252  }
253  if (_lastHardReset != (*l1ts)[0].lastHardReset()) {
254  _lastHardReset = (*l1ts)[0].lastHardReset();
255  LogDebug("TTCSignalReceived") << "New HardReset at orbit " << _lastHardReset;
256  }
257  if (_lastTestEnable != (*l1ts)[0].lastTestEnable()) {
258  _lastTestEnable = (*l1ts)[0].lastTestEnable();
259  // LogDebug("TTCSignalReceived") << "New TestEnable at orbit " << _lastTestEnable ;
260  }
261  if (_lastOrbitCounter0 != (*l1ts)[0].lastOrbitCounter0()) {
262  _lastOrbitCounter0 = (*l1ts)[0].lastOrbitCounter0();
263  LogDebug("TTCSignalReceived") << "New OrbitCounter0 at orbit " << _lastOrbitCounter0;
264  }
265  if (_lastEventCounter0 != (*l1ts)[0].lastEventCounter0()) {
266  _lastEventCounter0 = (*l1ts)[0].lastEventCounter0();
267  LogDebug("TTCSignalReceived") << "New EventCounter0 at orbit " << _lastEventCounter0;
268  }
269  if (_lastStart != (*l1ts)[0].lastStart()) {
270  _lastStart = (*l1ts)[0].lastStart();
271  LogDebug("TTCSignalReceived") << "New Start at orbit " << _lastStart;
272  }
273 
274  if (!isBadRun(iEvent.run())) {
275  phasechange = ((long long)(orbitoffset * 3564)) % 70;
276 
277  for (unsigned int ipart = 0; ipart < phases.size(); ++ipart) {
278  phases[ipart] = (_defphases[ipart] + phasechange) % 70;
279  }
280  }
281  }
282  }
283 
284  if (phases.size() < partnames.size()) {
285  // throw exception
286  throw cms::Exception("InvalidAPVCyclePhases")
287  << " Inconsistent phases/partitions vector sizes: " << phases.size() << " " << partnames.size();
288  }
289 
290  for (unsigned int ipart = 0; ipart < partnames.size(); ++ipart) {
291  // if(phases[ipart]>=0) {
292  // apvphases->get()[partnames[ipart]] = (phases[ipart]+phasechange)%70;
293  apvphases->get()[partnames[ipart]] = phases[ipart];
294 
295  // }
296  }
297 
298  iEvent.put(std::move(apvphases));
299 }
bool isRealData() const
edm::EDGetTokenT< TCDSRecord > _tcdsRecordToken
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
EventAuxiliary const & eventAuxiliary() const override
Definition: Event.h:95
def move
Definition: eostools.py:511
RunNumber_t run() const
Definition: Event.h:109
bool isBadRun(const unsigned int) const
std::vector< int > phases
edm::EDGetTokenT< Level1TriggerScalersCollection > _l1tscollectionToken
#define LogDebug(id)

Member Data Documentation

edm::ESGetToken<SiStripConfObject, SiStripConfObjectRcd> APVCyclePhaseProducerFromL1TS::_confObjectToken
private

Definition at line 76 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by beginRun().

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

Definition at line 78 of file APVCyclePhaseProducerFromL1TS.cc.

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

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

Definition at line 79 of file APVCyclePhaseProducerFromL1TS.cc.

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

const bool APVCyclePhaseProducerFromL1TS::_forceSCAL
private

Definition at line 83 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

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

Definition at line 74 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastEventCounter0
private

Definition at line 90 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastHardReset
private

Definition at line 88 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastOrbitCounter0
private

Definition at line 91 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastResync
private

Definition at line 87 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastStart
private

Definition at line 89 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastTestEnable
private

Definition at line 92 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

int APVCyclePhaseProducerFromL1TS::_magicOffset
private

Definition at line 81 of file APVCyclePhaseProducerFromL1TS.cc.

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

edm::EDGetTokenT<TCDSRecord> APVCyclePhaseProducerFromL1TS::_tcdsRecordToken
private

Definition at line 75 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> APVCyclePhaseProducerFromL1TS::_tTopoToken
private

Definition at line 77 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by beginRun().

bool APVCyclePhaseProducerFromL1TS::_useEC0
private

Definition at line 80 of file APVCyclePhaseProducerFromL1TS.cc.

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

bool APVCyclePhaseProducerFromL1TS::m_badRun
private

Definition at line 82 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 85 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by _lastTestEnable(), and isBadRun().

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

Definition at line 73 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by beginRun().

const bool APVCyclePhaseProducerFromL1TS::m_ignoreDB
private

Definition at line 72 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by beginRun().