32 : monitorName_(ps.getUntrackedParameter<
string>(
"MonitorName")),
35 scalerLabel_(consumes<
BeamSpot>(ps.getUntrackedParameter<
InputTag>(
"ScalerLabel"))),
37 perLSsaving_(ps.getUntrackedParameter<
bool>(
"perLSsaving",
false)),
38 numberOfValuesToSave_(0) {
82 histosMap_[*itV][itM->first][itM->second] =
nullptr;
110 for (map<string, MonitorElement*>::iterator itMM = itM->second[
"run"].begin(); itMM != itM->second[
"run"].end();
112 name =
string(
"h") + itM->first + itMM->first;
113 title = itM->first +
"_{0} " + itMM->first;
114 if (itM->first ==
"x" || itM->first ==
"y") {
115 if (itMM->first ==
"Coordinate") {
117 }
else if (itMM->first ==
"PrimaryVertex fit-DataBase" || itMM->first ==
"PrimaryVertex fit-BeamFit" ||
118 itMM->first ==
"PrimaryVertex fit-Online" || itMM->first ==
"PrimaryVertex-DataBase" ||
119 itMM->first ==
"PrimaryVertex-BeamFit" || itMM->first ==
"PrimaryVertex-Online") {
124 }
else if (itM->first ==
"z") {
125 if (itMM->first ==
"Coordinate") {
127 }
else if (itMM->first ==
"PrimaryVertex fit-DataBase" || itMM->first ==
"PrimaryVertex fit-BeamFit" ||
128 itMM->first ==
"PrimaryVertex fit-Online") {
130 }
else if (itMM->first ==
"PrimaryVertex-DataBase" || itMM->first ==
"PrimaryVertex-BeamFit" ||
131 itMM->first ==
"PrimaryVertex-Online") {
136 }
else if (itM->first ==
"sigmaX" || itM->first ==
"sigmaY") {
137 if (itMM->first ==
"Coordinate") {
139 }
else if (itMM->first ==
"PrimaryVertex fit-DataBase" || itMM->first ==
"PrimaryVertex fit-BeamFit" ||
140 itMM->first ==
"PrimaryVertex fit-Online" || itMM->first ==
"PrimaryVertex-DataBase" ||
141 itMM->first ==
"PrimaryVertex-BeamFit" || itMM->first ==
"PrimaryVertex-Online") {
142 itMM->second =
nullptr;
146 }
else if (itM->first ==
"sigmaZ") {
147 if (itMM->first ==
"Coordinate") {
149 }
else if (itMM->first ==
"PrimaryVertex fit-DataBase" || itMM->first ==
"PrimaryVertex fit-BeamFit" ||
150 itMM->first ==
"PrimaryVertex fit-Online" || itMM->first ==
"PrimaryVertex-DataBase" ||
151 itMM->first ==
"PrimaryVertex-BeamFit" || itMM->first ==
"PrimaryVertex-Online") {
159 if (itMM->second !=
nullptr) {
160 if (itMM->first ==
"Coordinate") {
161 itMM->second->
setAxisTitle(itM->first +
"_{0} (cm)", 1);
162 }
else if (itMM->first ==
"PrimaryVertex fit-DataBase" || itMM->first ==
"PrimaryVertex fit-BeamFit" ||
163 itMM->first ==
"PrimaryVertex fit-Online" || itMM->first ==
"PrimaryVertex-DataBase" ||
164 itMM->first ==
"PrimaryVertex-BeamFit" || itMM->first ==
"PrimaryVertex-Online") {
165 itMM->second->setAxisTitle(itMM->first +
" " + itM->first +
"_{0} (cm)", 1);
167 itMM->second->setAxisTitle(
"Entries", 2);
173 for (
map<
string, map<string, MonitorElement*> >::iterator itMM = itM->second.begin(); itMM != itM->second.end();
175 if (itMM->first !=
"run") {
176 for (map<string, MonitorElement*>::iterator itMMM = itMM->second.begin(); itMMM != itMM->second.end();
178 name =
string(
"h") + itM->first + itMMM->first;
179 title = itM->first +
"_{0} " + itMMM->first;
180 if (itMM->first ==
"lumi") {
184 }
else if (itMM->first ==
"validation" && itMMM->first ==
"Lumibased Online-DataBase fit") {
188 }
else if (itMM->first ==
"validation" && itMMM->first !=
"Lumibased Online-DataBase fit" &&
189 (itM->first ==
"x" || itM->first ==
"y" || itM->first ==
"z")) {
193 }
else if (itMM->first ==
"validation" &&
194 (itM->first ==
"sigmaX" || itM->first ==
"sigmaY" || itM->first ==
"sigmaZ")) {
196 itMMM->second =
nullptr;
198 LogInfo(
"AlcaBeamMonitorClient") <<
"Unrecognized category " << itMM->first;
201 if (itMMM->second !=
nullptr) {
202 if (itMMM->first.find(
'-') != string::npos) {
203 itMMM->second->setAxisTitle(
string(
"#Delta ") + itM->first +
"_{0} (cm)", 2);
205 itMMM->second->setAxisTitle(itM->first +
"_{0} (cm)", 2);
207 itMMM->second->setAxisTitle(
"Lumisection", 1);
217 hD0Phi0_ = ibooker.
bookProfile(
"hD0Phi0",
"d_{0} vs. #phi_{0} (All Tracks)", 63, -3.15, 3.15, 100, -0.5, 0.5,
"");
222 hDxyBS_ = ibooker.
book1D(
"hDxyBS",
"dxy_{0} w.r.t. Beam spot (All Tracks)", 100, -0.1, 0.1);
231 auto beamSpotInfo = std::make_shared<alcabeammonitor::BeamSpotInfo>();
241 if (bsDBHandle.isValid()) {
254 beamSpotInfo->beamSpotMap_[
"DB"] =
257 BeamSpot* aSpot = &(beamSpotInfo->beamSpotMap_[
"DB"]);
262 aSpot->setbetaStar(spotDB->
betaStar());
284 auto beamSpotInfo = luminosityBlockCache(
iEvent.getLuminosityBlock().index());
285 if (beamSpotInfo->beamSpotMap_.find(
"DB") != beamSpotInfo->beamSpotMap_.end()) {
292 hDxyBS_->
Fill(-1 *
track->dxy(beamSpotInfo->beamSpotMap_[
"DB"].position()));
299 std::vector<alcabeammonitor::pvPosAndErr>
vertices;
302 if (
pv.isFake() ||
pv.tracksSize() < 10)
310 if (beamSpotInfo->beamSpotMap_.find(
"SC") == beamSpotInfo->beamSpotMap_.end()) {
313 beamSpotInfo->beamSpotMap_[
"SC"] = *recoBeamSpotHandle;
314 if (beamSpotInfo->beamSpotMap_[
"SC"].BeamWidthX() != 0) {
320 LogWarning(
"AlcaBeamMonitor") <<
"No BeamSpot from scalers is available";
330 auto beamSpotInfo = luminosityBlockCache(iLumi.
index());
340 beamSpotInfo->beamSpotMap_[
"PV"] =
thePVFitter_->getBeamSpot();
345 map<std::string, pair<double, double> > resultsMap;
346 vector<pair<double, double> > vertexResults;
350 for (BeamSpotContainer::iterator itBS = beamSpotInfo->beamSpotMap_.begin();
351 itBS != beamSpotInfo->beamSpotMap_.end();
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());
367 LogInfo(
"AlcaBeamMonitor") <<
"The histosMap_ has been built with the name " << *itV
368 <<
" that I can't recognize!";
373 vertexResults.clear();
375 for (
const auto& itPV : beamSpotInfo->vertices_) {
376 for (
const auto&
pv : itPV) {
378 vertexResults.push_back(
pv.xWithError());
379 }
else if (*itV ==
"y") {
380 vertexResults.push_back(
pv.yWithError());
381 }
else if (*itV ==
"z") {
382 vertexResults.push_back(
pv.zWithError());
383 }
else if (*itV !=
"sigmaX" && *itV !=
"sigmaY" && *itV !=
"sigmaZ") {
384 LogInfo(
"AlcaBeamMonitor") <<
"The histosMap_ has been built with the name " << *itV
385 <<
" that I can't recognize!";
395 if (itM->second ==
"Coordinate") {
396 if (beamSpotInfo->beamSpotMap_.find(
"DB") != beamSpotInfo->beamSpotMap_.end()) {
399 }
else if (itM->second ==
"PrimaryVertex fit-DataBase") {
400 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"DB") != resultsMap.end()) {
403 }
else if (itM->second ==
"PrimaryVertex fit-BeamFit") {
404 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"BF") != resultsMap.end()) {
407 }
else if (itM->second ==
"PrimaryVertex fit-Online") {
408 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"SC") != resultsMap.end()) {
411 }
else if (itM->second ==
"PrimaryVertex-DataBase") {
412 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"DB") != resultsMap.end()) {
413 for (
vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
415 histo->Fill(itPV->first - resultsMap[
"DB"].first);
418 }
else if (itM->second ==
"PrimaryVertex-BeamFit") {
419 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"BF") != resultsMap.end()) {
420 for (
vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
422 histo->Fill(itPV->first - resultsMap[
"BF"].first);
425 }
else if (itM->second ==
"PrimaryVertex-Online") {
426 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"SC") != resultsMap.end()) {
427 for (
vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
429 histo->Fill(itPV->first - resultsMap[
"SC"].first);
432 }
else if (itM->second ==
"Lumibased BeamSpotFit") {
433 if (resultsMap.find(
"BF") != resultsMap.end()) {
437 }
else if (itM->second ==
"Lumibased PrimaryVertex") {
438 if (resultsMap.find(
"PV") != resultsMap.end()) {
442 }
else if (itM->second ==
"Lumibased DataBase") {
443 if (resultsMap.find(
"DB") != resultsMap.end()) {
447 }
else if (itM->second ==
"Lumibased Online") {
448 if (resultsMap.find(
"SC") != resultsMap.end()) {
452 }
else if (itM->second ==
"Lumibased PrimaryVertex-DataBase fit") {
453 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"DB") != resultsMap.end()) {
458 }
else if (itM->second ==
"Lumibased PrimaryVertex-Online fit") {
459 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"SC") != resultsMap.end()) {
464 }
else if (itM->second ==
"Lumibased Online-DataBase fit") {
465 if (resultsMap.find(
"SC") != resultsMap.end() && resultsMap.find(
"DB") != resultsMap.end()) {
470 }
else if (itM->second ==
"Lumibased PrimaryVertex-DataBase") {
471 if (resultsMap.find(
"DB") != resultsMap.end() && !vertexResults.empty()) {
472 for (
vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
479 }
else if (itM->second ==
"Lumibased PrimaryVertex-Online") {
480 if (resultsMap.find(
"SC") != resultsMap.end() && !vertexResults.empty()) {
481 for (
vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
495 LogInfo(
"AlcaBeamMonitor") <<
"The histosMap_ have a histogram named " << itM->second
496 <<
" that I can't recognize in this loop!";
508 const double bigNumber = 1000000.;
514 for (
map<
string, map<string, MonitorElement*> >::iterator itHH = itH->second.begin(); itHH != itH->second.end();
516 double min = bigNumber;
517 double max = -bigNumber;
518 double minDelta = bigNumber;
522 if (itHH->first !=
"run") {
523 for (map<string, MonitorElement*>::iterator itHHH = itHH->second.begin(); itHHH != itHH->second.end();
525 if (itHHH->second !=
nullptr) {
526 for (
int bin = 1;
bin <= itHHH->second->getTH1()->GetNbinsX();
bin++) {
527 if (itHHH->second->getTH1()->GetBinError(
bin) != 0 || itHHH->second->getTH1()->GetBinContent(
bin) != 0) {
528 if (itHHH->first ==
"Lumibased BeamSpotFit" || itHHH->first ==
"Lumibased PrimaryVertex" ||
529 itHHH->first ==
"Lumibased DataBase" || itHHH->first ==
"Lumibased Online") {
530 if (
min > itHHH->second->getTH1()->GetBinContent(
bin)) {
531 min = itHHH->second->getTH1()->GetBinContent(
bin);
533 if (max < itHHH->
second->getTH1()->GetBinContent(
bin)) {
534 max = itHHH->second->getTH1()->GetBinContent(
bin);
536 }
else if (itHHH->first ==
"Lumibased PrimaryVertex-DataBase fit" ||
537 itHHH->first ==
"Lumibased PrimaryVertex-Online fit" ||
538 itHHH->first ==
"Lumibased Online-DataBase fit" ||
539 itHHH->first ==
"Lumibased PrimaryVertex-DataBase" ||
540 itHHH->first ==
"Lumibased PrimaryVertex-Online") {
541 if (minDelta > itHHH->second->getTH1()->GetBinContent(
bin)) {
542 minDelta = itHHH->second->getTH1()->GetBinContent(
bin);
544 if (maxDelta < itHHH->
second->getTH1()->GetBinContent(
bin)) {
545 maxDelta = itHHH->second->getTH1()->GetBinContent(
bin);
548 LogInfo(
"AlcaBeamMonitorClient") <<
"The histosMap_ have a histogram named " << itHHH->first
549 <<
" that I can't recognize in this loop!";
556 for (map<string, MonitorElement*>::iterator itHHH = itHH->second.begin(); itHHH != itHH->second.end();
558 if (itHHH->second !=
nullptr) {
559 if (itHHH->first ==
"Lumibased BeamSpotFit" || itHHH->first ==
"Lumibased PrimaryVertex" ||
560 itHHH->first ==
"Lumibased DataBase" || itHHH->first ==
"Lumibased Online") {
561 if ((
max == -bigNumber &&
min == bigNumber) ||
max -
min == 0) {
562 itHHH->second->getTH1()->SetMinimum(itHHH->second->getTH1()->GetMinimum() - 0.01);
563 itHHH->second->getTH1()->SetMaximum(itHHH->second->getTH1()->GetMaximum() + 0.01);
565 itHHH->second->getTH1()->SetMinimum(
min - 0.1 * (
max -
min));
566 itHHH->second->getTH1()->SetMaximum(
max + 0.1 * (
max -
min));
568 }
else if (itHHH->first ==
"Lumibased PrimaryVertex-DataBase fit" ||
569 itHHH->first ==
"Lumibased PrimaryVertex-Online fit" ||
570 itHHH->first ==
"Lumibased Online-DataBase fit" ||
571 itHHH->first ==
"Lumibased PrimaryVertex-DataBase" ||
572 itHHH->first ==
"Lumibased PrimaryVertex-Online") {
573 if ((
maxDelta == -bigNumber && minDelta == bigNumber) ||
maxDelta - minDelta == 0) {
574 itHHH->second->getTH1()->SetMinimum(itHHH->second->getTH1()->GetMinimum() - 0.01);
575 itHHH->second->getTH1()->SetMaximum(itHHH->second->getTH1()->GetMaximum() + 0.01);
577 itHHH->second->getTH1()->SetMinimum(minDelta - 2 * (
maxDelta - minDelta));
581 LogInfo(
"AlcaBeamMonitorClient") <<
"The histosMap_ have a histogram named " << itHHH->first
582 <<
" that I can't recognize in this loop!";
584 itHHH->second->getTH1()->GetXaxis()->SetRangeUser(firstLumi - 0.5,
lastLumi + 0.5);
double emittanceX() const
get emittance
MonitorElement * hD0Phi0_
math::Error< dimension >::type CovarianceMatrix
LuminosityBlockNumber_t luminosityBlock() const
double z() const
get Z beam position
double dydz() const
get dydz slope, crossing angle in YZ
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &)
double covariance(int i, int j) const
get i,j element of the full covariance matrix 7x7
virtual void setCurrentFolder(std::string const &fullpath)
std::vector< Track > TrackCollection
collection of Tracks
std::multimap< std::string, std::string > histoByCategoryNames_
std::vector< Vertex > VertexCollection
collection of Vertex objects
math::XYZPoint Point
point in the space
double beamWidthX() const
get average transverse beam width
Log< level::Error, false > LogError
int beamType() const
get beam type
U second(std::pair< T, U > const &p)
std::vector< std::string > varNamesV_
AlcaBeamMonitor(const edm::ParameterSet &)
void addDefault(ParameterSetDescription const &psetDescription)
void setBeamWidthY(double v)
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())
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
std::shared_ptr< alcabeammonitor::BeamSpotInfo > globalBeginLuminosityBlock(const edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup) const override
std::vector< int > processedLumis_
double x() const
get X beam position
#define DEFINE_FWK_MODULE(type)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
const edm::ESGetToken< BeamSpotObjects, BeamSpotObjectsRcd > beamSpotToken_
double beamWidthY() const
get average transverse beam width
Log< level::Info, false > LogInfo
double y() const
get Y beam position
static void fillDescription(edm::ParameterSetDescription &)
std::unique_ptr< PVFitter > thePVFitter_
std::unique_ptr< BeamFitter > theBeamFitter_
LuminosityBlockID id() const
HistosContainer histosMap_
double sigmaZ() const
get sigma Z, RMS bunch length
void globalEndLuminosityBlock(const edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup) override
double emittanceY() const
get emittance
LuminosityBlockIndex index() const
double betaStar() const
get beta star
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
const edm::EDGetTokenT< reco::BeamSpot > scalerLabel_
static void fillDescription(edm::ParameterSetDescription &)
const edm::EDGetTokenT< reco::TrackCollection > trackLabel_
Log< level::Warning, false > LogWarning
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
const edm::EDGetTokenT< reco::VertexCollection > primaryVertexLabel_
double dxdz() const
get dxdz slope, crossing angle in XZ
Power< A, B >::type pow(const A &a, const B &b)
void dqmEndRun(edm::Run const &, edm::EventSetup const &) override
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)