30 : monitorName_(ps.getUntrackedParameter<
string>(
"MonitorName")),
34 numberOfValuesToSave_(0),
35 appendRunTxt_(ps.getUntrackedParameter<
bool>(
"AppendRunToFileName")),
36 writeDIPTxt_(ps.getUntrackedParameter<
bool>(
"WriteDIPAscii")),
37 outputDIPTxt_(ps.getUntrackedParameter<
std::
string>(
"DIPFileName")) {
64 histosMap_[itV][itM.first][itM.second] =
nullptr;
90 for (
auto& itMM : itM.second) {
91 if (itMM.first !=
"run") {
92 for (
auto& itMMM : itMM.second) {
94 title = itM.first +
"_{0} " + itMMM.first;
95 if (itMM.first ==
"lumi") {
100 LogInfo(
"OnlineBeamMonitorClient") <<
"Unrecognized category " << itMM.first;
102 if (itMMM.second !=
nullptr) {
103 if (itMMM.first.find(
'-') != string::npos) {
104 itMMM.second->setAxisTitle(
string(
"#Delta ") + itM.first +
"_{0} (cm)", 2);
106 itMMM.second->setAxisTitle(itM.first +
"_{0} (cm)", 2);
108 itMMM.second->setAxisTitle(
"Lumisection", 1);
119 "BS Choice (+1): HLT - (-1): Legacy - (-10): Fake BS - (0): No Transient ",
138 template <
typename T,
class Except,
class Func,
class Response>
141 LogDebug(
"BeamSpotOnlineParameters") <<
"I have tried" << std::endl;
143 }
catch (Except&
e) {
144 LogDebug(
"BeamSpotOnlineParameters") <<
"I have caught!" << std::endl;
146 return static_cast<T>(
"-999");
164 return m_payload.startTime();
166 return m_payload.endTime();
168 return m_payload.lumiRange();
179 auto beamSpotInfo = std::make_shared<onlinebeammonitor::BeamSpotInfo>();
198 auto const& spotDB = *bsHLTHandle;
212 for (
int i = 0;
i < 7; ++
i) {
213 for (
int j = 0;
j < 7; ++
j) {
218 beamSpotInfo->beamSpotsMap_[
"HLT"] =
219 BeamSpot(apoint, spotDB.sigmaZ(), spotDB.dxdz(), spotDB.dydz(), spotDB.beamWidthX(),
matrix);
221 BeamSpot* aSpot = &(beamSpotInfo->beamSpotsMap_[
"HLT"]);
224 aSpot->setEmittanceX(spotDB.emittanceX());
225 aSpot->setEmittanceY(spotDB.emittanceY());
226 aSpot->setbetaStar(spotDB.betaStar());
228 if (spotDB.beamType() == 2) {
239 auto const& spotDB = *bsLegacyHandle;
245 startTimeStampLegacy_ =
247 stopTimeStampLegacy_ =
253 for (
int i = 0;
i < 7; ++
i) {
254 for (
int j = 0;
j < 7; ++
j) {
259 beamSpotInfo->beamSpotsMap_[
"Legacy"] =
260 BeamSpot(apoint, spotDB.sigmaZ(), spotDB.dxdz(), spotDB.dydz(), spotDB.beamWidthX(),
matrix);
262 BeamSpot* aSpot = &(beamSpotInfo->beamSpotsMap_[
"Legacy"]);
265 aSpot->setEmittanceX(spotDB.emittanceX());
266 aSpot->setEmittanceY(spotDB.emittanceY());
267 aSpot->setbetaStar(spotDB.betaStar());
269 if (spotDB.beamType() == 2) {
280 auto const& spotDB = *bsTransientHandle;
287 for (
int i = 0;
i < 7; ++
i) {
288 for (
int j = 0;
j < 7; ++
j) {
293 beamSpotInfo->beamSpotsMap_[
"Transient"] =
294 BeamSpot(apoint, spotDB.sigmaZ(), spotDB.dxdz(), spotDB.dydz(), spotDB.beamWidthX(),
matrix);
296 BeamSpot* aSpot = &(beamSpotInfo->beamSpotsMap_[
"Transient"]);
299 aSpot->setEmittanceX(spotDB.emittanceX());
300 aSpot->setEmittanceY(spotDB.emittanceY());
301 aSpot->setbetaStar(spotDB.betaStar());
302 if (spotDB.beamType() == 2) {
316 sprintf(
index,
"%s%i",
"_Run", frun);
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()) {
325 startTimeStamp_ = startTimeStampHLT_;
326 stopTimeStamp_ = stopTimeStampHLT_;
327 lumiRange_ = lumiRangeHLT_;
329 }
else if (beamSpotInfo->beamSpotsMap_.find(
"Legacy") != beamSpotInfo->beamSpotsMap_.end() &&
330 beamSpotInfo->beamSpotsMap_[
"Transient"].x0() == beamSpotInfo->beamSpotsMap_[
"Legacy"].x0()) {
332 startTimeStamp_ = startTimeStampLegacy_;
333 stopTimeStamp_ = stopTimeStampLegacy_;
334 lumiRange_ = lumiRangeLegacy_;
340 outFile <<
"Runnumber " << frun <<
" bx " << 0 << std::endl;
341 outFile <<
"BeginTimeOfFit " << startTimeStamp_ <<
" " << 0 << std::endl;
342 outFile <<
"EndTimeOfFit " << stopTimeStamp_ <<
" " << 0 << 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) {
356 for (
int j = 0;
j < 7; ++
j) {
357 outFile << aSpot->covariance(
i,
j) <<
" ";
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;
379 auto beamSpotInfo = luminosityBlockCache(iLumi.
index());
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()) {
387 }
else if (beamSpotInfo->beamSpotsMap_.find(
"Legacy") != beamSpotInfo->beamSpotsMap_.end() &&
388 beamSpotInfo->beamSpotsMap_[
"Transient"].x0() == beamSpotInfo->beamSpotsMap_[
"Legacy"].x0()) {
401 map<std::string, pair<double, double> > resultsMap;
402 vector<pair<double, double> > vertexResults;
406 for (
const auto& itBS : beamSpotInfo->beamSpotsMap_) {
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());
421 LogInfo(
"OnlineBeamMonitor") <<
"The histosMap_ has been built with the name " << itV
422 <<
" that I can't recognize!";
430 if (itM.second ==
"Lumibased BeamSpotHLT") {
431 if (resultsMap.find(
"HLT") != resultsMap.end()) {
435 }
else if (itM.second ==
"Lumibased BeamSpotLegacy") {
436 if (resultsMap.find(
"Legacy") != resultsMap.end()) {
440 }
else if (itM.second ==
"Lumibased BeamSpotTransient") {
441 if (resultsMap.find(
"Transient") != resultsMap.end()) {
446 LogInfo(
"OnlineBeamMonitor") <<
"The histosMap_ have a histogram named " << itM.second
447 <<
" that I can't recognize in this loop!";
458 const double bigNumber = 1000000.;
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);
477 if (max < itHHH.second->getTH1()->GetBinContent(
bin)) {
478 max = itHHH.second->getTH1()->GetBinContent(
bin);
481 LogInfo(
"OnlineBeamMonitorClient") <<
"The histosMap_ have a histogram named " << itHHH.first
482 <<
" that I can't recognize in this loop!";
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);
496 itHHH.second->getTH1()->SetMinimum(
min - 0.1 * (
max -
min));
497 itHHH.second->getTH1()->SetMaximum(
max + 0.1 * (
max -
min));
500 LogInfo(
"OnlineBeamMonitorClient")
501 <<
"The histosMap_ have a histogram named " << itHHH.first <<
" that I can't recognize in this loop!";
503 itHHH.second->getTH1()->GetXaxis()->SetRangeUser(firstLumi - 0.5,
lastLumi + 0.5);
math::Error< dimension >::type CovarianceMatrix
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
LuminosityBlockNumber_t luminosityBlock() const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
std::multimap< std::string, std::string > histoByCategoryNames_
virtual void setCurrentFolder(std::string const &fullpath)
Run const & getRun() const
ret
prodAgent to be discontinued
edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineLegacyObjectsRcd > bsLegacyToken_
void dqmEndRun(edm::Run const &, edm::EventSetup const &) override
math::XYZPoint Point
point in the space
Log< level::Error, false > LogError
std::function< std::string(BSparameters, BeamSpotOnlineObjects)> myStringFunctor
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
std::string outputDIPTxt_
std::vector< std::string > varNamesV_
void setBeamWidthY(double v)
T try_(Func f, Response r)
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())
OnlineBeamMonitor(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
void globalEndLuminosityBlock(const edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup) override
std::shared_ptr< onlinebeammonitor::BeamSpotInfo > globalBeginLuminosityBlock(const edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup) const override
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
std::vector< int > processedLumis_
Log< level::Info, false > LogInfo
LuminosityBlockID id() const
static void print_error(const std::exception &e)
MonitorElement * bsChoice_
LuminosityBlockIndex index() const
edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineHLTObjectsRcd > bsHLTToken_
static void fillDescriptions(edm::ConfigurationDescriptions &)
HistosContainer histosMap_
edm::ESGetToken< BeamSpotObjects, BeamSpotTransientObjectsRcd > bsTransientToken_
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)