CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Types | Private Attributes

AlcaBeamMonitor Class Reference

#include <AlcaBeamMonitor.h>

Inheritance diagram for AlcaBeamMonitor:
edm::EDAnalyzer

List of all members.

Public Member Functions

 AlcaBeamMonitor (const edm::ParameterSet &)
 ~AlcaBeamMonitor ()

Protected Member Functions

void analyze (const edm::Event &iEvent, const edm::EventSetup &iSetup)
void beginJob (void)
void beginLuminosityBlock (const edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup)
void beginRun (const edm::Run &iRun, const edm::EventSetup &iSetup)
void endJob (const edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup)
void endLuminosityBlock (const edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup)
void endRun (const edm::Run &iRun, const edm::EventSetup &iSetup)

Private Types

typedef std::map< std::string,
reco::BeamSpot
BeamSpotContainer
typedef std::map< std::string,
std::map< std::string,
std::map< std::string,
MonitorElement * > > > 
HistosContainer
typedef std::map< std::string,
std::map< std::string,
std::map< std::string, int > > > 
PositionContainer

Private Attributes

edm::InputTag beamSpotLabel_
BeamSpotContainer beamSpotsMap_
DQMStoredbe_
MonitorElementhD0Phi0_
MonitorElementhDxyBS_
std::multimap< std::string,
std::string > 
histoByCategoryNames_
HistosContainer histosMap_
std::string monitorName_
int numberOfValuesToSave_
edm::ParameterSet parameters_
PositionContainer positionsMap_
edm::InputTag primaryVertexLabel_
edm::InputTag scalerLabel_
BeamFittertheBeamFitter_
PVFitterthePVFitter_
MonitorElementtheValuesContainer_
edm::InputTag trackLabel_
std::vector< std::string > varNamesV_
std::vector
< reco::VertexCollection
vertices_

Detailed Description

*

Date:
2010/09/24 06:36:04
Revision:
1.5
Author:
Lorenzo Uplegger/FNAL

Definition at line 30 of file AlcaBeamMonitor.h.


Member Typedef Documentation

typedef std::map<std::string,reco::BeamSpot> AlcaBeamMonitor::BeamSpotContainer [private]

Definition at line 48 of file AlcaBeamMonitor.h.

typedef std::map<std::string,std::map<std::string,std::map<std::string,MonitorElement*> > > AlcaBeamMonitor::HistosContainer [private]

Definition at line 50 of file AlcaBeamMonitor.h.

typedef std::map<std::string,std::map<std::string,std::map<std::string,int> > > AlcaBeamMonitor::PositionContainer [private]

Definition at line 52 of file AlcaBeamMonitor.h.


Constructor & Destructor Documentation

AlcaBeamMonitor::AlcaBeamMonitor ( const edm::ParameterSet ps)

Definition at line 34 of file AlcaBeamMonitor.cc.

