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
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::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: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::NoCache > >.

Definition at line 448 of file OnlineBeamMonitor.cc.

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

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

References appendRunTxt_, align::BeamSpot, beamSpotsMap_, 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(), processedLumis_, 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  processedLumis_.push_back(iLumi.id().luminosityBlock());
180  //Read BeamSpot from DB
182  ESHandle<BeamSpotOnlineObjects> bsLegacyHandle;
183  ESHandle<BeamSpotObjects> bsTransientHandle;
184  //int lastLumiHLT_ = 0;
185  //int lastLumiLegacy_ = 0;
186  std::string startTimeStamp_ = "0";
187  std::string startTimeStampHLT_ = "0";
188  std::string startTimeStampLegacy_ = "0";
189  std::string stopTimeStamp_ = "0";
190  std::string stopTimeStampHLT_ = "0";
191  std::string stopTimeStampLegacy_ = "0";
192  std::string lumiRange_ = "0 - 0";
193  std::string lumiRangeHLT_ = "0 - 0";
194  std::string lumiRangeLegacy_ = "0 - 0";
195 
196  if (auto bsHLTHandle = iSetup.getHandle(bsHLTToken_)) {
197  auto const& spotDB = *bsHLTHandle;
198 
199  //lastLumiHLT_ = spotDB.lastAnalyzedLumi();
200  startTimeStampHLT_ =
201  try_<std::string, std::out_of_range>(std::bind(myStringFunctor, BSparameters::startTime, spotDB), print_error);
202  stopTimeStampHLT_ =
203  try_<std::string, std::out_of_range>(std::bind(myStringFunctor, BSparameters::endTime, spotDB), print_error);
204  lumiRangeHLT_ =
205  try_<std::string, std::out_of_range>(std::bind(myStringFunctor, BSparameters::lumiRange, spotDB), print_error);
206 
207  // translate from BeamSpotObjects to reco::BeamSpot
208  BeamSpot::Point apoint(spotDB.x(), spotDB.y(), spotDB.z());
209 
211  for (int i = 0; i < 7; ++i) {
212  for (int j = 0; j < 7; ++j) {
213  matrix(i, j) = spotDB.covariance(i, j);
214  }
215  }
216 
217  beamSpotsMap_["HLT"] = BeamSpot(apoint, spotDB.sigmaZ(), spotDB.dxdz(), spotDB.dydz(), spotDB.beamWidthX(), matrix);
218 
219  BeamSpot* aSpot = &(beamSpotsMap_["HLT"]);
220 
221  aSpot->setBeamWidthY(spotDB.beamWidthY());
222  aSpot->setEmittanceX(spotDB.emittanceX());
223  aSpot->setEmittanceY(spotDB.emittanceY());
224  aSpot->setbetaStar(spotDB.betaStar());
225 
226  if (spotDB.beamType() == 2) {
227  aSpot->setType(reco::BeamSpot::Tracker);
228  } else {
229  aSpot->setType(reco::BeamSpot::Fake);
230  }
231  //LogInfo("OnlineBeamMonitor")
232  // << *aSpot << std::endl;
233  } else {
234  LogInfo("OnlineBeamMonitor") << "Database BeamSpot is not valid at lumi: " << iLumi.id().luminosityBlock();
235  }
236  if (auto bsLegacyHandle = iSetup.getHandle(bsLegacyToken_)) {
237  auto const& spotDB = *bsLegacyHandle;
238 
239  // translate from BeamSpotObjects to reco::BeamSpot
240  BeamSpot::Point apoint(spotDB.x(), spotDB.y(), spotDB.z());
241 
242  //lastLumiLegacy_ = spotDB.lastAnalyzedLumi();
243  startTimeStampLegacy_ =
244  try_<std::string, std::out_of_range>(std::bind(myStringFunctor, BSparameters::startTime, spotDB), print_error);
245  stopTimeStampLegacy_ =
246  try_<std::string, std::out_of_range>(std::bind(myStringFunctor, BSparameters::endTime, spotDB), print_error);
247  lumiRangeLegacy_ =
248  try_<std::string, std::out_of_range>(std::bind(myStringFunctor, BSparameters::lumiRange, spotDB), print_error);
249 
251  for (int i = 0; i < 7; ++i) {
252  for (int j = 0; j < 7; ++j) {
253  matrix(i, j) = spotDB.covariance(i, j);
254  }
255  }
256 
257  beamSpotsMap_["Legacy"] =
258  BeamSpot(apoint, spotDB.sigmaZ(), spotDB.dxdz(), spotDB.dydz(), spotDB.beamWidthX(), matrix);
259 
260  BeamSpot* aSpot = &(beamSpotsMap_["Legacy"]);
261 
262  aSpot->setBeamWidthY(spotDB.beamWidthY());
263  aSpot->setEmittanceX(spotDB.emittanceX());
264  aSpot->setEmittanceY(spotDB.emittanceY());
265  aSpot->setbetaStar(spotDB.betaStar());
266 
267  if (spotDB.beamType() == 2) {
268  aSpot->setType(reco::BeamSpot::Tracker);
269  } else {
270  aSpot->setType(reco::BeamSpot::Fake);
271  }
272  //LogInfo("OnlineBeamMonitor")
273  // << *aSpot << std::endl;
274  } else {
275  LogInfo("OnlineBeamMonitor") << "Database BeamSpot is not valid at lumi: " << iLumi.id().luminosityBlock();
276  }
277  if (auto bsTransientHandle = iSetup.getHandle(bsTransientToken_)) {
278  auto const& spotDB = *bsTransientHandle;
279  //std::cout << " from the DB " << spotDB << std::endl;
280 
281  // translate from BeamSpotObjects to reco::BeamSpot
282  BeamSpot::Point apoint(spotDB.x(), spotDB.y(), spotDB.z());
283 
285  for (int i = 0; i < 7; ++i) {
286  for (int j = 0; j < 7; ++j) {
287  matrix(i, j) = spotDB.covariance(i, j);
288  }
289  }
290 
291  beamSpotsMap_["Transient"] =
292  BeamSpot(apoint, spotDB.sigmaZ(), spotDB.dxdz(), spotDB.dydz(), spotDB.beamWidthX(), matrix);
293 
294  BeamSpot* aSpot = &(beamSpotsMap_["Transient"]);
295 
296  aSpot->setBeamWidthY(spotDB.beamWidthY());
297  aSpot->setEmittanceX(spotDB.emittanceX());
298  aSpot->setEmittanceY(spotDB.emittanceY());
299  aSpot->setbetaStar(spotDB.betaStar());
300  if (spotDB.beamType() == 2) {
301  aSpot->setType(reco::BeamSpot::Tracker);
302  } else {
303  aSpot->setType(reco::BeamSpot::Fake);
304  }
305 
306  if (writeDIPTxt_) {
307  std::ofstream outFile;
308 
309  std::string tmpname = outputDIPTxt_;
310  int frun = iLumi.getRun().run();
311 
312  char index[15];
313  if (appendRunTxt_ && writeDIPTxt_) {
314  sprintf(index, "%s%i", "_Run", frun);
315  tmpname.insert(outputDIPTxt_.length() - 4, index);
316  }
317  //int lastLumiAnalyzed_ = iLumi.id().luminosityBlock();
318 
319  if (beamSpotsMap_.find("Transient") != beamSpotsMap_.end()) {
320  if (beamSpotsMap_.find("HLT") != beamSpotsMap_.end() &&
321  beamSpotsMap_["Transient"].x0() == beamSpotsMap_["HLT"].x0()) {
322  // lastLumiAnalyzed_ = lastLumiHLT_;
323  startTimeStamp_ = startTimeStampHLT_;
324  stopTimeStamp_ = stopTimeStampHLT_;
325  lumiRange_ = lumiRangeHLT_;
326 
327  } else if (beamSpotsMap_.find("Legacy") != beamSpotsMap_.end() &&
328  beamSpotsMap_["Transient"].x0() == beamSpotsMap_["Legacy"].x0()) {
329  //lastLumiAnalyzed_ = lastLumiLegacy_;
330  startTimeStamp_ = startTimeStampLegacy_;
331  stopTimeStamp_ = stopTimeStampLegacy_;
332  lumiRange_ = lumiRangeLegacy_;
333  }
334  }
335 
336  outFile.open(tmpname.c_str());
337 
338  outFile << "Runnumber " << frun << " bx " << 0 << std::endl;
339  outFile << "BeginTimeOfFit " << startTimeStamp_ << " " << 0 << std::endl;
340  outFile << "EndTimeOfFit " << stopTimeStamp_ << " " << 0 << std::endl;
341  //outFile << "LumiRange " << lumiRange_ << " - " << lastLumiAnalyzed_ << std::endl;
342  outFile << "LumiRange " << lumiRange_ << std::endl;
343  outFile << "Type " << aSpot->type() << std::endl;
344  outFile << "X0 " << aSpot->x0() << std::endl;
345  outFile << "Y0 " << aSpot->y0() << std::endl;
346  outFile << "Z0 " << aSpot->z0() << std::endl;
347  outFile << "sigmaZ0 " << aSpot->sigmaZ() << std::endl;
348  outFile << "dxdz " << aSpot->dxdz() << std::endl;
349  outFile << "dydz " << aSpot->dydz() << std::endl;
350  outFile << "BeamWidthX " << aSpot->BeamWidthX() << std::endl;
351  outFile << "BeamWidthY " << aSpot->BeamWidthY() << std::endl;
352  for (int i = 0; i < 6; ++i) {
353  outFile << "Cov(" << i << ",j) ";
354  for (int j = 0; j < 7; ++j) {
355  outFile << aSpot->covariance(i, j) << " ";
356  }
357  outFile << std::endl;
358  }
359  outFile << "Cov(6,j) 0 0 0 0 0 0 " << aSpot->covariance(6, 6) << std::endl;
360  outFile << "EmittanceX " << aSpot->emittanceX() << std::endl;
361  outFile << "EmittanceY " << aSpot->emittanceY() << std::endl;
362  outFile << "BetaStar " << aSpot->betaStar() << std::endl;
363 
364  outFile.close();
365  }
366  //LogInfo("OnlineBeamMonitor")
367  // << *aSpot << std::endl;
368  } else {
369  LogInfo("OnlineBeamMonitor") << "Database BeamSpot is not valid at lumi: " << iLumi.id().luminosityBlock();
370  }
371  return nullptr;
372 }
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::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
std::vector< int > processedLumis_
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 375 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_.

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