CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Attributes
OnlineBeamMonitor Class Reference

#include <OnlineBeamMonitor.h>

Inheritance diagram for OnlineBeamMonitor:
DQMOneEDAnalyzer< edm::LuminosityBlockCache< onlinebeammonitor::BeamSpotInfo > > edm::one::EDProducer< edm::EndRunProducer, edm::one::WatchRuns, edm::Accumulator, Args... > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 OnlineBeamMonitor (const edm::ParameterSet &)
 
- Public Member Functions inherited from DQMOneEDAnalyzer< edm::LuminosityBlockCache< onlinebeammonitor::BeamSpotInfo > >
void accumulate (edm::Event const &event, edm::EventSetup const &setup) override
 
void beginRun (edm::Run const &run, edm::EventSetup const &setup) final
 
 DQMOneEDAnalyzer ()
 
void endRun (edm::Run const &, edm::EventSetup const &) final
 
void endRunProduce (edm::Run &run, edm::EventSetup const &setup) final
 
virtual bool getCanSaveByLumi ()
 
- Public Member Functions inherited from edm::one::EDProducer< edm::EndRunProducer, edm::one::WatchRuns, edm::Accumulator, Args... >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () 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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~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)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Protected Member Functions

void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
 
void dqmEndRun (edm::Run const &, edm::EventSetup const &) override
 
std::shared_ptr< onlinebeammonitor::BeamSpotInfoglobalBeginLuminosityBlock (const edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup) const override
 
void globalEndLuminosityBlock (const edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup) override
 
- Protected Member Functions inherited from DQMOneEDAnalyzer< edm::LuminosityBlockCache< onlinebeammonitor::BeamSpotInfo > >
virtual void analyze (edm::Event const &, edm::EventSetup const &)
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
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< Bconsumes (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 ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
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)
 

Private Types

typedef std::map< std::string, reco::BeamSpotBeamSpotContainer
 
typedef std::map< std::string, std::map< std::string, std::map< std::string, MonitorElement * > > > HistosContainer
 
typedef std::map< std::string, std::map< std::string, std::map< std::string, int > > > PositionContainer
 

Private Attributes

bool appendRunTxt_
 
MonitorElementbsChoice_
 
edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineHLTObjectsRcdbsHLTToken_
 
edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineLegacyObjectsRcdbsLegacyToken_
 
edm::ESGetToken< BeamSpotObjects, BeamSpotTransientObjectsRcdbsTransientToken_
 
std::ofstream fasciiDIP
 
std::multimap< std::string, std::string > histoByCategoryNames_
 
HistosContainer histosMap_
 
std::string monitorName_
 
int numberOfValuesToSave_
 
std::string outputDIPTxt_
 
PositionContainer positionsMap_
 
std::vector< int > processedLumis_
 
std::vector< std::string > varNamesV_
 
bool writeDIPTxt_
 

Additional Inherited Members

- Public Types inherited from DQMOneEDAnalyzer< edm::LuminosityBlockCache< onlinebeammonitor::BeamSpotInfo > >
typedef dqm::reco::DQMStore DQMStore
 
typedef dqm::reco::MonitorElement MonitorElement
 
- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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
 
- Protected Attributes inherited from DQMOneEDAnalyzer< edm::LuminosityBlockCache< onlinebeammonitor::BeamSpotInfo > >
edm::EDPutTokenT< DQMTokenrunToken_
 

Detailed Description

Definition at line 35 of file OnlineBeamMonitor.h.

Member Typedef Documentation

◆ BeamSpotContainer

typedef std::map<std::string, reco::BeamSpot> OnlineBeamMonitor::BeamSpotContainer
private

Definition at line 50 of file OnlineBeamMonitor.h.

◆ HistosContainer

typedef std::map<std::string, std::map<std::string, std::map<std::string, MonitorElement*> > > OnlineBeamMonitor::HistosContainer
private

Definition at line 52 of file OnlineBeamMonitor.h.

◆ PositionContainer

typedef std::map<std::string, std::map<std::string, std::map<std::string, int> > > OnlineBeamMonitor::PositionContainer
private

Definition at line 54 of file OnlineBeamMonitor.h.

Constructor & Destructor Documentation

◆ OnlineBeamMonitor()

OnlineBeamMonitor::OnlineBeamMonitor ( const edm::ParameterSet ps)

Definition at line 29 of file OnlineBeamMonitor.cc.

References edm::BeginLuminosityBlock, histoByCategoryNames_, histosMap_, monitorName_, processedLumis_, and varNamesV_.