References dbe_, histoByCategoryNames_, histosMap_, monitorName_, numberOfValuesToSave_, cmsCodeRules::cppFunctionSkipper::operator, parameters_, positionsMap_, BeamFitter::resetLSRange(), BeamFitter::resetPVFitter(), BeamFitter::resetRefTime(), BeamFitter::resetTrkVector(), theBeamFitter_, thePVFitter_, and varNamesV_.

                                                         : 
  parameters_           (ps),
  monitorName_          (parameters_.getUntrackedParameter<string>("MonitorName","YourSubsystemName")),
  primaryVertexLabel_   (parameters_.getUntrackedParameter<InputTag>("PrimaryVertexLabel")),
  beamSpotLabel_        (parameters_.getUntrackedParameter<InputTag>("BeamSpotLabel")),
  trackLabel_           (parameters_.getUntrackedParameter<InputTag>("TrackLabel")),
  scalerLabel_          (parameters_.getUntrackedParameter<InputTag>("ScalerLabel")),
  numberOfValuesToSave_ (0)
{
  dbe_ = Service<DQMStore>().operator->();
  
  if (monitorName_ != "" ) monitorName_ = monitorName_+"/" ;
  
  theBeamFitter_ = new BeamFitter(parameters_);
  theBeamFitter_->resetTrkVector();
  theBeamFitter_->resetLSRange();
  theBeamFitter_->resetRefTime();
  theBeamFitter_->resetPVFitter();

  thePVFitter_ = new PVFitter(parameters_);


  varNamesV_.push_back("x");
  varNamesV_.push_back("y");
  varNamesV_.push_back("z");
  varNamesV_.push_back("sigmaX");
  varNamesV_.push_back("sigmaY");
  varNamesV_.push_back("sigmaZ");

  histoByCategoryNames_.insert( pair<string,string>("run",        "Coordinate"));
  histoByCategoryNames_.insert( pair<string,string>("run",        "PrimaryVertex fit-DataBase"));
  histoByCategoryNames_.insert( pair<string,string>("run",        "PrimaryVertex fit-BeamFit"));
  histoByCategoryNames_.insert( pair<string,string>("run",        "PrimaryVertex fit-Scalers"));
  histoByCategoryNames_.insert( pair<string,string>("run",        "PrimaryVertex-DataBase"));
  histoByCategoryNames_.insert( pair<string,string>("run",        "PrimaryVertex-BeamFit"));
  histoByCategoryNames_.insert( pair<string,string>("run",        "PrimaryVertex-Scalers"));

  histoByCategoryNames_.insert( pair<string,string>("lumi",       "Lumibased BeamSpotFit"));  
  histoByCategoryNames_.insert( pair<string,string>("lumi",       "Lumibased PrimaryVertex"));
  histoByCategoryNames_.insert( pair<string,string>("lumi",       "Lumibased DataBase"));     
  histoByCategoryNames_.insert( pair<string,string>("lumi",       "Lumibased Scalers"));      
  histoByCategoryNames_.insert( pair<string,string>("lumi",       "Lumibased PrimaryVertex-DataBase fit"));
  histoByCategoryNames_.insert( pair<string,string>("lumi",       "Lumibased PrimaryVertex-Scalers fit"));
  histoByCategoryNames_.insert( pair<string,string>("validation", "Lumibased Scalers-DataBase fit"));
  histoByCategoryNames_.insert( pair<string,string>("validation", "Lumibased PrimaryVertex-DataBase"));
  histoByCategoryNames_.insert( pair<string,string>("validation", "Lumibased PrimaryVertex-Scalers"));


  for(vector<string>::iterator itV=varNamesV_.begin(); itV!=varNamesV_.end(); itV++){
    for(multimap<string,string>::iterator itM=histoByCategoryNames_.begin(); itM!=histoByCategoryNames_.end(); itM++){
      if(itM->first=="run"){
        histosMap_[*itV][itM->first][itM->second] = 0;
      }
      else{
        positionsMap_[*itV][itM->first][itM->second] = 3*numberOfValuesToSave_;//value, error, ok 
        ++numberOfValuesToSave_;
      }
    }
  }
  
//  beamSpotsMap_["BF"] = map<LuminosityBlockNumber_t,BeamSpot>();//For each lumi the beamfitter will have a result
//  beamSpotsMap_["PV"] = map<LuminosityBlockNumber_t,BeamSpot>();//For each lumi the PVfitter will have a result
//  beamSpotsMap_["DB"] = map<LuminosityBlockNumber_t,BeamSpot>();//For each lumi we take the values that are stored in the database, already collapsed then
//  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
//  beamSpotsMap_["BF"] = 0;//For each lumi the beamfitter will have a result
//  beamSpotsMap_["PV"] = 0;//For each lumi the PVfitter will have a result
//  beamSpotsMap_["DB"] = 0;//For each lumi we take the values that are stored in the database, already collapsed then
//  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
}
AlcaBeamMonitor::~AlcaBeamMonitor ( )

Definition at line 105 of file AlcaBeamMonitor.cc.

References theBeamFitter_, and thePVFitter_.

                                  {
  if(theBeamFitter_ != 0){
    delete theBeamFitter_;
  }
  
  if(thePVFitter_ != 0){
    delete thePVFitter_;
  }
}

Member Function Documentation

void AlcaBeamMonitor::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [protected, virtual]

Implements edm::EDAnalyzer.

Definition at line 270 of file AlcaBeamMonitor.cc.

