CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

AlcaBeamSpotProducer Class Reference

#include <AlcaBeamSpotProducer.h>

Inheritance diagram for AlcaBeamSpotProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

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

Private Member Functions

virtual void beginLuminosityBlock (edm::LuminosityBlock &lumiSeg, const edm::EventSetup &iSetup)
virtual void endLuminosityBlock (edm::LuminosityBlock &lumiSeg, const edm::EventSetup &iSetup)
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)

Private Attributes

int beginLumiOfBSFit_
int countEvt_
int countLumi_
int endLumiOfBSFit_
int fitNLumi_
int ftmprun
int ftmprun0
int ftotalevents
double inputBeamWidth_
std::time_t refBStime [2]
int resetFitNLumi_
bool runallfitters_
bool runbeamwidthfit_
BeamFittertheBeamFitter
bool write2DB_

Detailed Description

_________________________________________________________________ class: AlcaBeamSpotProducer.h package: Calibration/TkAlCaRecoProducers

author: Francisco Yumiceva, Fermilab (yumiceva@fnal.gov)

version

Id:
AlcaBeamSpotProducer.h,v 1.1 2010/06/21 18:02:19 yumiceva Exp

________________________________________________________________

Definition at line 27 of file AlcaBeamSpotProducer.h.


Constructor & Destructor Documentation

AlcaBeamSpotProducer::AlcaBeamSpotProducer ( const edm::ParameterSet iConfig) [explicit]

_________________________________________________________________ class: AlcaBeamSpotProducer.cc package: RecoVertex/BeamSpotProducer

author: Francisco Yumiceva, Fermilab (yumiceva@fnal.gov) Geng-Yuan Jeng, UC Riverside (Geng-Yuan.Jeng@cern.ch)

version

Id:
AlcaBeamSpotProducer.cc,v 1.2 2010/07/20 02:58:20 wmtan Exp

________________________________________________________________

Definition at line 35 of file AlcaBeamSpotProducer.cc.

References ExpressReco_HICollisions_FallBack::BeamFitter, beginLumiOfBSFit_, countLumi_, endLumiOfBSFit_, fitNLumi_, ftmprun, ftmprun0, ftotalevents, edm::ParameterSet::getParameter(), BeamFitter::resetCutFlow(), resetFitNLumi_, BeamFitter::resetLSRange(), BeamFitter::resetPVFitter(), BeamFitter::resetRefTime(), BeamFitter::resetTrkVector(), runallfitters_, runbeamwidthfit_, theBeamFitter, and write2DB_.

                                                                        {
  // get parameter
  write2DB_        = iConfig.getParameter<edm::ParameterSet>("AlcaBeamSpotProducerParameters").getParameter<bool>("WriteToDB");
  runallfitters_   = iConfig.getParameter<edm::ParameterSet>("AlcaBeamSpotProducerParameters").getParameter<bool>("RunAllFitters");
  fitNLumi_        = iConfig.getParameter<edm::ParameterSet>("AlcaBeamSpotProducerParameters").getUntrackedParameter<int>("fitEveryNLumi",-1);
  resetFitNLumi_   = iConfig.getParameter<edm::ParameterSet>("AlcaBeamSpotProducerParameters").getUntrackedParameter<int>("resetEveryNLumi",-1);
  runbeamwidthfit_ = iConfig.getParameter<edm::ParameterSet>("AlcaBeamSpotProducerParameters").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;
  
  produces<reco::BeamSpot, edm::InLumi>("alcaBeamSpot");
}
AlcaBeamSpotProducer::~AlcaBeamSpotProducer ( )

Definition at line 59 of file AlcaBeamSpotProducer.cc.

References theBeamFitter.

                                           {
  delete theBeamFitter;
}

Member Function Documentation

void AlcaBeamSpotProducer::beginLuminosityBlock ( edm::LuminosityBlock lumiSeg,
const edm::EventSetup iSetup 
) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 71 of file AlcaBeamSpotProducer.cc.

References beginLumiOfBSFit_, edm::LuminosityBlockBase::beginTime(), countLumi_, ftmprun, ftmprun0, edm::LuminosityBlockBase::luminosityBlock(), 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_++;
  
}
void AlcaBeamSpotProducer::endLuminosityBlock ( edm::LuminosityBlock lumiSeg,
const edm::EventSetup iSetup 
) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 87 of file AlcaBeamSpotProducer.cc.