30  : monitorName_(ps.getUntrackedParameter<string>("MonitorName")),
31  bsTransientToken_(esConsumes<edm::Transition::BeginLuminosityBlock>()),
32  bsHLTToken_(esConsumes<edm::Transition::BeginLuminosityBlock>()),
33  bsLegacyToken_(esConsumes<edm::Transition::BeginLuminosityBlock>()),
35  appendRunTxt_(ps.getUntrackedParameter<bool>("AppendRunToFileName")),
36  writeDIPTxt_(ps.getUntrackedParameter<bool>("WriteDIPAscii")),
37  outputDIPTxt_(ps.getUntrackedParameter<std::string>("DIPFileName")) {
38  if (!monitorName_.empty())
39  monitorName_ = monitorName_ + "/";
40 
41  processedLumis_.clear();
42 
43  varNamesV_.push_back("x");
44  varNamesV_.push_back("y");
45  varNamesV_.push_back("z");
46  varNamesV_.push_back("sigmaX");
47  varNamesV_.push_back("sigmaY");
48  varNamesV_.push_back("sigmaZ");
49 
50  //histoByCategoryNames_.insert(pair<string, string>("run", "Coordinate"));
51  //histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex fit-DataBase"));
52  //histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex fit-BeamFit"));
53  //histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex fit-Scalers"));
54  //histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex-DataBase"));
55  //histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex-BeamFit"));
56  //histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex-Scalers"));
57 
58  histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased BeamSpotHLT"));
59  histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased BeamSpotLegacy"));
60  histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased BeamSpotTransient"));
61 
62  for (const auto& itV : varNamesV_) {
63  for (const auto& itM : histoByCategoryNames_) {
64  histosMap_[itV][itM.first][itM.second] = nullptr;
65  }
66  }
67 }
std::multimap< std::string, std::string > histoByCategoryNames_
edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineLegacyObjectsRcd > bsLegacyToken_
T getUntrackedParameter(std::string const &, T const &) const
std::string outputDIPTxt_
std::vector< std::string > varNamesV_
std::vector< int > processedLumis_
std::string monitorName_
edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineHLTObjectsRcd > bsHLTToken_
HistosContainer histosMap_
edm::ESGetToken< BeamSpotObjects, BeamSpotTransientObjectsRcd > bsTransientToken_

Member Function Documentation

◆ bookHistograms()

void OnlineBeamMonitor::bookHistograms ( DQMStore::IBooker ibooker,
edm::Run const &  iRun,
edm::EventSetup const &  iSetup 
)
overrideprotectedvirtual

Implements DQMOneEDAnalyzer< edm::LuminosityBlockCache< onlinebeammonitor::BeamSpotInfo > >.

Definition at line 80 of file OnlineBeamMonitor.cc.

References dqm::implementation::IBooker::book1D(), dqm::implementation::IBooker::bookProfile(), bsChoice_, histosMap_, beamSpotPI::lastLumi, monitorName_, Skims_PA_cff::name, dqm::impl::MonitorElement::setAxisTitle(), dqm::implementation::NavigatorBase::setCurrentFolder(), dqm::impl::MonitorElement::setEfficiencyFlag(), AlCaHLTBitMon_QueryRunRegistry::string, and runGCPTkAlMap::title.

82  {
83  string name;
84  string title;
85  int firstLumi = 1;
86  int lastLumi = 3000;
87  for (auto& itM : histosMap_) {
88  //Making histos per Lumi
89  // x,y,z,sigmaX,sigmaY,sigmaZ
90  for (auto& itMM : itM.second) {
91  if (itMM.first != "run") {
92  for (auto& itMMM : itMM.second) {
93  name = string("h") + itM.first + itMMM.first;
94  title = itM.first + "_{0} " + itMMM.first;
95  if (itMM.first == "lumi") {
96  ibooker.setCurrentFolder(monitorName_ + "Debug");
97  itMMM.second = ibooker.book1D(name, title, lastLumi - firstLumi + 1, firstLumi - 0.5, lastLumi + 0.5);
98  itMMM.second->setEfficiencyFlag();
99  } else {
100  LogInfo("OnlineBeamMonitorClient") << "Unrecognized category " << itMM.first;
101  }
102  if (itMMM.second != nullptr) {
103  if (itMMM.first.find('-') != string::npos) {
104  itMMM.second->setAxisTitle(string("#Delta ") + itM.first + "_{0} (cm)", 2);
105  } else {
106  itMMM.second->setAxisTitle(itM.first + "_{0} (cm)", 2);
107  }
108  itMMM.second->setAxisTitle("Lumisection", 1);
109  }
110  }
111  }
112  }
113  }
114 
115  // create and cd into new folder
116  ibooker.setCurrentFolder(monitorName_ + "Validation");
117  //Book histograms
118  bsChoice_ = ibooker.bookProfile("bsChoice",
119  "BS Choice: +1=HLT / -1=Legacy / -10=Fake (fallback to PCL) / 0=No Transient ",
120  lastLumi - firstLumi + 1,
121  firstLumi - 0.5,
122  lastLumi + 0.5,
123  100,
124  -10,
125  1,
126  "");
127  bsChoice_->setAxisTitle("Lumisection", 1);
128  bsChoice_->setAxisTitle("Choice", 2);
129 }
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:399
Log< level::Info, false > LogInfo
std::string monitorName_
MonitorElement * bsChoice_
HistosContainer histosMap_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)

