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 ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 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
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void beginJob ()
 
virtual void beginRun (const edm::Run &, const edm::EventSetup &) override
 
virtual void endJob ()
 
bool isBadRun (const unsigned int) const
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

const std::vector< std::string > _defpartnames
 
const std::vector< int > _defphases
 
TH1F ** _hdlec0lresync
 
TH1F ** _hdlresynclHR
 
TH1F ** _hlEC0
 
TH1F ** _hlHR
 
TH1F ** _hlOC0
 
TH1F ** _hlresync
 
TH1F ** _hlstart
 
TH1F ** _hlTE
 
TH1F ** _hsize
 
const edm::InputTag _l1tscollection
 
long long _lastEventCounter0
 
long long _lastHardReset
 
long long _lastOrbitCounter0
 
long long _lastResync
 
long long _lastStart
 
long long _lastTestEnable
 
const int _magicOffset
 
const bool _useEC0
 
const bool _wantHistos
 
std::vector< std::pair
< unsigned int, unsigned int > > 
m_badruns
 
const unsigned int m_LSfrac
 
const unsigned int m_maxLS
 
RunHistogramManager m_rhm
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 55 of file APVCyclePhaseProducerFromL1TS.cc.

Constructor & Destructor Documentation

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

Definition at line 116 of file APVCyclePhaseProducerFromL1TS.cc.

References _hdlec0lresync, _hdlresynclHR, _hlEC0, _hlHR, _hlOC0, _hlresync, _hlstart, _hlTE, _hsize, _wantHistos, m_badruns, m_LSfrac, m_maxLS, m_rhm, and RunHistogramManager::makeTH1F().

