CMS 3D CMS Logo

AlcaBeamMonitor.cc
Go to the documentation of this file.
1 /*
2  * \file AlcaBeamMonitor.cc
3  * \author Lorenzo Uplegger/FNAL
4  *
5  */
6 
14 //#include "DataFormats/Scalers/interface/BeamSpotOnline.h"
25 #include <numeric>
26 
27 using namespace std;
28 using namespace edm;
29 using namespace reco;
30 
31 //----------------------------------------------------------------------------------------------------------------------
33  : parameters_(ps),
34  monitorName_(parameters_.getUntrackedParameter<string>("MonitorName", "YourSubsystemName")),
35  primaryVertexLabel_(
36  consumes<VertexCollection>(parameters_.getUntrackedParameter<InputTag>("PrimaryVertexLabel"))),
37  trackLabel_(consumes<reco::TrackCollection>(parameters_.getUntrackedParameter<InputTag>("TrackLabel"))),
38  scalerLabel_(consumes<BeamSpot>(parameters_.getUntrackedParameter<InputTag>("ScalerLabel"))),
39  beamSpotLabel_(parameters_.getUntrackedParameter<InputTag>("BeamSpotLabel")),
40  numberOfValuesToSave_(0) {
41  if (!monitorName_.empty())
42  monitorName_ = monitorName_ + "/";
43 
49 
51 
52  varNamesV_.push_back("x");
53  varNamesV_.push_back("y");
54  varNamesV_.push_back("z");
55  varNamesV_.push_back("sigmaX");
56  varNamesV_.push_back("sigmaY");
57  varNamesV_.push_back("sigmaZ");
58 
59  histoByCategoryNames_.insert(pair<string, string>("run", "Coordinate"));
60  histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex fit-DataBase"));
61  histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex fit-BeamFit"));
62  histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex fit-Scalers"));
63  histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex-DataBase"));
64  histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex-BeamFit"));
65  histoByCategoryNames_.insert(pair<string, string>("run", "PrimaryVertex-Scalers"));
66 
67  histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased BeamSpotFit"));
68  histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased PrimaryVertex"));
69  histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased DataBase"));
70  histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased Scalers"));
71  histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased PrimaryVertex-DataBase fit"));
72  histoByCategoryNames_.insert(pair<string, string>("lumi", "Lumibased PrimaryVertex-Scalers fit"));
73  histoByCategoryNames_.insert(pair<string, string>("validation", "Lumibased Scalers-DataBase fit"));
74  histoByCategoryNames_.insert(pair<string, string>("validation", "Lumibased PrimaryVertex-DataBase"));
75  histoByCategoryNames_.insert(pair<string, string>("validation", "Lumibased PrimaryVertex-Scalers"));
76 
77  for (vector<string>::iterator itV = varNamesV_.begin(); itV != varNamesV_.end(); itV++) {
78  for (multimap<string, string>::iterator itM = histoByCategoryNames_.begin(); itM != histoByCategoryNames_.end();
79  itM++) {
80  if (itM->first == "run") {
81  histosMap_[*itV][itM->first][itM->second] = nullptr;
82  } else {
83  positionsMap_[*itV][itM->first][itM->second] = 3 * numberOfValuesToSave_; //value, error, ok
85  }
86  }
87  }
88 
89  // beamSpotsMap_["BF"] = map<LuminosityBlockNumber_t,BeamSpot>();//For each lumi the beamfitter will have a result
90  // beamSpotsMap_["PV"] = map<LuminosityBlockNumber_t,BeamSpot>();//For each lumi the PVfitter will have a result
91  // beamSpotsMap_["DB"] = map<LuminosityBlockNumber_t,BeamSpot>();//For each lumi we take the values that are stored in the database, already collapsed then
92  // beamSpotsMap_["SC"] = map<LuminosityBlockNumber_t,BeamSpot>();//For each lumi we take the beamspot value in the file that is the same as the scaler for the alca reco stream
93  // beamSpotsMap_["BF"] = 0;//For each lumi the beamfitter will have a result
94  // beamSpotsMap_["PV"] = 0;//For each lumi the PVfitter will have a result
95  // beamSpotsMap_["DB"] = 0;//For each lumi we take the values that are stored in the database, already collapsed then
96  // beamSpotsMap_["SC"] = 0;//For each lumi we take the beamspot value in the file that is the same as the scaler for the alca reco stream
97 }
98 
100  if (theBeamFitter_ != nullptr) {
101  delete theBeamFitter_;
102  }
103 
104  if (thePVFitter_ != nullptr) {
105  delete thePVFitter_;
106  }
107 }
108 
109 //----------------------------------------------------------------------------------------------------------------------
110 void AlcaBeamMonitor::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) {
111  string name;
112  string title;
113  ibooker.setCurrentFolder(monitorName_ + "Debug");
114  for (HistosContainer::iterator itM = histosMap_.begin(); itM != histosMap_.end(); itM++) {
115  for (map<string, MonitorElement*>::iterator itMM = itM->second["run"].begin(); itMM != itM->second["run"].end();
116  itMM++) {
117  name = string("h") + itM->first + itMM->first;
118  title = itM->first + "_{0} " + itMM->first;
119  if (itM->first == "x" || itM->first == "y") {
120  if (itMM->first == "Coordinate") {
121  itMM->second = ibooker.book1D(name, title, 1001, -0.2525, 0.2525);
122  } else if (itMM->first == "PrimaryVertex fit-DataBase" || itMM->first == "PrimaryVertex fit-BeamFit" ||
123  itMM->first == "PrimaryVertex fit-Scalers" || itMM->first == "PrimaryVertex-DataBase" ||
124  itMM->first == "PrimaryVertex-BeamFit" || itMM->first == "PrimaryVertex-Scalers") {
125  itMM->second = ibooker.book1D(name, title, 1001, -0.02525, 0.02525);
126  } else {
127  //assert(0);
128  }
129  } else if (itM->first == "z") {
130  if (itMM->first == "Coordinate") {
131  itMM->second = ibooker.book1D(name, title, 101, -5.05, 5.05);
132  } else if (itMM->first == "PrimaryVertex fit-DataBase" || itMM->first == "PrimaryVertex fit-BeamFit" ||
133  itMM->first == "PrimaryVertex fit-Scalers") {
134  itMM->second = ibooker.book1D(name, title, 101, -0.505, 0.505);
135  } else if (itMM->first == "PrimaryVertex-DataBase" || itMM->first == "PrimaryVertex-BeamFit" ||
136  itMM->first == "PrimaryVertex-Scalers") {
137  itMM->second = ibooker.book1D(name, title, 1001, -5.005, 5.005);
138  } else {
139  //assert(0);
140  }
141  } else if (itM->first == "sigmaX" || itM->first == "sigmaY") {
142  if (itMM->first == "Coordinate") {
143  itMM->second = ibooker.book1D(name, title, 100, 0, 0.015);
144  } else if (itMM->first == "PrimaryVertex fit-DataBase" || itMM->first == "PrimaryVertex fit-BeamFit" ||
145  itMM->first == "PrimaryVertex fit-Scalers" || itMM->first == "PrimaryVertex-DataBase" ||
146  itMM->first == "PrimaryVertex-BeamFit" || itMM->first == "PrimaryVertex-Scalers") {
147  itMM->second = nullptr;
148  } else {
149  //assert(0);
150  }
151  } else if (itM->first == "sigmaZ") {
152  if (itMM->first == "Coordinate") {
153  itMM->second = ibooker.book1D(name, title, 110, 0, 11);
154  } else if (itMM->first == "PrimaryVertex fit-DataBase" || itMM->first == "PrimaryVertex fit-BeamFit" ||
155  itMM->first == "PrimaryVertex fit-Scalers" || itMM->first == "PrimaryVertex-DataBase" ||
156  itMM->first == "PrimaryVertex-BeamFit" || itMM->first == "PrimaryVertex-Scalers") {
157  itMM->second = ibooker.book1D(name, title, 101, -5.05, 5.05);
158  } else {
159  //assert(0);
160  }
161  } else {
162  //assert(0);
163  }
164  if (itMM->second != nullptr) {
165  if (itMM->first == "Coordinate") {
166  itMM->second->setAxisTitle(itM->first + "_{0} (cm)", 1);
167  } else if (itMM->first == "PrimaryVertex fit-DataBase" || itMM->first == "PrimaryVertex fit-BeamFit" ||
168  itMM->first == "PrimaryVertex fit-Scalers" || itMM->first == "PrimaryVertex-DataBase" ||
169  itMM->first == "PrimaryVertex-BeamFit" || itMM->first == "PrimaryVertex-Scalers") {
170  itMM->second->setAxisTitle(itMM->first + " " + itM->first + "_{0} (cm)", 1);
171  }
172  itMM->second->setAxisTitle("Entries", 2);
173  }
174  }
175  }
176  ibooker.setCurrentFolder(monitorName_ + "Service");
177  theValuesContainer_ = ibooker.bookProfile("hHistoLumiValues",
178  "Histo Lumi Values",
180  0.,
182  100.,
183  -100.,
184  9000.,
185  " ");
187 
188  // create and cd into new folder
189  ibooker.setCurrentFolder(monitorName_ + "Validation");
190  //Book histograms
191  hD0Phi0_ = ibooker.bookProfile("hD0Phi0", "d_{0} vs. #phi_{0} (All Tracks)", 63, -3.15, 3.15, 100, -0.5, 0.5, "");
192  hD0Phi0_->setAxisTitle("#phi_{0} (rad)", 1);
193  hD0Phi0_->setAxisTitle("d_{0} (cm)", 2);
194 
195  ibooker.setCurrentFolder(monitorName_ + "Debug");
196  hDxyBS_ = ibooker.book1D("hDxyBS", "dxy_{0} w.r.t. Beam spot (All Tracks)", 100, -0.1, 0.1);
197  hDxyBS_->setAxisTitle("dxy_{0} w.r.t. Beam spot (cm)", 1);
198 }
199 
200 //----------------------------------------------------------------------------------------------------------------------
202  // Always create a beamspot group for each lumi weather we have results or not! Each Beamspot will be of unknown type!
203 
204  vertices_.clear();
206  beamSpotsMap_.clear();
207 
208  //Read BeamSpot from DB
209  ESHandle<BeamSpotObjects> bsDBHandle;
210  try {
211  iSetup.get<BeamSpotObjectsRcd>().get(bsDBHandle);
212  } catch (cms::Exception& exception) {
213  LogInfo("AlcaBeamMonitor") << exception.what();
214  return;
215  }
216  if (bsDBHandle.isValid()) { // check the product
217  const BeamSpotObjects* spotDB = bsDBHandle.product();
218 
219  // translate from BeamSpotObjects to reco::BeamSpot
220  BeamSpot::Point apoint(spotDB->GetX(), spotDB->GetY(), spotDB->GetZ());
221 
223  for (int i = 0; i < 7; ++i) {
224  for (int j = 0; j < 7; ++j) {
225  matrix(i, j) = spotDB->GetCovariance(i, j);
226  }
227  }
228 
229  beamSpotsMap_["DB"] =
230  BeamSpot(apoint, spotDB->GetSigmaZ(), spotDB->Getdxdz(), spotDB->Getdydz(), spotDB->GetBeamWidthX(), matrix);
231 
232  BeamSpot* aSpot = &(beamSpotsMap_["DB"]);
233 
234  aSpot->setBeamWidthY(spotDB->GetBeamWidthY());
235  aSpot->setEmittanceX(spotDB->GetEmittanceX());
236  aSpot->setEmittanceY(spotDB->GetEmittanceY());
237  aSpot->setbetaStar(spotDB->GetBetaStar());
238 
239  if (spotDB->GetBeamType() == 2) {
240  aSpot->setType(reco::BeamSpot::Tracker);
241  } else {
242  aSpot->setType(reco::BeamSpot::Fake);
243  }
244  //LogInfo("AlcaBeamMonitor")
245  // << *aSpot << std::endl;
246  } else {
247  LogInfo("AlcaBeamMonitor") << "Database BeamSpot is not valid at lumi: " << iLumi.id().luminosityBlock();
248  }
249 }
250 
251 //----------------------------------------------------------------------------------------------------------------------
252 void AlcaBeamMonitor::analyze(const Event& iEvent, const EventSetup& iSetup) {
253  //------ BeamFitter
254  theBeamFitter_->readEvent(iEvent);
255  //------ PVFitter
256  thePVFitter_->readEvent(iEvent);
257 
258  if (beamSpotsMap_.find("DB") != beamSpotsMap_.end()) {
259  //------ Tracks
261  iEvent.getByToken(trackLabel_, TrackCollection);
262  const reco::TrackCollection* tracks = TrackCollection.product();
263  for (reco::TrackCollection::const_iterator track = tracks->begin(); track != tracks->end(); ++track) {
264  hD0Phi0_->Fill(track->phi(), -1 * track->dxy());
265  hDxyBS_->Fill(-1 * track->dxy(beamSpotsMap_["DB"].position()));
266  }
267  }
268 
269  //------ Primary Vertices
271  if (iEvent.getByToken(primaryVertexLabel_, PVCollection)) {
272  vertices_.push_back(*PVCollection.product());
273  }
274 
275  if (beamSpotsMap_.find("SC") == beamSpotsMap_.end()) {
276  //BeamSpot from file for this stream is = to the scalar BeamSpot
277  Handle<BeamSpot> recoBeamSpotHandle;
278  try {
279  iEvent.getByToken(scalerLabel_, recoBeamSpotHandle);
280  } catch (cms::Exception& exception) {
281  LogInfo("AlcaBeamMonitor") << exception.what();
282  return;
283  }
284  beamSpotsMap_["SC"] = *recoBeamSpotHandle;
285  if (beamSpotsMap_["SC"].BeamWidthX() != 0) {
286  beamSpotsMap_["SC"].setType(reco::BeamSpot::Tracker);
287  } else {
288  beamSpotsMap_["SC"].setType(reco::BeamSpot::Fake);
289  }
290  }
291 }
292 
293 //----------------------------------------------------------------------------------------------------------------------
297  }
302 
303  if (thePVFitter_->runFitter()) {
305  }
307 
308  // "PV,BF..." Value,Error
309  map<std::string, pair<double, double> > resultsMap;
310  vector<pair<double, double> > vertexResults;
311  MonitorElement* histo = nullptr;
312  int position = 0;
313  for (vector<string>::iterator itV = varNamesV_.begin(); itV != varNamesV_.end(); itV++) {
314  resultsMap.clear();
315  for (BeamSpotContainer::iterator itBS = beamSpotsMap_.begin(); itBS != beamSpotsMap_.end(); itBS++) {
316  if (itBS->second.type() == BeamSpot::Tracker) {
317  if (*itV == "x") {
318  resultsMap[itBS->first] = pair<double, double>(itBS->second.x0(), itBS->second.x0Error());
319  } else if (*itV == "y") {
320  resultsMap[itBS->first] = pair<double, double>(itBS->second.y0(), itBS->second.y0Error());
321  } else if (*itV == "z") {
322  resultsMap[itBS->first] = pair<double, double>(itBS->second.z0(), itBS->second.z0Error());
323  } else if (*itV == "sigmaX") {
324  resultsMap[itBS->first] = pair<double, double>(itBS->second.BeamWidthX(), itBS->second.BeamWidthXError());
325  } else if (*itV == "sigmaY") {
326  resultsMap[itBS->first] = pair<double, double>(itBS->second.BeamWidthY(), itBS->second.BeamWidthYError());
327  } else if (*itV == "sigmaZ") {
328  resultsMap[itBS->first] = pair<double, double>(itBS->second.sigmaZ(), itBS->second.sigmaZ0Error());
329  } else {
330  LogInfo("AlcaBeamMonitor") << "The histosMap_ has been built with the name " << *itV
331  << " that I can't recognize!";
332  //assert(0);
333  }
334  }
335  }
336  vertexResults.clear();
337  for (vector<VertexCollection>::iterator itPV = vertices_.begin(); itPV != vertices_.end(); itPV++) {
338  if (!itPV->empty()) {
339  for (VertexCollection::const_iterator pv = itPV->begin(); pv != itPV->end(); pv++) {
340  if (pv->isFake() || pv->tracksSize() < 10)
341  continue;
342  if (*itV == "x") {
343  vertexResults.push_back(pair<double, double>(pv->x(), pv->xError()));
344  } else if (*itV == "y") {
345  vertexResults.push_back(pair<double, double>(pv->y(), pv->yError()));
346  } else if (*itV == "z") {
347  vertexResults.push_back(pair<double, double>(pv->z(), pv->zError()));
348  } else if (*itV != "sigmaX" && *itV != "sigmaY" && *itV != "sigmaZ") {
349  LogInfo("AlcaBeamMonitor") << "The histosMap_ has been built with the name " << *itV
350  << " that I can't recognize!";
351  //assert(0);
352  }
353  }
354  }
355  }
356  /*
357  histoByCategoryNames_.insert( pair<string,string>("run", "Coordinate"));
358  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex fit-DataBase"));
359  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex fit-BeamFit"));
360  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex fit-Scalers"));
361  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex-DataBase"));
362  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex-BeamFit"));
363  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex-Scalers"));
364 
365  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased BeamSpotFit"));
366  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased PrimaryVertex"));
367  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased DataBase"));
368  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased Scalers"));
369  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased PrimaryVertex-DataBase fit"));
370  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased PrimaryVertex-Scalers fit"));
371  histoByCategoryNames_.insert( pair<string,string>("validation", "Lumibased Scalers-DataBase fit"));
372  histoByCategoryNames_.insert( pair<string,string>("validation", "Lumibased PrimaryVertex-DataBase"));
373  histoByCategoryNames_.insert( pair<string,string>("validation", "Lumibased PrimaryVertex-Scalers"));
374 */
375  for (multimap<string, string>::iterator itM = histoByCategoryNames_.begin(); itM != histoByCategoryNames_.end();
376  itM++) {
377  if (itM->first == "run" && (histo = histosMap_[*itV][itM->first][itM->second]) == nullptr) {
378  continue;
379  } else if (itM->first != "run") {
380  position = positionsMap_[*itV][itM->first][itM->second];
381  }
382  if (itM->second == "Coordinate") {
383  if (beamSpotsMap_.find("DB") != beamSpotsMap_.end()) {
384  histo->Fill(resultsMap["DB"].first);
385  }
386  } else if (itM->second == "PrimaryVertex fit-DataBase") {
387  if (resultsMap.find("PV") != resultsMap.end() && resultsMap.find("DB") != resultsMap.end()) {
388  histo->Fill(resultsMap["PV"].first - resultsMap["DB"].first);
389  }
390  } else if (itM->second == "PrimaryVertex fit-BeamFit") {
391  if (resultsMap.find("PV") != resultsMap.end() && resultsMap.find("BF") != resultsMap.end()) {
392  histo->Fill(resultsMap["PV"].first - resultsMap["BF"].first);
393  }
394  } else if (itM->second == "PrimaryVertex fit-Scalers") {
395  if (resultsMap.find("PV") != resultsMap.end() && resultsMap.find("SC") != resultsMap.end()) {
396  histo->Fill(resultsMap["PV"].first - resultsMap["SC"].first);
397  }
398  } else if (itM->second == "PrimaryVertex-DataBase") {
399  if (resultsMap.find("PV") != resultsMap.end() && resultsMap.find("DB") != resultsMap.end()) {
400  for (vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
401  itPV++) {
402  histo->Fill(itPV->first - resultsMap["DB"].first);
403  }
404  }
405  } else if (itM->second == "PrimaryVertex-BeamFit") {
406  if (resultsMap.find("PV") != resultsMap.end() && resultsMap.find("BF") != resultsMap.end()) {
407  for (vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
408  itPV++) {
409  histo->Fill(itPV->first - resultsMap["BF"].first);
410  }
411  }
412  } else if (itM->second == "PrimaryVertex-Scalers") {
413  if (resultsMap.find("PV") != resultsMap.end() && resultsMap.find("SC") != resultsMap.end()) {
414  for (vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
415  itPV++) {
416  histo->Fill(itPV->first - resultsMap["SC"].first);
417  }
418  }
419  } else if (itM->second == "Lumibased BeamSpotFit") {
420  if (resultsMap.find("BF") != resultsMap.end()) {
421  theValuesContainer_->Fill(position, resultsMap["BF"].first); //Value
422  theValuesContainer_->Fill(position + 1, resultsMap["BF"].second); //Error
423  theValuesContainer_->Fill(position + 2, 1); //ok
424  }
425  } else if (itM->second == "Lumibased PrimaryVertex") {
426  if (resultsMap.find("PV") != resultsMap.end()) {
427  theValuesContainer_->Fill(position, resultsMap["PV"].first); //Value
428  theValuesContainer_->Fill(position + 1, resultsMap["PV"].second); //Error
429  theValuesContainer_->Fill(position + 2, 1); //ok
430  }
431  } else if (itM->second == "Lumibased DataBase") {
432  if (resultsMap.find("DB") != resultsMap.end()) {
433  theValuesContainer_->Fill(position, resultsMap["DB"].first); //Value
434  theValuesContainer_->Fill(position + 1, resultsMap["DB"].second); //Error
435  theValuesContainer_->Fill(position + 2, 1); //ok
436  }
437  } else if (itM->second == "Lumibased Scalers") {
438  if (resultsMap.find("SC") != resultsMap.end()) {
439  theValuesContainer_->Fill(position, resultsMap["SC"].first); //Value
440  theValuesContainer_->Fill(position + 1, resultsMap["SC"].second); //Error
441  theValuesContainer_->Fill(position + 2, 1); //ok
442  }
443  } else if (itM->second == "Lumibased PrimaryVertex-DataBase fit") {
444  if (resultsMap.find("PV") != resultsMap.end() && resultsMap.find("DB") != resultsMap.end()) {
445  theValuesContainer_->Fill(position, resultsMap["PV"].first - resultsMap["DB"].first); //Value
447  position + 1,
448  std::sqrt(std::pow(resultsMap["PV"].second, 2) + std::pow(resultsMap["DB"].second, 2))); //Error
449  theValuesContainer_->Fill(position + 2, 1); //ok
450  }
451  } else if (itM->second == "Lumibased PrimaryVertex-Scalers fit") {
452  if (resultsMap.find("PV") != resultsMap.end() && resultsMap.find("SC") != resultsMap.end()) {
453  theValuesContainer_->Fill(position, resultsMap["PV"].first - resultsMap["SC"].first); //Value
455  position + 1,
456  std::sqrt(std::pow(resultsMap["PV"].second, 2) + std::pow(resultsMap["SC"].second, 2))); //Error
457  theValuesContainer_->Fill(position + 2, 1); //ok
458  }
459  } else if (itM->second == "Lumibased Scalers-DataBase fit") {
460  if (resultsMap.find("SC") != resultsMap.end() && resultsMap.find("DB") != resultsMap.end()) {
461  theValuesContainer_->Fill(position, resultsMap["SC"].first - resultsMap["DB"].first); //Value
463  position + 1,
464  std::sqrt(std::pow(resultsMap["SC"].second, 2) + std::pow(resultsMap["DB"].second, 2))); //Error
465  theValuesContainer_->Fill(position + 2, 1); //ok
466  }
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();
470  itPV++) {
471  theValuesContainer_->Fill(position, (*itPV).first - resultsMap["DB"].first); //Value
472  }
473  /*
474  double error = 0;
475  if(vertexResults.size() != 0){
476  for(vector<pair<double,double> >::iterator itPV=vertexResults.begin(); itPV!=vertexResults.end(); itPV++){
477  error += std::pow((*itPV).first-resultsMap["DB"].first-theValuesContainer_->getTProfile()->GetBinContent(position+1),2.);
478  }
479  error = std::sqrt(error)/vertexResults.size();
480  }
481 // theValuesContainer_->Fill(position+1,std::sqrt(std::pow((*itPV).second,2)+std::pow(resultsMap["DB"].second,2)));//Error
482  theValuesContainer_->Fill(position+1,error);//Error
483 */
484  theValuesContainer_->Fill(position + 1,
485  theValuesContainer_->getTProfile()->GetBinError(position + 1)); //Error
486  theValuesContainer_->Fill(position + 2, 1); //ok
487  }
488  } else if (itM->second == "Lumibased PrimaryVertex-Scalers") {
489  if (resultsMap.find("SC") != resultsMap.end() && !vertexResults.empty()) {
490  for (vector<pair<double, double> >::iterator itPV = vertexResults.begin(); itPV != vertexResults.end();
491  itPV++) {
492  theValuesContainer_->Fill(position, (*itPV).first - resultsMap["SC"].first); //Value
493  }
494  /*
495  double error = 0;
496  if(vertexResults.size() != 0){
497  for(vector<pair<double,double> >::iterator itPV=vertexResults.begin(); itPV!=vertexResults.end(); itPV++){
498  error += std::pow((*itPV).first-resultsMap["SC"].first-theValuesContainer_->getTProfile()->GetBinContent(position+1),2.);
499  }
500  error = std::sqrt(error)/vertexResults.size();
501  }
502 // theValuesContainer_->Fill(position+1,std::sqrt(std::pow((*itPV).second,2)+std::pow(resultsMap["SC"].second,2)));//Error
503  theValuesContainer_->Fill(position+1,error);//Error
504 */
505  theValuesContainer_->Fill(position + 1,
506  theValuesContainer_->getTProfile()->GetBinError(position + 1)); //Error
507  theValuesContainer_->Fill(position + 2, 1); //ok
508  }
509  }
510  // else if(itM->second == "Lumibased Scalers-DataBase"){
511  // if(resultsMap.find("SC") != resultsMap.end() && resultsMap.find("DB") != resultsMap.end()){
512  // itHHH->second->Fill(bin,resultsMap["SC"].first-resultsMap["DB"].first);
513  // }
514  // }
515  else {
516  LogInfo("AlcaBeamMonitor") << "The histosMap_ have a histogram named " << itM->second
517  << " that I can't recognize in this loop!";
518  //assert(0);
519  }
520  }
521  }
522 }
523 
double Getdydz() const
get dydz slope, crossing angle in YZ
LuminosityBlockID id() const
MonitorElement * hD0Phi0_
math::Error< dimension >::type CovarianceMatrix
Definition: BeamSpot.h:29
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
Definition: DQMStore.cc:239
edm::EDGetTokenT< reco::TrackCollection > trackLabel_
MonitorElement * hDxyBS_
double GetY() const
get Y beam position
void dqmEndLuminosityBlock(const edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup) override
bool runPVandTrkFitter()
Definition: BeamFitter.cc:412
void dqmBeginLuminosityBlock(const edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:418
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
std::multimap< std::string, std::string > histoByCategoryNames_
void setLumiFlag()
this ME is meant to be stored for each luminosity section
double GetSigmaZ() const
get sigma Z, RMS bunch length
edm::EDGetTokenT< reco::VertexCollection > primaryVertexLabel_
double GetBeamWidthX() const
get average transverse beam width
void resetTrkVector()
Definition: BeamFitter.h:55
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:27
char const * what() const override
Definition: Exception.cc:103
PositionContainer positionsMap_
double GetBeamWidthY() const
get average transverse beam width
void readEvent(const edm::Event &iEvent)
Definition: BeamFitter.cc:224
double GetEmittanceX() const
get emittance
void Fill(long long x)
U second(std::pair< T, U > const &p)
virtual void Reset()
reset ME (ie. contents, errors, etc)
std::vector< std::string > varNamesV_
int iEvent
Definition: GenABIO.cc:224
AlcaBeamMonitor(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void readEvent(const edm::Event &iEvent)
Definition: PVFitter.cc:93
void setBeamWidthY(double v)
Definition: BeamSpot.h:105
int GetBeamType() const
get beam type
edm::EDGetTokenT< reco::BeamSpot > scalerLabel_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
T sqrt(T t)
Definition: SSEVec.h:19
BeamSpotContainer beamSpotsMap_
BeamFitter * theBeamFitter_
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, char const *option="s")
Definition: DQMStore.cc:333
def pv(vc)
Definition: MetAnalyzer.py:7
double GetZ() const
get Z beam position
void resetLSRange()
Definition: BeamFitter.h:57
double Getdxdz() const
get dxdz slope, crossing angle in XZ
PVFitter * thePVFitter_
virtual TProfile * getTProfile()
double GetX() const
get X beam position
T const * product() const
Definition: Handle.h:69
bool runFitter()
Definition: PVFitter.cc:304
HistosContainer histosMap_
LuminosityBlockNumber_t luminosityBlock() const
void resetAll()
Definition: PVFitter.h:80
double GetBetaStar() const
get beta star
~AlcaBeamMonitor() override
std::string monitorName_
fixed size matrix
double GetCovariance(int i, int j) const
get i,j element of the full covariance matrix 7x7
HLT enums.
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
void resetPVFitter()
Definition: BeamFitter.h:69
static int position[264][3]
Definition: ReadPGInfo.cc:289
T get() const
Definition: EventSetup.h:73
double GetEmittanceY() const
get emittance
reco::BeamSpot getBeamSpot()
Definition: PVFitter.h:91
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
bool isValid() const
Definition: ESHandle.h:44
T const * product() const
Definition: ESHandle.h:86
edm::ParameterSet parameters_
MonitorElement * theValuesContainer_
reco::BeamSpot getBeamSpot()
Definition: BeamFitter.h:90
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
Definition: Run.h:45
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)
void resetRefTime()
Definition: BeamFitter.h:58