◆ dqmEndRun()

void OnlineBeamMonitor::dqmEndRun ( edm::Run const &  ,
edm::EventSetup const &   
)
overrideprotectedvirtual

Reimplemented from DQMOneEDAnalyzer< edm::LuminosityBlockCache< onlinebeammonitor::BeamSpotInfo > >.

Definition at line 453 of file OnlineBeamMonitor.cc.

References newFWLiteAna::bin, bsChoice_, dqm::impl::MonitorElement::getTH1(), histosMap_, beamSpotPI::lastLumi, SiStripPI::max, SiStripPI::min, processedLumis_, and jetUpdater_cfi::sort.

453  {
454  if (processedLumis_.empty()) {
455  return;
456  }
457 
458  const double bigNumber = 1000000.;
459  std::sort(processedLumis_.begin(), processedLumis_.end());
460  int firstLumi = *processedLumis_.begin();
461  int lastLumi = *(--processedLumis_.end());
462  bsChoice_->getTH1()->GetXaxis()->SetRangeUser(firstLumi - 0.5, lastLumi + 0.5);
463  for (auto& itH : histosMap_) {
464  for (auto& itHH : itH.second) {
465  double min = bigNumber;
466  double max = -bigNumber;
467  if (itHH.first != "run") {
468  for (auto& itHHH : itHH.second) {
469  if (itHHH.second != nullptr) {
470  for (int bin = 1; bin <= itHHH.second->getTH1()->GetNbinsX(); bin++) {
471  if (itHHH.second->getTH1()->GetBinError(bin) != 0 || itHHH.second->getTH1()->GetBinContent(bin) != 0) {
472  if (itHHH.first == "Lumibased BeamSpotHLT" || itHHH.first == "Lumibased BeamSpotLegacy" ||
473  itHHH.first == "Lumibased BeamSpotTransient") {
474  if (min > itHHH.second->getTH1()->GetBinContent(bin)) {
475  min = itHHH.second->getTH1()->GetBinContent(bin);
476  }
477  if (max < itHHH.second->getTH1()->GetBinContent(bin)) {
478  max = itHHH.second->getTH1()->GetBinContent(bin);
479  }
480  } else {
481  LogInfo("OnlineBeamMonitorClient") << "The histosMap_ have a histogram named " << itHHH.first
482  << " that I can't recognize in this loop!";
483  }
484  }
485  }
486  }
487  }
488  for (auto& itHHH : itHH.second) {
489  if (itHHH.second != nullptr) {
490  if (itHHH.first == "Lumibased BeamSpotHLT" || itHHH.first == "Lumibased BeamSpotLegacy" ||
491  itHHH.first == "Lumibased BeamSpotTransient") {
492  if ((max == -bigNumber && min == bigNumber) || max - min == 0) {
493  itHHH.second->getTH1()->SetMinimum(itHHH.second->getTH1()->GetMinimum() - 0.01);
494  itHHH.second->getTH1()->SetMaximum(itHHH.second->getTH1()->GetMaximum() + 0.01);
495  } else {
496  itHHH.second->getTH1()->SetMinimum(min - 0.1 * (max - min));
497  itHHH.second->getTH1()->SetMaximum(max + 0.1 * (max - min));
498  }
499  } else {
500  LogInfo("OnlineBeamMonitorClient")
501  << "The histosMap_ have a histogram named " << itHHH.first << " that I can't recognize in this loop!";
502  }
503  itHHH.second->getTH1()->GetXaxis()->SetRangeUser(firstLumi - 0.5, lastLumi + 0.5);
504  }
505  }
506  }
507  }
508  }
509 }
std::vector< int > processedLumis_
Log< level::Info, false > LogInfo
MonitorElement * bsChoice_
HistosContainer histosMap_

