72 virtual void endJob()
override ;
74 bool isBadRun(
const unsigned int)
const;
105 std::vector<std::pair<unsigned int, unsigned int> >
m_badruns;
131 _l1tscollection(iConfig.getParameter<edm::InputTag>(
"l1TSCollection")),
132 m_ignoreDB(iConfig.getUntrackedParameter<bool>(
"ignoreDB",
false)),
133 m_rcdLabel(iConfig.getUntrackedParameter<std::
string>(
"recordLabel",
"apvphaseoffsets")),
134 _defpartnames(iConfig.getParameter<std::vector<std::
string> >(
"defaultPartitionNames")),
135 _defphases(iConfig.getParameter<std::vector<int> >(
"defaultPhases")),
136 _wantHistos(iConfig.getUntrackedParameter<bool>(
"wantHistos",
false)),
137 _useEC0(iConfig.getUntrackedParameter<bool>(
"useEC0",
false)),
138 _magicOffset(iConfig.getUntrackedParameter<int>(
"magicOffset",8)),
140 m_maxLS(iConfig.getUntrackedParameter<unsigned int>(
"maxLSBeforeRebin",250)),
141 m_LSfrac(iConfig.getUntrackedParameter<unsigned int>(
"startingLSFraction",16)),
143 _hsize(0),_hlresync(0),_hlOC0(0),_hlTE(0),_hlstart(0),_hlEC0(0),_hlHR(0),_hdlec0lresync(0),_hdlresynclHR(0),
145 _lastResync(-1),_lastHardReset(-1),_lastStart(-1),
146 _lastEventCounter0(-1),_lastOrbitCounter0(-1),_lastTestEnable(-1)
149 std::stringstream ss;
151 edm::LogInfo(
"ConfigurationAtConstruction") << ss.str();
154 produces<APVCyclePhaseCollection,edm::InEvent>();
156 m_badruns.push_back(std::pair<unsigned int, unsigned int>(0,131767));
157 m_badruns.push_back(std::pair<unsigned int, unsigned int>(193150,193733));
205 confObj->printDebug(summary);
206 LogDebug(
"SiStripConfObjectSummary") << summary.str();
208 _defpartnames = confObj->get<std::vector<std::string> >(
"defaultPartitionNames");
209 _defphases = confObj->get<std::vector<int> >(
"defaultPhases");
210 _useEC0 = confObj->get<
bool>(
"useEC0");
211 m_badRun = confObj->get<
bool>(
"badRun");
214 std::stringstream ss;
226 (*_hlresync)->GetXaxis()->SetTitle(
"Orbit"); (*_hlresync)->GetYaxis()->SetTitle(
"Events");
227 (*_hlresync)->SetBit(TH1::kCanRebin);
231 (*_hlOC0)->GetXaxis()->SetTitle(
"Orbit"); (*_hlOC0)->GetYaxis()->SetTitle(
"Events");
232 (*_hlOC0)->SetBit(TH1::kCanRebin);
236 (*_hlTE)->GetXaxis()->SetTitle(
"Orbit"); (*_hlTE)->GetYaxis()->SetTitle(
"Events");
237 (*_hlTE)->SetBit(TH1::kCanRebin);
241 (*_hlstart)->GetXaxis()->SetTitle(
"Orbit"); (*_hlstart)->GetYaxis()->SetTitle(
"Events");
242 (*_hlstart)->SetBit(TH1::kCanRebin);
246 (*_hlEC0)->GetXaxis()->SetTitle(
"Orbit"); (*_hlEC0)->GetYaxis()->SetTitle(
"Events");
247 (*_hlEC0)->SetBit(TH1::kCanRebin);
251 (*_hlHR)->GetXaxis()->SetTitle(
"Orbit"); (*_hlHR)->GetYaxis()->SetTitle(
"Events");
252 (*_hlHR)->SetBit(TH1::kCanRebin);
256 (*_hdlec0lresync)->GetXaxis()->SetTitle(
"lastEC0-lastResync");
260 (*_hdlresynclHR)->GetXaxis()->SetTitle(
"lastEC0-lastResync");
266 LogDebug(
"UnreliableMissingL1TriggerScalers") <<
267 "In this run L1TriggerScalers is missing or unreliable for phase determination: invlid phase will be returned";
295 long long orbitoffset = 0;
299 if((*l1ts)[0].lastResync()!=0) {
305 if(
_hlOC0 && *
_hlOC0) (*_hlOC0)->Fill((*l1ts)[0].lastOrbitCounter0());
306 if(
_hlTE && *
_hlTE) (*_hlTE)->Fill((*l1ts)[0].lastTestEnable());
308 if(
_hlEC0 && *
_hlEC0) (*_hlEC0)->Fill((*l1ts)[0].lastEventCounter0());
309 if(
_hlHR && *
_hlHR) (*_hlHR)->Fill((*l1ts)[0].lastHardReset());
340 phasechange = ((
long long)(orbitoffset*3564))%70;
342 for(
unsigned int ipart=0;ipart<phases.size();++ipart) {
343 phases[ipart] = (
_defphases[ipart]+phasechange)%70;
350 if(phases.size() < partnames.size() ) {
352 throw cms::Exception(
"InvalidAPVCyclePhases") <<
" Inconsistent phases/partitions vector sizes: "
353 << phases.size() <<
" "
357 for(
unsigned int ipart=0;ipart<partnames.size();++ipart) {
360 apvphases->get()[partnames[ipart]] = phases[ipart];
366 iEvent.
put(apvphases);
384 for(std::vector<std::pair<unsigned int, unsigned int> >::const_iterator runpair =
m_badruns.begin();runpair!=
m_badruns.end();++runpair) {
385 if( run >= runpair->first && run <= runpair->
second)
return true;
400 ss <<
_defphases.size() <<
" default phases: ";
401 for(std::vector<int>::const_iterator phase=
_defphases.begin();phase!=
_defphases.end();++phase) {
406 ss <<
" use ECO: " <<
_useEC0 << std::endl;
407 ss <<
" bad run: " <<
m_badRun << std::endl;
virtual void endJob() override
std::vector< std::string > _defpartnames
#define DEFINE_FWK_MODULE(type)
long long _lastOrbitCounter0
edm::ESWatcher< SiStripConfObjectRcd > m_eswatcher
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
U second(std::pair< T, U > const &p)
const unsigned int m_LSfrac
TH1F ** makeTH1F(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
RunHistogramManager m_rhm
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
virtual void beginJob() override
void printConfiguration(std::stringstream &ss) const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
bool isBadRun(const unsigned int) const
virtual void produce(edm::Event &, const edm::EventSetup &) override
long long _lastTestEnable
void beginRun(const edm::Run &iRun)
bool check(const edm::EventSetup &iSetup)
std::vector< std::pair< unsigned int, unsigned int > > m_badruns
const edm::InputTag _l1tscollection
const std::string m_rcdLabel
long long _lastEventCounter0
APVCyclePhaseProducerFromL1TS(const edm::ParameterSet &)
std::vector< int > _defphases
volatile std::atomic< bool > shutdown_flag false
~APVCyclePhaseProducerFromL1TS()
const unsigned int m_maxLS