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::NoCache > > 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::NoCache > >
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::NoCacheglobalBeginLuminosityBlock (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::NoCache > >
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_
 
BeamSpotContainer beamSpotsMap_
 
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 numberOfProcessedLumis_
 
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::NoCache > >
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
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::NoCache > >
edm::EDPutTokenT< DQMTokenrunToken_
 

Detailed Description

Definition at line 32 of file OnlineBeamMonitor.h.

Member Typedef Documentation

◆ BeamSpotContainer

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

Definition at line 47 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 49 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 51 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::NoCache > >.

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 BS - (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:32
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::NoCache > >.

Definition at line 399 of file OnlineBeamMonitor.cc.

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

399  {
400  if (processedLumis_.empty()) {
401  return;
402  }
403 
404  const double bigNumber = 1000000.;
405  std::sort(processedLumis_.begin(), processedLumis_.end());
406  int firstLumi = *processedLumis_.begin();
407  int lastLumi = *(--processedLumis_.end());
408  bsChoice_->getTH1()->GetXaxis()->SetRangeUser(firstLumi - 0.5, lastLumi + 0.5);
409  for (auto& itH : histosMap_) {
410  for (auto& itHH : itH.second) {
411  double min = bigNumber;
412  double max = -bigNumber;
413  if (itHH.first != "run") {
414  for (auto& itHHH : itHH.second) {
415  if (itHHH.second != nullptr) {
416  for (int bin = 1; bin <= itHHH.second->getTH1()->GetNbinsX(); bin++) {
417  if (itHHH.second->getTH1()->GetBinError(bin) != 0 || itHHH.second->getTH1()->GetBinContent(bin) != 0) {
418  if (itHHH.first == "Lumibased BeamSpotHLT" || itHHH.first == "Lumibased BeamSpotLegacy" ||
419  itHHH.first == "Lumibased BeamSpotTransient") {
420  if (min > itHHH.second->getTH1()->GetBinContent(bin)) {
421  min = itHHH.second->getTH1()->GetBinContent(bin);
422  }
423  if (max < itHHH.second->getTH1()->GetBinContent(bin)) {
424  max = itHHH.second->getTH1()->GetBinContent(bin);
425  }
426  } else {
427  LogInfo("OnlineBeamMonitorClient") << "The histosMap_ have a histogram named " << itHHH.first
428  << " that I can't recognize in this loop!";
429  }
430  }
431  }
432  }
433  }
434  for (auto& itHHH : itHH.second) {
435  if (itHHH.second != nullptr) {
436  if (itHHH.first == "Lumibased BeamSpotHLT" || itHHH.first == "Lumibased BeamSpotLegacy" ||
437  itHHH.first == "Lumibased BeamSpotTransient") {
438  if ((max == -bigNumber && min == bigNumber) || max - min == 0) {
439  itHHH.second->getTH1()->SetMinimum(itHHH.second->getTH1()->GetMinimum() - 0.01);
440  itHHH.second->getTH1()->SetMaximum(itHHH.second->getTH1()->GetMaximum() + 0.01);
441  } else {
442  itHHH.second->getTH1()->SetMinimum(min - 0.1 * (max - min));
443  itHHH.second->getTH1()->SetMaximum(max + 0.1 * (max - min));
444  }
445  } else {
446  LogInfo("OnlineBeamMonitorClient")
447  << "The histosMap_ have a histogram named " << itHHH.first << " that I can't recognize in this loop!";
448  }
449  itHHH.second->getTH1()->GetXaxis()->SetRangeUser(firstLumi - 0.5, lastLumi + 0.5);
450  }
451  }
452  }
453  }
454  }
455 }
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::NoCache > OnlineBeamMonitor::globalBeginLuminosityBlock ( const edm::LuminosityBlock iLumi,
const edm::EventSetup iSetup 
) const
overrideprotected

Definition at line 132 of file OnlineBeamMonitor.cc.

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

133  {
134  // Always create a beamspot group for each lumi weather we have results or not! Each Beamspot will be of unknown type!
135 
136  processedLumis_.push_back(iLumi.id().luminosityBlock());
137  //Read BeamSpot from DB
139  ESHandle<BeamSpotOnlineObjects> bsLegacyHandle;
140  ESHandle<BeamSpotObjects> bsTransientHandle;
141  //int lastLumiHLT_ = 0;
142  //int lastLumiLegacy_ = 0;
143  std::string startTimeStamp_ = "0";
144  std::string startTimeStampHLT_ = "0";
145  std::string startTimeStampLegacy_ = "0";
146  std::string stopTimeStamp_ = "0";
147  std::string stopTimeStampHLT_ = "0";
148  std::string stopTimeStampLegacy_ = "0";
149  std::string lumiRange_ = "0 - 0";
150  std::string lumiRangeHLT_ = "0 - 0";
151  std::string lumiRangeLegacy_ = "0 - 0";
152 
153  if (auto bsHLTHandle = iSetup.getHandle(bsHLTToken_)) {
154  auto const& spotDB = *bsHLTHandle;
155 
156  //lastLumiHLT_ = spotDB.lastAnalyzedLumi();
157  startTimeStampHLT_ = spotDB.startTime();
158  stopTimeStampHLT_ = spotDB.endTime();
159  lumiRangeHLT_ = spotDB.lumiRange();
160 
161  // translate from BeamSpotObjects to reco::BeamSpot
162  BeamSpot::Point apoint(spotDB.x(), spotDB.y(), spotDB.z());
163 
165  for (int i = 0; i < 7; ++i) {
166  for (int j = 0; j < 7; ++j) {
167  matrix(i, j) = spotDB.covariance(i, j);
168  }
169  }
170 
171  beamSpotsMap_["HLT"] = BeamSpot(apoint, spotDB.sigmaZ(), spotDB.dxdz(), spotDB.dydz(), spotDB.beamWidthX(), matrix);
172 
173  BeamSpot* aSpot = &(beamSpotsMap_["HLT"]);
174 
175  aSpot->setBeamWidthY(spotDB.beamWidthY());
176  aSpot->setEmittanceX(spotDB.emittanceX());
177  aSpot->setEmittanceY(spotDB.emittanceY());
178  aSpot->setbetaStar(spotDB.betaStar());
179 
180  if (spotDB.beamType() == 2) {
181  aSpot->setType(reco::BeamSpot::Tracker);
182  } else {
183  aSpot->setType(reco::BeamSpot::Fake);
184  }
185  //LogInfo("OnlineBeamMonitor")
186  // << *aSpot << std::endl;
187  } else {
188  LogInfo("OnlineBeamMonitor") << "Database BeamSpot is not valid at lumi: " << iLumi.id().luminosityBlock();
189  }
190  if (auto bsLegacyHandle = iSetup.getHandle(bsLegacyToken_)) {
191  auto const& spotDB = *bsLegacyHandle;
192 
193  // translate from BeamSpotObjects to reco::BeamSpot
194  BeamSpot::Point apoint(spotDB.x(), spotDB.y(), spotDB.z());
195 
196  //lastLumiLegacy_ = spotDB.lastAnalyzedLumi();
197  startTimeStampLegacy_ = spotDB.startTime();
198  stopTimeStampLegacy_ = spotDB.endTime();
199  lumiRangeLegacy_ = spotDB.lumiRange();
200 
202  for (int i = 0; i < 7; ++i) {
203  for (int j = 0; j < 7; ++j) {
204  matrix(i, j) = spotDB.covariance(i, j);
205  }
206  }
207 
208  beamSpotsMap_["Legacy"] =
209  BeamSpot(apoint, spotDB.sigmaZ(), spotDB.dxdz(), spotDB.dydz(), spotDB.beamWidthX(), matrix);
210 
211  BeamSpot* aSpot = &(beamSpotsMap_["Legacy"]);
212 
213  aSpot->setBeamWidthY(spotDB.beamWidthY());
214  aSpot->setEmittanceX(spotDB.emittanceX());
215  aSpot->setEmittanceY(spotDB.emittanceY());
216  aSpot->setbetaStar(spotDB.betaStar());
217 
218  if (spotDB.beamType() == 2) {
219  aSpot->setType(reco::BeamSpot::Tracker);
220  } else {
221  aSpot->setType(reco::BeamSpot::Fake);
222  }
223  //LogInfo("OnlineBeamMonitor")
224  // << *aSpot << std::endl;
225  } else {
226  LogInfo("OnlineBeamMonitor") << "Database BeamSpot is not valid at lumi: " << iLumi.id().luminosityBlock();
227  }
228  if (auto bsTransientHandle = iSetup.getHandle(bsTransientToken_)) {
229  auto const& spotDB = *bsTransientHandle;
230  //std::cout << " from the DB " << spotDB << std::endl;
231 
232  // translate from BeamSpotObjects to reco::BeamSpot
233  BeamSpot::Point apoint(spotDB.x(), spotDB.y(), spotDB.z());
234 
236  for (int i = 0; i < 7; ++i) {
237  for (int j = 0; j < 7; ++j) {
238  matrix(i, j) = spotDB.covariance(i, j);
239  }
240  }
241 
242  beamSpotsMap_["Transient"] =
243  BeamSpot(apoint, spotDB.sigmaZ(), spotDB.dxdz(), spotDB.dydz(), spotDB.beamWidthX(), matrix);
244 
245  BeamSpot* aSpot = &(beamSpotsMap_["Transient"]);
246 
247  aSpot->setBeamWidthY(spotDB.beamWidthY());
248  aSpot->setEmittanceX(spotDB.emittanceX());
249  aSpot->setEmittanceY(spotDB.emittanceY());
250  aSpot->setbetaStar(spotDB.betaStar());
251  if (spotDB.beamType() == 2) {
252  aSpot->setType(reco::BeamSpot::Tracker);
253  } else {
254  aSpot->setType(reco::BeamSpot::Fake);
255  }
256 
257  if (writeDIPTxt_) {
258  std::ofstream outFile;
259 
260  std::string tmpname = outputDIPTxt_;
261  int frun = iLumi.getRun().run();
262 
263  char index[15];
264  if (appendRunTxt_ && writeDIPTxt_) {
265  sprintf(index, "%s%i", "_Run", frun);
266  tmpname.insert(outputDIPTxt_.length() - 4, index);
267  }
268  //int lastLumiAnalyzed_ = iLumi.id().luminosityBlock();
269 
270  if (beamSpotsMap_.find("Transient") != beamSpotsMap_.end()) {
271  if (beamSpotsMap_.find("HLT") != beamSpotsMap_.end() &&
272  beamSpotsMap_["Transient"].x0() == beamSpotsMap_["HLT"].x0()) {
273  // lastLumiAnalyzed_ = lastLumiHLT_;
274  startTimeStamp_ = startTimeStampHLT_;
275  stopTimeStamp_ = stopTimeStampHLT_;
276  lumiRange_ = lumiRangeHLT_;
277 
278  } else if (beamSpotsMap_.find("Legacy") != beamSpotsMap_.end() &&
279  beamSpotsMap_["Transient"].x0() == beamSpotsMap_["Legacy"].x0()) {
280  //lastLumiAnalyzed_ = lastLumiLegacy_;
281  startTimeStamp_ = startTimeStampLegacy_;
282  stopTimeStamp_ = stopTimeStampLegacy_;
283  lumiRange_ = lumiRangeLegacy_;
284  }
285  }
286 
287  outFile.open(tmpname.c_str());
288 
289  outFile << "Runnumber " << frun << " bx " << 0 << std::endl;
290  outFile << "BeginTimeOfFit " << startTimeStamp_ << " " << 0 << std::endl;
291  outFile << "EndTimeOfFit " << stopTimeStamp_ << " " << 0 << std::endl;
292  //outFile << "LumiRange " << lumiRange_ << " - " << lastLumiAnalyzed_ << std::endl;
293  outFile << "LumiRange " << lumiRange_ << std::endl;
294  outFile << "Type " << aSpot->type() << std::endl;
295  outFile << "X0 " << aSpot->x0() << std::endl;
296  outFile << "Y0 " << aSpot->y0() << std::endl;
297  outFile << "Z0 " << aSpot->z0() << std::endl;
298  outFile << "sigmaZ0 " << aSpot->sigmaZ() << std::endl;
299  outFile << "dxdz " << aSpot->dxdz() << std::endl;
300  outFile << "dydz " << aSpot->dydz() << std::endl;
301  outFile << "BeamWidthX " << aSpot->BeamWidthX() << std::endl;
302  outFile << "BeamWidthY " << aSpot->BeamWidthY() << std::endl;
303  for (int i = 0; i < 6; ++i) {
304  outFile << "Cov(" << i << ",j) ";
305  for (int j = 0; j < 7; ++j) {
306  outFile << aSpot->covariance(i, j) << " ";
307  }
308  outFile << std::endl;
309  }
310  outFile << "Cov(6,j) 0 0 0 0 0 0 " << aSpot->covariance(6, 6) << std::endl;
311  outFile << "EmittanceX " << aSpot->emittanceX() << std::endl;
312  outFile << "EmittanceY " << aSpot->emittanceY() << std::endl;
313  outFile << "BetaStar " << aSpot->betaStar() << std::endl;
314 
315  outFile.close();
316  }
317  //LogInfo("OnlineBeamMonitor")
318  // << *aSpot << std::endl;
319  } else {
320  LogInfo("OnlineBeamMonitor") << "Database BeamSpot is not valid at lumi: " << iLumi.id().luminosityBlock();
321  }
322  return nullptr;
323 }
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
BeamSpotContainer beamSpotsMap_
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:151
std::vector< int > processedLumis_
Log< level::Info, false > LogInfo
LuminosityBlockID id() const
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 326 of file OnlineBeamMonitor.cc.

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

326  {
327  //Setting up the choice
328  if (beamSpotsMap_.find("Transient") != beamSpotsMap_.end()) {
329  if (beamSpotsMap_.find("HLT") != beamSpotsMap_.end() &&
330  beamSpotsMap_["Transient"].x0() == beamSpotsMap_["HLT"].x0()) {
331  bsChoice_->Fill(iLumi.id().luminosityBlock(), 1);
332  bsChoice_->setBinError(iLumi.id().luminosityBlock(), 0.05);
333  } else if (beamSpotsMap_.find("Legacy") != beamSpotsMap_.end() &&
334  beamSpotsMap_["Transient"].x0() == beamSpotsMap_["Legacy"].x0()) {
335  bsChoice_->Fill(iLumi.id().luminosityBlock(), -1);
336  bsChoice_->setBinError(iLumi.id().luminosityBlock(), 0.05);
337  } else {
338  bsChoice_->Fill(iLumi.id().luminosityBlock(), -10);
339  bsChoice_->setBinError(iLumi.id().luminosityBlock(), 0.05);
340  }
341  } else {
342  bsChoice_->Fill(iLumi.id().luminosityBlock(), 0);
343  bsChoice_->setBinError(iLumi.id().luminosityBlock(), 0.05);
344  }
345 
346  // "PV,BF..." Value,Error
347  map<std::string, pair<double, double> > resultsMap;
348  vector<pair<double, double> > vertexResults;
349  MonitorElement* histo = nullptr;
350  for (const auto& itV : varNamesV_) {
351  resultsMap.clear();
352  for (const auto& itBS : beamSpotsMap_) {
353  if (itBS.second.type() == BeamSpot::Tracker) {
354  if (itV == "x") {
355  resultsMap[itBS.first] = pair<double, double>(itBS.second.x0(), itBS.second.x0Error());
356  } else if (itV == "y") {
357  resultsMap[itBS.first] = pair<double, double>(itBS.second.y0(), itBS.second.y0Error());
358  } else if (itV == "z") {
359  resultsMap[itBS.first] = pair<double, double>(itBS.second.z0(), itBS.second.z0Error());
360  } else if (itV == "sigmaX") {
361  resultsMap[itBS.first] = pair<double, double>(itBS.second.BeamWidthX(), itBS.second.BeamWidthXError());
362  } else if (itV == "sigmaY") {
363  resultsMap[itBS.first] = pair<double, double>(itBS.second.BeamWidthY(), itBS.second.BeamWidthYError());
364  } else if (itV == "sigmaZ") {
365  resultsMap[itBS.first] = pair<double, double>(itBS.second.sigmaZ(), itBS.second.sigmaZ0Error());
366  } else {
367  LogInfo("OnlineBeamMonitor") << "The histosMap_ has been built with the name " << itV
368  << " that I can't recognize!";
369  }
370  }
371  }
372 
373  for (const auto& itM : histoByCategoryNames_) {
374  if ((histo = histosMap_[itV][itM.first][itM.second]) == nullptr)
375  continue;
376  if (itM.second == "Lumibased BeamSpotHLT") {
377  if (resultsMap.find("HLT") != resultsMap.end()) {
378  histo->setBinContent(iLumi.id().luminosityBlock(), resultsMap["HLT"].first);
379  histo->setBinError(iLumi.id().luminosityBlock(), resultsMap["HLT"].second);
380  }
381  } else if (itM.second == "Lumibased BeamSpotLegacy") {
382  if (resultsMap.find("Legacy") != resultsMap.end()) {
383  histo->setBinContent(iLumi.id().luminosityBlock(), resultsMap["Legacy"].first);
384  histo->setBinError(iLumi.id().luminosityBlock(), resultsMap["Legacy"].second);
385  }
386  } else if (itM.second == "Lumibased BeamSpotTransient") {
387  if (resultsMap.find("Transient") != resultsMap.end()) {
388  histo->setBinContent(iLumi.id().luminosityBlock(), resultsMap["Transient"].first);
389  histo->setBinError(iLumi.id().luminosityBlock(), resultsMap["Transient"].second);
390  }
391  } else {
392  LogInfo("OnlineBeamMonitor") << "The histosMap_ have a histogram named " << itM.second
393  << " that I can't recognize in this loop!";
394  }
395  }
396  }
397 }
LuminosityBlockNumber_t luminosityBlock() const
std::multimap< std::string, std::string > histoByCategoryNames_
BeamSpotContainer beamSpotsMap_
void Fill(long long x)
std::vector< std::string > varNamesV_
Log< level::Info, false > LogInfo
LuminosityBlockID id() const
MonitorElement * bsChoice_
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 75 of file OnlineBeamMonitor.h.

Referenced by globalBeginLuminosityBlock().

◆ beamSpotsMap_

BeamSpotContainer OnlineBeamMonitor::beamSpotsMap_
mutableprivate

Definition at line 68 of file OnlineBeamMonitor.h.

Referenced by globalBeginLuminosityBlock(), and globalEndLuminosityBlock().

◆ bsChoice_

MonitorElement* OnlineBeamMonitor::bsChoice_
private

Definition at line 65 of file OnlineBeamMonitor.h.

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

◆ bsHLTToken_

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

Definition at line 56 of file OnlineBeamMonitor.h.

Referenced by globalBeginLuminosityBlock().

◆ bsLegacyToken_

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

Definition at line 57 of file OnlineBeamMonitor.h.

Referenced by globalBeginLuminosityBlock().

◆ bsTransientToken_

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

Definition at line 55 of file OnlineBeamMonitor.h.

Referenced by globalBeginLuminosityBlock().

◆ fasciiDIP

std::ofstream OnlineBeamMonitor::fasciiDIP
private

Definition at line 58 of file OnlineBeamMonitor.h.

◆ histoByCategoryNames_

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

Definition at line 72 of file OnlineBeamMonitor.h.

Referenced by globalEndLuminosityBlock(), and OnlineBeamMonitor().

◆ histosMap_

HistosContainer OnlineBeamMonitor::histosMap_
private

◆ monitorName_

std::string OnlineBeamMonitor::monitorName_
private

Definition at line 54 of file OnlineBeamMonitor.h.

Referenced by bookHistograms(), and OnlineBeamMonitor().

◆ numberOfProcessedLumis_

int OnlineBeamMonitor::numberOfProcessedLumis_
mutableprivate

Definition at line 62 of file OnlineBeamMonitor.h.

◆ numberOfValuesToSave_

int OnlineBeamMonitor::numberOfValuesToSave_
private

Definition at line 61 of file OnlineBeamMonitor.h.

◆ outputDIPTxt_

std::string OnlineBeamMonitor::outputDIPTxt_
private

Definition at line 77 of file OnlineBeamMonitor.h.

Referenced by globalBeginLuminosityBlock().

◆ positionsMap_

PositionContainer OnlineBeamMonitor::positionsMap_
private

Definition at line 70 of file OnlineBeamMonitor.h.

◆ processedLumis_

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

Definition at line 63 of file OnlineBeamMonitor.h.

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

◆ varNamesV_

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

Definition at line 71 of file OnlineBeamMonitor.h.

Referenced by globalEndLuminosityBlock(), and OnlineBeamMonitor().

◆ writeDIPTxt_

bool OnlineBeamMonitor::writeDIPTxt_
private

Definition at line 76 of file OnlineBeamMonitor.h.

Referenced by globalBeginLuminosityBlock().