◆ fillDescriptions()

void OnlineBeamMonitor::fillDescriptions ( edm::ConfigurationDescriptions iDesc)
static

Definition at line 69 of file OnlineBeamMonitor.cc.

References edm::ParameterSetDescription::addUntracked(), edm::ConfigurationDescriptions::addWithDefaultLabel(), and AlCaHLTBitMon_QueryRunRegistry::string.

69  {
71  ps.addUntracked<std::string>("MonitorName", "YourSubsystemName");
72  ps.addUntracked<bool>("AppendRunToFileName", false);
73  ps.addUntracked<bool>("WriteDIPAscii", true);
74  ps.addUntracked<std::string>("DIPFileName", "BeamFitResultsForDIP.txt");
75 
76  iDesc.addWithDefaultLabel(ps);
77 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)

◆ globalBeginLuminosityBlock()

std::shared_ptr< onlinebeammonitor::BeamSpotInfo > OnlineBeamMonitor::globalBeginLuminosityBlock ( const edm::LuminosityBlock iLumi,
const edm::EventSetup iSetup 
) const
overrideprotected

Definition at line 175 of file OnlineBeamMonitor.cc.

References appendRunTxt_, align::BeamSpot, bsHLTToken_, bsLegacyToken_, bsTransientToken_, endTime, reco::BeamSpot::Fake, edm::EventSetup::getHandle(), edm::LuminosityBlock::getRun(), mps_fire::i, edm::LuminosityBlockBase::id(), dqmiolumiharvest::j, edm::LuminosityBlockID::luminosityBlock(), lumiRange, makeMuonMisalignmentScenario::matrix, myStringFunctor, L1TdeCSCTF_cfi::outFile, outputDIPTxt_, print_error(), edm::RunBase::run(), reco::BeamSpot::setBeamWidthY(), startTime, AlCaHLTBitMon_QueryRunRegistry::string, reco::BeamSpot::Tracker, and writeDIPTxt_.