References beamSpotsMap_, exception, reco::BeamSpot::Fake, MonitorElement::Fill(), edm::Event::getByLabel(), hD0Phi0_, hDxyBS_, position, primaryVertexLabel_, edm::Handle< T >::product(), PVFitter::readEvent(), BeamFitter::readEvent(), scalerLabel_, theBeamFitter_, thePVFitter_, reco::BeamSpot::Tracker, trackLabel_, testEve_cfg::tracks, vertices_, and cms::Exception::what().

                                                                           {
  
  //------ BeamFitter 
  theBeamFitter_->readEvent(iEvent);
  //------ PVFitter 
  thePVFitter_->readEvent(iEvent);
  
  if(beamSpotsMap_.find("DB") != beamSpotsMap_.end()){
    //------ Tracks
    Handle<reco::TrackCollection> TrackCollection;
    iEvent.getByLabel(trackLabel_, TrackCollection);
    const reco::TrackCollection *tracks = TrackCollection.product();
    for ( reco::TrackCollection::const_iterator track = tracks->begin(); track != tracks->end(); ++track ) {    
      hD0Phi0_->Fill(track->phi(), -1*track->dxy(beamSpotsMap_["DB"].position()));
      hDxyBS_->Fill(-1*track->dxy(beamSpotsMap_["DB"].position()));
    }
  }
  
  //------ Primary Vertices
  Handle<VertexCollection > PVCollection;
  if (iEvent.getByLabel(primaryVertexLabel_, PVCollection )) {
    vertices_.push_back(*PVCollection.product());
  }

  if(beamSpotsMap_.find("SC") == beamSpotsMap_.end()){
    //BeamSpot from file for this stream is = to the scalar BeamSpot
    Handle<BeamSpot> recoBeamSpotHandle;
    try{
      iEvent.getByLabel(scalerLabel_,recoBeamSpotHandle);
    }
    catch( cms::Exception& exception ){                               
      LogInfo("AlcaBeamMonitor") 
      << exception.what(); 
      return;         
    }                                 
    beamSpotsMap_["SC"] = *recoBeamSpotHandle;
    if ( beamSpotsMap_["SC"].BeamWidthX() != 0 ) {
      beamSpotsMap_["SC"].setType( reco::BeamSpot::Tracker );
    } else{
      beamSpotsMap_["SC"].setType( reco::BeamSpot::Fake );
    }
  }
}
void AlcaBeamMonitor::beginJob ( void  ) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 117 of file AlcaBeamMonitor.cc.

References DQMStore::book1D(), DQMStore::bookProfile(), dbe_, histosMap_, monitorName_, mergeVDriftHistosByStation::name, numberOfValuesToSave_, MonitorElement::setAxisTitle(), DQMStore::setCurrentFolder(), MonitorElement::setLumiFlag(), theValuesContainer_, and indexGen::title.

                               {
  string name;
  string title;
  dbe_->setCurrentFolder(monitorName_+"Debug");
  for(HistosContainer::iterator itM=histosMap_.begin(); itM!=histosMap_.end(); itM++){
    for(map<string,MonitorElement*>::iterator itMM=itM->second["run"].begin(); itMM!=itM->second["run"].end(); itMM++){
      name = string("h") + itM->first + itMM->first;
      title = itM->first + "_{0} " + itMM->first;
      if(itM->first == "x" || itM->first == "y"){
        if(itMM->first == "Coordinate"){
          itMM->second = dbe_->book1D(name,title,1001,-0.2525,0.2525);
        }
        else if(itMM->first == "PrimaryVertex fit-DataBase" || itMM->first == "PrimaryVertex fit-BeamFit" || itMM->first == "PrimaryVertex fit-Scalers"
             || itMM->first == "PrimaryVertex-DataBase" || itMM->first == "PrimaryVertex-BeamFit" || itMM->first == "PrimaryVertex-Scalers"){
          itMM->second = dbe_->book1D(name,title,1001,-0.02525,0.02525);
        }
        else{
          //assert(0);
        }
      }
      else if(itM->first == "z"){
        if(itMM->first == "Coordinate"){
          itMM->second = dbe_->book1D(name,title,101,-5.05,5.05);
        }
        else if(itMM->first == "PrimaryVertex fit-DataBase" || itMM->first == "PrimaryVertex fit-BeamFit" || itMM->first == "PrimaryVertex fit-Scalers"){
          itMM->second = dbe_->book1D(name,title,101,-0.505,0.505);
        }
        else if(itMM->first == "PrimaryVertex-DataBase" || itMM->first == "PrimaryVertex-BeamFit" || itMM->first == "PrimaryVertex-Scalers"){
          itMM->second = dbe_->book1D(name,title,1001,-5.005,5.005);
        }
        else{
          //assert(0);
        }
      }
      else if(itM->first == "sigmaX" || itM->first == "sigmaY"){
        if(itMM->first == "Coordinate"){
          itMM->second = dbe_->book1D(name,title,100,0,0.015);
        }
        else if(itMM->first == "PrimaryVertex fit-DataBase" || itMM->first == "PrimaryVertex fit-BeamFit" || itMM->first == "PrimaryVertex fit-Scalers"
             || itMM->first == "PrimaryVertex-DataBase" || itMM->first == "PrimaryVertex-BeamFit" || itMM->first == "PrimaryVertex-Scalers"){
          itMM->second = 0;
        }
        else{
          //assert(0);
        }
      }
      else if(itM->first == "sigmaZ"){
        if(itMM->first == "Coordinate"){
          itMM->second = dbe_->book1D(name,title,110,0,11);
        }
        else if(itMM->first == "PrimaryVertex fit-DataBase" || itMM->first == "PrimaryVertex fit-BeamFit" || itMM->first == "PrimaryVertex fit-Scalers"
             || itMM->first == "PrimaryVertex-DataBase" || itMM->first == "PrimaryVertex-BeamFit" || itMM->first == "PrimaryVertex-Scalers"){
          itMM->second = dbe_->book1D(name,title,101,-5.05,5.05);
        }
        else{
          //assert(0);
        }
      }
      else{
        //assert(0);
      }
      if(itMM->second != 0){
        if(itMM->first == "Coordinate"){                                
          itMM->second->setAxisTitle(itM->first + "_{0} (cm)",1);  
        }
        else if(itMM->first == "PrimaryVertex fit-DataBase" || itMM->first == "PrimaryVertex fit-BeamFit" || itMM->first == "PrimaryVertex fit-Scalers"
             || itMM->first == "PrimaryVertex-DataBase" || itMM->first == "PrimaryVertex-BeamFit" || itMM->first == "PrimaryVertex-Scalers"){
          itMM->second->setAxisTitle(itMM->first + " " + itM->first + "_{0} (cm)",1);  
        }
        itMM->second->setAxisTitle("Entries",2);
      }         
    }
  }
  dbe_->setCurrentFolder(monitorName_+"Service");
  theValuesContainer_ = dbe_->bookProfile("hHistoLumiValues","Histo Lumi Values", 3*numberOfValuesToSave_, 0., 3*numberOfValuesToSave_, 100., -100., 9000., " ");
  theValuesContainer_->setLumiFlag();

}
void AlcaBeamMonitor::beginLuminosityBlock ( const edm::LuminosityBlock iLumi,
const edm::EventSetup iSetup 
) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 211 of file AlcaBeamMonitor.cc.