References beginLumiOfBSFit_, countLumi_, endLumiOfBSFit_, edm::LuminosityBlockBase::endTime(), reco::BeamSpot::Fake, fitNLumi_, ftmprun, ftmprun0, BeamFitter::getBeamSpot(), BeamFitter::getBSvector(), BeamFitter::getFitLSRange(), edm::LuminosityBlockBase::luminosityBlock(), edm::LuminosityBlock::put(), refBStime, BeamFitter::resetCutFlow(), resetFitNLumi_, BeamFitter::resetLSRange(), BeamFitter::resetPVFitter(), BeamFitter::resetRefTime(), BeamFitter::resetTrkVector(), query::result, BeamFitter::runPVandTrkFitter(), BeamFitter::setFitLSRange(), BeamFitter::setRefTime(), BeamFitter::setRun(), reco::BeamSpot::setType(), and theBeamFitter.

                                                                                                     {
  const edm::TimeValue_t fendtimestamp = lumiSeg.endTime().value();
  const std::time_t fendtime = fendtimestamp >> 32;
  refBStime[1] = fendtime;
    
  endLumiOfBSFit_ = lumiSeg.luminosityBlock();
    
  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);
    
  int * LSRange = theBeamFitter->getFitLSRange();

  reco::BeamSpot bs;
  if (theBeamFitter->runPVandTrkFitter()){
    bs = theBeamFitter->getBeamSpot();
    edm::LogInfo("AlcaBeamSpotProducer")
        << "\n RESULTS OF DEFAULT FIT " << std::endl
        << " for runs: " << ftmprun0 << " - " << ftmprun << std::endl
        << " for lumi blocks : " << LSRange[0] << " - " << LSRange[1] << std::endl
        << " lumi counter # " << countLumi_ << std::endl
        << bs << std::endl
        << "fit done. \n" << std::endl; 
  }
  else { // Fill in empty beam spot if beamfit fails
    bs.setType(reco::BeamSpot::Fake);
    edm::LogInfo("AlcaBeamSpotProducer")
        << "\n Empty Beam spot fit" << std::endl
        << " for runs: " << ftmprun0 << " - " << ftmprun << std::endl
        << " for lumi blocks : " << LSRange[0] << " - " << LSRange[1] << std::endl
        << " lumi counter # " << countLumi_ << std::endl
        << bs << std::endl
        << "fit failed \n" << std::endl;
  }

  std::auto_ptr<reco::BeamSpot> result(new reco::BeamSpot);
  *result = bs;
  lumiSeg.put(result, std::string("alcaBeamSpot"));
        
  if (resetFitNLumi_ > 0 && countLumi_%resetFitNLumi_ == 0) {
    std::vector<BSTrkParameters> theBSvector = theBeamFitter->getBSvector();
    edm::LogInfo("AlcaBeamSpotProducer")
        << "Total number of tracks accumulated = " << theBSvector.size() << std::endl
        << "Reset track collection for beam fit" <<std::endl;
    theBeamFitter->resetTrkVector();
    theBeamFitter->resetLSRange();
    theBeamFitter->resetCutFlow();
    theBeamFitter->resetRefTime();
    theBeamFitter->resetPVFitter();
    countLumi_=0;
  }
}
void AlcaBeamSpotProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Member Data Documentation

Definition at line 40 of file AlcaBeamSpotProducer.h.

Definition at line 44 of file AlcaBeamSpotProducer.h.

Referenced by AlcaBeamSpotProducer(), and endLuminosityBlock().

Definition at line 38 of file AlcaBeamSpotProducer.h.

Referenced by AlcaBeamSpotProducer(), and endLuminosityBlock().

Definition at line 37 of file AlcaBeamSpotProducer.h.

Referenced by AlcaBeamSpotProducer(), and produce().

Definition at line 50 of file AlcaBeamSpotProducer.h.

std::time_t AlcaBeamSpotProducer::refBStime[2] [private]

Definition at line 45 of file AlcaBeamSpotProducer.h.

Referenced by beginLuminosityBlock(), and endLuminosityBlock().

Definition at line 49 of file AlcaBeamSpotProducer.h.

Referenced by AlcaBeamSpotProducer().

Definition at line 48 of file AlcaBeamSpotProducer.h.

Referenced by AlcaBeamSpotProducer().

Definition at line 47 of file AlcaBeamSpotProducer.h.

Referenced by AlcaBeamSpotProducer().