CMS 3D CMS Logo

Public Member Functions | Private Attributes

AlcaBeamSpotHarvester Class Reference

#include <AlcaBeamSpotHarvester.h>

Inheritance diagram for AlcaBeamSpotHarvester:
edm::EDAnalyzer

List of all members.

Public Member Functions

 AlcaBeamSpotHarvester (const edm::ParameterSet &)
 Constructor.
virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginJob (void)
virtual void beginLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &)
virtual void beginRun (const edm::Run &, const edm::EventSetup &)
virtual void endJob (void)
virtual void endLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &)
virtual void endRun (const edm::Run &, const edm::EventSetup &)
virtual ~AlcaBeamSpotHarvester ()
 Destructor.

Private Attributes

std::string beamSpotOutputBase_
std::string outputrecordName_
double sigmaZValue_
AlcaBeamSpotManager theAlcaBeamSpotManager_

Detailed Description

No description available.

Date:
2011/02/16 12:40:30
Revision:
1.6
Author:
L. Uplegger F. Yumiceva - Fermilab

Definition at line 17 of file AlcaBeamSpotHarvester.h.


Constructor & Destructor Documentation

AlcaBeamSpotHarvester::AlcaBeamSpotHarvester ( const edm::ParameterSet iConfig)

Constructor.

