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