81 std::map<edm::EventNumber_t, long long>
_offsets;
98 : _l1abccollectionToken(
101 _defpartnames(iConfig.getParameter<
std::vector<
std::
string> >(
"defaultPartitionNames")),
102 _defphases(iConfig.getParameter<
std::vector<
int> >(
"defaultPhases")),
103 _orbitoffsetSOR(iConfig.getParameter<
int>(
"StartOfRunOrbitOffset")),
104 _wantHistos(iConfig.getUntrackedParameter<
bool>(
"wantHistos",
false)),
105 _forceSCAL(iConfig.getParameter<
bool>(
"forceSCAL")),
106 m_rhm(consumesCollector()),
110 _firstgoodrun(110878),
114 produces<APVCyclePhaseCollection, edm::InEvent>();
119 _hbx =
m_rhm.
makeTH1F(
"l1abcbx",
"BX number from TCDS (or L1ABC as fallback)", 4096, -0.5, 4095.5);
141 edm::LogInfo(
"AbsoluteBXOffsetReset") <<
"Absolute BX offset map reset";
147 (*_hbx)->GetXaxis()->SetTitle(
"BX");
148 (*_hbx)->GetYaxis()->SetTitle(
"Events");
152 (*_hdbx)->GetXaxis()->SetTitle(
"#DeltaBX");
153 (*_hdbx)->GetYaxis()->SetTitle(
"Events");
157 (*_hdorbit)->GetXaxis()->SetTitle(
"#Deltaorbit");
158 (*_hdorbit)->GetYaxis()->SetTitle(
"Events");
163 edm::LogInfo(
"UnreliableMissingL1AcceptBunchCrossingCollection")
164 <<
"In this run L1AcceptBunchCrossingCollection is missing or unreliable: default phases will be used";
171 edm::LogInfo(
"L1AcceptBunchCrossingAbsoluteBXOffsetSummary") <<
"Absolute BX offset summary:";
196 const auto* tcdsRecord = useTCDS ? tcds_pIn.
product() :
nullptr;
203 if (tcdsRecord->getL1aHistoryEntry(0).getIndex() == 0) {
204 if (tcdsRecord->getEventType() != 0) {
205 orbitoffset = (
long long)tcdsRecord->getOrbitNr() - (
long long)
iEvent.orbitNumber();
207 bxoffset =
iEvent.bunchCrossing() - tcdsRecord->getBXID();
211 (*_hbx)->Fill(tcdsRecord->getBXID());
213 (*_hdbx)->Fill(bxoffset);
215 (*_hdorbit)->Fill(orbitoffset);
219 edm::LogWarning(
"L1AcceptBunchCrossingNoType") <<
"L1AcceptBunchCrossing with no type found: ";
223 for (L1AcceptBunchCrossingCollection::const_iterator l1abc = pIn->begin(); l1abc != pIn->end(); ++l1abc) {
224 if (l1abc->l1AcceptOffset() == 0) {
225 if (l1abc->eventType() != 0) {
226 orbitoffset = (
long long)
iEvent.orbitNumber() - (
long long)l1abc->orbitNumber();
229 l1abc->bunchCrossing();
233 (*_hbx)->Fill(l1abc->bunchCrossing());
235 (*_hdbx)->Fill(bxoffset);
237 (*_hdorbit)->Fill(orbitoffset);
240 edm::LogWarning(
"L1AcceptBunchCrossingNoType") <<
"L1AcceptBunchCrossing with no type found: ";
241 for (L1AcceptBunchCrossingCollection::const_iterator debu = pIn->begin(); debu != pIn->end(); ++debu) {
249 long long absbxoffset = orbitoffset * 3564 + bxoffset;
252 phasechange = (orbitoffset * 3564) % 70;
261 edm::LogInfo(
"L1AcceptBunchCrossingAbsoluteBXOffsetChanged")
262 <<
"Absolute BX offset changed from " <<
_curroffset <<
" to " << absbxoffset <<
" at orbit "
263 <<
iEvent.orbitNumber() <<
" and BX " <<
iEvent.bunchCrossing();
267 for (L1AcceptBunchCrossingCollection::const_iterator l1abc = pIn->begin(); l1abc != pIn->end(); ++l1abc) {
280 if (
phases.size() < partnames.size()) {
283 <<
" Inconsistent phases/partitions vector sizes: " <<
phases.size() <<
" " << partnames.size();
286 for (
unsigned int ipart = 0; ipart < partnames.size(); ++ipart) {
288 apvphases->get()[partnames[ipart]] = (
phases[ipart] + phasechange) % 70;