References align::BeamSpot, beamSpotsMap_, exception, reco::BeamSpot::Fake, edm::EventSetup::get(), BeamSpotObjects::GetBeamType(), BeamSpotObjects::GetBeamWidthX(), BeamSpotObjects::GetBeamWidthY(), BeamSpotObjects::GetBetaStar(), BeamSpotObjects::GetCovariance(), BeamSpotObjects::Getdxdz(), BeamSpotObjects::Getdydz(), BeamSpotObjects::GetEmittanceX(), BeamSpotObjects::GetEmittanceY(), BeamSpotObjects::GetSigmaZ(), BeamSpotObjects::GetX(), BeamSpotObjects::GetY(), BeamSpotObjects::GetZ(), i, edm::LuminosityBlockBase::id(), edm::ESHandleBase::isValid(), j, edm::LuminosityBlockID::luminosityBlock(), edm::ESHandle< T >::product(), MonitorElement::Reset(), reco::BeamSpot::setBeamWidthY(), theValuesContainer_, reco::BeamSpot::Tracker, vertices_, and cms::Exception::what().

                                                                                                 {
  // Always create a beamspot group for each lumi weather we have results or not! Each Beamspot will be of unknown type!
  
  vertices_.clear();
  theValuesContainer_->Reset();
  beamSpotsMap_.clear();
  
  //Read BeamSpot from DB
  ESHandle<BeamSpotObjects> bsDBHandle;
  try{
    iSetup.get<BeamSpotObjectsRcd>().get(bsDBHandle);
  }
  catch( cms::Exception& exception ){                                 
    LogInfo("AlcaBeamMonitor") 
      << exception.what(); 
    return;           
  }                                   
  if(bsDBHandle.isValid()) { // check the product
    const BeamSpotObjects *spotDB = bsDBHandle.product();

    // translate from BeamSpotObjects to reco::BeamSpot
    BeamSpot::Point apoint( spotDB->GetX(), spotDB->GetY(), spotDB->GetZ() );
  
    BeamSpot::CovarianceMatrix matrix;
    for ( int i=0; i<7; ++i ) {
      for ( int j=0; j<7; ++j ) {
        matrix(i,j) = spotDB->GetCovariance(i,j);
      }
    }
  
    beamSpotsMap_["DB"] = BeamSpot( apoint,
                                    spotDB->GetSigmaZ(),
                                    spotDB->Getdxdz(),
                                    spotDB->Getdydz(),
                                    spotDB->GetBeamWidthX(),
                                    matrix );

    BeamSpot* aSpot = &(beamSpotsMap_["DB"]);

    aSpot->setBeamWidthY( spotDB->GetBeamWidthY() );
    aSpot->setEmittanceX( spotDB->GetEmittanceX() );
    aSpot->setEmittanceY( spotDB->GetEmittanceY() );
    aSpot->setbetaStar( spotDB->GetBetaStar() );

    if ( spotDB->GetBeamType() == 2 ) {
      aSpot->setType( reco::BeamSpot::Tracker );
    } else{
      aSpot->setType( reco::BeamSpot::Fake );
    }
    //LogInfo("AlcaBeamMonitor")
    //  << *aSpot << std::endl;
  }
  else {
    LogInfo("AlcaBeamMonitor") 
      << "Database BeamSpot is not valid at lumi: " << iLumi.id().luminosityBlock(); 
  }
}
void AlcaBeamMonitor::beginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 197 of file AlcaBeamMonitor.cc.

