CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
APVCyclePhaseProducerFromL1ABC Class Reference

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

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

Public Member Functions

 APVCyclePhaseProducerFromL1ABC (const edm::ParameterSet &)
 
 ~APVCyclePhaseProducerFromL1ABC () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector
< edm::ProductResolverIndex >
const & 
indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector
< edm::ProductResolverIndex >
const & 
putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector
< ProductResolverIndexAndSkipBit >
const & 
itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void beginJob () override
 
void beginRun (const edm::Run &, const edm::EventSetup &) override
 
void endJob () override
 
void endRun (const edm::Run &, const edm::EventSetup &) override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::EventNumber_t _curroffevent
 
long long _curroffset
 
const std::vector< std::string > _defpartnames
 
const std::vector< int > _defphases
 
const unsigned int _firstgoodrun
 
const bool _forceSCAL
 
TH1F ** _hbx
 
TH1F ** _hdbx
 
TH1F ** _hdorbit
 
edm::EDGetTokenT
< L1AcceptBunchCrossingCollection
_l1abccollectionToken
 
std::map< edm::EventNumber_t,
long long > 
_offsets
 
const int _orbitoffsetSOR
 
edm::EDGetTokenT< TCDSRecord_tcdsRecordToken
 
const bool _wantHistos
 
RunHistogramManager m_rhm
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
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)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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 54 of file APVCyclePhaseProducerFromL1ABC.cc.

Constructor & Destructor Documentation

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

Definition at line 97 of file APVCyclePhaseProducerFromL1ABC.cc.

References _hbx, _hdbx, _hdorbit, _wantHistos, m_rhm, and RunHistogramManager::makeTH1F().

