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