References DQMStore::book1D(), DQMStore::bookProfile(), dbe_, hD0Phi0_, hDxyBS_, monitorName_, MonitorElement::setAxisTitle(), and DQMStore::setCurrentFolder().

                                                                         {
  // create and cd into new folder
  dbe_->setCurrentFolder(monitorName_+"Validation");
  //Book histograms
  hD0Phi0_ = dbe_->bookProfile("hD0Phi0","d_{0} vs. #phi_{0} (All Tracks)",63,-3.15,3.15,100,-0.1,0.1,"");
  hD0Phi0_->setAxisTitle("#phi_{0} (rad)",1);
  hD0Phi0_->setAxisTitle("d_{0} (cm)",2);

  dbe_->setCurrentFolder(monitorName_+"Debug");
  hDxyBS_ = dbe_->book1D("hDxyBS","dxy_{0} w.r.t. Beam spot (All Tracks)",100,-0.1,0.1);
  hDxyBS_->setAxisTitle("dxy_{0} w.r.t. Beam spot (cm)",1);
}
void AlcaBeamMonitor::endJob ( const edm::LuminosityBlock iLumi,
const edm::EventSetup iSetup 
) [protected]

Definition at line 562 of file AlcaBeamMonitor.cc.

                                                                                  {
}
void AlcaBeamMonitor::endLuminosityBlock ( const edm::LuminosityBlock iLumi,
const edm::EventSetup iSetup 
) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 316 of file AlcaBeamMonitor.cc.

