26 monitorName_(parameters_.getUntrackedParameter<
string>(
27 "MonitorName",
"YourSubsystemName")),
28 numberOfValuesToSave_(0) {
41 pair<string, string>(
"lumi",
"Lumibased BeamSpotFit"));
43 pair<string, string>(
"lumi",
"Lumibased PrimaryVertex"));
45 pair<string, string>(
"lumi",
"Lumibased DataBase"));
47 pair<string, string>(
"lumi",
"Lumibased Scalers"));
49 pair<string, string>(
"lumi",
"Lumibased PrimaryVertex-DataBase fit"));
51 pair<string, string>(
"lumi",
"Lumibased PrimaryVertex-Scalers fit"));
53 pair<string, string>(
"validation",
"Lumibased Scalers-DataBase fit"));
55 pair<string, string>(
"validation",
"Lumibased PrimaryVertex-DataBase"));
57 pair<string, string>(
"validation",
"Lumibased PrimaryVertex-Scalers"));
59 for (vector<string>::iterator itV =
varNamesV_.begin();
63 histosMap_[*itV][itM->first][itM->second] =
nullptr;
79 for (HistosContainer::iterator itM =
histosMap_.begin();
81 for (
map<
string, map<string, MonitorElement*> >::iterator itMM =
83 itMM != itM->second.end(); itMM++) {
84 if (itMM->first !=
"run") {
85 for (map<string, MonitorElement*>::iterator itMMM =
87 itMMM != itMM->second.end(); itMMM++) {
88 if (itMMM->second !=
nullptr) {
89 if (itMM->first ==
"lumi") {
91 itMMM->second->getName());
92 }
else if (itMM->first ==
"validation") {
94 itMMM->second->getName());
96 LogInfo(
"AlcaBeamMonitorClient") <<
"Unrecognized category " 100 itMMM->second =
nullptr;
135 LogInfo(
"AlcaBeamMonitorClient")
138 "Service/hHistoLumiValues which contains all the values has not " 139 "been found in any lumi!";
148 LogInfo(
"AlcaBeamMonitorClient") <<
"End of run " << iRun.
id().
run() <<
"(" 149 << firstLumi <<
"-" << lastLumi <<
")";
154 for (HistosContainer::iterator itM =
histosMap_.begin();
156 for (
map<
string, map<string, MonitorElement*> >::iterator itMM =
158 itMM != itM->second.end(); itMM++) {
159 if (itMM->first !=
"run") {
160 for (map<string, MonitorElement*>::iterator itMMM =
161 itMM->second.begin();
162 itMMM != itMM->second.end(); itMMM++) {
163 name =
string(
"h") + itM->first + itMMM->first;
164 title = itM->first +
"_{0} " + itMMM->first;
165 if (itMM->first ==
"lumi") {
167 itMMM->second =
dbe_->book1D(name, title, lastLumi - firstLumi + 1,
168 firstLumi - 0.5, lastLumi + 0.5);
169 itMMM->second->setEfficiencyFlag();
170 }
else if (itMM->first ==
"validation" &&
171 itMMM->first ==
"Lumibased Scalers-DataBase fit") {
173 itMMM->second =
dbe_->book1D(name, title, lastLumi - firstLumi + 1,
174 firstLumi - 0.5, lastLumi + 0.5);
175 itMMM->second->setEfficiencyFlag();
176 }
else if (itMM->first ==
"validation" &&
177 itMMM->first !=
"Lumibased Scalers-DataBase fit" &&
178 (itM->first ==
"x" || itM->first ==
"y" ||
179 itM->first ==
"z")) {
181 itMMM->second =
dbe_->book1D(name, title, lastLumi - firstLumi + 1,
182 firstLumi - 0.5, lastLumi + 0.5);
183 itMMM->second->setEfficiencyFlag();
185 else if (itMM->first ==
"validation" &&
186 (itM->first ==
"sigmaX" || itM->first ==
"sigmaY" ||
187 itM->first ==
"sigmaZ")) {
189 itMMM->second =
nullptr;
191 LogInfo(
"AlcaBeamMonitorClient") <<
"Unrecognized category " 195 if (itMMM->second !=
nullptr) {
196 if (itMMM->first.find(
'-') != string::npos) {
197 itMMM->second->setAxisTitle(
198 string(
"#Delta ") + itM->first +
"_{0} (cm)", 2);
200 itMMM->second->setAxisTitle(itM->first +
"_{0} (cm)", 2);
202 itMMM->second->setAxisTitle(
"Lumisection", 1);
209 unsigned int bin = 0;
210 for (HistosContainer::iterator itH =
histosMap_.begin();
212 for (
map<
string, map<string, MonitorElement*> >::iterator itHH =
214 itHH != itH->second.end(); itHH++) {
215 for (map<string, MonitorElement*>::iterator itHHH = itHH->second.begin();
216 itHHH != itHH->second.end(); itHHH++) {
220 if (itHHH->second !=
nullptr) {
226 bin = itHHH->second->getTH1()->FindBin(itVal->first);
227 itHHH->second->setBinContent(
230 itHHH->second->setBinError(
242 const double bigNumber = 1000000.;
243 for (HistosContainer::iterator itH =
histosMap_.begin();
245 for (
map<
string, map<string, MonitorElement*> >::iterator itHH =
247 itHH != itH->second.end(); itHH++) {
248 double min = bigNumber;
249 double max = -bigNumber;
250 double minDelta = bigNumber;
254 if (itHH->first !=
"run") {
255 for (map<string, MonitorElement*>::iterator itHHH =
256 itHH->second.begin();
257 itHHH != itHH->second.end(); itHHH++) {
258 if (itHHH->second !=
nullptr) {
259 for (
int bin = 1; bin <= itHHH->second->getTH1()->GetNbinsX();
261 if (itHHH->second->getTH1()->GetBinError(bin) != 0 ||
262 itHHH->second->getTH1()->GetBinContent(bin) != 0) {
263 if (itHHH->first ==
"Lumibased BeamSpotFit" ||
264 itHHH->first ==
"Lumibased PrimaryVertex" ||
265 itHHH->first ==
"Lumibased DataBase" ||
266 itHHH->first ==
"Lumibased Scalers") {
267 if (min > itHHH->second->getTH1()->GetBinContent(bin)) {
268 min = itHHH->second->getTH1()->GetBinContent(bin);
270 if (max < itHHH->
second->getTH1()->GetBinContent(bin)) {
271 max = itHHH->second->getTH1()->GetBinContent(bin);
273 }
else if (itHHH->first ==
274 "Lumibased PrimaryVertex-DataBase fit" ||
276 "Lumibased PrimaryVertex-Scalers fit" ||
277 itHHH->first ==
"Lumibased Scalers-DataBase fit" ||
278 itHHH->first ==
"Lumibased PrimaryVertex-DataBase" ||
279 itHHH->first ==
"Lumibased PrimaryVertex-Scalers") {
280 if (minDelta > itHHH->second->getTH1()->GetBinContent(bin)) {
281 minDelta = itHHH->second->getTH1()->GetBinContent(bin);
283 if (maxDelta < itHHH->
second->getTH1()->GetBinContent(bin)) {
284 maxDelta = itHHH->second->getTH1()->GetBinContent(bin);
288 LogInfo(
"AlcaBeamMonitorClient")
289 <<
"The histosMap_ have a histogram named " 291 <<
" that I can't recognize in this loop!";
298 for (map<string, MonitorElement*>::iterator itHHH =
299 itHH->second.begin();
300 itHHH != itHH->second.end(); itHHH++) {
301 if (itHHH->second !=
nullptr) {
302 if (itHHH->first ==
"Lumibased BeamSpotFit" ||
303 itHHH->first ==
"Lumibased PrimaryVertex" ||
304 itHHH->first ==
"Lumibased DataBase" ||
305 itHHH->first ==
"Lumibased Scalers") {
306 if ((max == -bigNumber && min == bigNumber) || max - min == 0) {
307 itHHH->second->getTH1()->SetMinimum(
308 itHHH->second->getTH1()->GetMinimum() - 0.01);
309 itHHH->second->getTH1()->SetMaximum(
310 itHHH->second->getTH1()->GetMaximum() + 0.01);
312 itHHH->second->getTH1()->SetMinimum(min - 0.1 * (max - min));
313 itHHH->second->getTH1()->SetMaximum(max + 0.1 * (max - min));
315 }
else if (itHHH->first ==
"Lumibased PrimaryVertex-DataBase fit" ||
316 itHHH->first ==
"Lumibased PrimaryVertex-Scalers fit" ||
317 itHHH->first ==
"Lumibased Scalers-DataBase fit" ||
318 itHHH->first ==
"Lumibased PrimaryVertex-DataBase" ||
319 itHHH->first ==
"Lumibased PrimaryVertex-Scalers") {
320 if ((maxDelta == -bigNumber && minDelta == bigNumber) ||
321 maxDelta - minDelta == 0) {
322 itHHH->second->getTH1()->SetMinimum(
323 itHHH->second->getTH1()->GetMinimum() - 0.01);
324 itHHH->second->getTH1()->SetMaximum(
325 itHHH->second->getTH1()->GetMaximum() + 0.01);
327 itHHH->second->getTH1()->SetMinimum(minDelta -
328 2 * (maxDelta - minDelta));
329 itHHH->second->getTH1()->SetMaximum(maxDelta +
330 2 * (maxDelta - minDelta));
334 LogInfo(
"AlcaBeamMonitorClient")
335 <<
"The histosMap_ have a histogram named " << itHHH->first
336 <<
" that I can't recognize in this loop!";
LuminosityBlockID id() const
#define DEFINE_FWK_MODULE(type)
void beginJob(void) override
PositionContainer positionsMap_
HistosContainer histosMap_
void beginRun(const edm::Run &iRun, const edm::EventSetup &iSetup) override
unsigned int LuminosityBlockNumber_t
std::multimap< std::string, std::string > histoByCategoryNames_
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
U second(std::pair< T, U > const &p)
void beginLuminosityBlock(const edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup) override
void endRun(const edm::Run &iRun, const edm::EventSetup &iSetup) override
int numberOfValuesToSave_
bin
set the eta bin as selection string.
~AlcaBeamMonitorClient() override
LuminosityBlockNumber_t luminosityBlock() const
AlcaBeamMonitorClient(const edm::ParameterSet &)
std::vector< std::vector< double > > tmp
std::map< edm::LuminosityBlockNumber_t, std::vector< double > > valuesMap_
std::vector< std::string > varNamesV_
TProfile * getTProfile(void) const
void endLuminosityBlock(const edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup) override