CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AlcaBeamMonitor.cc
Go to the documentation of this file.
1 /*
2  * \file AlcaBeamMonitor.cc
3  * \author Lorenzo Uplegger/FNAL
4  * $Date: 2011/03/22 03:07:39 $
5  * $Revision: 1.9 $
6  *
7  */
8 
16 //#include "DataFormats/Scalers/interface/BeamSpotOnline.h"
26 #include <numeric>
27 //#include <iostream>
28 
29 using namespace std;
30 using namespace edm;
31 using namespace reco;
32 
33 //----------------------------------------------------------------------------------------------------------------------
35  parameters_ (ps),
36  monitorName_ (parameters_.getUntrackedParameter<string>("MonitorName","YourSubsystemName")),
37  primaryVertexLabel_ (parameters_.getUntrackedParameter<InputTag>("PrimaryVertexLabel")),
38  beamSpotLabel_ (parameters_.getUntrackedParameter<InputTag>("BeamSpotLabel")),
39  trackLabel_ (parameters_.getUntrackedParameter<InputTag>("TrackLabel")),
40  scalerLabel_ (parameters_.getUntrackedParameter<InputTag>("ScalerLabel")),
41  numberOfValuesToSave_ (0)
42 {
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] = 0;
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_ != 0){
107  delete theBeamFitter_;
108  }
109 
110  if(thePVFitter_ != 0){
111  delete thePVFitter_;
112  }
113 }
114 
115 
116 //----------------------------------------------------------------------------------------------------------------------
118  string name;
119  string title;
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 = dbe_->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 = dbe_->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 = dbe_->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 = dbe_->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 = dbe_->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 = dbe_->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 = 0;
158  }
159  else{
160  //assert(0);
161  }
162  }
163  else if(itM->first == "sigmaZ"){
164  if(itMM->first == "Coordinate"){
165  itMM->second = dbe_->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 = dbe_->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 != 0){
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  dbe_->setCurrentFolder(monitorName_+"Service");
191  theValuesContainer_ = dbe_->bookProfile("hHistoLumiValues","Histo Lumi Values", 3*numberOfValuesToSave_, 0., 3*numberOfValuesToSave_, 100., -100., 9000., " ");
193 
194 }
195 
196 //----------------------------------------------------------------------------------------------------------------------
197 void AlcaBeamMonitor::beginRun(const edm::Run& r, const EventSetup& context) {
198  // create and cd into new folder
199  dbe_->setCurrentFolder(monitorName_+"Validation");
200  //Book histograms
201  hD0Phi0_ = dbe_->bookProfile("hD0Phi0","d_{0} vs. #phi_{0} (All Tracks)",63,-3.15,3.15,100,-0.1,0.1,"");
202  hD0Phi0_->setAxisTitle("#phi_{0} (rad)",1);
203  hD0Phi0_->setAxisTitle("d_{0} (cm)",2);
204 
206  hDxyBS_ = dbe_->book1D("hDxyBS","dxy_{0} w.r.t. Beam spot (All Tracks)",100,-0.1,0.1);
207  hDxyBS_->setAxisTitle("dxy_{0} w.r.t. Beam spot (cm)",1);
208 }
209 
210 //----------------------------------------------------------------------------------------------------------------------
212  // Always create a beamspot group for each lumi weather we have results or not! Each Beamspot will be of unknown type!
213 
214  vertices_.clear();
216  beamSpotsMap_.clear();
217 
218  //Read BeamSpot from DB
219  ESHandle<BeamSpotObjects> bsDBHandle;
220  try{
221  iSetup.get<BeamSpotObjectsRcd>().get(bsDBHandle);
222  }
223  catch( cms::Exception& exception ){
224  LogInfo("AlcaBeamMonitor")
225  << exception.what();
226  return;
227  }
228  if(bsDBHandle.isValid()) { // check the product
229  const BeamSpotObjects *spotDB = bsDBHandle.product();
230 
231  // translate from BeamSpotObjects to reco::BeamSpot
232  BeamSpot::Point apoint( spotDB->GetX(), spotDB->GetY(), spotDB->GetZ() );
233 
235  for ( int i=0; i<7; ++i ) {
236  for ( int j=0; j<7; ++j ) {
237  matrix(i,j) = spotDB->GetCovariance(i,j);
238  }
239  }
240 
241  beamSpotsMap_["DB"] = BeamSpot( apoint,
242  spotDB->GetSigmaZ(),
243  spotDB->Getdxdz(),
244  spotDB->Getdydz(),
245  spotDB->GetBeamWidthX(),
246  matrix );
247 
248  BeamSpot* aSpot = &(beamSpotsMap_["DB"]);
249 
250  aSpot->setBeamWidthY( spotDB->GetBeamWidthY() );
251  aSpot->setEmittanceX( spotDB->GetEmittanceX() );
252  aSpot->setEmittanceY( spotDB->GetEmittanceY() );
253  aSpot->setbetaStar( spotDB->GetBetaStar() );
254 
255  if ( spotDB->GetBeamType() == 2 ) {
256  aSpot->setType( reco::BeamSpot::Tracker );
257  } else{
258  aSpot->setType( reco::BeamSpot::Fake );
259  }
260  //LogInfo("AlcaBeamMonitor")
261  // << *aSpot << std::endl;
262  }
263  else {
264  LogInfo("AlcaBeamMonitor")
265  << "Database BeamSpot is not valid at lumi: " << iLumi.id().luminosityBlock();
266  }
267 }
268 
269 //----------------------------------------------------------------------------------------------------------------------
270 void AlcaBeamMonitor::analyze(const Event& iEvent, const EventSetup& iSetup ){
271 
272  //------ BeamFitter
273  theBeamFitter_->readEvent(iEvent);
274  //------ PVFitter
275  thePVFitter_->readEvent(iEvent);
276 
277  if(beamSpotsMap_.find("DB") != beamSpotsMap_.end()){
278  //------ Tracks
280  iEvent.getByLabel(trackLabel_, TrackCollection);
281  const reco::TrackCollection *tracks = TrackCollection.product();
282  for ( reco::TrackCollection::const_iterator track = tracks->begin(); track != tracks->end(); ++track ) {
283  hD0Phi0_->Fill(track->phi(), -1*track->dxy(beamSpotsMap_["DB"].position()));
284  hDxyBS_->Fill(-1*track->dxy(beamSpotsMap_["DB"].position()));
285  }
286  }
287 
288  //------ Primary Vertices
289  Handle<VertexCollection > PVCollection;
290  if (iEvent.getByLabel(primaryVertexLabel_, PVCollection )) {
291  vertices_.push_back(*PVCollection.product());
292  }
293 
294  if(beamSpotsMap_.find("SC") == beamSpotsMap_.end()){
295  //BeamSpot from file for this stream is = to the scalar BeamSpot
296  Handle<BeamSpot> recoBeamSpotHandle;
297  try{
298  iEvent.getByLabel(scalerLabel_,recoBeamSpotHandle);
299  }
300  catch( cms::Exception& exception ){
301  LogInfo("AlcaBeamMonitor")
302  << exception.what();
303  return;
304  }
305  beamSpotsMap_["SC"] = *recoBeamSpotHandle;
306  if ( beamSpotsMap_["SC"].BeamWidthX() != 0 ) {
307  beamSpotsMap_["SC"].setType( reco::BeamSpot::Tracker );
308  } else{
309  beamSpotsMap_["SC"].setType( reco::BeamSpot::Fake );
310  }
311  }
312 }
313 
314 
315 //----------------------------------------------------------------------------------------------------------------------
319  }
324 
325  if ( thePVFitter_->runFitter() ) {
327  }
329 
330  // "PV,BF..." Value,Error
331  map<std::string,pair<double,double> > resultsMap;
332  vector<pair<double,double> > vertexResults;
334  int position = 0;
335  for(vector<string>::iterator itV=varNamesV_.begin(); itV!=varNamesV_.end(); itV++){
336  resultsMap.clear();
337  for(BeamSpotContainer::iterator itBS = beamSpotsMap_.begin(); itBS != beamSpotsMap_.end(); itBS++){
338  if(itBS->second.type() == BeamSpot::Tracker){
339  if(*itV == "x"){
340  resultsMap[itBS->first] = pair<double,double>(itBS->second.x0(),itBS->second.x0Error());
341  }
342  else if(*itV == "y"){
343  resultsMap[itBS->first] = pair<double,double>(itBS->second.y0(),itBS->second.y0Error());
344  }
345  else if(*itV == "z"){
346  resultsMap[itBS->first] = pair<double,double>(itBS->second.z0(),itBS->second.z0Error());
347  }
348  else if(*itV == "sigmaX"){
349  resultsMap[itBS->first] = pair<double,double>(itBS->second.BeamWidthX(),itBS->second.BeamWidthXError());
350  }
351  else if(*itV == "sigmaY"){
352  resultsMap[itBS->first] = pair<double,double>(itBS->second.BeamWidthY(),itBS->second.BeamWidthYError());
353  }
354  else if(*itV == "sigmaZ"){
355  resultsMap[itBS->first] = pair<double,double>(itBS->second.sigmaZ(),itBS->second.sigmaZ0Error());
356  }
357  else{
358  LogInfo("AlcaBeamMonitor")
359  << "The histosMap_ has been built with the name " << *itV << " that I can't recognize!";
360  //assert(0);
361  }
362  }
363  }
364  vertexResults.clear();
365  for(vector<VertexCollection>::iterator itPV = vertices_.begin(); itPV != vertices_.end(); itPV++){
366  if(itPV->size() != 0){
367  for(VertexCollection::const_iterator pv = itPV->begin(); pv != itPV->end(); pv++) {
368  if (pv->isFake() || pv->tracksSize()<10) continue;
369  if(*itV == "x"){
370  vertexResults.push_back(pair<double,double>(pv->x(),pv->xError()));
371  }
372  else if(*itV == "y"){
373  vertexResults.push_back(pair<double,double>(pv->y(),pv->yError()));
374  }
375  else if(*itV == "z"){
376  vertexResults.push_back(pair<double,double>(pv->z(),pv->zError()));
377  }
378  else if(*itV != "sigmaX" && *itV != "sigmaY" && *itV != "sigmaZ"){
379  LogInfo("AlcaBeamMonitor")
380  << "The histosMap_ has been built with the name " << *itV << " that I can't recognize!";
381  //assert(0);
382  }
383  }
384  }
385  }
386 /*
387  histoByCategoryNames_.insert( pair<string,string>("run", "Coordinate"));
388  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex fit-DataBase"));
389  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex fit-BeamFit"));
390  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex fit-Scalers"));
391  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex-DataBase"));
392  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex-BeamFit"));
393  histoByCategoryNames_.insert( pair<string,string>("run", "PrimaryVertex-Scalers"));
394 
395  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased BeamSpotFit"));
396  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased PrimaryVertex"));
397  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased DataBase"));
398  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased Scalers"));
399  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased PrimaryVertex-DataBase fit"));
400  histoByCategoryNames_.insert( pair<string,string>("lumi", "Lumibased PrimaryVertex-Scalers fit"));
401  histoByCategoryNames_.insert( pair<string,string>("validation", "Lumibased Scalers-DataBase fit"));
402  histoByCategoryNames_.insert( pair<string,string>("validation", "Lumibased PrimaryVertex-DataBase"));
403  histoByCategoryNames_.insert( pair<string,string>("validation", "Lumibased PrimaryVertex-Scalers"));
404 */
405  for(multimap<string,string>::iterator itM=histoByCategoryNames_.begin(); itM!=histoByCategoryNames_.end(); itM++){
406  if(itM->first == "run" && (histo = histosMap_[*itV][itM->first][itM->second]) == 0){
407  continue;
408  }
409  else if(itM->first != "run"){
410  position = positionsMap_[*itV][itM->first][itM->second];
411  }
412  if(itM->second == "Coordinate"){
413  if(beamSpotsMap_.find("DB") != beamSpotsMap_.end()){
414  histo->Fill(resultsMap["DB"].first);
415  }
416  }
417  else if(itM->second == "PrimaryVertex fit-DataBase"){
418  if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("DB") != resultsMap.end()){
419  histo->Fill(resultsMap["PV"].first-resultsMap["DB"].first);
420  }
421  }
422  else if(itM->second == "PrimaryVertex fit-BeamFit"){
423  if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("BF") != resultsMap.end()){
424  histo->Fill(resultsMap["PV"].first-resultsMap["BF"].first);
425  }
426  }
427  else if(itM->second == "PrimaryVertex fit-Scalers"){
428  if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("SC") != resultsMap.end()){
429  histo->Fill(resultsMap["PV"].first-resultsMap["SC"].first);
430  }
431  }
432  else if(itM->second == "PrimaryVertex-DataBase"){
433  if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("DB") != resultsMap.end()){
434  for(vector<pair<double,double> >::iterator itPV=vertexResults.begin(); itPV!=vertexResults.end(); itPV++){
435  histo->Fill(itPV->first-resultsMap["DB"].first);
436  }
437  }
438  }
439  else if(itM->second == "PrimaryVertex-BeamFit"){
440  if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("BF") != resultsMap.end()){
441  for(vector<pair<double,double> >::iterator itPV=vertexResults.begin(); itPV!=vertexResults.end(); itPV++){
442  histo->Fill(itPV->first-resultsMap["BF"].first);
443  }
444  }
445  }
446  else if(itM->second == "PrimaryVertex-Scalers"){
447  if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("SC") != resultsMap.end()){
448  for(vector<pair<double,double> >::iterator itPV=vertexResults.begin(); itPV!=vertexResults.end(); itPV++){
449  histo->Fill(itPV->first-resultsMap["SC"].first);
450  }
451  }
452  }
453  else if(itM->second == "Lumibased BeamSpotFit"){
454  if(resultsMap.find("BF") != resultsMap.end()){
455  theValuesContainer_->Fill(position ,resultsMap["BF"].first);//Value
456  theValuesContainer_->Fill(position+1,resultsMap["BF"].second);//Error
457  theValuesContainer_->Fill(position+2,1);//ok
458  }
459  }
460  else if(itM->second == "Lumibased PrimaryVertex"){
461  if(resultsMap.find("PV") != resultsMap.end()){
462  theValuesContainer_->Fill(position ,resultsMap["PV"].first);//Value
463  theValuesContainer_->Fill(position+1,resultsMap["PV"].second);//Error
464  theValuesContainer_->Fill(position+2,1);//ok
465  }
466  }
467  else if(itM->second == "Lumibased DataBase"){
468  if(resultsMap.find("DB") != resultsMap.end()){
469  theValuesContainer_->Fill(position ,resultsMap["DB"].first);//Value
470  theValuesContainer_->Fill(position+1,resultsMap["DB"].second);//Error
471  theValuesContainer_->Fill(position+2,1);//ok
472  }
473  }
474  else if(itM->second == "Lumibased Scalers"){
475  if(resultsMap.find("SC") != resultsMap.end()){
476  theValuesContainer_->Fill(position ,resultsMap["SC"].first);//Value
477  theValuesContainer_->Fill(position+1,resultsMap["SC"].second);//Error
478  theValuesContainer_->Fill(position+2,1);//ok
479  }
480  }
481  else if(itM->second == "Lumibased PrimaryVertex-DataBase fit"){
482  if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("DB") != resultsMap.end()){
483  theValuesContainer_->Fill(position ,resultsMap["PV"].first-resultsMap["DB"].first);//Value
484  theValuesContainer_->Fill(position+1,std::sqrt(std::pow(resultsMap["PV"].second,2)+std::pow(resultsMap["DB"].second,2)));//Error
485  theValuesContainer_->Fill(position+2,1);//ok
486  }
487  }
488  else if(itM->second == "Lumibased PrimaryVertex-Scalers fit"){
489  if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("SC") != resultsMap.end()){
490  theValuesContainer_->Fill(position ,resultsMap["PV"].first-resultsMap["SC"].first);//Value
491  theValuesContainer_->Fill(position+1,std::sqrt(std::pow(resultsMap["PV"].second,2)+std::pow(resultsMap["SC"].second,2)));//Error
492  theValuesContainer_->Fill(position+2,1);//ok
493  }
494  }
495  else if(itM->second == "Lumibased Scalers-DataBase fit"){
496  if(resultsMap.find("SC") != resultsMap.end() && resultsMap.find("DB") != resultsMap.end()){
497  theValuesContainer_->Fill(position ,resultsMap["SC"].first-resultsMap["DB"].first);//Value
498  theValuesContainer_->Fill(position+1,std::sqrt(std::pow(resultsMap["SC"].second,2)+std::pow(resultsMap["DB"].second,2)));//Error
499  theValuesContainer_->Fill(position+2,1);//ok
500  }
501  }
502  else if(itM->second == "Lumibased PrimaryVertex-DataBase"){
503  if(resultsMap.find("DB") != resultsMap.end() && vertexResults.size() != 0){
504  for(vector<pair<double,double> >::iterator itPV=vertexResults.begin(); itPV!=vertexResults.end(); itPV++){
505  theValuesContainer_->Fill(position ,(*itPV).first-resultsMap["DB"].first);//Value
506  }
507 /*
508  double error = 0;
509  if(vertexResults.size() != 0){
510  for(vector<pair<double,double> >::iterator itPV=vertexResults.begin(); itPV!=vertexResults.end(); itPV++){
511  error += std::pow((*itPV).first-resultsMap["DB"].first-theValuesContainer_->getTProfile()->GetBinContent(position+1),2.);
512  }
513  error = std::sqrt(error)/vertexResults.size();
514  }
515 // theValuesContainer_->Fill(position+1,std::sqrt(std::pow((*itPV).second,2)+std::pow(resultsMap["DB"].second,2)));//Error
516  theValuesContainer_->Fill(position+1,error);//Error
517 */
518  theValuesContainer_->Fill(position+1,theValuesContainer_->getTProfile()->GetBinError(position+1));//Error
519  theValuesContainer_->Fill(position+2,1);//ok
520  }
521  }
522  else if(itM->second == "Lumibased PrimaryVertex-Scalers"){
523  if(resultsMap.find("SC") != resultsMap.end() && vertexResults.size() != 0){
524  for(vector<pair<double,double> >::iterator itPV=vertexResults.begin(); itPV!=vertexResults.end(); itPV++){
525  theValuesContainer_->Fill(position ,(*itPV).first-resultsMap["SC"].first);//Value
526  }
527 /*
528  double error = 0;
529  if(vertexResults.size() != 0){
530  for(vector<pair<double,double> >::iterator itPV=vertexResults.begin(); itPV!=vertexResults.end(); itPV++){
531  error += std::pow((*itPV).first-resultsMap["SC"].first-theValuesContainer_->getTProfile()->GetBinContent(position+1),2.);
532  }
533  error = std::sqrt(error)/vertexResults.size();
534  }
535 // theValuesContainer_->Fill(position+1,std::sqrt(std::pow((*itPV).second,2)+std::pow(resultsMap["SC"].second,2)));//Error
536  theValuesContainer_->Fill(position+1,error);//Error
537 */
538  theValuesContainer_->Fill(position+1,theValuesContainer_->getTProfile()->GetBinError(position+1));//Error
539  theValuesContainer_->Fill(position+2,1);//ok
540  }
541  }
542 // else if(itM->second == "Lumibased Scalers-DataBase"){
543 // if(resultsMap.find("SC") != resultsMap.end() && resultsMap.find("DB") != resultsMap.end()){
544 // itHHH->second->Fill(bin,resultsMap["SC"].first-resultsMap["DB"].first);
545 // }
546 // }
547  else{
548  LogInfo("AlcaBeamMonitor")
549  << "The histosMap_ have a histogram named " << itM->second << " that I can't recognize in this loop!";
550  //assert(0);
551 
552  }
553  }
554  }
555 }
556 
557 //----------------------------------------------------------------------------------------------------------------------
558 void AlcaBeamMonitor::endRun(const Run& iRun, const EventSetup& context){
559 }
560 
561 //----------------------------------------------------------------------------------------------------------------------
562 void AlcaBeamMonitor::endJob(const LuminosityBlock& iLumi, const EventSetup& iSetup){
563 }
564 
565 
double Getdydz() const
get dydz slope, crossing angle in YZ
edm::InputTag trackLabel_
virtual char const * what() const
Definition: Exception.cc:141
LuminosityBlockID id() const
MonitorElement * hD0Phi0_
math::Error< dimension >::type CovarianceMatrix
Definition: BeamSpot.h:32
int i
Definition: DBlmapReader.cc:9
MonitorElement * hDxyBS_
double GetY() const
get Y beam position
bool runPVandTrkFitter()
Definition: BeamFitter.cc:409
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:722
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::InputTag primaryVertexLabel_
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
double GetSigmaZ() const
get sigma Z, RMS bunch length
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup)
double GetBeamWidthX() const
get average transverse beam width
void resetTrkVector()
Definition: BeamFitter.h:48
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:30
PositionContainer positionsMap_
double GetBeamWidthY() const
get average transverse beam width
void readEvent(const edm::Event &iEvent)
Definition: BeamFitter.cc:223
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
double GetEmittanceX() const
get emittance
void endRun(const edm::Run &iRun, const edm::EventSetup &iSetup)
void Fill(long long x)
U second(std::pair< T, U > const &p)
std::vector< std::string > varNamesV_
int iEvent
Definition: GenABIO.cc:243
AlcaBeamMonitor(const edm::ParameterSet &)
void readEvent(const edm::Event &iEvent)
Definition: PVFitter.cc:84
void beginRun(const edm::Run &iRun, const edm::EventSetup &iSetup)
void setBeamWidthY(double v)
Definition: BeamSpot.h:110
int GetBeamType() const
get beam type
T sqrt(T t)
Definition: SSEVec.h:48
BeamSpotContainer beamSpotsMap_
BeamFitter * theBeamFitter_
virtual void endJob()
Definition: EDAnalyzer.h:60
int j
Definition: DBlmapReader.cc:9
double GetZ() const
get Z beam position
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
Definition: DQMStore.cc:1036
void resetLSRange()
Definition: BeamFitter.h:50
double Getdxdz() const
get dxdz slope, crossing angle in XZ
bool first
Definition: L1TdeRCT.cc:94
PVFitter * thePVFitter_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
std::multimap< std::string, std::string > histoByCategoryNames_
double GetX() const
get X beam position
void beginLuminosityBlock(const edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup)
tuple tracks
Definition: testEve_cfg.py:39
bool runFitter()
Definition: PVFitter.cc:320
HistosContainer histosMap_
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
LuminosityBlockNumber_t luminosityBlock() const
void resetAll()
Definition: PVFitter.h:74
double GetBetaStar() const
get beta star
T const * product() const
Definition: Handle.h:74
void endLuminosityBlock(const edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup)
std::string monitorName_
double GetCovariance(int i, int j) const
get i,j element of the full covariance matrix 7x7
void resetPVFitter()
Definition: BeamFitter.h:64
TProfile * getTProfile(void) const
double GetEmittanceY() const
get emittance
reco::BeamSpot getBeamSpot()
Definition: PVFitter.h:85
void setLumiFlag(void)
this ME is meant to be stored for each luminosity section
bool isValid() const
Definition: ESHandle.h:37
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)
edm::ParameterSet parameters_
MonitorElement * theValuesContainer_
reco::BeamSpot getBeamSpot()
Definition: BeamFitter.h:89
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
edm::InputTag scalerLabel_
Definition: Run.h:36
std::vector< reco::VertexCollection > vertices_
void resetRefTime()
Definition: BeamFitter.h:51