References beamSpotsMap_, MonitorElement::Fill(), first, BeamFitter::getBeamSpot(), PVFitter::getBeamSpot(), MonitorElement::getTProfile(), trackerHits::histo, histoByCategoryNames_, histosMap_, position, positionsMap_, funct::pow(), PVFitter::resetAll(), BeamFitter::resetLSRange(), BeamFitter::resetPVFitter(), BeamFitter::resetRefTime(), BeamFitter::resetTrkVector(), PVFitter::runFitter(), BeamFitter::runPVandTrkFitter(), edm::second(), mathSSE::sqrt(), theBeamFitter_, thePVFitter_, theValuesContainer_, align::Tracker, varNamesV_, and vertices_.

                                                                                               {
  if (theBeamFitter_->runPVandTrkFitter()) {
    beamSpotsMap_["BF"] = theBeamFitter_->getBeamSpot();
  }
  theBeamFitter_->resetTrkVector();
  theBeamFitter_->resetLSRange();
  theBeamFitter_->resetRefTime();
  theBeamFitter_->resetPVFitter();

  if ( thePVFitter_->runFitter() ) {
    beamSpotsMap_["PV"] = thePVFitter_->getBeamSpot();
  }
  thePVFitter_->resetAll();

  //    "PV,BF..."      Value,Error
  map<std::string,pair<double,double> >   resultsMap;
  vector<pair<double,double> >  vertexResults;
  MonitorElement* histo=0;
  int position = 0;
  for(vector<string>::iterator itV=varNamesV_.begin(); itV!=varNamesV_.end(); itV++){
    resultsMap.clear();
    for(BeamSpotContainer::iterator itBS = beamSpotsMap_.begin(); itBS != beamSpotsMap_.end(); itBS++){
      if(itBS->second.type() == BeamSpot::Tracker){
        if(*itV == "x"){
          resultsMap[itBS->first] = pair<double,double>(itBS->second.x0(),itBS->second.x0Error());
        }
        else if(*itV == "y"){
          resultsMap[itBS->first] = pair<double,double>(itBS->second.y0(),itBS->second.y0Error());
        }
        else if(*itV == "z"){
          resultsMap[itBS->first] = pair<double,double>(itBS->second.z0(),itBS->second.z0Error());
        }
        else if(*itV == "sigmaX"){
          resultsMap[itBS->first] = pair<double,double>(itBS->second.BeamWidthX(),itBS->second.BeamWidthXError());
        }
        else if(*itV == "sigmaY"){
          resultsMap[itBS->first] = pair<double,double>(itBS->second.BeamWidthY(),itBS->second.BeamWidthYError());
        }
        else if(*itV == "sigmaZ"){
          resultsMap[itBS->first] = pair<double,double>(itBS->second.sigmaZ(),itBS->second.sigmaZ0Error());
        }
        else{
          LogInfo("AlcaBeamMonitor")
            << "The histosMap_ has been built with the name " << *itV << " that I can't recognize!";
          //assert(0);
        }
      }
    }
    vertexResults.clear();
    for(vector<VertexCollection>::iterator itPV = vertices_.begin(); itPV != vertices_.end(); itPV++){
      if(itPV->size() != 0){
        for(VertexCollection::const_iterator pv = itPV->begin(); pv != itPV->end(); pv++) {
          if (pv->isFake() || pv->tracksSize()<10)  continue;
          if(*itV == "x"){                                                                                    
            vertexResults.push_back(pair<double,double>(pv->x(),pv->xError()));       
          }                                                                                                           
          else if(*itV == "y"){                                                                               
            vertexResults.push_back(pair<double,double>(pv->y(),pv->yError()));       
          }                                                                                                           
          else if(*itV == "z"){                                                                               
            vertexResults.push_back(pair<double,double>(pv->z(),pv->zError()));       
          }                                                                                                           
          else if(*itV != "sigmaX" && *itV != "sigmaY" && *itV != "sigmaZ"){                  
            LogInfo("AlcaBeamMonitor")                                                                                
              << "The histosMap_ has been built with the name " << *itV << " that I can't recognize!";
            //assert(0);                                                                                              
          }                                                                                                           
        }
      }
    }
/*
  histoByCategoryNames_.insert( pair<string,string>("run",        "Coordinate"));
  histoByCategoryNames_.insert( pair<string,string>("run",        "PrimaryVertex fit-DataBase"));
  histoByCategoryNames_.insert( pair<string,string>("run",        "PrimaryVertex fit-BeamFit"));
  histoByCategoryNames_.insert( pair<string,string>("run",        "PrimaryVertex fit-Scalers"));
  histoByCategoryNames_.insert( pair<string,string>("run",        "PrimaryVertex-DataBase"));
  histoByCategoryNames_.insert( pair<string,string>("run",        "PrimaryVertex-BeamFit"));
  histoByCategoryNames_.insert( pair<string,string>("run",        "PrimaryVertex-Scalers"));

  histoByCategoryNames_.insert( pair<string,string>("lumi",       "Lumibased BeamSpotFit"));  
  histoByCategoryNames_.insert( pair<string,string>("lumi",       "Lumibased PrimaryVertex"));
  histoByCategoryNames_.insert( pair<string,string>("lumi",       "Lumibased DataBase"));     
  histoByCategoryNames_.insert( pair<string,string>("lumi",       "Lumibased Scalers"));      
  histoByCategoryNames_.insert( pair<string,string>("lumi",       "Lumibased PrimaryVertex-DataBase fit"));
  histoByCategoryNames_.insert( pair<string,string>("lumi",       "Lumibased PrimaryVertex-Scalers fit"));
  histoByCategoryNames_.insert( pair<string,string>("validation", "Lumibased Scalers-DataBase fit"));
  histoByCategoryNames_.insert( pair<string,string>("validation", "Lumibased PrimaryVertex-DataBase"));
  histoByCategoryNames_.insert( pair<string,string>("validation", "Lumibased PrimaryVertex-Scalers"));
*/
    for(multimap<string,string>::iterator itM=histoByCategoryNames_.begin(); itM!=histoByCategoryNames_.end(); itM++){
      if(itM->first == "run" && (histo = histosMap_[*itV][itM->first][itM->second]) == 0){
        continue;
      }
      else if(itM->first != "run"){
        position = positionsMap_[*itV][itM->first][itM->second];
      }
      if(itM->second == "Coordinate"){
        if(beamSpotsMap_.find("DB") != beamSpotsMap_.end()){
          histo->Fill(resultsMap["DB"].first);
        }
      }
      else if(itM->second == "PrimaryVertex fit-DataBase"){
        if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("DB") != resultsMap.end()){
          histo->Fill(resultsMap["PV"].first-resultsMap["DB"].first);
        }
      }
      else if(itM->second == "PrimaryVertex fit-BeamFit"){
        if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("BF") != resultsMap.end()){
          histo->Fill(resultsMap["PV"].first-resultsMap["BF"].first);
        }
      }
      else if(itM->second == "PrimaryVertex fit-Scalers"){
        if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("SC") != resultsMap.end()){
          histo->Fill(resultsMap["PV"].first-resultsMap["SC"].first);
        }
      }
      else if(itM->second == "PrimaryVertex-DataBase"){
        if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("DB") != resultsMap.end()){
          for(vector<pair<double,double> >::iterator itPV=vertexResults.begin(); itPV!=vertexResults.end(); itPV++){
            histo->Fill(itPV->first-resultsMap["DB"].first);
          }
        }
      }
      else if(itM->second == "PrimaryVertex-BeamFit"){
        if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("BF") != resultsMap.end()){
          for(vector<pair<double,double> >::iterator itPV=vertexResults.begin(); itPV!=vertexResults.end(); itPV++){
            histo->Fill(itPV->first-resultsMap["BF"].first);
          }
        }
      }
      else if(itM->second == "PrimaryVertex-Scalers"){
        if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("SC") != resultsMap.end()){
          for(vector<pair<double,double> >::iterator itPV=vertexResults.begin(); itPV!=vertexResults.end(); itPV++){
            histo->Fill(itPV->first-resultsMap["SC"].first);
          }
        }
      }
      else if(itM->second == "Lumibased BeamSpotFit"){
        if(resultsMap.find("BF") != resultsMap.end()){
          theValuesContainer_->Fill(position  ,resultsMap["BF"].first);//Value
          theValuesContainer_->Fill(position+1,resultsMap["BF"].second);//Error
          theValuesContainer_->Fill(position+2,1);//ok
        }
      }
      else if(itM->second == "Lumibased PrimaryVertex"){
        if(resultsMap.find("PV") != resultsMap.end()){
          theValuesContainer_->Fill(position  ,resultsMap["PV"].first);//Value
          theValuesContainer_->Fill(position+1,resultsMap["PV"].second);//Error
          theValuesContainer_->Fill(position+2,1);//ok
        }
      }
      else if(itM->second == "Lumibased DataBase"){
        if(resultsMap.find("DB") != resultsMap.end()){
          theValuesContainer_->Fill(position  ,resultsMap["DB"].first);//Value
          theValuesContainer_->Fill(position+1,resultsMap["DB"].second);//Error           
          theValuesContainer_->Fill(position+2,1);//ok
        }
      }
      else if(itM->second == "Lumibased Scalers"){
        if(resultsMap.find("SC") != resultsMap.end()){
          theValuesContainer_->Fill(position  ,resultsMap["SC"].first);//Value
          theValuesContainer_->Fill(position+1,resultsMap["SC"].second);//Error           
          theValuesContainer_->Fill(position+2,1);//ok
        }
      }
      else if(itM->second == "Lumibased PrimaryVertex-DataBase fit"){
        if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("DB") != resultsMap.end()){
          theValuesContainer_->Fill(position  ,resultsMap["PV"].first-resultsMap["DB"].first);//Value
          theValuesContainer_->Fill(position+1,std::sqrt(std::pow(resultsMap["PV"].second,2)+std::pow(resultsMap["DB"].second,2)));//Error        
          theValuesContainer_->Fill(position+2,1);//ok
        }
      }
      else if(itM->second == "Lumibased PrimaryVertex-Scalers fit"){
        if(resultsMap.find("PV") != resultsMap.end() && resultsMap.find("SC") != resultsMap.end()){
          theValuesContainer_->Fill(position  ,resultsMap["PV"].first-resultsMap["SC"].first);//Value
          theValuesContainer_->Fill(position+1,std::sqrt(std::pow(resultsMap["PV"].second,2)+std::pow(resultsMap["SC"].second,2)));//Error        
          theValuesContainer_->Fill(position+2,1);//ok
        }
      }
      else if(itM->second == "Lumibased Scalers-DataBase fit"){
        if(resultsMap.find("SC") != resultsMap.end() && resultsMap.find("DB") != resultsMap.end()){
          theValuesContainer_->Fill(position  ,resultsMap["SC"].first-resultsMap["DB"].first);//Value
          theValuesContainer_->Fill(position+1,std::sqrt(std::pow(resultsMap["SC"].second,2)+std::pow(resultsMap["DB"].second,2)));//Error        
          theValuesContainer_->Fill(position+2,1);//ok
        }
      }
      else if(itM->second == "Lumibased PrimaryVertex-DataBase"){
        if(resultsMap.find("DB") != resultsMap.end() && vertexResults.size() != 0){
          for(vector<pair<double,double> >::iterator itPV=vertexResults.begin(); itPV!=vertexResults.end(); itPV++){
            theValuesContainer_->Fill(position  ,(*itPV).first-resultsMap["DB"].first);//Value
          }
/*
          double error = 0;
          if(vertexResults.size() != 0){
            for(vector<pair<double,double> >::iterator itPV=vertexResults.begin(); itPV!=vertexResults.end(); itPV++){
              error += std::pow((*itPV).first-resultsMap["DB"].first-theValuesContainer_->getTProfile()->GetBinContent(position+1),2.);
            }
            error = std::sqrt(error)/vertexResults.size();
          }
//          theValuesContainer_->Fill(position+1,std::sqrt(std::pow((*itPV).second,2)+std::pow(resultsMap["DB"].second,2)));//Error       
          theValuesContainer_->Fill(position+1,error);//Error     
*/
          theValuesContainer_->Fill(position+1,theValuesContainer_->getTProfile()->GetBinError(position+1));//Error       
          theValuesContainer_->Fill(position+2,1);//ok
        }
      }
      else if(itM->second == "Lumibased PrimaryVertex-Scalers"){
        if(resultsMap.find("SC") != resultsMap.end() && vertexResults.size() != 0){
          for(vector<pair<double,double> >::iterator itPV=vertexResults.begin(); itPV!=vertexResults.end(); itPV++){
            theValuesContainer_->Fill(position  ,(*itPV).first-resultsMap["SC"].first);//Value
          }
/*
          double error = 0;
          if(vertexResults.size() != 0){
            for(vector<pair<double,double> >::iterator itPV=vertexResults.begin(); itPV!=vertexResults.end(); itPV++){
              error += std::pow((*itPV).first-resultsMap["SC"].first-theValuesContainer_->getTProfile()->GetBinContent(position+1),2.);
            }
            error = std::sqrt(error)/vertexResults.size();
          }
//          theValuesContainer_->Fill(position+1,std::sqrt(std::pow((*itPV).second,2)+std::pow(resultsMap["SC"].second,2)));//Error       
          theValuesContainer_->Fill(position+1,error);//Error     
*/
          theValuesContainer_->Fill(position+1,theValuesContainer_->getTProfile()->GetBinError(position+1));//Error       
          theValuesContainer_->Fill(position+2,1);//ok
        }
      }
