CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
BeamSpotAnalyzer Class Reference

#include <BeamSpotAnalyzer.h>

Inheritance diagram for BeamSpotAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 BeamSpotAnalyzer (const edm::ParameterSet &)
 
 ~BeamSpotAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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_
 
BeamFittertheBeamFitter
 
bool write2DB_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description


class: BeamSpotAnalyzer.h package: RecoVertex/BeamSpotProducer

author: Francisco Yumiceva, Fermilab (yumic.nosp@m.eva@.nosp@m.fnal..nosp@m.gov)


Definition at line 26 of file BeamSpotAnalyzer.h.

Constructor & Destructor Documentation

BeamSpotAnalyzer::BeamSpotAnalyzer ( const edm::ParameterSet iConfig)
explicit

class: BeamSpotAnalyzer.cc package: RecoVertex/BeamSpotProducer

author: Francisco Yumiceva, Fermilab (yumic.nosp@m.eva@.nosp@m.fnal..nosp@m.gov) Geng-Yuan Jeng, UC Riverside (Geng-.nosp@m.Yuan.nosp@m..Jeng.nosp@m.@cer.nosp@m.n.ch)


Definition at line 28 of file BeamSpotAnalyzer.cc.

References beginLumiOfBSFit_, edm::EDConsumerBase::consumesCollector(), 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_.

29 {
30  // get parameter
31  write2DB_ = iConfig.getParameter<edm::ParameterSet>("BSAnalyzerParameters").getParameter<bool>("WriteToDB");
32  runallfitters_ = iConfig.getParameter<edm::ParameterSet>("BSAnalyzerParameters").getParameter<bool>("RunAllFitters");
33  fitNLumi_ = iConfig.getParameter<edm::ParameterSet>("BSAnalyzerParameters").getUntrackedParameter<int>("fitEveryNLumi",-1);
34  resetFitNLumi_ = iConfig.getParameter<edm::ParameterSet>("BSAnalyzerParameters").getUntrackedParameter<int>("resetEveryNLumi",-1);
35  runbeamwidthfit_ = iConfig.getParameter<edm::ParameterSet>("BSAnalyzerParameters").getParameter<bool>("RunBeamWidthFit");
36 
37  theBeamFitter = new BeamFitter(iConfig, consumesCollector());
43 
44  ftotalevents = 0;
45  ftmprun0 = ftmprun = -1;
46  countLumi_ = 0;
50 }
T getParameter(std::string const &) const
void resetTrkVector()
Definition: BeamFitter.h:53
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
void resetLSRange()
Definition: BeamFitter.h:55
BeamFitter * theBeamFitter
void resetPVFitter()
Definition: BeamFitter.h:69
void resetCutFlow()
Definition: BeamFitter.h:105
void resetRefTime()
Definition: BeamFitter.h:56
BeamSpotAnalyzer::~BeamSpotAnalyzer ( )

Definition at line 53 of file BeamSpotAnalyzer.cc.

References theBeamFitter.

54 {
55  delete theBeamFitter;
56 }
BeamFitter * theBeamFitter

Member Function Documentation

void BeamSpotAnalyzer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 60 of file BeamSpotAnalyzer.cc.

References ftmprun, ftotalevents, edm::EventBase::id(), BeamFitter::readEvent(), edm::EventID::run(), and theBeamFitter.

61 {
62  ftotalevents++;
63  theBeamFitter->readEvent(iEvent);
64  ftmprun = iEvent.id().run();
65 
66 }
RunNumber_t run() const
Definition: EventID.h:42
void readEvent(const edm::Event &iEvent)
Definition: BeamFitter.cc:224
BeamFitter * theBeamFitter
edm::EventID id() const
Definition: EventBase.h:56
void BeamSpotAnalyzer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 71 of file BeamSpotAnalyzer.cc.

72 {
73 }
void BeamSpotAnalyzer::beginLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup context 
)
privatevirtual

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_, edm::LuminosityBlockBase::run(), and edm::Timestamp::value().

78  {
79 
80  const edm::TimeValue_t fbegintimestamp = lumiSeg.beginTime().value();
81  const std::time_t ftmptime = fbegintimestamp >> 32;
82 
83  if ( countLumi_ == 0 || (resetFitNLumi_ > 0 && countLumi_%resetFitNLumi_ == 0) ) {
84  ftmprun0 = lumiSeg.run();
85  ftmprun = ftmprun0;
87  refBStime[0] = ftmptime;
88  }
89 
90  countLumi_++;
91  //std::cout << "Lumi # " << countLumi_ << std::endl;
92  if ( ftmprun == previousRun_ ) {
93  if ( (previousLumi_ + 1) != int(lumiSeg.luminosityBlock()) )
94  edm::LogWarning("BeamSpotAnalyzer") << "LUMI SECTIONS ARE NOT SORTED!";
95  }
96 }
Timestamp const & beginTime() const
LuminosityBlockNumber_t luminosityBlock() const
std::time_t refBStime[2]
RunNumber_t run() const
unsigned long long TimeValue_t
Definition: Timestamp.h:28
TimeValue_t value() const
Definition: Timestamp.h:56
void BeamSpotAnalyzer::endJob ( void  )
privatevirtual

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_.