176  {
177  // Always create a beamspot group for each lumi weather we have results or not! Each Beamspot will be of unknown type!
178 
179  auto beamSpotInfo = std::make_shared<onlinebeammonitor::BeamSpotInfo>();
180 
181  //Read BeamSpot from DB
183  ESHandle<BeamSpotOnlineObjects> bsLegacyHandle;
184  ESHandle<BeamSpotObjects> bsTransientHandle;
185  //int lastLumiHLT_ = 0;
186  //int lastLumiLegacy_ = 0;
187  std::string startTimeStamp_ = "0";
188  std::string startTimeStampHLT_ = "0";
189  std::string startTimeStampLegacy_ = "0";
190  std::string stopTimeStamp_ = "0";
191  std::string stopTimeStampHLT_ = "0";
192  std::string stopTimeStampLegacy_ = "0";
193  std::string lumiRange_ = "0 - 0";
194  std::string lumiRangeHLT_ = "0 - 0";
195  std::string lumiRangeLegacy_ = "0 - 0";
196 
197  if (auto bsHLTHandle = iSetup.getHandle(bsHLTToken_)) {
198  auto const& spotDB = *bsHLTHandle;
199 
200  //lastLumiHLT_ = spotDB.lastAnalyzedLumi();
201  startTimeStampHLT_ =
202  try_<std::string, std::out_of_range>(std::bind(myStringFunctor, BSparameters::startTime, spotDB), print_error);
203  stopTimeStampHLT_ =
204  try_<std::string, std::out_of_range>(std::bind(myStringFunctor, BSparameters::endTime, spotDB), print_error);
205  lumiRangeHLT_ =
206  try_<std::string, std::out_of_range>(std::bind(myStringFunctor, BSparameters::lumiRange, spotDB), print_error);
207 
208  // translate from BeamSpotObjects to reco::BeamSpot
209  BeamSpot::Point apoint(spotDB.x(), spotDB.y(), spotDB.z());
210 
212  for (int i = 0; i < 7; ++i) {
213  for (int j = 0; j < 7; ++j) {
214  matrix(i, j) = spotDB.covariance(i, j);
215  }
216  }
217 
218  beamSpotInfo->beamSpotsMap_["HLT"] =
219  BeamSpot(apoint, spotDB.sigmaZ(), spotDB.dxdz(), spotDB.dydz(), spotDB.beamWidthX(), matrix);
220 
221  BeamSpot* aSpot = &(beamSpotInfo->beamSpotsMap_["HLT"]);
222 
223  aSpot->setBeamWidthY(spotDB.beamWidthY());
224  aSpot->setEmittanceX(spotDB.emittanceX());
225  aSpot->setEmittanceY(spotDB.emittanceY());
226  aSpot->setbetaStar(spotDB.betaStar());
227 
228  if (spotDB.beamType() == 2) {
229  aSpot->setType(reco::BeamSpot::Tracker);
230  } else {
231  aSpot->setType(reco::BeamSpot::Fake);
232  }
233  //LogInfo("OnlineBeamMonitor")
234  // << *aSpot << std::endl;
235  } else {
236  LogInfo("OnlineBeamMonitor") << "Database BeamSpot is not valid at lumi: " << iLumi.id().luminosityBlock();
237  }
238  if (auto bsLegacyHandle = iSetup.getHandle(bsLegacyToken_)) {
239  auto const& spotDB = *bsLegacyHandle;
240 
241  // translate from BeamSpotObjects to reco::BeamSpot
242  BeamSpot::Point apoint(spotDB.x(), spotDB.y(), spotDB.z());
243 
244  //lastLumiLegacy_ = spotDB.lastAnalyzedLumi();
245  startTimeStampLegacy_ =
246  try_<std::string, std::out_of_range>(std::bind(myStringFunctor, BSparameters::startTime, spotDB), print_error);
247  stopTimeStampLegacy_ =
248  try_<std::string, std::out_of_range>(std::bind(myStringFunctor, BSparameters::endTime, spotDB), print_error);
249  lumiRangeLegacy_ =
250  try_<std::string, std::out_of_range>(std::bind(myStringFunctor, BSparameters::lumiRange, spotDB), print_error);
251 
253  for (int i = 0; i < 7; ++i) {
254  for (int j = 0; j < 7; ++j) {
255  matrix(i, j) = spotDB.covariance(i, j);
256  }
257  }
258 
259  beamSpotInfo->beamSpotsMap_["Legacy"] =
260  BeamSpot(apoint, spotDB.sigmaZ(), spotDB.dxdz(), spotDB.dydz(), spotDB.beamWidthX(), matrix);
261 
262  BeamSpot* aSpot = &(beamSpotInfo->beamSpotsMap_["Legacy"]);
263 
264  aSpot->setBeamWidthY(spotDB.beamWidthY());
265  aSpot->setEmittanceX(spotDB.emittanceX());
266  aSpot->setEmittanceY(spotDB.emittanceY());
267  aSpot->setbetaStar(spotDB.betaStar());
268 
269  if (spotDB.beamType() == 2) {
270  aSpot->setType(reco::BeamSpot::Tracker);
271  } else {
272  aSpot->setType(reco::BeamSpot::Fake);
273  }
274  //LogInfo("OnlineBeamMonitor")
275  // << *aSpot << std::endl;
276  } else {
277  LogInfo("OnlineBeamMonitor") << "Database BeamSpot is not valid at lumi: " << iLumi.id().luminosityBlock();
278  }
279  if (auto bsTransientHandle = iSetup.getHandle(bsTransientToken_)) {
280  auto const& spotDB = *bsTransientHandle;
281  //std::cout << " from the DB " << spotDB << std::endl;
282 
283  // translate from BeamSpotObjects to reco::BeamSpot
284  BeamSpot::Point apoint(spotDB.x(), spotDB.y(), spotDB.z());
285 
287  for (int i = 0; i < 7; ++i) {
288  for (int j = 0; j < 7; ++j) {
289  matrix(i, j) = spotDB.covariance(i, j);
290  }
291  }
292 
293  beamSpotInfo->beamSpotsMap_["Transient"] =
294  BeamSpot(apoint, spotDB.sigmaZ(), spotDB.dxdz(), spotDB.dydz(), spotDB.beamWidthX(), matrix);
295 
296  BeamSpot* aSpot = &(beamSpotInfo->beamSpotsMap_["Transient"]);
297 
298  aSpot->setBeamWidthY(spotDB.beamWidthY());
299  aSpot->setEmittanceX(spotDB.emittanceX());
300  aSpot->setEmittanceY(spotDB.emittanceY());
301  aSpot->setbetaStar(spotDB.betaStar());
302  if (spotDB.beamType() == 2) {
303  aSpot->setType(reco::BeamSpot::Tracker);
304  } else {
305  aSpot->setType(reco::BeamSpot::Fake);
306  }
307 
308  if (writeDIPTxt_) {
309  std::ofstream outFile;
310 
311  std::string tmpname = outputDIPTxt_;
312  int frun = iLumi.getRun().run();
313 
314  char index[15];
315  if (appendRunTxt_ && writeDIPTxt_) {
316  sprintf(index, "%s%i", "_Run", frun);
317  tmpname.insert(outputDIPTxt_.length() - 4, index);
318  }
319  //int lastLumiAnalyzed_ = iLumi.id().luminosityBlock();
320 
321  if (beamSpotInfo->beamSpotsMap_.find("Transient") != beamSpotInfo->beamSpotsMap_.end()) {
322  if (beamSpotInfo->beamSpotsMap_.find("HLT") != beamSpotInfo->beamSpotsMap_.end() &&
323  beamSpotInfo->beamSpotsMap_["Transient"].x0() == beamSpotInfo->beamSpotsMap_["HLT"].x0()) {
324  // lastLumiAnalyzed_ = lastLumiHLT_;
325  startTimeStamp_ = startTimeStampHLT_;
326  stopTimeStamp_ = stopTimeStampHLT_;
327  lumiRange_ = lumiRangeHLT_;
328 
329  } else if (beamSpotInfo->beamSpotsMap_.find("Legacy") != beamSpotInfo->beamSpotsMap_.end() &&
330  beamSpotInfo->beamSpotsMap_["Transient"].x0() == beamSpotInfo->beamSpotsMap_["Legacy"].x0()) {
331  //lastLumiAnalyzed_ = lastLumiLegacy_;
332  startTimeStamp_ = startTimeStampLegacy_;
333  stopTimeStamp_ = stopTimeStampLegacy_;
334  lumiRange_ = lumiRangeLegacy_;
335  }
336  }
337 
338  outFile.open(tmpname.c_str());
339 
340  outFile << "Runnumber " << frun << " bx " << 0 << std::endl;
341  outFile << "BeginTimeOfFit " << startTimeStamp_ << " " << 0 << std::endl;
342  outFile << "EndTimeOfFit " << stopTimeStamp_ << " " << 0 << std::endl;
343  //outFile << "LumiRange " << lumiRange_ << " - " << lastLumiAnalyzed_ << std::endl;
344  outFile << "LumiRange " << lumiRange_ << std::endl;
345  outFile << "Type " << aSpot->type() << std::endl;
346  outFile << "X0 " << aSpot->x0() << std::endl;
347  outFile << "Y0 " << aSpot->y0() << std::endl;
348  outFile << "Z0 " << aSpot->z0() << std::endl;
349  outFile << "sigmaZ0 " << aSpot->sigmaZ() << std::endl;
350  outFile << "dxdz " << aSpot->dxdz() << std::endl;
351  outFile << "dydz " << aSpot->dydz() << std::endl;
352  outFile << "BeamWidthX " << aSpot->BeamWidthX() << std::endl;
353  outFile << "BeamWidthY " << aSpot->BeamWidthY() << std::endl;
354  for (int i = 0; i < 6; ++i) {
355  outFile << "Cov(" << i << ",j) ";
356  for (int j = 0; j < 7; ++j) {
357  outFile << aSpot->covariance(i, j) << " ";
358  }
359  outFile << std::endl;
360  }
361  outFile << "Cov(6,j) 0 0 0 0 0 0 " << aSpot->covariance(6, 6) << std::endl;
362  outFile << "EmittanceX " << aSpot->emittanceX() << std::endl;
363  outFile << "EmittanceY " << aSpot->emittanceY() << std::endl;
364  outFile << "BetaStar " << aSpot->betaStar() << std::endl;
365 
366  outFile.close();
367  }
368  //LogInfo("OnlineBeamMonitor")
369  // << *aSpot << std::endl;
370  } else {
371  LogInfo("OnlineBeamMonitor") << "Database BeamSpot is not valid at lumi: " << iLumi.id().luminosityBlock();
372  }
373  return beamSpotInfo;
374 }
math::Error< dimension >::type CovarianceMatrix
Definition: BeamSpot.h:29
LuminosityBlockNumber_t luminosityBlock() const
Run const & getRun() const
edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineLegacyObjectsRcd > bsLegacyToken_
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:27
std::function< std::string(BSparameters, BeamSpotOnlineObjects)> myStringFunctor
std::string outputDIPTxt_
RunNumber_t run() const
Definition: RunBase.h:40
void setBeamWidthY(double v)
Definition: BeamSpot.h:105
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
Log< level::Info, false > LogInfo
LuminosityBlockID id() const
static void print_error(const std::exception &e)
edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineHLTObjectsRcd > bsHLTToken_
edm::ESGetToken< BeamSpotObjects, BeamSpotTransientObjectsRcd > bsTransientToken_