//      else if(itM->second == "Lumibased Scalers-DataBase"){
//      if(resultsMap.find("SC") != resultsMap.end() && resultsMap.find("DB") != resultsMap.end()){
//        itHHH->second->Fill(bin,resultsMap["SC"].first-resultsMap["DB"].first);
//      }
//    }
      else{
        LogInfo("AlcaBeamMonitor")
          << "The histosMap_ have a histogram named " << itM->second << " that I can't recognize in this loop!";
        //assert(0);

      }
    }
  }
}
void AlcaBeamMonitor::endRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 558 of file AlcaBeamMonitor.cc.

                                                                      {
}

Member Data Documentation

Definition at line 58 of file AlcaBeamMonitor.h.

Definition at line 74 of file AlcaBeamMonitor.h.

Referenced by analyze(), beginLuminosityBlock(), and endLuminosityBlock().

Definition at line 64 of file AlcaBeamMonitor.h.

Referenced by AlcaBeamMonitor(), beginJob(), and beginRun().

Definition at line 69 of file AlcaBeamMonitor.h.

Referenced by analyze(), and beginRun().

Definition at line 70 of file AlcaBeamMonitor.h.

Referenced by analyze(), and beginRun().

std::multimap<std::string,std::string> AlcaBeamMonitor::histoByCategoryNames_ [private]