170  {
171  std::cout << "\n-------------------------------------\n" << std::endl;
172  std::cout << "\n Total number of events processed: "<< ftotalevents << std::endl;
173  std::cout << "\n-------------------------------------\n\n" << std::endl;
174 
175  if ( fitNLumi_ == -1 && resetFitNLumi_ == -1 ) {
176 
178  reco::BeamSpot beam_default = theBeamFitter->getBeamSpot();
179  std::pair<int,int> LSRange = theBeamFitter->getFitLSRange();
180 
181  std::cout << "\n RESULTS OF DEFAULT FIT:" << std::endl;
182  std::cout << " for runs: " << ftmprun0 << " - " << ftmprun << std::endl;
183  std::cout << " for lumi blocks : " << LSRange.first << " - " << LSRange.second << std::endl;
184  std::cout << " lumi counter # " << countLumi_ << std::endl;
185  std::cout << beam_default << std::endl;
186 
187  if (write2DB_) {
188  std::cout << "\n-------------------------------------\n\n" << std::endl;
189  std::cout << " write results to DB..." << std::endl;
191  }
192 
193  if (runallfitters_) {
195  }
196 
197  }
198  if ((runbeamwidthfit_)){
200  reco::BeamSpot beam_width = theBeamFitter->getBeamWidth();
201  std::cout <<beam_width<< std::endl;
202  }
203 
204  else std::cout << "[BeamSpotAnalyzer] beamfit fails !!!" << std::endl;
205  }
206 
207  std::cout << "[BeamSpotAnalyzer] endJob done \n" << std::endl;
208 }
bool runPVandTrkFitter()
Definition: BeamFitter.cc:410
void write2DB()
Definition: BeamFitter.cc:740
bool runBeamWidthFitter()
Definition: BeamFitter.cc:591
reco::BeamSpot getBeamWidth()
Definition: BeamFitter.h:51
void runAllFitter()
Definition: BeamFitter.cc:780
BeamFitter * theBeamFitter
tuple cout
Definition: gather_cfg.py:121
std::pair< int, int > getFitLSRange()
Definition: BeamFitter.h:117
reco::BeamSpot getBeamSpot()
Definition: BeamFitter.h:94
void BeamSpotAnalyzer::endLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
)
privatevirtual

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(), theBeamFitter, and edm::Timestamp::value().