◆ globalEndLuminosityBlock()

void OnlineBeamMonitor::globalEndLuminosityBlock ( const edm::LuminosityBlock iLumi,
const edm::EventSetup iSetup 
)
overrideprotected

Definition at line 377 of file OnlineBeamMonitor.cc.

References bsChoice_, dqm::impl::MonitorElement::Fill(), timingPdfMaker::histo, histoByCategoryNames_, histosMap_, edm::LuminosityBlockBase::id(), edm::LuminosityBlock::index(), edm::LuminosityBlockID::luminosityBlock(), processedLumis_, dqm::impl::MonitorElement::setBinError(), align::Tracker, and varNamesV_.

377  {
378  processedLumis_.push_back(iLumi.id().luminosityBlock());
379  auto beamSpotInfo = luminosityBlockCache(iLumi.index());
380 
381  //Setting up the choice
382  if (beamSpotInfo->beamSpotsMap_.find("Transient") != beamSpotInfo->beamSpotsMap_.end()) {
383  if (beamSpotInfo->beamSpotsMap_.find("HLT") != beamSpotInfo->beamSpotsMap_.end() &&
384  beamSpotInfo->beamSpotsMap_["Transient"].x0() == beamSpotInfo->beamSpotsMap_["HLT"].x0()) {
385  bsChoice_->Fill(iLumi.id().luminosityBlock(), 1);
386  bsChoice_->setBinError(iLumi.id().luminosityBlock(), 0.05);
387  } else if (beamSpotInfo->beamSpotsMap_.find("Legacy") != beamSpotInfo->beamSpotsMap_.end() &&
388  beamSpotInfo->beamSpotsMap_["Transient"].x0() == beamSpotInfo->beamSpotsMap_["Legacy"].x0()) {
389  bsChoice_->Fill(iLumi.id().luminosityBlock(), -1);
390  bsChoice_->setBinError(iLumi.id().luminosityBlock(), 0.05);
391  } else {
392  bsChoice_->Fill(iLumi.id().luminosityBlock(), -10);
393  bsChoice_->setBinError(iLumi.id().luminosityBlock(), 0.05);
394  }
395  } else {
396  bsChoice_->Fill(iLumi.id().luminosityBlock(), 0);
397  bsChoice_->setBinError(iLumi.id().luminosityBlock(), 0.05);
398  }
399 
400  // "PV,BF..." Value,Error
401  map<std::string, pair<double, double> > resultsMap;
402  vector<pair<double, double> > vertexResults;
403  MonitorElement* histo = nullptr;
404  for (const auto& itV : varNamesV_) {
405  resultsMap.clear();
406  for (const auto& itBS : beamSpotInfo->beamSpotsMap_) {
407  if (itBS.second.type() == BeamSpot::Tracker) {
408  if (itV == "x") {
409  resultsMap[itBS.first] = pair<double, double>(itBS.second.x0(), itBS.second.x0Error());
410  } else if (itV == "y") {
411  resultsMap[itBS.first] = pair<double, double>(itBS.second.y0(), itBS.second.y0Error());
412  } else if (itV == "z") {
413  resultsMap[itBS.first] = pair<double, double>(itBS.second.z0(), itBS.second.z0Error());
414  } else if (itV == "sigmaX") {
415  resultsMap[itBS.first] = pair<double, double>(itBS.second.BeamWidthX(), itBS.second.BeamWidthXError());
416  } else if (itV == "sigmaY") {
417  resultsMap[itBS.first] = pair<double, double>(itBS.second.BeamWidthY(), itBS.second.BeamWidthYError());
418  } else if (itV == "sigmaZ") {
419  resultsMap[itBS.first] = pair<double, double>(itBS.second.sigmaZ(), itBS.second.sigmaZ0Error());
420  } else {
421  LogInfo("OnlineBeamMonitor") << "The histosMap_ has been built with the name " << itV
422  << " that I can't recognize!";
423  }
424  }
425  }
426 
427  for (const auto& itM : histoByCategoryNames_) {
428  if ((histo = histosMap_[itV][itM.first][itM.second]) == nullptr)
429  continue;
430  if (itM.second == "Lumibased BeamSpotHLT") {
431  if (resultsMap.find("HLT") != resultsMap.end()) {
432  histo->setBinContent(iLumi.id().luminosityBlock(), resultsMap["HLT"].first);
433  histo->setBinError(iLumi.id().luminosityBlock(), resultsMap["HLT"].second);
434  }
435  } else if (itM.second == "Lumibased BeamSpotLegacy") {
436  if (resultsMap.find("Legacy") != resultsMap.end()) {
437  histo->setBinContent(iLumi.id().luminosityBlock(), resultsMap["Legacy"].first);
438  histo->setBinError(iLumi.id().luminosityBlock(), resultsMap["Legacy"].second);
439  }
440  } else if (itM.second == "Lumibased BeamSpotTransient") {
441  if (resultsMap.find("Transient") != resultsMap.end()) {
442  histo->setBinContent(iLumi.id().luminosityBlock(), resultsMap["Transient"].first);
443  histo->setBinError(iLumi.id().luminosityBlock(), resultsMap["Transient"].second);
444  }
445  } else {
446  LogInfo("OnlineBeamMonitor") << "The histosMap_ have a histogram named " << itM.second
447  << " that I can't recognize in this loop!";
448  }
449  }
450  }
451 }
LuminosityBlockNumber_t luminosityBlock() const
std::multimap< std::string, std::string > histoByCategoryNames_
void Fill(long long x)
std::vector< std::string > varNamesV_
std::vector< int > processedLumis_
Log< level::Info, false > LogInfo
LuminosityBlockID id() const
MonitorElement * bsChoice_
LuminosityBlockIndex index() const
HistosContainer histosMap_
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)

