32 : monitorName_(ps.getUntrackedParameter<
string>(
"MonitorName")),
35 scalerLabel_(consumes<
BeamSpot>(ps.getUntrackedParameter<
InputTag>(
"ScalerLabel"))),
37 numberOfValuesToSave_(0) {
79 histosMap_[*itV][itM->first][itM->second] =
nullptr;
106 for (map<string, MonitorElement*>::iterator itMM = itM->second[
"run"].begin(); itMM != itM->second[
"run"].end();
108 name =
string(
"h") + itM->first + itMM->first;
109 title = itM->first +
"_{0} " + itMM->first;
110 if (itM->first ==
"x" || itM->first ==
"y") {
111 if (itMM->first ==
"Coordinate") {
113 }
else if (itMM->first ==
"PrimaryVertex fit-DataBase" || itMM->first ==
"PrimaryVertex fit-BeamFit" ||
114 itMM->first ==
"PrimaryVertex fit-Scalers" || itMM->first ==
"PrimaryVertex-DataBase" ||
115 itMM->first ==
"PrimaryVertex-BeamFit" || itMM->first ==
"PrimaryVertex-Scalers") {
120 }
else if (itM->first ==
"z") {
121 if (itMM->first ==
"Coordinate") {
123 }
else if (itMM->first ==
"PrimaryVertex fit-DataBase" || itMM->first ==
"PrimaryVertex fit-BeamFit" ||
124 itMM->first ==
"PrimaryVertex fit-Scalers") {
126 }
else if (itMM->first ==
"PrimaryVertex-DataBase" || itMM->first ==
"PrimaryVertex-BeamFit" ||
127 itMM->first ==
"PrimaryVertex-Scalers") {
132 }
else if (itM->first ==
"sigmaX" || itM->first ==
"sigmaY") {
133 if (itMM->first ==
"Coordinate") {
135 }
else if (itMM->first ==
"PrimaryVertex fit-DataBase" || itMM->first ==
"PrimaryVertex fit-BeamFit" ||
136 itMM->first ==
"PrimaryVertex fit-Scalers" || itMM->first ==
"PrimaryVertex-DataBase" ||
137 itMM->first ==
"PrimaryVertex-BeamFit" || itMM->first ==
"PrimaryVertex-Scalers") {
138 itMM->second =
nullptr;
142 }
else if (itM->first ==
"sigmaZ") {
143 if (itMM->first ==
"Coordinate") {
145 }
else if (itMM->first ==
"PrimaryVertex fit-DataBase" || itMM->first ==
"PrimaryVertex fit-BeamFit" ||
146 itMM->first ==
"PrimaryVertex fit-Scalers" || itMM->first ==
"PrimaryVertex-DataBase" ||
147 itMM->first ==
"PrimaryVertex-BeamFit" || itMM->first ==
"PrimaryVertex-Scalers") {
155 if (itMM->second !=
nullptr) {
156 if (itMM->first ==
"Coordinate") {
157 itMM->second->
setAxisTitle(itM->first +
"_{0} (cm)", 1);
158 }
else if (itMM->first ==
"PrimaryVertex fit-DataBase" || itMM->first ==
"PrimaryVertex fit-BeamFit" ||
159 itMM->first ==
"PrimaryVertex fit-Scalers" || itMM->first ==
"PrimaryVertex-DataBase" ||
160 itMM->first ==
"PrimaryVertex-BeamFit" || itMM->first ==
"PrimaryVertex-Scalers") {
161 itMM->second->setAxisTitle(itMM->first +
" " + itM->first +
"_{0} (cm)", 1);
163 itMM->second->setAxisTitle(
"Entries", 2);
169 for (
map<
string, map<string, MonitorElement*> >::iterator itMM = itM->second.begin(); itMM != itM->second.end();
171 if (itMM->first !=
"run") {
172 for (map<string, MonitorElement*>::iterator itMMM = itMM->second.begin(); itMMM != itMM->second.end();
174 name =
string(
"h") + itM->first + itMMM->first;
175 title = itM->first +
"_{0} " + itMMM->first;
176 if (itMM->first ==
"lumi") {
180 }
else if (itMM->first ==
"validation" && itMMM->first ==
"Lumibased Scalers-DataBase fit") {
184 }
else if (itMM->first ==
"validation" && itMMM->first !=
"Lumibased Scalers-DataBase fit" &&
185 (itM->first ==
"x" || itM->first ==
"y" || itM->first ==
"z")) {
189 }
else if (itMM->first ==
"validation" &&
190 (itM->first ==
"sigmaX" || itM->first ==
"sigmaY" || itM->first ==
"sigmaZ")) {
192 itMMM->second =
nullptr;
194 LogInfo(
"AlcaBeamMonitorClient") <<
"Unrecognized category " << itMM->first;
197 if (itMMM->second !=
nullptr) {
198 if (itMMM->first.find(
'-') != string::npos) {
199 itMMM->second->setAxisTitle(
string(
"#Delta ") + itM->first +
"_{0} (cm)", 2);
201 itMMM->second->setAxisTitle(itM->first +
"_{0} (cm)", 2);
203 itMMM->second->setAxisTitle(
"Lumisection", 1);
213 hD0Phi0_ = ibooker.
bookProfile(
"hD0Phi0",
"d_{0} vs. #phi_{0} (All Tracks)", 63, -3.15, 3.15, 100, -0.5, 0.5,
"");
218 hDxyBS_ = ibooker.
book1D(
"hDxyBS",
"dxy_{0} w.r.t. Beam spot (All Tracks)", 100, -0.1, 0.1);
245 for (
int i = 0;
i < 7; ++
i) {
246 for (
int j = 0;
j < 7; ++
j) {
332 map<std::string, pair<double, double> > resultsMap;
333 vector<pair<double, double> > vertexResults;
340 resultsMap[itBS->first] = pair<double, double>(itBS->second.x0(), itBS->second.x0Error());
341 }
else if (*itV ==
"y") {
342 resultsMap[itBS->first] = pair<double, double>(itBS->second.y0(), itBS->second.y0Error());
343 }
else if (*itV ==
"z") {
344 resultsMap[itBS->first] = pair<double, double>(itBS->second.z0(), itBS->second.z0Error());
345 }
else if (*itV ==
"sigmaX") {
346 resultsMap[itBS->first] = pair<double, double>(itBS->second.BeamWidthX(), itBS->second.BeamWidthXError());
347 }
else if (*itV ==
"sigmaY") {
348 resultsMap[itBS->first] = pair<double, double>(itBS->second.BeamWidthY(), itBS->second.BeamWidthYError());
349 }
else if (*itV ==
"sigmaZ") {
350 resultsMap[itBS->first] = pair<double, double>(itBS->second.sigmaZ(), itBS->second.sigmaZ0Error());
352 LogInfo(
"AlcaBeamMonitor") <<
"The histosMap_ has been built with the name " << *itV
353 <<
" that I can't recognize!";
358 vertexResults.clear();
359 for (vector<VertexCollection>::iterator itPV =
vertices_.begin(); itPV !=
vertices_.end(); itPV++) {
360 if (!itPV->empty()) {
361 for (VertexCollection::const_iterator
pv = itPV->begin();
pv != itPV->end();
pv++) {
362 if (
pv->isFake() ||
pv->tracksSize() < 10)
365 vertexResults.push_back(pair<double, double>(
pv->x(),
pv->xError()));
366 }
else if (*itV ==
"y") {
367 vertexResults.push_back(pair<double, double>(
pv->y(),
pv->yError()));
368 }
else if (*itV ==
"z") {
369 vertexResults.push_back(pair<double, double>(
pv->z(),
pv->zError()));
370 }
else if (*itV !=
"sigmaX" && *itV !=
"sigmaY" && *itV !=
"sigmaZ") {
371 LogInfo(
"AlcaBeamMonitor") <<
"The histosMap_ has been built with the name " << *itV
372 <<
" that I can't recognize!";
383 if (itM->second ==
"Coordinate") {
387 }
else if (itM->second ==
"PrimaryVertex fit-DataBase") {
388 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"DB") != resultsMap.end()) {
391 }
else if (itM->second ==
"PrimaryVertex fit-BeamFit") {
392 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"BF") != resultsMap.end()) {
395 }
else if (itM->second ==
"PrimaryVertex fit-Scalers") {
396 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"SC") != resultsMap.end()) {
399 }
else if (itM->second ==
"PrimaryVertex-DataBase") {
400 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"DB") != resultsMap.end()) {
401 for (
vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
403 histo->Fill(itPV->first - resultsMap[
"DB"].first);
406 }
else if (itM->second ==
"PrimaryVertex-BeamFit") {
407 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"BF") != resultsMap.end()) {
408 for (
vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
410 histo->Fill(itPV->first - resultsMap[
"BF"].first);
413 }
else if (itM->second ==
"PrimaryVertex-Scalers") {
414 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"SC") != resultsMap.end()) {
415 for (
vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
417 histo->Fill(itPV->first - resultsMap[
"SC"].first);
420 }
else if (itM->second ==
"Lumibased BeamSpotFit") {
421 if (resultsMap.find(
"BF") != resultsMap.end()) {
425 }
else if (itM->second ==
"Lumibased PrimaryVertex") {
426 if (resultsMap.find(
"PV") != resultsMap.end()) {
430 }
else if (itM->second ==
"Lumibased DataBase") {
431 if (resultsMap.find(
"DB") != resultsMap.end()) {
435 }
else if (itM->second ==
"Lumibased Scalers") {
436 if (resultsMap.find(
"SC") != resultsMap.end()) {
440 }
else if (itM->second ==
"Lumibased PrimaryVertex-DataBase fit") {
441 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"DB") != resultsMap.end()) {
446 }
else if (itM->second ==
"Lumibased PrimaryVertex-Scalers fit") {
447 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"SC") != resultsMap.end()) {
452 }
else if (itM->second ==
"Lumibased Scalers-DataBase fit") {
453 if (resultsMap.find(
"SC") != resultsMap.end() && resultsMap.find(
"DB") != resultsMap.end()) {
458 }
else if (itM->second ==
"Lumibased PrimaryVertex-DataBase") {
459 if (resultsMap.find(
"DB") != resultsMap.end() && !vertexResults.empty()) {
460 for (
vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
467 }
else if (itM->second ==
"Lumibased PrimaryVertex-Scalers") {
468 if (resultsMap.find(
"SC") != resultsMap.end() && !vertexResults.empty()) {
469 for (
vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
483 LogInfo(
"AlcaBeamMonitor") <<
"The histosMap_ have a histogram named " << itM->second
484 <<
" that I can't recognize in this loop!";
496 const double bigNumber = 1000000.;
502 for (
map<
string, map<string, MonitorElement*> >::iterator itHH = itH->second.begin(); itHH != itH->second.end();
504 double min = bigNumber;
505 double max = -bigNumber;
506 double minDelta = bigNumber;
510 if (itHH->first !=
"run") {
511 for (map<string, MonitorElement*>::iterator itHHH = itHH->second.begin(); itHHH != itHH->second.end();
513 if (itHHH->second !=
nullptr) {
514 for (
int bin = 1;
bin <= itHHH->second->getTH1()->GetNbinsX();
bin++) {
515 if (itHHH->second->getTH1()->GetBinError(
bin) != 0 || itHHH->second->getTH1()->GetBinContent(
bin) != 0) {
516 if (itHHH->first ==
"Lumibased BeamSpotFit" || itHHH->first ==
"Lumibased PrimaryVertex" ||
517 itHHH->first ==
"Lumibased DataBase" || itHHH->first ==
"Lumibased Scalers") {
518 if (
min > itHHH->second->getTH1()->GetBinContent(
bin)) {
519 min = itHHH->second->getTH1()->GetBinContent(
bin);
521 if (max < itHHH->
second->getTH1()->GetBinContent(
bin)) {
522 max = itHHH->second->getTH1()->GetBinContent(
bin);
524 }
else if (itHHH->first ==
"Lumibased PrimaryVertex-DataBase fit" ||
525 itHHH->first ==
"Lumibased PrimaryVertex-Scalers fit" ||
526 itHHH->first ==
"Lumibased Scalers-DataBase fit" ||
527 itHHH->first ==
"Lumibased PrimaryVertex-DataBase" ||
528 itHHH->first ==
"Lumibased PrimaryVertex-Scalers") {
529 if (minDelta > itHHH->second->getTH1()->GetBinContent(
bin)) {
530 minDelta = itHHH->second->getTH1()->GetBinContent(
bin);
532 if (maxDelta < itHHH->
second->getTH1()->GetBinContent(
bin)) {
533 maxDelta = itHHH->second->getTH1()->GetBinContent(
bin);
536 LogInfo(
"AlcaBeamMonitorClient") <<
"The histosMap_ have a histogram named " << itHHH->first
537 <<
" that I can't recognize in this loop!";
544 for (map<string, MonitorElement*>::iterator itHHH = itHH->second.begin(); itHHH != itHH->second.end();
546 if (itHHH->second !=
nullptr) {
547 if (itHHH->first ==
"Lumibased BeamSpotFit" || itHHH->first ==
"Lumibased PrimaryVertex" ||
548 itHHH->first ==
"Lumibased DataBase" || itHHH->first ==
"Lumibased Scalers") {
549 if ((
max == -bigNumber &&
min == bigNumber) ||
max -
min == 0) {
550 itHHH->second->getTH1()->SetMinimum(itHHH->second->getTH1()->GetMinimum() - 0.01);
551 itHHH->second->getTH1()->SetMaximum(itHHH->second->getTH1()->GetMaximum() + 0.01);
553 itHHH->second->getTH1()->SetMinimum(
min - 0.1 * (
max -
min));
554 itHHH->second->getTH1()->SetMaximum(
max + 0.1 * (
max -
min));
556 }
else if (itHHH->first ==
"Lumibased PrimaryVertex-DataBase fit" ||
557 itHHH->first ==
"Lumibased PrimaryVertex-Scalers fit" ||
558 itHHH->first ==
"Lumibased Scalers-DataBase fit" ||
559 itHHH->first ==
"Lumibased PrimaryVertex-DataBase" ||
560 itHHH->first ==
"Lumibased PrimaryVertex-Scalers") {
561 if ((
maxDelta == -bigNumber && minDelta == bigNumber) ||
maxDelta - minDelta == 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(minDelta - 2 * (
maxDelta - minDelta));
569 LogInfo(
"AlcaBeamMonitorClient") <<
"The histosMap_ have a histogram named " << itHHH->first
570 <<
" that I can't recognize in this loop!";
572 itHHH->second->getTH1()->GetXaxis()->SetRangeUser(firstLumi - 0.5,
lastLumi + 0.5);