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()) {
248 for (
int i = 0;
i < 7; ++
i) {
249 for (
int j = 0;
j < 7; ++
j) {
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 beamSpotInfo->vertices_.push_back(*
PVCollection.product());
302 if (beamSpotInfo->beamSpotMap_.find(
"SC") == beamSpotInfo->beamSpotMap_.end()) {
305 beamSpotInfo->beamSpotMap_[
"SC"] = *recoBeamSpotHandle;
306 if (beamSpotInfo->beamSpotMap_[
"SC"].BeamWidthX() != 0) {
312 LogWarning(
"AlcaBeamMonitor") <<
"No BeamSpot from scalers is available";
322 auto beamSpotInfo = luminosityBlockCache(iLumi.
index());
332 beamSpotInfo->beamSpotMap_[
"PV"] =
thePVFitter_->getBeamSpot();
337 map<std::string, pair<double, double> > resultsMap;
338 vector<pair<double, double> > vertexResults;
342 for (BeamSpotContainer::iterator itBS = beamSpotInfo->beamSpotMap_.begin();
343 itBS != beamSpotInfo->beamSpotMap_.end();
347 resultsMap[itBS->first] = pair<double, double>(itBS->second.x0(), itBS->second.x0Error());
348 }
else if (*itV ==
"y") {
349 resultsMap[itBS->first] = pair<double, double>(itBS->second.y0(), itBS->second.y0Error());
350 }
else if (*itV ==
"z") {
351 resultsMap[itBS->first] = pair<double, double>(itBS->second.z0(), itBS->second.z0Error());
352 }
else if (*itV ==
"sigmaX") {
353 resultsMap[itBS->first] = pair<double, double>(itBS->second.BeamWidthX(), itBS->second.BeamWidthXError());
354 }
else if (*itV ==
"sigmaY") {
355 resultsMap[itBS->first] = pair<double, double>(itBS->second.BeamWidthY(), itBS->second.BeamWidthYError());
356 }
else if (*itV ==
"sigmaZ") {
357 resultsMap[itBS->first] = pair<double, double>(itBS->second.sigmaZ(), itBS->second.sigmaZ0Error());
359 LogInfo(
"AlcaBeamMonitor") <<
"The histosMap_ has been built with the name " << *itV
360 <<
" that I can't recognize!";
365 vertexResults.clear();
366 for (vector<VertexCollection>::iterator itPV = beamSpotInfo->vertices_.begin();
367 itPV != beamSpotInfo->vertices_.end();
369 if (!itPV->empty()) {
370 for (VertexCollection::const_iterator
pv = itPV->begin();
pv != itPV->end();
pv++) {
371 if (
pv->isFake() ||
pv->tracksSize() < 10)
374 vertexResults.push_back(pair<double, double>(
pv->x(),
pv->xError()));
375 }
else if (*itV ==
"y") {
376 vertexResults.push_back(pair<double, double>(
pv->y(),
pv->yError()));
377 }
else if (*itV ==
"z") {
378 vertexResults.push_back(pair<double, double>(
pv->z(),
pv->zError()));
379 }
else if (*itV !=
"sigmaX" && *itV !=
"sigmaY" && *itV !=
"sigmaZ") {
380 LogInfo(
"AlcaBeamMonitor") <<
"The histosMap_ has been built with the name " << *itV
381 <<
" that I can't recognize!";
392 if (itM->second ==
"Coordinate") {
393 if (beamSpotInfo->beamSpotMap_.find(
"DB") != beamSpotInfo->beamSpotMap_.end()) {
396 }
else if (itM->second ==
"PrimaryVertex fit-DataBase") {
397 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"DB") != resultsMap.end()) {
400 }
else if (itM->second ==
"PrimaryVertex fit-BeamFit") {
401 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"BF") != resultsMap.end()) {
404 }
else if (itM->second ==
"PrimaryVertex fit-Online") {
405 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"SC") != resultsMap.end()) {
408 }
else if (itM->second ==
"PrimaryVertex-DataBase") {
409 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"DB") != resultsMap.end()) {
410 for (
vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
412 histo->Fill(itPV->first - resultsMap[
"DB"].first);
415 }
else if (itM->second ==
"PrimaryVertex-BeamFit") {
416 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"BF") != resultsMap.end()) {
417 for (
vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
419 histo->Fill(itPV->first - resultsMap[
"BF"].first);
422 }
else if (itM->second ==
"PrimaryVertex-Online") {
423 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"SC") != resultsMap.end()) {
424 for (
vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
426 histo->Fill(itPV->first - resultsMap[
"SC"].first);
429 }
else if (itM->second ==
"Lumibased BeamSpotFit") {
430 if (resultsMap.find(
"BF") != resultsMap.end()) {
434 }
else if (itM->second ==
"Lumibased PrimaryVertex") {
435 if (resultsMap.find(
"PV") != resultsMap.end()) {
439 }
else if (itM->second ==
"Lumibased DataBase") {
440 if (resultsMap.find(
"DB") != resultsMap.end()) {
444 }
else if (itM->second ==
"Lumibased Online") {
445 if (resultsMap.find(
"SC") != resultsMap.end()) {
449 }
else if (itM->second ==
"Lumibased PrimaryVertex-DataBase fit") {
450 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"DB") != resultsMap.end()) {
455 }
else if (itM->second ==
"Lumibased PrimaryVertex-Online fit") {
456 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"SC") != resultsMap.end()) {
461 }
else if (itM->second ==
"Lumibased Online-DataBase fit") {
462 if (resultsMap.find(
"SC") != resultsMap.end() && resultsMap.find(
"DB") != resultsMap.end()) {
467 }
else if (itM->second ==
"Lumibased PrimaryVertex-DataBase") {
468 if (resultsMap.find(
"DB") != resultsMap.end() && !vertexResults.empty()) {
469 for (
vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
476 }
else if (itM->second ==
"Lumibased PrimaryVertex-Online") {
477 if (resultsMap.find(
"SC") != resultsMap.end() && !vertexResults.empty()) {
478 for (
vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
492 LogInfo(
"AlcaBeamMonitor") <<
"The histosMap_ have a histogram named " << itM->second
493 <<
" that I can't recognize in this loop!";
505 const double bigNumber = 1000000.;
511 for (
map<
string, map<string, MonitorElement*> >::iterator itHH = itH->second.begin(); itHH != itH->second.end();
513 double min = bigNumber;
514 double max = -bigNumber;
515 double minDelta = bigNumber;
519 if (itHH->first !=
"run") {
520 for (map<string, MonitorElement*>::iterator itHHH = itHH->second.begin(); itHHH != itHH->second.end();
522 if (itHHH->second !=
nullptr) {
523 for (
int bin = 1;
bin <= itHHH->second->getTH1()->GetNbinsX();
bin++) {
524 if (itHHH->second->getTH1()->GetBinError(
bin) != 0 || itHHH->second->getTH1()->GetBinContent(
bin) != 0) {
525 if (itHHH->first ==
"Lumibased BeamSpotFit" || itHHH->first ==
"Lumibased PrimaryVertex" ||
526 itHHH->first ==
"Lumibased DataBase" || itHHH->first ==
"Lumibased Online") {
527 if (
min > itHHH->second->getTH1()->GetBinContent(
bin)) {
528 min = itHHH->second->getTH1()->GetBinContent(
bin);
530 if (max < itHHH->
second->getTH1()->GetBinContent(
bin)) {
531 max = itHHH->second->getTH1()->GetBinContent(
bin);
533 }
else if (itHHH->first ==
"Lumibased PrimaryVertex-DataBase fit" ||
534 itHHH->first ==
"Lumibased PrimaryVertex-Online fit" ||
535 itHHH->first ==
"Lumibased Online-DataBase fit" ||
536 itHHH->first ==
"Lumibased PrimaryVertex-DataBase" ||
537 itHHH->first ==
"Lumibased PrimaryVertex-Online") {
538 if (minDelta > itHHH->second->getTH1()->GetBinContent(
bin)) {
539 minDelta = itHHH->second->getTH1()->GetBinContent(
bin);
541 if (maxDelta < itHHH->
second->getTH1()->GetBinContent(
bin)) {
542 maxDelta = itHHH->second->getTH1()->GetBinContent(
bin);
545 LogInfo(
"AlcaBeamMonitorClient") <<
"The histosMap_ have a histogram named " << itHHH->first
546 <<
" that I can't recognize in this loop!";
553 for (map<string, MonitorElement*>::iterator itHHH = itHH->second.begin(); itHHH != itHH->second.end();
555 if (itHHH->second !=
nullptr) {
556 if (itHHH->first ==
"Lumibased BeamSpotFit" || itHHH->first ==
"Lumibased PrimaryVertex" ||
557 itHHH->first ==
"Lumibased DataBase" || itHHH->first ==
"Lumibased Online") {
558 if ((
max == -bigNumber &&
min == bigNumber) ||
max -
min == 0) {
559 itHHH->second->getTH1()->SetMinimum(itHHH->second->getTH1()->GetMinimum() - 0.01);
560 itHHH->second->getTH1()->SetMaximum(itHHH->second->getTH1()->GetMaximum() + 0.01);
562 itHHH->second->getTH1()->SetMinimum(
min - 0.1 * (
max -
min));
563 itHHH->second->getTH1()->SetMaximum(
max + 0.1 * (
max -
min));
565 }
else if (itHHH->first ==
"Lumibased PrimaryVertex-DataBase fit" ||
566 itHHH->first ==
"Lumibased PrimaryVertex-Online fit" ||
567 itHHH->first ==
"Lumibased Online-DataBase fit" ||
568 itHHH->first ==
"Lumibased PrimaryVertex-DataBase" ||
569 itHHH->first ==
"Lumibased PrimaryVertex-Online") {
570 if ((
maxDelta == -bigNumber && minDelta == bigNumber) ||
maxDelta - minDelta == 0) {
571 itHHH->second->getTH1()->SetMinimum(itHHH->second->getTH1()->GetMinimum() - 0.01);
572 itHHH->second->getTH1()->SetMaximum(itHHH->second->getTH1()->GetMaximum() + 0.01);
574 itHHH->second->getTH1()->SetMinimum(minDelta - 2 * (
maxDelta - minDelta));
578 LogInfo(
"AlcaBeamMonitorClient") <<
"The histosMap_ have a histogram named " << itHHH->first
579 <<
" that I can't recognize in this loop!";
581 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)