Member Data Documentation

◆ appendRunTxt_

bool OnlineBeamMonitor::appendRunTxt_
private

Definition at line 76 of file OnlineBeamMonitor.h.

Referenced by globalBeginLuminosityBlock().

◆ bsChoice_

MonitorElement* OnlineBeamMonitor::bsChoice_
private

Definition at line 67 of file OnlineBeamMonitor.h.

Referenced by bookHistograms(), dqmEndRun(), and globalEndLuminosityBlock().

◆ bsHLTToken_

edm::ESGetToken<BeamSpotOnlineObjects, BeamSpotOnlineHLTObjectsRcd> OnlineBeamMonitor::bsHLTToken_
private

Definition at line 59 of file OnlineBeamMonitor.h.

Referenced by globalBeginLuminosityBlock().

◆ bsLegacyToken_

edm::ESGetToken<BeamSpotOnlineObjects, BeamSpotOnlineLegacyObjectsRcd> OnlineBeamMonitor::bsLegacyToken_
private

Definition at line 60 of file OnlineBeamMonitor.h.

Referenced by globalBeginLuminosityBlock().

◆ bsTransientToken_

edm::ESGetToken<BeamSpotObjects, BeamSpotTransientObjectsRcd> OnlineBeamMonitor::bsTransientToken_
private