99  mayConsume<L1AcceptBunchCrossingCollection>(iConfig.getParameter<edm::InputTag>("l1ABCCollection"))),
100  _tcdsRecordToken(mayConsume<TCDSRecord>(iConfig.getParameter<edm::InputTag>("tcdsRecordLabel"))),
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")),
107  _hbx(nullptr),
108  _hdbx(nullptr),
109  _hdorbit(nullptr),
110  _firstgoodrun(110878),
111  _offsets(),
112  _curroffset(0),
113  _curroffevent(0) {
114  produces<APVCyclePhaseCollection, edm::InEvent>();
115 
116  //now do what ever other initialization is needed
117 
118  if (_wantHistos) {
119  _hbx = m_rhm.makeTH1F("l1abcbx", "BX number from TCDS (or L1ABC as fallback)", 4096, -0.5, 4095.5);
120  _hdbx = m_rhm.makeTH1F("dbx", "BX number difference", 4096 * 2 - 1, -4095.5, 4095.5);
121  _hdorbit = m_rhm.makeTH1F("dorbit", "Orbit Number difference", 9999, -4999.5, 4999.5);
122  }
123 }
T getUntrackedParameter(std::string const &, T const &) const
std::map< edm::EventNumber_t, long long > _offsets
const std::vector< std::string > _defpartnames
edm::EDGetTokenT< L1AcceptBunchCrossingCollection > _l1abccollectionToken
edm::EDGetTokenT< TCDSRecord > _tcdsRecordToken
TH1F ** makeTH1F(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
APVCyclePhaseProducerFromL1ABC::~APVCyclePhaseProducerFromL1ABC ( )
override

Definition at line 125 of file APVCyclePhaseProducerFromL1ABC.cc.

125  {
126  // do anything here that needs to be done at desctruction time
127  // (e.g. close files, deallocate resources etc.)
128 }

Member Function Documentation

void APVCyclePhaseProducerFromL1ABC::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 296 of file APVCyclePhaseProducerFromL1ABC.cc.

296 {}
void APVCyclePhaseProducerFromL1ABC::beginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 135 of file APVCyclePhaseProducerFromL1ABC.cc.

References _firstgoodrun, _hbx, _hdbx, _hdorbit, _offsets, _wantHistos, RunHistogramManager::beginRun(), m_rhm, and edm::RunBase::run().

137 {
138  // reset offset vector
139 
140  _offsets.clear();
141  edm::LogInfo("AbsoluteBXOffsetReset") << "Absolute BX offset map reset";
142 
143  if (_wantHistos) {
144  m_rhm.beginRun(iRun);
145 
146  if (_hbx && *_hbx) {
147  (*_hbx)->GetXaxis()->SetTitle("BX");
148  (*_hbx)->GetYaxis()->SetTitle("Events");
149  }
150 
151  if (_hdbx && *_hdbx) {
152  (*_hdbx)->GetXaxis()->SetTitle("#DeltaBX");
153  (*_hdbx)->GetYaxis()->SetTitle("Events");
154  }
155 
156  if (_hdorbit && *_hdorbit) {
157  (*_hdorbit)->GetXaxis()->SetTitle("#Deltaorbit");
158  (*_hdorbit)->GetYaxis()->SetTitle("Events");
159  }
160  }
161 
162  if (iRun.run() < _firstgoodrun) {
163  edm::LogInfo("UnreliableMissingL1AcceptBunchCrossingCollection")
164  << "In this run L1AcceptBunchCrossingCollection is missing or unreliable: default phases will be used";
165  }
166 }
std::map< edm::EventNumber_t, long long > _offsets
RunNumber_t run() const
Definition: RunBase.h:40
Log< level::Info, false > LogInfo
void beginRun(const edm::Run &iRun)
void APVCyclePhaseProducerFromL1ABC::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 299 of file APVCyclePhaseProducerFromL1ABC.cc.

299 {}
void APVCyclePhaseProducerFromL1ABC::endRun ( const edm::Run ,
const edm::EventSetup  
)
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 168 of file APVCyclePhaseProducerFromL1ABC.cc.

References _offsets, and hltrates_dqm_sourceclient-live_cfg::offset.

168  {
169  // summary of absolute bx offset vector
170 
171  edm::LogInfo("L1AcceptBunchCrossingAbsoluteBXOffsetSummary") << "Absolute BX offset summary:";
172  for (std::map<edm::EventNumber_t, long long>::const_iterator offset = _offsets.begin(); offset != _offsets.end();
173  ++offset) {
174  edm::LogVerbatim("L1AcceptBunchCrossingAbsoluteBXOffsetSummary") << offset->first << " " << offset->second;
175  }
176 }
Log< level::Info, true > LogVerbatim
std::map< edm::EventNumber_t, long long > _offsets
Log< level::Info, false > LogInfo
void APVCyclePhaseProducerFromL1ABC::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 178 of file APVCyclePhaseProducerFromL1ABC.cc.

References _curroffevent, _curroffset, _defpartnames, _defphases, _firstgoodrun, _forceSCAL, _hbx, _hdbx, _hdorbit, _l1abccollectionToken, _offsets, _orbitoffsetSOR, _tcdsRecordToken, _wantHistos, edm::EventBase::bunchCrossing(), edm::EventID::event(), Exception, edm::Event::getByToken(), edm::EventBase::id(), edm::HandleBase::isValid(), eostools::move(), edm::EventBase::orbitNumber(), phases, edm::Handle< T >::product(), edm::Event::put(), and edm::Event::run().

178  {
179  using namespace edm;
180 
181  std::unique_ptr<APVCyclePhaseCollection> apvphases(new APVCyclePhaseCollection());
182 
183  const std::vector<int>& phases = _defphases;
184  const std::vector<std::string>& partnames = _defpartnames;
185 
186  // Look for the L1AcceptBunchCrossingCollection
187 
188  int phasechange = 0;
189 
190  if (iEvent.run() >= _firstgoodrun) {
192  iEvent.getByToken(_l1abccollectionToken, pIn);
193  Handle<TCDSRecord> tcds_pIn;
194  iEvent.getByToken(_tcdsRecordToken, tcds_pIn);
195  bool useTCDS(tcds_pIn.isValid() && !_forceSCAL);
196  const auto* tcdsRecord = useTCDS ? tcds_pIn.product() : nullptr;
197  // offset computation
198 
199  long long orbitoffset = _orbitoffsetSOR;
200  int bxoffset = 0;
201 
202  if (useTCDS) {
203  if (tcdsRecord->getL1aHistoryEntry(0).getIndex() == 0) {
204  if (tcdsRecord->getEventType() != 0) {
205  orbitoffset = (long long)tcdsRecord->getOrbitNr() - (long long)iEvent.orbitNumber();
206  // In EventWithHistoryProducerFromL1ABC, it's -1\times this, following the corresponding L1ABC line below. I keep this difference here, because I am not sure if it should be kept or not
207  bxoffset = iEvent.bunchCrossing() - tcdsRecord->getBXID();
208  // If I understand correctly, tcdsRecord has no l1AcceptOffset thing, so the control done for l1abc can be safely skipped
209  if (_wantHistos) {
210  if (_hbx && *_hbx)
211  (*_hbx)->Fill(tcdsRecord->getBXID());
212  if (_hdbx && *_hdbx)
213  (*_hdbx)->Fill(bxoffset);
214  if (_hdorbit && *_hdorbit)
215  (*_hdorbit)->Fill(orbitoffset);
216  }
217  }
218  } else {
219  edm::LogWarning("L1AcceptBunchCrossingNoType") << "L1AcceptBunchCrossing with no type found: ";
220  edm::LogPrint("L1AcceptBunchCrossingNoType") << *tcdsRecord;
221  }
222  } else {
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();
227  bxoffset =
228  iEvent.bunchCrossing() -
229  l1abc->bunchCrossing(); // In EventWithHistoryProducerFromL1ABC, it's l1abc - iEvent. I keep this difference here, because I am not sure if it should be kept or not
230 
231  if (_wantHistos) {
232  if (_hbx && *_hbx)
233  (*_hbx)->Fill(l1abc->bunchCrossing());
234  if (_hdbx && *_hdbx)
235  (*_hdbx)->Fill(bxoffset);
236  if (_hdorbit && *_hdorbit)
237  (*_hdorbit)->Fill(orbitoffset);
238  }
239  } else {
240  edm::LogWarning("L1AcceptBunchCrossingNoType") << "L1AcceptBunchCrossing with no type found: ";
241  for (L1AcceptBunchCrossingCollection::const_iterator debu = pIn->begin(); debu != pIn->end(); ++debu) {
242  edm::LogPrint("L1AcceptBunchCrossingNoType") << *debu;
243  }
244  }
245  }
246  }
247  }
248 
249  long long absbxoffset = orbitoffset * 3564 + bxoffset;
250 
251  if (orbitoffset != _orbitoffsetSOR)
252  phasechange = (orbitoffset * 3564) % 70;
253 
254  if (_offsets.empty()) {
255  _curroffset = absbxoffset;
256  _curroffevent = iEvent.id().event();
257  _offsets[iEvent.id().event()] = absbxoffset;
258  } else {
259  if (_curroffset != absbxoffset || iEvent.id().event() < _curroffevent) {
260  if (_curroffset != absbxoffset) {
261  edm::LogInfo("L1AcceptBunchCrossingAbsoluteBXOffsetChanged")
262  << "Absolute BX offset changed from " << _curroffset << " to " << absbxoffset << " at orbit "
263  << iEvent.orbitNumber() << " and BX " << iEvent.bunchCrossing();
264  if (useTCDS) {
265  edm::LogVerbatim("AbsoluteBXOffsetChanged") << *tcdsRecord; // Not sure about this
266  } else {
267  for (L1AcceptBunchCrossingCollection::const_iterator l1abc = pIn->begin(); l1abc != pIn->end(); ++l1abc) {
268  edm::LogVerbatim("L1AcceptBunchCrossingAbsoluteBXOffsetChanged") << *l1abc;
269  }
270  }
271  }
272 
273  _curroffset = absbxoffset;
274  _curroffevent = iEvent.id().event();
275  _offsets[iEvent.id().event()] = absbxoffset;
276  }
277  }
278  }
279 
280  if (phases.size() < partnames.size()) {
281  // throw exception
282  throw cms::Exception("InvalidAPVCyclePhases")
283  << " Inconsistent phases/partitions vector sizes: " << phases.size() << " " << partnames.size();
284  }
285 
286  for (unsigned int ipart = 0; ipart < partnames.size(); ++ipart) {
287  if (phases[ipart] >= 0) {
288  apvphases->get()[partnames[ipart]] = (phases[ipart] + phasechange) % 70;
289  }
290  }
291 
292  iEvent.put(std::move(apvphases));
293 }
Log< level::Info, true > LogVerbatim
EventNumber_t event() const
Definition: EventID.h:40
std::map< edm::EventNumber_t, long long > _offsets
const std::vector< std::string > _defpartnames
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
int bunchCrossing() const
Definition: EventBase.h:64
edm::EDGetTokenT< L1AcceptBunchCrossingCollection > _l1abccollectionToken
edm::EDGetTokenT< TCDSRecord > _tcdsRecordToken
def move
Definition: eostools.py:511
RunNumber_t run() const
Definition: Event.h:109
int orbitNumber() const
Definition: EventBase.h:65
bool isValid() const
Definition: HandleBase.h:70
Log< level::Warning, true > LogPrint
Log< level::Info, false > LogInfo
std::vector< int > phases
T const * product() const
Definition: Handle.h:70
edm::EventID id() const
Definition: EventBase.h:59
Log< level::Warning, false > LogWarning

