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-Scalers" || itMM->first ==
"PrimaryVertex-DataBase" ||
119 itMM->first ==
"PrimaryVertex-BeamFit" || itMM->first ==
"PrimaryVertex-Scalers") {
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-Scalers") {
130 }
else if (itMM->first ==
"PrimaryVertex-DataBase" || itMM->first ==
"PrimaryVertex-BeamFit" ||
131 itMM->first ==
"PrimaryVertex-Scalers") {
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-Scalers" || itMM->first ==
"PrimaryVertex-DataBase" ||
141 itMM->first ==
"PrimaryVertex-BeamFit" || itMM->first ==
"PrimaryVertex-Scalers") {
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-Scalers" || itMM->first ==
"PrimaryVertex-DataBase" ||
151 itMM->first ==
"PrimaryVertex-BeamFit" || itMM->first ==
"PrimaryVertex-Scalers") {
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-Scalers" || itMM->first ==
"PrimaryVertex-DataBase" ||
164 itMM->first ==
"PrimaryVertex-BeamFit" || itMM->first ==
"PrimaryVertex-Scalers") {
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 Scalers-DataBase fit") {
188 }
else if (itMM->first ==
"validation" && itMMM->first !=
"Lumibased Scalers-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);
249 for (
int i = 0;
i < 7; ++
i) {
250 for (
int j = 0;
j < 7; ++
j) {
263 aSpot->setbetaStar(spotDB->
betaStar());
336 map<std::string, pair<double, double> > resultsMap;
337 vector<pair<double, double> > vertexResults;
344 resultsMap[itBS->first] = pair<double, double>(itBS->second.x0(), itBS->second.x0Error());
345 }
else if (*itV ==
"y") {
346 resultsMap[itBS->first] = pair<double, double>(itBS->second.y0(), itBS->second.y0Error());
347 }
else if (*itV ==
"z") {
348 resultsMap[itBS->first] = pair<double, double>(itBS->second.z0(), itBS->second.z0Error());
349 }
else if (*itV ==
"sigmaX") {
350 resultsMap[itBS->first] = pair<double, double>(itBS->second.BeamWidthX(), itBS->second.BeamWidthXError());
351 }
else if (*itV ==
"sigmaY") {
352 resultsMap[itBS->first] = pair<double, double>(itBS->second.BeamWidthY(), itBS->second.BeamWidthYError());
353 }
else if (*itV ==
"sigmaZ") {
354 resultsMap[itBS->first] = pair<double, double>(itBS->second.sigmaZ(), itBS->second.sigmaZ0Error());
356 LogInfo(
"AlcaBeamMonitor") <<
"The histosMap_ has been built with the name " << *itV
357 <<
" that I can't recognize!";
362 vertexResults.clear();
363 for (vector<VertexCollection>::iterator itPV =
vertices_.begin(); itPV !=
vertices_.end(); itPV++) {
364 if (!itPV->empty()) {
365 for (VertexCollection::const_iterator
pv = itPV->begin();
pv != itPV->end();
pv++) {
366 if (
pv->isFake() ||
pv->tracksSize() < 10)
369 vertexResults.push_back(pair<double, double>(
pv->x(),
pv->xError()));
370 }
else if (*itV ==
"y") {
371 vertexResults.push_back(pair<double, double>(
pv->y(),
pv->yError()));
372 }
else if (*itV ==
"z") {
373 vertexResults.push_back(pair<double, double>(
pv->z(),
pv->zError()));
374 }
else if (*itV !=
"sigmaX" && *itV !=
"sigmaY" && *itV !=
"sigmaZ") {
375 LogInfo(
"AlcaBeamMonitor") <<
"The histosMap_ has been built with the name " << *itV
376 <<
" that I can't recognize!";
387 if (itM->second ==
"Coordinate") {
391 }
else if (itM->second ==
"PrimaryVertex fit-DataBase") {
392 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"DB") != resultsMap.end()) {
395 }
else if (itM->second ==
"PrimaryVertex fit-BeamFit") {
396 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"BF") != resultsMap.end()) {
399 }
else if (itM->second ==
"PrimaryVertex fit-Scalers") {
400 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"SC") != resultsMap.end()) {
403 }
else if (itM->second ==
"PrimaryVertex-DataBase") {
404 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"DB") != resultsMap.end()) {
405 for (
vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
407 histo->Fill(itPV->first - resultsMap[
"DB"].first);
410 }
else if (itM->second ==
"PrimaryVertex-BeamFit") {
411 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"BF") != resultsMap.end()) {
412 for (
vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
414 histo->Fill(itPV->first - resultsMap[
"BF"].first);
417 }
else if (itM->second ==
"PrimaryVertex-Scalers") {
418 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"SC") != resultsMap.end()) {
419 for (
vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
421 histo->Fill(itPV->first - resultsMap[
"SC"].first);
424 }
else if (itM->second ==
"Lumibased BeamSpotFit") {
425 if (resultsMap.find(
"BF") != resultsMap.end()) {
429 }
else if (itM->second ==
"Lumibased PrimaryVertex") {
430 if (resultsMap.find(
"PV") != resultsMap.end()) {
434 }
else if (itM->second ==
"Lumibased DataBase") {
435 if (resultsMap.find(
"DB") != resultsMap.end()) {
439 }
else if (itM->second ==
"Lumibased Scalers") {
440 if (resultsMap.find(
"SC") != resultsMap.end()) {
444 }
else if (itM->second ==
"Lumibased PrimaryVertex-DataBase fit") {
445 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"DB") != resultsMap.end()) {
450 }
else if (itM->second ==
"Lumibased PrimaryVertex-Scalers fit") {
451 if (resultsMap.find(
"PV") != resultsMap.end() && resultsMap.find(
"SC") != resultsMap.end()) {
456 }
else if (itM->second ==
"Lumibased Scalers-DataBase fit") {
457 if (resultsMap.find(
"SC") != resultsMap.end() && resultsMap.find(
"DB") != resultsMap.end()) {
462 }
else if (itM->second ==
"Lumibased PrimaryVertex-DataBase") {
463 if (resultsMap.find(
"DB") != resultsMap.end() && !vertexResults.empty()) {
464 for (
vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
471 }
else if (itM->second ==
"Lumibased PrimaryVertex-Scalers") {
472 if (resultsMap.find(
"SC") != resultsMap.end() && !vertexResults.empty()) {
473 for (
vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
487 LogInfo(
"AlcaBeamMonitor") <<
"The histosMap_ have a histogram named " << itM->second
488 <<
" that I can't recognize in this loop!";
500 const double bigNumber = 1000000.;
506 for (
map<
string, map<string, MonitorElement*> >::iterator itHH = itH->second.begin(); itHH != itH->second.end();
508 double min = bigNumber;
509 double max = -bigNumber;
510 double minDelta = bigNumber;
514 if (itHH->first !=
"run") {
515 for (map<string, MonitorElement*>::iterator itHHH = itHH->second.begin(); itHHH != itHH->second.end();
517 if (itHHH->second !=
nullptr) {
518 for (
int bin = 1;
bin <= itHHH->second->getTH1()->GetNbinsX();
bin++) {
519 if (itHHH->second->getTH1()->GetBinError(
bin) != 0 || itHHH->second->getTH1()->GetBinContent(
bin) != 0) {
520 if (itHHH->first ==
"Lumibased BeamSpotFit" || itHHH->first ==
"Lumibased PrimaryVertex" ||
521 itHHH->first ==
"Lumibased DataBase" || itHHH->first ==
"Lumibased Scalers") {
522 if (
min > itHHH->second->getTH1()->GetBinContent(
bin)) {
523 min = itHHH->second->getTH1()->GetBinContent(
bin);
525 if (max < itHHH->
second->getTH1()->GetBinContent(
bin)) {
526 max = itHHH->second->getTH1()->GetBinContent(
bin);
528 }
else if (itHHH->first ==
"Lumibased PrimaryVertex-DataBase fit" ||
529 itHHH->first ==
"Lumibased PrimaryVertex-Scalers fit" ||
530 itHHH->first ==
"Lumibased Scalers-DataBase fit" ||
531 itHHH->first ==
"Lumibased PrimaryVertex-DataBase" ||
532 itHHH->first ==
"Lumibased PrimaryVertex-Scalers") {
533 if (minDelta > itHHH->second->getTH1()->GetBinContent(
bin)) {
534 minDelta = itHHH->second->getTH1()->GetBinContent(
bin);
536 if (maxDelta < itHHH->
second->getTH1()->GetBinContent(
bin)) {
537 maxDelta = itHHH->second->getTH1()->GetBinContent(
bin);
540 LogInfo(
"AlcaBeamMonitorClient") <<
"The histosMap_ have a histogram named " << itHHH->first
541 <<
" that I can't recognize in this loop!";
548 for (map<string, MonitorElement*>::iterator itHHH = itHH->second.begin(); itHHH != itHH->second.end();
550 if (itHHH->second !=
nullptr) {
551 if (itHHH->first ==
"Lumibased BeamSpotFit" || itHHH->first ==
"Lumibased PrimaryVertex" ||
552 itHHH->first ==
"Lumibased DataBase" || itHHH->first ==
"Lumibased Scalers") {
553 if ((
max == -bigNumber &&
min == bigNumber) ||
max -
min == 0) {
554 itHHH->second->getTH1()->SetMinimum(itHHH->second->getTH1()->GetMinimum() - 0.01);
555 itHHH->second->getTH1()->SetMaximum(itHHH->second->getTH1()->GetMaximum() + 0.01);
557 itHHH->second->getTH1()->SetMinimum(
min - 0.1 * (
max -
min));
558 itHHH->second->getTH1()->SetMaximum(
max + 0.1 * (
max -
min));
560 }
else if (itHHH->first ==
"Lumibased PrimaryVertex-DataBase fit" ||
561 itHHH->first ==
"Lumibased PrimaryVertex-Scalers fit" ||
562 itHHH->first ==
"Lumibased Scalers-DataBase fit" ||
563 itHHH->first ==
"Lumibased PrimaryVertex-DataBase" ||
564 itHHH->first ==
"Lumibased PrimaryVertex-Scalers") {
565 if ((
maxDelta == -bigNumber && minDelta == bigNumber) ||
maxDelta - minDelta == 0) {
566 itHHH->second->getTH1()->SetMinimum(itHHH->second->getTH1()->GetMinimum() - 0.01);
567 itHHH->second->getTH1()->SetMaximum(itHHH->second->getTH1()->GetMaximum() + 0.01);
569 itHHH->second->getTH1()->SetMinimum(minDelta - 2 * (
maxDelta - minDelta));
573 LogInfo(
"AlcaBeamMonitorClient") <<
"The histosMap_ have a histogram named " << itHHH->first
574 <<
" that I can't recognize in this loop!";
576 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_
T const * product() const
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.
BeamSpotContainer beamSpotsMap_
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_
auto const & tracks
cannot be loose
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
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_
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)
std::shared_ptr< alcabeammonitor::NoCache > globalBeginLuminosityBlock(const edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup) const override
void dqmEndRun(edm::Run const &, edm::EventSetup const &) override
std::vector< reco::VertexCollection > vertices_
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)