Definition at line 58 of file OnlineBeamMonitor.h.

Referenced by globalBeginLuminosityBlock().

◆ fasciiDIP

std::ofstream OnlineBeamMonitor::fasciiDIP
private

Definition at line 61 of file OnlineBeamMonitor.h.

◆ histoByCategoryNames_

std::multimap<std::string, std::string> OnlineBeamMonitor::histoByCategoryNames_
private

Definition at line 73 of file OnlineBeamMonitor.h.

Referenced by globalEndLuminosityBlock(), and OnlineBeamMonitor().

◆ histosMap_

HistosContainer OnlineBeamMonitor::histosMap_
private

◆ monitorName_

std::string OnlineBeamMonitor::monitorName_
private

Definition at line 57 of file OnlineBeamMonitor.h.

Referenced by bookHistograms(), and OnlineBeamMonitor().

◆ numberOfValuesToSave_

int OnlineBeamMonitor::numberOfValuesToSave_
private

Definition at line 64 of file OnlineBeamMonitor.h.

◆ outputDIPTxt_

std::string OnlineBeamMonitor::outputDIPTxt_
private

Definition at line 78 of file OnlineBeamMonitor.h.

Referenced by globalBeginLuminosityBlock().

◆ positionsMap_

PositionContainer OnlineBeamMonitor::positionsMap_
private

Definition at line 71 of file OnlineBeamMonitor.h.

◆ processedLumis_

std::vector<int> OnlineBeamMonitor::processedLumis_
private

Definition at line 65 of file OnlineBeamMonitor.h.

Referenced by dqmEndRun(), globalEndLuminosityBlock(), and OnlineBeamMonitor().

◆ varNamesV_

std::vector<std::string> OnlineBeamMonitor::varNamesV_
private

Definition at line 72 of file OnlineBeamMonitor.h.

Referenced by globalEndLuminosityBlock(), and OnlineBeamMonitor().

◆ writeDIPTxt_

bool OnlineBeamMonitor::writeDIPTxt_
private

Definition at line 77 of file OnlineBeamMonitor.h.

Referenced by globalBeginLuminosityBlock().