101  {
102 
103  //LogDebug("BeamSpotAnalyzer") <<
104  std::cout <<
105  "for lumis "<< beginLumiOfBSFit_ << " - " << endLumiOfBSFit_ << std::endl <<
106  "number of selected tracks = " << theBeamFitter->getNTracks() << std::endl;
107  std::cout << "number of selected PVs = " << theBeamFitter->getNPVs() << std::endl;
108  //std::cout << "number of selected PVs per bx: " << std::endl;
109  //theBeamFitter->getNPVsperBX();
110 
111  const edm::TimeValue_t fendtimestamp = lumiSeg.endTime().value();
112  const std::time_t fendtime = fendtimestamp >> 32;
113  refBStime[1] = fendtime;
114 
115  endLumiOfBSFit_ = lumiSeg.luminosityBlock();
117 
118  if ( fitNLumi_ == -1 && resetFitNLumi_ == -1 ) return;
119 
120  if (fitNLumi_ > 0 && countLumi_%fitNLumi_!=0) return;
121 
125 
126  std::pair<int,int> LSRange = theBeamFitter->getFitLSRange();
127 
130  std::cout << "\n RESULTS OF DEFAULT FIT " << std::endl;
131  std::cout << " for runs: " << ftmprun0 << " - " << ftmprun << std::endl;
132  std::cout << " for lumi blocks : " << LSRange.first << " - " << LSRange.second << std::endl;
133  std::cout << " lumi counter # " << countLumi_ << std::endl;
134  std::cout << bs << std::endl;
135  std::cout << "[BeamFitter] fit done. \n" << std::endl;
136  }
137  else { // Fill in empty beam spot if beamfit fails
138  reco::BeamSpot bs;
140  std::cout << "\n Empty Beam spot fit" << std::endl;
141  std::cout << " for runs: " << ftmprun0 << " - " << ftmprun << std::endl;
142  std::cout << " for lumi blocks : " << LSRange.first << " - " << LSRange.second << std::endl;
143  std::cout << " lumi counter # " << countLumi_ << std::endl;
144  std::cout << bs << std::endl;
145  std::cout << "[BeamFitter] fit failed \n" << std::endl;
146  //accumulate more events
147  // dissable this for the moment
148  //resetFitNLumi_ += 1;
149  //std::cout << "reset fitNLumi " << resetFitNLumi_ << std::endl;
150  }
151 
152  if (resetFitNLumi_ > 0 && countLumi_%resetFitNLumi_ == 0) {
153  std::vector<BSTrkParameters> theBSvector = theBeamFitter->getBSvector();
154  std::cout << "Total number of tracks accumulated = " << theBSvector.size() << std::endl;
155  std::cout << "Reset track collection for beam fit" <<std::endl;
161  countLumi_=0;
162  // reset counter to orginal
164  }
165 
166 }
int getNPVs()
Definition: BeamFitter.h:129
int getNTracks()
Definition: BeamFitter.h:126
bool runPVandTrkFitter()
Definition: BeamFitter.cc:410
void setRun(int run)
Definition: BeamFitter.h:124
std::vector< BSTrkParameters > getBSvector()
Definition: BeamFitter.h:96
void resetTrkVector()
Definition: BeamFitter.h:53
void setType(BeamType type)
set beam type
Definition: BeamSpot.h:131
LuminosityBlockNumber_t luminosityBlock() const
Timestamp const & endTime() const
std::time_t refBStime[2]
void setFitLSRange(int ls0, int ls1)
Definition: BeamFitter.h:120
void resetLSRange()
Definition: BeamFitter.h:55
unsigned long long TimeValue_t
Definition: Timestamp.h:28
BeamFitter * theBeamFitter
void resetPVFitter()
Definition: BeamFitter.h:69
void resetCutFlow()
Definition: BeamFitter.h:105
tuple cout
Definition: gather_cfg.py:121
void setRefTime(time_t t0, time_t t1)
Definition: BeamFitter.h:57
std::pair< int, int > getFitLSRange()
Definition: BeamFitter.h:117
TimeValue_t value() const
Definition: Timestamp.h:56
reco::BeamSpot getBeamSpot()
Definition: BeamFitter.h:94
void resetRefTime()
Definition: BeamFitter.h:56

Member Data Documentation

int BeamSpotAnalyzer::beginLumiOfBSFit_
private

Definition at line 49 of file BeamSpotAnalyzer.h.

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

int BeamSpotAnalyzer::countEvt_
private

Definition at line 43 of file BeamSpotAnalyzer.h.

int BeamSpotAnalyzer::countLumi_
private
int BeamSpotAnalyzer::endLumiOfBSFit_
private

Definition at line 50 of file BeamSpotAnalyzer.h.

Referenced by BeamSpotAnalyzer(), and endLuminosityBlock().

int BeamSpotAnalyzer::fitNLumi_
private

Definition at line 41 of file BeamSpotAnalyzer.h.

Referenced by BeamSpotAnalyzer(), endJob(), and endLuminosityBlock().

int BeamSpotAnalyzer::ftmprun
private
int BeamSpotAnalyzer::ftmprun0
private
int BeamSpotAnalyzer::ftotalevents
private

Definition at line 40 of file BeamSpotAnalyzer.h.

Referenced by analyze(), BeamSpotAnalyzer(), and endJob().

double BeamSpotAnalyzer::inputBeamWidth_
private

Definition at line 56 of file BeamSpotAnalyzer.h.

int BeamSpotAnalyzer::Org_resetFitNLumi_
private

Definition at line 45 of file BeamSpotAnalyzer.h.

Referenced by BeamSpotAnalyzer(), and endLuminosityBlock().

int BeamSpotAnalyzer::previousLumi_
private

Definition at line 46 of file BeamSpotAnalyzer.h.

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

int BeamSpotAnalyzer::previousRun_
private

Definition at line 47 of file BeamSpotAnalyzer.h.

Referenced by BeamSpotAnalyzer(), and beginLuminosityBlock().

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

Definition at line 51 of file BeamSpotAnalyzer.h.

Referenced by beginLuminosityBlock(), and endLuminosityBlock().

int BeamSpotAnalyzer::resetFitNLumi_
private
bool BeamSpotAnalyzer::runallfitters_
private

Definition at line 55 of file BeamSpotAnalyzer.h.

Referenced by BeamSpotAnalyzer(), and endJob().

bool BeamSpotAnalyzer::runbeamwidthfit_
private

Definition at line 54 of file BeamSpotAnalyzer.h.

Referenced by BeamSpotAnalyzer(), and endJob().

BeamFitter* BeamSpotAnalyzer::theBeamFitter
private
bool BeamSpotAnalyzer::write2DB_
private

Definition at line 53 of file BeamSpotAnalyzer.h.

Referenced by BeamSpotAnalyzer(), and endJob().