Member Data Documentation

edm::EventNumber_t APVCyclePhaseProducerFromL1ABC::_curroffevent
private

Definition at line 83 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

long long APVCyclePhaseProducerFromL1ABC::_curroffset
private

Definition at line 82 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

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

Definition at line 70 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

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

Definition at line 71 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

const unsigned int APVCyclePhaseProducerFromL1ABC::_firstgoodrun
private

Definition at line 80 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by beginRun(), and produce().

const bool APVCyclePhaseProducerFromL1ABC::_forceSCAL
private

Definition at line 74 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

TH1F** APVCyclePhaseProducerFromL1ABC::_hbx
private
TH1F** APVCyclePhaseProducerFromL1ABC::_hdbx
private
TH1F** APVCyclePhaseProducerFromL1ABC::_hdorbit
private
edm::EDGetTokenT<L1AcceptBunchCrossingCollection> APVCyclePhaseProducerFromL1ABC::_l1abccollectionToken
private

Definition at line 68 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

std::map<edm::EventNumber_t, long long> APVCyclePhaseProducerFromL1ABC::_offsets
private

Definition at line 81 of file APVCyclePhaseProducerFromL1ABC.cc.

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

const int APVCyclePhaseProducerFromL1ABC::_orbitoffsetSOR
private

Definition at line 72 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

edm::EDGetTokenT<TCDSRecord> APVCyclePhaseProducerFromL1ABC::_tcdsRecordToken
private

Definition at line 69 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by produce().

const bool APVCyclePhaseProducerFromL1ABC::_wantHistos
private
RunHistogramManager APVCyclePhaseProducerFromL1ABC::m_rhm
private

Definition at line 75 of file APVCyclePhaseProducerFromL1ABC.cc.

Referenced by APVCyclePhaseProducerFromL1ABC(), and beginRun().