116  :
117  _l1tscollection(iConfig.getParameter<edm::InputTag>("l1TSCollection")),
118  _defpartnames(iConfig.getParameter<std::vector<std::string> >("defaultPartitionNames")),
119  _defphases(iConfig.getParameter<std::vector<int> >("defaultPhases")),
120  _wantHistos(iConfig.getUntrackedParameter<bool>("wantHistos",false)),
121  _useEC0(iConfig.getUntrackedParameter<bool>("useEC0",false)),
122  _magicOffset(iConfig.getUntrackedParameter<int>("magicOffset",8)),
123  m_maxLS(iConfig.getUntrackedParameter<unsigned int>("maxLSBeforeRebin",250)),
124  m_LSfrac(iConfig.getUntrackedParameter<unsigned int>("startingLSFraction",16)),
125  m_rhm(),
127  m_badruns(),
130 {
131 
132  produces<APVCyclePhaseCollection,edm::InEvent>();
133 
134  m_badruns.push_back(std::pair<unsigned int, unsigned int>(0,131767));
135  m_badruns.push_back(std::pair<unsigned int, unsigned int>(193150,193733));
136 
137  //now do what ever other initialization is needed
138 
139  if(_wantHistos) {
140  _hsize = m_rhm.makeTH1F("size","Level1TriggerScalers Collection size",20,-0.5,19.5);
141 
142  _hlresync = m_rhm.makeTH1F("lresync","Orbit of last resync",m_LSfrac*m_maxLS,0,m_maxLS*262144);
143  _hlOC0 = m_rhm.makeTH1F("lOC0","Orbit of last OC0",m_LSfrac*m_maxLS,0,m_maxLS*262144);
144  _hlTE = m_rhm.makeTH1F("lTE","Orbit of last TestEnable",m_LSfrac*m_maxLS,0,m_maxLS*262144);
145  _hlstart = m_rhm.makeTH1F("lstart","Orbit of last Start",m_LSfrac*m_maxLS,0,m_maxLS*262144);
146  _hlEC0 = m_rhm.makeTH1F("lEC0","Orbit of last EC0",m_LSfrac*m_maxLS,0,m_maxLS*262144);
147  _hlHR = m_rhm.makeTH1F("lHR","Orbit of last HardReset",m_LSfrac*m_maxLS,0,m_maxLS*262144);
148  _hdlec0lresync = m_rhm.makeTH1F("dlec0lresync","Orbit difference EC0-Resync",4000,-1999.5,2000.5);
149  _hdlresynclHR = m_rhm.makeTH1F("dlresynclHR","Orbit difference Resync-HR",4000,-1999.5,2000.5);
150 
151  }
152 
153 
154 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const std::vector< std::string > _defpartnames
TH1F ** makeTH1F(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
std::vector< std::pair< unsigned int, unsigned int > > m_badruns
APVCyclePhaseProducerFromL1TS::~APVCyclePhaseProducerFromL1TS ( )

Definition at line 157 of file APVCyclePhaseProducerFromL1TS.cc.

158 {
159 
160  // do anything here that needs to be done at desctruction time
161  // (e.g. close files, deallocate resources etc.)
162 
163 }

Member Function Documentation

void APVCyclePhaseProducerFromL1TS::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 329 of file APVCyclePhaseProducerFromL1TS.cc.

330 {
331 }
void APVCyclePhaseProducerFromL1TS::beginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 172 of file APVCyclePhaseProducerFromL1TS.cc.

References _hdlec0lresync, _hdlresynclHR, _hlEC0, _hlHR, _hlOC0, _hlresync, _hlstart, _hlTE, _wantHistos, RunHistogramManager::beginRun(), isBadRun(), LogDebug, m_rhm, and edm::RunBase::run().

174 {
175 
176  // reset offset vector
177 
178  if(_wantHistos) {
179 
180  m_rhm.beginRun(iRun);
181 
182  if(_hlresync && *_hlresync) {
183  (*_hlresync)->GetXaxis()->SetTitle("Orbit"); (*_hlresync)->GetYaxis()->SetTitle("Events");
184  (*_hlresync)->SetBit(TH1::kCanRebin);
185  }
186 
187  if(_hlOC0 && *_hlOC0) {
188  (*_hlOC0)->GetXaxis()->SetTitle("Orbit"); (*_hlOC0)->GetYaxis()->SetTitle("Events");
189  (*_hlOC0)->SetBit(TH1::kCanRebin);
190  }
191 
192  if(_hlTE && *_hlTE) {
193  (*_hlTE)->GetXaxis()->SetTitle("Orbit"); (*_hlTE)->GetYaxis()->SetTitle("Events");
194  (*_hlTE)->SetBit(TH1::kCanRebin);
195  }
196 
197  if(_hlstart && *_hlstart) {
198  (*_hlstart)->GetXaxis()->SetTitle("Orbit"); (*_hlstart)->GetYaxis()->SetTitle("Events");
199  (*_hlstart)->SetBit(TH1::kCanRebin);
200  }
201 
202  if(_hlEC0 && *_hlEC0) {
203  (*_hlEC0)->GetXaxis()->SetTitle("Orbit"); (*_hlEC0)->GetYaxis()->SetTitle("Events");
204  (*_hlEC0)->SetBit(TH1::kCanRebin);
205  }
206 
207  if(_hlHR && *_hlHR) {
208  (*_hlHR)->GetXaxis()->SetTitle("Orbit"); (*_hlHR)->GetYaxis()->SetTitle("Events");
209  (*_hlHR)->SetBit(TH1::kCanRebin);
210  }
211 
213  (*_hdlec0lresync)->GetXaxis()->SetTitle("lastEC0-lastResync");
214  }
215 
216  if(_hdlresynclHR && *_hdlresynclHR) {
217  (*_hdlresynclHR)->GetXaxis()->SetTitle("lastEC0-lastResync");
218  }
219 
220  }
221 
222  if(isBadRun(iRun.run())) {
223  LogDebug("UnreliableMissingL1TriggerScalers") <<
224  "In this run L1TriggerScalers is missing or unreliable for phase determination: invlid phase will be returned";
225  }
226 
227 }
#define LogDebug(id)
RunNumber_t run() const
Definition: RunBase.h:42
bool isBadRun(const unsigned int) const
void beginRun(const edm::Run &iRun)
void APVCyclePhaseProducerFromL1TS::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 335 of file APVCyclePhaseProducerFromL1TS.cc.

335  {
336 }
bool APVCyclePhaseProducerFromL1TS::isBadRun ( const unsigned int  run) const
private

Definition at line 339 of file APVCyclePhaseProducerFromL1TS.cc.

References m_badruns, and edm::second().

Referenced by beginRun(), and produce().

339  {
340 
341  for(std::vector<std::pair<unsigned int, unsigned int> >::const_iterator runpair = m_badruns.begin();runpair!=m_badruns.end();++runpair) {
342  if( run >= runpair->first && run <= runpair->second) return true;
343  }
344 
345  return false;
346 
347 }
U second(std::pair< T, U > const &p)
std::vector< std::pair< unsigned int, unsigned int > > m_badruns
void APVCyclePhaseProducerFromL1TS::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 231 of file APVCyclePhaseProducerFromL1TS.cc.

References _defpartnames, _defphases, _hdlec0lresync, _hdlresynclHR, _hlEC0, _hlHR, _hlOC0, _hlresync, _hlstart, _hlTE, _hsize, _l1tscollection, _lastEventCounter0, _lastHardReset, _lastOrbitCounter0, _lastResync, _lastStart, _lastTestEnable, _magicOffset, _useEC0, _wantHistos, edm::hlt::Exception, edm::Event::getByLabel(), APVCyclePhaseCollection::invalid, isBadRun(), LogDebug, edm::Event::put(), and edm::Event::run().

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

231  {
232 
233  using namespace edm;
234 
235  std::auto_ptr<APVCyclePhaseCollection> apvphases(new APVCyclePhaseCollection() );
236 
237 
238  std::vector<int> phases(_defphases.size(),APVCyclePhaseCollection::invalid);
239 
240  const std::vector<std::string>& partnames = _defpartnames;
241 
242  int phasechange = 0;
243 
244 
246  iEvent.getByLabel(_l1tscollection,l1ts);
247 
248  if(_wantHistos && _hsize && *_hsize) (*_hsize)->Fill(l1ts->size());
249 
250  // offset computation
251 
252  long long orbitoffset = 0;
253 
254  if(l1ts->size()>0) {
255 
256  if((*l1ts)[0].lastResync()!=0) {
257  orbitoffset = _useEC0 ? (*l1ts)[0].lastEventCounter0() + _magicOffset : (*l1ts)[0].lastResync() + _magicOffset;
258  }
259 
260  if(_wantHistos) {
261  if(_hlresync && *_hlresync) (*_hlresync)->Fill((*l1ts)[0].lastResync());
262  if(_hlOC0 && *_hlOC0) (*_hlOC0)->Fill((*l1ts)[0].lastOrbitCounter0());
263  if(_hlTE && *_hlTE) (*_hlTE)->Fill((*l1ts)[0].lastTestEnable());
264  if(_hlstart && *_hlstart) (*_hlstart)->Fill((*l1ts)[0].lastStart());
265  if(_hlEC0 && *_hlEC0) (*_hlEC0)->Fill((*l1ts)[0].lastEventCounter0());
266  if(_hlHR && *_hlHR) (*_hlHR)->Fill((*l1ts)[0].lastHardReset());
267  }
268 
269  if(_lastResync != (*l1ts)[0].lastResync()) {
270  _lastResync = (*l1ts)[0].lastResync();
271  if(_wantHistos && _hdlec0lresync && *_hdlec0lresync) (*_hdlec0lresync)->Fill((*l1ts)[0].lastEventCounter0()-(*l1ts)[0].lastResync());
272  LogDebug("TTCSignalReceived") << "New Resync at orbit " << _lastResync ;
273  }
274  if(_lastHardReset != (*l1ts)[0].lastHardReset()) {
275  _lastHardReset = (*l1ts)[0].lastHardReset();
276  if(_wantHistos && _hdlresynclHR && *_hdlresynclHR) (*_hdlresynclHR)->Fill((*l1ts)[0].lastResync()-(*l1ts)[0].lastHardReset());
277  LogDebug("TTCSignalReceived") << "New HardReset at orbit " << _lastHardReset ;
278  }
279  if(_lastTestEnable != (*l1ts)[0].lastTestEnable()) {
280  _lastTestEnable = (*l1ts)[0].lastTestEnable();
281  // LogDebug("TTCSignalReceived") << "New TestEnable at orbit " << _lastTestEnable ;
282  }
283  if(_lastOrbitCounter0 != (*l1ts)[0].lastOrbitCounter0()) {
284  _lastOrbitCounter0 = (*l1ts)[0].lastOrbitCounter0();
285  LogDebug("TTCSignalReceived") << "New OrbitCounter0 at orbit " << _lastOrbitCounter0 ;
286  }
287  if(_lastEventCounter0 != (*l1ts)[0].lastEventCounter0()) {
288  _lastEventCounter0 = (*l1ts)[0].lastEventCounter0();
289  LogDebug("TTCSignalReceived") << "New EventCounter0 at orbit " << _lastEventCounter0 ;
290  }
291  if(_lastStart != (*l1ts)[0].lastStart()) {
292  _lastStart = (*l1ts)[0].lastStart();
293  LogDebug("TTCSignalReceived") << "New Start at orbit " << _lastStart ;
294  }
295 
296  if(!isBadRun(iEvent.run())) {
297  phasechange = ((long long)(orbitoffset*3564))%70;
298 
299  for(unsigned int ipart=0;ipart<phases.size();++ipart) {
300  phases[ipart] = (_defphases[ipart]+phasechange)%70;
301  }
302 
303  }
304  }
305 
306 
307  if(phases.size() < partnames.size() ) {
308  // throw exception
309  throw cms::Exception("InvalidAPVCyclePhases") << " Inconsistent phases/partitions vector sizes: "
310  << phases.size() << " "
311  << partnames.size();
312  }
313 
314  for(unsigned int ipart=0;ipart<partnames.size();++ipart) {
315  // if(phases[ipart]>=0) {
316  // apvphases->get()[partnames[ipart]] = (phases[ipart]+phasechange)%70;
317  apvphases->get()[partnames[ipart]] = phases[ipart];
318 
319  // }
320  }
321 
322 
323  iEvent.put(apvphases);
324 
325 }
#define LogDebug(id)
const std::vector< std::string > _defpartnames
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
RunNumber_t run() const
Definition: Event.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
bool isBadRun(const unsigned int) const

Member Data Documentation

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

Definition at line 71 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

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

Definition at line 72 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

TH1F** APVCyclePhaseProducerFromL1TS::_hdlec0lresync
private
TH1F** APVCyclePhaseProducerFromL1TS::_hdlresynclHR
private
TH1F** APVCyclePhaseProducerFromL1TS::_hlEC0
private
TH1F** APVCyclePhaseProducerFromL1TS::_hlHR
private
TH1F** APVCyclePhaseProducerFromL1TS::_hlOC0
private
TH1F** APVCyclePhaseProducerFromL1TS::_hlresync
private
TH1F** APVCyclePhaseProducerFromL1TS::_hlstart
private
TH1F** APVCyclePhaseProducerFromL1TS::_hlTE
private
TH1F** APVCyclePhaseProducerFromL1TS::_hsize
private

Definition at line 81 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by APVCyclePhaseProducerFromL1TS(), and produce().

const edm::InputTag APVCyclePhaseProducerFromL1TS::_l1tscollection
private

Definition at line 70 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastEventCounter0
private

Definition at line 97 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastHardReset
private

Definition at line 95 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastOrbitCounter0
private

Definition at line 98 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastResync
private

Definition at line 94 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastStart
private

Definition at line 96 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1TS::_lastTestEnable
private

Definition at line 99 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

const int APVCyclePhaseProducerFromL1TS::_magicOffset
private

Definition at line 75 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

const bool APVCyclePhaseProducerFromL1TS::_useEC0
private

Definition at line 74 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by produce().

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

Definition at line 92 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by APVCyclePhaseProducerFromL1TS(), and isBadRun().

const unsigned int APVCyclePhaseProducerFromL1TS::m_LSfrac
private

Definition at line 77 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by APVCyclePhaseProducerFromL1TS().

const unsigned int APVCyclePhaseProducerFromL1TS::m_maxLS
private

Definition at line 76 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by APVCyclePhaseProducerFromL1TS().

RunHistogramManager APVCyclePhaseProducerFromL1TS::m_rhm
private

Definition at line 79 of file APVCyclePhaseProducerFromL1TS.cc.

Referenced by APVCyclePhaseProducerFromL1TS(), and beginRun().