Definition at line 78 of file AlcaBeamMonitor.h.

Referenced by AlcaBeamMonitor(), and endLuminosityBlock().

Definition at line 75 of file AlcaBeamMonitor.h.

Referenced by AlcaBeamMonitor(), beginJob(), and endLuminosityBlock().

std::string AlcaBeamMonitor::monitorName_ [private]

Definition at line 56 of file AlcaBeamMonitor.h.

Referenced by AlcaBeamMonitor(), beginJob(), and beginRun().

Definition at line 63 of file AlcaBeamMonitor.h.

Referenced by AlcaBeamMonitor(), and beginJob().

Definition at line 55 of file AlcaBeamMonitor.h.

Referenced by AlcaBeamMonitor().

Definition at line 76 of file AlcaBeamMonitor.h.

Referenced by AlcaBeamMonitor(), and endLuminosityBlock().

Definition at line 57 of file AlcaBeamMonitor.h.

Referenced by analyze().

Definition at line 60 of file AlcaBeamMonitor.h.

Referenced by analyze().

Definition at line 65 of file AlcaBeamMonitor.h.

Referenced by AlcaBeamMonitor(), analyze(), endLuminosityBlock(), and ~AlcaBeamMonitor().

Definition at line 66 of file AlcaBeamMonitor.h.

Referenced by AlcaBeamMonitor(), analyze(), endLuminosityBlock(), and ~AlcaBeamMonitor().

Definition at line 71 of file AlcaBeamMonitor.h.

Referenced by beginJob(), beginLuminosityBlock(), and endLuminosityBlock().

Definition at line 59 of file AlcaBeamMonitor.h.

Referenced by analyze().

std::vector<std::string> AlcaBeamMonitor::varNamesV_ [private]

Definition at line 77 of file AlcaBeamMonitor.h.

Referenced by AlcaBeamMonitor(), and endLuminosityBlock().

Definition at line 79 of file AlcaBeamMonitor.h.

Referenced by analyze(), beginLuminosityBlock(), and endLuminosityBlock().