#include <BeamSpotAnalyzer.h>
Public Member Functions | |
BeamSpotAnalyzer (const edm::ParameterSet &) | |
~BeamSpotAnalyzer () | |
Private Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
virtual void | beginJob () |
virtual void | beginLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context) |
virtual void | endJob () |
virtual void | endLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) |
Private Attributes | |
int | beginLumiOfBSFit_ |
int | countEvt_ |
int | countLumi_ |
int | endLumiOfBSFit_ |
int | fitNLumi_ |
int | ftmprun |
int | ftmprun0 |
int | ftotalevents |
double | inputBeamWidth_ |
int | Org_resetFitNLumi_ |
int | previousLumi_ |
int | previousRun_ |
std::time_t | refBStime [2] |
int | resetFitNLumi_ |
bool | runallfitters_ |
bool | runbeamwidthfit_ |
BeamFitter * | theBeamFitter |
bool | write2DB_ |
_________________________________________________________________ class: BeamSpotAnalyzer.h package: RecoVertex/BeamSpotProducer
author: Francisco Yumiceva, Fermilab (yumiceva@fnal.gov)
version
________________________________________________________________
Definition at line 27 of file BeamSpotAnalyzer.h.
BeamSpotAnalyzer::BeamSpotAnalyzer | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
_________________________________________________________________ class: BeamSpotAnalyzer.cc package: RecoVertex/BeamSpotProducer
author: Francisco Yumiceva, Fermilab (yumiceva@fnal.gov) Geng-Yuan Jeng, UC Riverside (Geng-Yuan.Jeng@cern.ch)
version
________________________________________________________________
Definition at line 28 of file BeamSpotAnalyzer.cc.
References beginLumiOfBSFit_, countLumi_, endLumiOfBSFit_, fitNLumi_, ftmprun, ftmprun0, ftotalevents, edm::ParameterSet::getParameter(), Org_resetFitNLumi_, previousLumi_, previousRun_, BeamFitter::resetCutFlow(), resetFitNLumi_, BeamFitter::resetLSRange(), BeamFitter::resetPVFitter(), BeamFitter::resetRefTime(), BeamFitter::resetTrkVector(), runallfitters_, runbeamwidthfit_, theBeamFitter, and write2DB_.
{ // get parameter write2DB_ = iConfig.getParameter<edm::ParameterSet>("BSAnalyzerParameters").getParameter<bool>("WriteToDB"); runallfitters_ = iConfig.getParameter<edm::ParameterSet>("BSAnalyzerParameters").getParameter<bool>("RunAllFitters"); fitNLumi_ = iConfig.getParameter<edm::ParameterSet>("BSAnalyzerParameters").getUntrackedParameter<int>("fitEveryNLumi",-1); resetFitNLumi_ = iConfig.getParameter<edm::ParameterSet>("BSAnalyzerParameters").getUntrackedParameter<int>("resetEveryNLumi",-1); runbeamwidthfit_ = iConfig.getParameter<edm::ParameterSet>("BSAnalyzerParameters").getParameter<bool>("RunBeamWidthFit"); theBeamFitter = new BeamFitter(iConfig); theBeamFitter->resetTrkVector(); theBeamFitter->resetLSRange(); theBeamFitter->resetCutFlow(); theBeamFitter->resetRefTime(); theBeamFitter->resetPVFitter(); ftotalevents = 0; ftmprun0 = ftmprun = -1; countLumi_ = 0; beginLumiOfBSFit_ = endLumiOfBSFit_ = -1; previousLumi_ = previousRun_ = 0; Org_resetFitNLumi_ = resetFitNLumi_; }
BeamSpotAnalyzer::~BeamSpotAnalyzer | ( | ) |
Definition at line 53 of file BeamSpotAnalyzer.cc.
References theBeamFitter.
{ delete theBeamFitter; }
void BeamSpotAnalyzer::analyze | ( | const edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Implements edm::EDAnalyzer.
Definition at line 60 of file BeamSpotAnalyzer.cc.
References ftmprun, ftotalevents, edm::EventBase::id(), BeamFitter::readEvent(), edm::EventID::run(), and theBeamFitter.
{ ftotalevents++; theBeamFitter->readEvent(iEvent); ftmprun = iEvent.id().run(); }
void BeamSpotAnalyzer::beginJob | ( | void | ) | [private, virtual] |
void BeamSpotAnalyzer::beginLuminosityBlock | ( | const edm::LuminosityBlock & | lumiSeg, |
const edm::EventSetup & | context | ||
) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 77 of file BeamSpotAnalyzer.cc.
References beginLumiOfBSFit_, edm::LuminosityBlockBase::beginTime(), countLumi_, ftmprun, ftmprun0, edm::LuminosityBlockBase::luminosityBlock(), previousLumi_, previousRun_, refBStime, resetFitNLumi_, and edm::LuminosityBlockBase::run().
{ const edm::TimeValue_t fbegintimestamp = lumiSeg.beginTime().value(); const std::time_t ftmptime = fbegintimestamp >> 32; if ( countLumi_ == 0 || (resetFitNLumi_ > 0 && countLumi_%resetFitNLumi_ == 0) ) { ftmprun0 = lumiSeg.run(); ftmprun = ftmprun0; beginLumiOfBSFit_ = lumiSeg.luminosityBlock(); refBStime[0] = ftmptime; } countLumi_++; //std::cout << "Lumi # " << countLumi_ << std::endl; if ( ftmprun == previousRun_ ) { if ( (previousLumi_ + 1) != int(lumiSeg.luminosityBlock()) ) edm::LogWarning("BeamSpotAnalyzer") << "LUMI SECTIONS ARE NOT SORTED!"; } }
void BeamSpotAnalyzer::endJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 170 of file BeamSpotAnalyzer.cc.
References countLumi_, gather_cfg::cout, fitNLumi_, ftmprun, ftmprun0, ftotalevents, BeamFitter::getBeamSpot(), BeamFitter::getBeamWidth(), BeamFitter::getFitLSRange(), resetFitNLumi_, BeamFitter::runAllFitter(), runallfitters_, runbeamwidthfit_, BeamFitter::runBeamWidthFitter(), BeamFitter::runPVandTrkFitter(), theBeamFitter, BeamFitter::write2DB(), and write2DB_.
{ std::cout << "\n-------------------------------------\n" << std::endl; std::cout << "\n Total number of events processed: "<< ftotalevents << std::endl; std::cout << "\n-------------------------------------\n\n" << std::endl; if ( fitNLumi_ == -1 && resetFitNLumi_ == -1 ) { if(theBeamFitter->runPVandTrkFitter()){ reco::BeamSpot beam_default = theBeamFitter->getBeamSpot(); std::pair<int,int> LSRange = theBeamFitter->getFitLSRange(); std::cout << "\n RESULTS OF DEFAULT FIT:" << std::endl; std::cout << " for runs: " << ftmprun0 << " - " << ftmprun << std::endl; std::cout << " for lumi blocks : " << LSRange.first << " - " << LSRange.second << std::endl; std::cout << " lumi counter # " << countLumi_ << std::endl; std::cout << beam_default << std::endl; if (write2DB_) { std::cout << "\n-------------------------------------\n\n" << std::endl; std::cout << " write results to DB..." << std::endl; theBeamFitter->write2DB(); } if (runallfitters_) { theBeamFitter->runAllFitter(); } } if ((runbeamwidthfit_)){ theBeamFitter->runBeamWidthFitter(); reco::BeamSpot beam_width = theBeamFitter->getBeamWidth(); std::cout <<beam_width<< std::endl; } else std::cout << "[BeamSpotAnalyzer] beamfit fails !!!" << std::endl; } std::cout << "[BeamSpotAnalyzer] endJob done \n" << std::endl; }
void BeamSpotAnalyzer::endLuminosityBlock | ( | const edm::LuminosityBlock & | lumiSeg, |
const edm::EventSetup & | c | ||
) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 100 of file BeamSpotAnalyzer.cc.
References beginLumiOfBSFit_, countLumi_, gather_cfg::cout, endLumiOfBSFit_, edm::LuminosityBlockBase::endTime(), reco::BeamSpot::Fake, fitNLumi_, ftmprun, ftmprun0, BeamFitter::getBeamSpot(), BeamFitter::getBSvector(), BeamFitter::getFitLSRange(), BeamFitter::getNPVs(), BeamFitter::getNTracks(), edm::LuminosityBlockBase::luminosityBlock(), Org_resetFitNLumi_, previousLumi_, refBStime, BeamFitter::resetCutFlow(), resetFitNLumi_, BeamFitter::resetLSRange(), BeamFitter::resetPVFitter(), BeamFitter::resetRefTime(), BeamFitter::resetTrkVector(), BeamFitter::runPVandTrkFitter(), BeamFitter::setFitLSRange(), BeamFitter::setRefTime(), BeamFitter::setRun(), reco::BeamSpot::setType(), and theBeamFitter.
{ //LogDebug("BeamSpotAnalyzer") << std::cout << "for lumis "<< beginLumiOfBSFit_ << " - " << endLumiOfBSFit_ << std::endl << "number of selected tracks = " << theBeamFitter->getNTracks() << std::endl; std::cout << "number of selected PVs = " << theBeamFitter->getNPVs() << std::endl; //std::cout << "number of selected PVs per bx: " << std::endl; //theBeamFitter->getNPVsperBX(); const edm::TimeValue_t fendtimestamp = lumiSeg.endTime().value(); const std::time_t fendtime = fendtimestamp >> 32; refBStime[1] = fendtime; endLumiOfBSFit_ = lumiSeg.luminosityBlock(); previousLumi_ = endLumiOfBSFit_; if ( fitNLumi_ == -1 && resetFitNLumi_ == -1 ) return; if (fitNLumi_ > 0 && countLumi_%fitNLumi_!=0) return; theBeamFitter->setFitLSRange(beginLumiOfBSFit_,endLumiOfBSFit_); theBeamFitter->setRefTime(refBStime[0],refBStime[1]); theBeamFitter->setRun(ftmprun0); std::pair<int,int> LSRange = theBeamFitter->getFitLSRange(); if (theBeamFitter->runPVandTrkFitter()){ reco::BeamSpot bs = theBeamFitter->getBeamSpot(); std::cout << "\n RESULTS OF DEFAULT FIT " << std::endl; std::cout << " for runs: " << ftmprun0 << " - " << ftmprun << std::endl; std::cout << " for lumi blocks : " << LSRange.first << " - " << LSRange.second << std::endl; std::cout << " lumi counter # " << countLumi_ << std::endl; std::cout << bs << std::endl; std::cout << "[BeamFitter] fit done. \n" << std::endl; } else { // Fill in empty beam spot if beamfit fails reco::BeamSpot bs; bs.setType(reco::BeamSpot::Fake); std::cout << "\n Empty Beam spot fit" << std::endl; std::cout << " for runs: " << ftmprun0 << " - " << ftmprun << std::endl; std::cout << " for lumi blocks : " << LSRange.first << " - " << LSRange.second << std::endl; std::cout << " lumi counter # " << countLumi_ << std::endl; std::cout << bs << std::endl; std::cout << "[BeamFitter] fit failed \n" << std::endl; //accumulate more events // dissable this for the moment //resetFitNLumi_ += 1; //std::cout << "reset fitNLumi " << resetFitNLumi_ << std::endl; } if (resetFitNLumi_ > 0 && countLumi_%resetFitNLumi_ == 0) { std::vector<BSTrkParameters> theBSvector = theBeamFitter->getBSvector(); std::cout << "Total number of tracks accumulated = " << theBSvector.size() << std::endl; std::cout << "Reset track collection for beam fit" <<std::endl; theBeamFitter->resetTrkVector(); theBeamFitter->resetLSRange(); theBeamFitter->resetCutFlow(); theBeamFitter->resetRefTime(); theBeamFitter->resetPVFitter(); countLumi_=0; // reset counter to orginal resetFitNLumi_ = Org_resetFitNLumi_; } }
int BeamSpotAnalyzer::beginLumiOfBSFit_ [private] |
Definition at line 50 of file BeamSpotAnalyzer.h.
Referenced by BeamSpotAnalyzer(), beginLuminosityBlock(), and endLuminosityBlock().
int BeamSpotAnalyzer::countEvt_ [private] |
Definition at line 44 of file BeamSpotAnalyzer.h.
int BeamSpotAnalyzer::countLumi_ [private] |
Definition at line 45 of file BeamSpotAnalyzer.h.
Referenced by BeamSpotAnalyzer(), beginLuminosityBlock(), endJob(), and endLuminosityBlock().
int BeamSpotAnalyzer::endLumiOfBSFit_ [private] |
Definition at line 51 of file BeamSpotAnalyzer.h.
Referenced by BeamSpotAnalyzer(), and endLuminosityBlock().
int BeamSpotAnalyzer::fitNLumi_ [private] |
Definition at line 42 of file BeamSpotAnalyzer.h.
Referenced by BeamSpotAnalyzer(), endJob(), and endLuminosityBlock().
int BeamSpotAnalyzer::ftmprun [private] |
Definition at line 49 of file BeamSpotAnalyzer.h.
Referenced by analyze(), BeamSpotAnalyzer(), beginLuminosityBlock(), endJob(), and endLuminosityBlock().
int BeamSpotAnalyzer::ftmprun0 [private] |
Definition at line 49 of file BeamSpotAnalyzer.h.
Referenced by BeamSpotAnalyzer(), beginLuminosityBlock(), endJob(), and endLuminosityBlock().
int BeamSpotAnalyzer::ftotalevents [private] |
Definition at line 41 of file BeamSpotAnalyzer.h.
Referenced by analyze(), BeamSpotAnalyzer(), and endJob().
double BeamSpotAnalyzer::inputBeamWidth_ [private] |
Definition at line 57 of file BeamSpotAnalyzer.h.
int BeamSpotAnalyzer::Org_resetFitNLumi_ [private] |
Definition at line 46 of file BeamSpotAnalyzer.h.
Referenced by BeamSpotAnalyzer(), and endLuminosityBlock().
int BeamSpotAnalyzer::previousLumi_ [private] |
Definition at line 47 of file BeamSpotAnalyzer.h.
Referenced by BeamSpotAnalyzer(), beginLuminosityBlock(), and endLuminosityBlock().
int BeamSpotAnalyzer::previousRun_ [private] |
Definition at line 48 of file BeamSpotAnalyzer.h.
Referenced by BeamSpotAnalyzer(), and beginLuminosityBlock().
std::time_t BeamSpotAnalyzer::refBStime[2] [private] |
Definition at line 52 of file BeamSpotAnalyzer.h.
Referenced by beginLuminosityBlock(), and endLuminosityBlock().
int BeamSpotAnalyzer::resetFitNLumi_ [private] |
Definition at line 43 of file BeamSpotAnalyzer.h.
Referenced by BeamSpotAnalyzer(), beginLuminosityBlock(), endJob(), and endLuminosityBlock().
bool BeamSpotAnalyzer::runallfitters_ [private] |
Definition at line 56 of file BeamSpotAnalyzer.h.
Referenced by BeamSpotAnalyzer(), and endJob().
bool BeamSpotAnalyzer::runbeamwidthfit_ [private] |
Definition at line 55 of file BeamSpotAnalyzer.h.
Referenced by BeamSpotAnalyzer(), and endJob().
BeamFitter* BeamSpotAnalyzer::theBeamFitter [private] |
Definition at line 59 of file BeamSpotAnalyzer.h.
Referenced by analyze(), BeamSpotAnalyzer(), endJob(), endLuminosityBlock(), and ~BeamSpotAnalyzer().
bool BeamSpotAnalyzer::write2DB_ [private] |
Definition at line 54 of file BeamSpotAnalyzer.h.
Referenced by BeamSpotAnalyzer(), and endJob().