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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 58 of file APVCyclePhaseProducerFromL1TS.cc.

Constructor & Destructor Documentation

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

Definition at line 106 of file APVCyclePhaseProducerFromL1TS.cc.

References m_badruns, and printConfiguration().

106  :
107  m_eswatcher(),
108  _l1tscollectionToken(consumes<Level1TriggerScalersCollection>(iConfig.getParameter<edm::InputTag>("l1TSCollection"))),
109  m_ignoreDB(iConfig.getUntrackedParameter<bool>("ignoreDB",false)),
110  m_rcdLabel(iConfig.getUntrackedParameter<std::string>("recordLabel","apvphaseoffsets")),
111  _defpartnames(iConfig.getParameter<std::vector<std::string> >("defaultPartitionNames")),
112  _defphases(iConfig.getParameter<std::vector<int> >("defaultPhases")),
113  _useEC0(iConfig.getUntrackedParameter<bool>("useEC0",false)),
114  _magicOffset(iConfig.getUntrackedParameter<int>("magicOffset",8)),
115  m_badRun(false),
116  m_badruns(),
119 {
120 
121  std::stringstream ss;
122  printConfiguration(ss);
123  edm::LogInfo("ConfigurationAtConstruction") << ss.str();
124 
125 
126  produces<APVCyclePhaseCollection,edm::InEvent>();
127 
128  m_badruns.push_back(std::pair<unsigned int, unsigned int>(0,131767));
129  m_badruns.push_back(std::pair<unsigned int, unsigned int>(193150,193733));
130 
131  //now do what ever other initialization is needed
132 
133 }
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 136 of file APVCyclePhaseProducerFromL1TS.cc.

137 {
138 
139  // do anything here that needs to be done at desctruction time
140  // (e.g. close files, deallocate resources etc.)
141 
142 }

Member Function Documentation

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

Definition at line 151 of file APVCyclePhaseProducerFromL1TS.cc.

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

153 {
154 
155  // update the parameters from DB
156 
157  if(!m_ignoreDB && m_eswatcher.check(iSetup)) {
159  iSetup.get<SiStripConfObjectRcd>().get(m_rcdLabel,confObj);
160 
162  iSetup.get<TrackerTopologyRcd>().get(tTopo);
163 
164  std::stringstream summary;
165  confObj->printDebug(summary, tTopo.product());
166  LogDebug("SiStripConfObjectSummary") << summary.str();
167 
168  _defpartnames = confObj->get<std::vector<std::string> >("defaultPartitionNames");
169  _defphases = confObj->get<std::vector<int> >("defaultPhases");
170  _useEC0 = confObj->get<bool>("useEC0");
171  m_badRun = confObj->get<bool>("badRun");
172  _magicOffset = confObj->get<int>("magicOffset");
173 
174  std::stringstream ss;
175  printConfiguration(ss);
176  edm::LogInfo("UpdatedConfiguration") << ss.str();
177 
178 
179  }
180 
181  if(isBadRun(iRun.run())) {
182  LogDebug("UnreliableMissingL1TriggerScalers") <<
183  "In this run L1TriggerScalers is missing or unreliable for phase determination: invlid phase will be returned";
184  }
185 
186 }
#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:57
T get() const
Definition: EventSetup.h:63
T const * product() const
Definition: ESHandle.h:86
bool APVCyclePhaseProducerFromL1TS::isBadRun ( const unsigned int  run) const
private

Definition at line 274 of file APVCyclePhaseProducerFromL1TS.cc.

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

Referenced by beginRun(), and produce().

274  {
275 
276  for(std::vector<std::pair<unsigned int, unsigned int> >::const_iterator runpair = m_badruns.begin();runpair!=m_badruns.end();++runpair) {
277  if( run >= runpair->first && run <= runpair->second) return true;
278  }
279 
280  return m_badRun;
281 
282 }
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 285 of file APVCyclePhaseProducerFromL1TS.cc.

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

Referenced by APVCyclePhaseProducerFromL1TS(), and beginRun().

285  {
286 
287  ss << _defpartnames.size() << " default partition names: ";
288  for(std::vector<std::string>::const_iterator part=_defpartnames.begin();part!=_defpartnames.end();++part) {
289  ss << *part << " ";
290  }
291  ss << std::endl;
292  ss << _defphases.size() << " default phases: ";
293  for(std::vector<int>::const_iterator phase=_defphases.begin();phase!=_defphases.end();++phase) {
294  ss << *phase << " ";
295  }
296  ss << std::endl;
297  ss << " Magic offset: " << _magicOffset << std::endl;
298  ss << " use ECO: " << _useEC0 << std::endl;
299  ss << " bad run: " << m_badRun << std::endl;
300 
301 }
part
Definition: HCALResponse.h:20
void APVCyclePhaseProducerFromL1TS::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 190 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().