Definition at line 38 of file AlcaBeamSpotHarvester.cc.

                                                                           :
  beamSpotOutputBase_    (iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters").getUntrackedParameter<std::string>("BeamSpotOutputBase")),
  outputrecordName_      (iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters").getUntrackedParameter<std::string>("outputRecordName", "BeamSpotObjectsRcd")),
  sigmaZValue_           (iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters").getUntrackedParameter<double>("SigmaZValue")),
  theAlcaBeamSpotManager_(iConfig) {  
}
AlcaBeamSpotHarvester::~AlcaBeamSpotHarvester ( ) [virtual]

Destructor.

Definition at line 46 of file AlcaBeamSpotHarvester.cc.

{}

Member Function Documentation

void AlcaBeamSpotHarvester::analyze ( const edm::Event iEvent,
const edm::EventSetup  
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 55 of file AlcaBeamSpotHarvester.cc.

                                                                                {
//  edm::LogInfo("AlcaBeamSpotHarvester")
//      << "Lumi: " << iEvent.luminosityBlock() 
//      << " Time: " << iEvent.time().unixTime() 
//      << std::endl;
}
void AlcaBeamSpotHarvester::beginJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 49 of file AlcaBeamSpotHarvester.cc.

{}
void AlcaBeamSpotHarvester::beginLuminosityBlock ( const edm::LuminosityBlock ,
const edm::EventSetup  
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 161 of file AlcaBeamSpotHarvester.cc.

{}
void AlcaBeamSpotHarvester::beginRun ( const edm::Run ,
const edm::EventSetup  
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 63 of file AlcaBeamSpotHarvester.cc.

References AlcaBeamSpotManager::reset(), and theAlcaBeamSpotManager_.

void AlcaBeamSpotHarvester::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 52 of file AlcaBeamSpotHarvester.cc.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 164 of file AlcaBeamSpotHarvester.cc.

References AlcaBeamSpotManager::readLumi(), and theAlcaBeamSpotManager_.

void AlcaBeamSpotHarvester::endRun ( const edm::Run iRun,
const edm::EventSetup  
) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 68 of file AlcaBeamSpotHarvester.cc.

References beamSpotOutputBase_, AlcaBeamSpotManager::createWeightedPayloads(), AlcaBeamSpotManager::getPayloads(), i, edm::RunBase::id(), edm::Service< T >::isAvailable(), j, outputrecordName_, edm::RunID::run(), BeamSpotObjects::SetBeamWidthX(), BeamSpotObjects::SetBeamWidthY(), BeamSpotObjects::SetBetaStar(), BeamSpotObjects::SetCovariance(), BeamSpotObjects::Setdxdz(), BeamSpotObjects::Setdydz(), BeamSpotObjects::SetEmittanceX(), BeamSpotObjects::SetEmittanceY(), BeamSpotObjects::SetPosition(), BeamSpotObjects::SetSigmaZ(), BeamSpotObjects::SetType(), sigmaZValue_, and theAlcaBeamSpotManager_.

                                                                          {
  theAlcaBeamSpotManager_.createWeightedPayloads();
  std::map<edm::LuminosityBlockNumber_t,reco::BeamSpot> beamSpotMap = theAlcaBeamSpotManager_.getPayloads();
  Service<cond::service::PoolDBOutputService> poolDbService;
//  cond::ExportIOVUtilities utilities;
  if(poolDbService.isAvailable() ) {
    for(AlcaBeamSpotManager::bsMap_iterator it=beamSpotMap.begin(); it!=beamSpotMap.end();it++){
      BeamSpotObjects *aBeamSpot = new BeamSpotObjects();
      aBeamSpot->SetType(it->second.type());
      aBeamSpot->SetPosition(it->second.x0(),it->second.y0(),it->second.z0());
      if(sigmaZValue_ == -1){
        aBeamSpot->SetSigmaZ(it->second.sigmaZ());
      }
      else{
        aBeamSpot->SetSigmaZ(sigmaZValue_);
      }
      aBeamSpot->Setdxdz(it->second.dxdz());
      aBeamSpot->Setdydz(it->second.dydz());
      aBeamSpot->SetBeamWidthX(it->second.BeamWidthX());
      aBeamSpot->SetBeamWidthY(it->second.BeamWidthY());
      aBeamSpot->SetEmittanceX(it->second.emittanceX());
      aBeamSpot->SetEmittanceY(it->second.emittanceY());
      aBeamSpot->SetBetaStar(it->second.betaStar() );
        
      for (int i=0; i<7; ++i) {
        for (int j=0; j<7; ++j) {
          aBeamSpot->SetCovariance(i,j,it->second.covariance(i,j));
        }
      }

      if(sigmaZValue_ > 0){
        aBeamSpot->SetCovariance(3,3,0.000025);
      }

      cond::Time_t thisIOV = 1;



      // run based      
      if (beamSpotOutputBase_ == "runbased" ) {
        thisIOV = (cond::Time_t) iRun.id().run();
      }
      // lumi based
      else if (beamSpotOutputBase_ == "lumibased" ) {
        edm::LuminosityBlockID lu(iRun.id().run(),it->first);
        thisIOV = (cond::Time_t)(lu.value()); 
      }
      if (poolDbService->isNewTagRequest(outputrecordName_) ) {
          edm::LogInfo("AlcaBeamSpotHarvester")
              << "new tag requested" << std::endl;
          //poolDbService->createNewIOV<BeamSpotObjects>(aBeamSpot, poolDbService->beginOfTime(),poolDbService->endOfTime(),"BeamSpotObjectsRcd");
          
          //poolDbService->createNewIOV<BeamSpotObjects>(aBeamSpot, poolDbService->currentTime(), poolDbService->endOfTime(),"BeamSpotObjectsRcd");
          poolDbService->writeOne<BeamSpotObjects>(aBeamSpot, thisIOV, outputrecordName_);
      } 
      else {
        edm::LogInfo("AlcaBeamSpotHarvester")
            << "no new tag requested, appending IOV" << std::endl;
        //poolDbService->appendSinceTime<BeamSpotObjects>(aBeamSpot, poolDbService->currentTime(),"BeamSpotObjectsRcd");
        poolDbService->writeOne<BeamSpotObjects>(aBeamSpot, thisIOV, outputrecordName_);
      }




/*
      int         argc = 15;
      const char* argv[] = {"endRun"
                           ,"-d","sqlite_file:combined.db"
                           ,"-s","sqlite_file:testbs2.db"
                           ,"-l","sqlite_file:log.db"
                           ,"-i","TestLSBasedBS"
                           ,"-t","TestLSBasedBS"
                           ,"-b","1"
                           ,"-e","10"
                           };
      
      edm::LogInfo("AlcaBeamSpotHarvester")
        << "Running utilities!" 
        << utilities.run(argc,(char**)argv);
      edm::LogInfo("AlcaBeamSpotHarvester")
        << "Run utilities!" 
        << std::endl;
*/
    }




  }
}

Member Data Documentation

Definition at line 38 of file AlcaBeamSpotHarvester.h.

Referenced by endRun().

Definition at line 39 of file AlcaBeamSpotHarvester.h.

Referenced by endRun().

Definition at line 40 of file AlcaBeamSpotHarvester.h.

Referenced by endRun().

Definition at line 43 of file AlcaBeamSpotHarvester.h.

Referenced by beginRun(), endLuminosityBlock(), and endRun().