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
APVCyclePhaseProducerFromL1TS Class Reference

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

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

Public Member Functions

 APVCyclePhaseProducerFromL1TS (const edm::ParameterSet &)
 
 ~APVCyclePhaseProducerFromL1TS ()
 
- 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 (const std::string &iProcessName, std::vector< const char * > &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 beginRun (const edm::Run &, const edm::EventSetup &) override
 
bool isBadRun (const unsigned int) const
 
void printConfiguration (std::stringstream &ss) const
 
virtual 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
< SiStripConfObjectRcd
m_eswatcher
 
const bool m_ignoreDB
 
const std::string m_rcdLabel
 

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 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, printConfiguration(), and contentValuesCheck::ss.

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 ( )

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 
)
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 151 of file APVCyclePhaseProducerFromL1TS.cc.

References _defpartnames, _defphases, _magicOffset, _useEC0, edm::ESWatcher< T >::check(), edm::EventSetup::get(), isBadRun(), LogDebug, m_badRun, m_eswatcher, m_ignoreDB, m_rcdLabel, printConfiguration(), edm::RunBase::run(), contentValuesCheck::ss, and edmLumisInFiles::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 
161  std::stringstream summary;
162  confObj->printDebug(summary);
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  }
177 
178  if(isBadRun(iRun.run())) {
179  LogDebug("UnreliableMissingL1TriggerScalers") <<
180  "In this run L1TriggerScalers is missing or unreliable for phase determination: invlid phase will be returned";
181  }
182 
183 }
#define LogDebug(id)
RunNumber_t run() const
Definition: RunBase.h:42
edm::ESWatcher< SiStripConfObjectRcd > m_eswatcher
void printConfiguration(std::stringstream &ss) const
bool isBadRun(const unsigned int) const
const T & get() const
Definition: EventSetup.h:55
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
bool APVCyclePhaseProducerFromL1TS::isBadRun ( const unsigned int  run) const
private

Definition at line 271 of file APVCyclePhaseProducerFromL1TS.cc.

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

Referenced by beginRun(), and produce().

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

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

Referenced by APVCyclePhaseProducerFromL1TS(), and beginRun().

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

Implements edm::EDProducer.

Definition at line 187 of file APVCyclePhaseProducerFromL1TS.cc.

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

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().