190  {
191 
192  using namespace edm;
193 
194  std::unique_ptr<APVCyclePhaseCollection> apvphases(new APVCyclePhaseCollection() );
195 
196 
197  std::vector<int> phases(_defphases.size(),APVCyclePhaseCollection::invalid);
198 
199  const std::vector<std::string>& partnames = _defpartnames;
200 
201  int phasechange = 0;
202 
203 
205  iEvent.getByToken(_l1tscollectionToken,l1ts);
206 
207  // offset computation
208 
209  long long orbitoffset = 0;
210 
211  if(!l1ts->empty()) {
212 
213  if((*l1ts)[0].lastResync()!=0) {
214  orbitoffset = _useEC0 ? (*l1ts)[0].lastEventCounter0() + _magicOffset : (*l1ts)[0].lastResync() + _magicOffset;
215  }
216 
217  if(_lastResync != (*l1ts)[0].lastResync()) {
218  _lastResync = (*l1ts)[0].lastResync();
219  LogDebug("TTCSignalReceived") << "New Resync at orbit " << _lastResync ;
220  }
221  if(_lastHardReset != (*l1ts)[0].lastHardReset()) {
222  _lastHardReset = (*l1ts)[0].lastHardReset();
223  LogDebug("TTCSignalReceived") << "New HardReset at orbit " << _lastHardReset ;
224  }
225  if(_lastTestEnable != (*l1ts)[0].lastTestEnable()) {
226  _lastTestEnable = (*l1ts)[0].lastTestEnable();
227  // LogDebug("TTCSignalReceived") << "New TestEnable at orbit " << _lastTestEnable ;
228  }
229  if(_lastOrbitCounter0 != (*l1ts)[0].lastOrbitCounter0()) {
230  _lastOrbitCounter0 = (*l1ts)[0].lastOrbitCounter0();
231  LogDebug("TTCSignalReceived") << "New OrbitCounter0 at orbit " << _lastOrbitCounter0 ;
232  }
233  if(_lastEventCounter0 != (*l1ts)[0].lastEventCounter0()) {
234  _lastEventCounter0 = (*l1ts)[0].lastEventCounter0();
235  LogDebug("TTCSignalReceived") << "New EventCounter0 at orbit " << _lastEventCounter0 ;
236  }
237  if(_lastStart != (*l1ts)[0].lastStart()) {
238  _lastStart = (*l1ts)[0].lastStart();
239  LogDebug("TTCSignalReceived") << "New Start at orbit " << _lastStart ;
240  }
241 
242  if(!isBadRun(iEvent.run())) {
243  phasechange = ((long long)(orbitoffset*3564))%70;
244 
245  for(unsigned int ipart=0;ipart<phases.size();++ipart) {
246  phases[ipart] = (_defphases[ipart]+phasechange)%70;
247  }
248 
249  }
250  }
251 
252 
253  if(phases.size() < partnames.size() ) {
254  // throw exception
255  throw cms::Exception("InvalidAPVCyclePhases") << " Inconsistent phases/partitions vector sizes: "
256  << phases.size() << " "
257  << partnames.size();
258  }
259 
260  for(unsigned int ipart=0;ipart<partnames.size();++ipart) {
261  // if(phases[ipart]>=0) {
262  // apvphases->get()[partnames[ipart]] = (phases[ipart]+phasechange)%70;
263  apvphases->get()[partnames[ipart]] = phases[ipart];
264 
265  // }
266  }
267 
268 
269  iEvent.put(std::move(apvphases));
270 
271 }
#define LogDebug(id)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
RunNumber_t run() const
Definition: Event.h:109
bool isBadRun(const unsigned int) const
std::vector< int > phases
HLT enums.
edm::EDGetTokenT< Level1TriggerScalersCollection > _l1tscollectionToken
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

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

Definition at line 76 of file APVCyclePhaseProducerFromL1TS.cc.

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

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

Definition at line 77 of file APVCyclePhaseProducerFromL1TS.cc.

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

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

Definition at line 73 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastEventCounter0
private

Definition at line 87 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastHardReset
private

Definition at line 85 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastOrbitCounter0
private

Definition at line 88 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastResync
private

Definition at line 84 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastStart
private

Definition at line 86 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastTestEnable
private

Definition at line 89 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

int APVCyclePhaseProducerFromL1TS::_magicOffset
private

Definition at line 79 of file APVCyclePhaseProducerFromL1TS.cc.

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

bool APVCyclePhaseProducerFromL1TS::_useEC0
private

Definition at line 78 of file APVCyclePhaseProducerFromL1TS.cc.

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

bool APVCyclePhaseProducerFromL1TS::m_badRun
private

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

Referenced by APVCyclePhaseProducerFromL1TS(), and isBadRun().

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

Definition at line 72 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by beginRun().

const bool APVCyclePhaseProducerFromL1TS::m_ignoreDB
private

Definition at line 74 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by beginRun().

const std::string APVCyclePhaseProducerFromL1TS::m_rcdLabel
private

Definition at line 75 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by beginRun().