CMS 3D CMS Logo

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 () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void beginLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context) override
 
void endJob () override
 
void endLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
 

Private Attributes

int beginLumiOfBSFit_
 
int countLumi_
 
int endLumiOfBSFit_
 
int fitNLumi_
 
int ftmprun
 
int ftmprun0
 
int ftotalevents
 
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
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 24 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 27 of file BeamSpotAnalyzer.cc.

References AlcaBeamMonitor_cfi::BeamFitter, 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_.

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

Definition at line 53 of file BeamSpotAnalyzer.cc.

References theBeamFitter.

53 { delete theBeamFitter; }
BeamFitter * theBeamFitter

Member Function Documentation

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

Definition at line 55 of file BeamSpotAnalyzer.cc.

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

55  {
56  ftotalevents++;
57  theBeamFitter->readEvent(iEvent);
58  ftmprun = iEvent.id().run();
59 }
RunNumber_t run() const
Definition: EventID.h:38
void readEvent(const edm::Event &iEvent)
Definition: BeamFitter.cc:224
BeamFitter * theBeamFitter
edm::EventID id() const
Definition: EventBase.h:59
void BeamSpotAnalyzer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 61 of file BeamSpotAnalyzer.cc.

61 {}
void BeamSpotAnalyzer::beginLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup context 
)
overrideprivate

Definition at line 64 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().

64  {
65  const edm::TimeValue_t fbegintimestamp = lumiSeg.beginTime().value();
66  const std::time_t ftmptime = fbegintimestamp >> 32;
67 
68  if (countLumi_ == 0 || (resetFitNLumi_ > 0 && countLumi_ % resetFitNLumi_ == 0)) {
69  ftmprun0 = lumiSeg.run();
70  ftmprun = ftmprun0;
72  refBStime[0] = ftmptime;
73  }
74 
75  countLumi_++;
76  //std::cout << "Lumi # " << countLumi_ << std::endl;
77  if (ftmprun == previousRun_) {
78  if ((previousLumi_ + 1) != int(lumiSeg.luminosityBlock()))
79  edm::LogWarning("BeamSpotAnalyzer") << "LUMI SECTIONS ARE NOT SORTED!";
80  }
81 }
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:45
void BeamSpotAnalyzer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 149 of file BeamSpotAnalyzer.cc.

References countLumi_, gather_cfg::cout, DEFINE_FWK_MODULE, fitNLumi_, ftmprun, ftmprun0, ftotalevents, BeamFitter::getBeamSpot(), BeamFitter::getBeamWidth(), BeamFitter::getFitLSRange(), resetFitNLumi_, BeamFitter::runAllFitter(), runallfitters_, runbeamwidthfit_, BeamFitter::runBeamWidthFitter(), BeamFitter::runPVandTrkFitter(), theBeamFitter, BeamFitter::write2DB(), and write2DB_.

149  {
150  std::cout << "\n-------------------------------------\n" << std::endl;
151  std::cout << "\n Total number of events processed: " << ftotalevents << std::endl;
152  std::cout << "\n-------------------------------------\n\n" << std::endl;
153 
154  if (fitNLumi_ == -1 && resetFitNLumi_ == -1) {
156  reco::BeamSpot beam_default = theBeamFitter->getBeamSpot();
157  std::pair<int, int> LSRange = theBeamFitter->getFitLSRange();
158 
159  std::cout << "\n RESULTS OF DEFAULT FIT:" << std::endl;
160  std::cout << " for runs: " << ftmprun0 << " - " << ftmprun << std::endl;
161  std::cout << " for lumi blocks : " << LSRange.first << " - " << LSRange.second << std::endl;
162  std::cout << " lumi counter # " << countLumi_ << std::endl;
163  std::cout << beam_default << std::endl;
164 
165  if (write2DB_) {
166  std::cout << "\n-------------------------------------\n\n" << std::endl;
167  std::cout << " write results to DB..." << std::endl;
169  }
170 
171  if (runallfitters_) {
173  }
174  }
175  if ((runbeamwidthfit_)) {
177  reco::BeamSpot beam_width = theBeamFitter->getBeamWidth();
178  std::cout << beam_width << std::endl;
179  }
180 
181  else
182  std::cout << "[BeamSpotAnalyzer] beamfit fails !!!" << std::endl;
183  }
184 
185  std::cout << "[BeamSpotAnalyzer] endJob done \n" << std::endl;
186 }
bool runPVandTrkFitter()
Definition: BeamFitter.cc:412
void write2DB()
Definition: BeamFitter.cc:709
bool runBeamWidthFitter()
Definition: BeamFitter.cc:583
reco::BeamSpot getBeamWidth()
Definition: BeamFitter.h:53
void runAllFitter()
Definition: BeamFitter.cc:747
BeamFitter * theBeamFitter
std::pair< int, int > getFitLSRange()
Definition: BeamFitter.h:111
reco::BeamSpot getBeamSpot()
Definition: BeamFitter.h:90
void BeamSpotAnalyzer::endLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
)
overrideprivate

Definition at line 84 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().

84  {
85  //LogDebug("BeamSpotAnalyzer") <<
86  std::cout << "for lumis " << beginLumiOfBSFit_ << " - " << endLumiOfBSFit_ << std::endl
87  << "number of selected tracks = " << theBeamFitter->getNTracks() << std::endl;
88  std::cout << "number of selected PVs = " << theBeamFitter->getNPVs() << std::endl;
89  //std::cout << "number of selected PVs per bx: " << std::endl;
90  //theBeamFitter->getNPVsperBX();
91 
92  const edm::TimeValue_t fendtimestamp = lumiSeg.endTime().value();
93  const std::time_t fendtime = fendtimestamp >> 32;
94  refBStime[1] = fendtime;
95 
96  endLumiOfBSFit_ = lumiSeg.luminosityBlock();
98 
99  if (fitNLumi_ == -1 && resetFitNLumi_ == -1)
100  return;
101 
102  if (fitNLumi_ > 0 && countLumi_ % fitNLumi_ != 0)
103  return;
104 
108 
109  std::pair<int, int> LSRange = theBeamFitter->getFitLSRange();
110 
113  std::cout << "\n RESULTS OF DEFAULT FIT " << std::endl;
114  std::cout << " for runs: " << ftmprun0 << " - " << ftmprun << std::endl;
115  std::cout << " for lumi blocks : " << LSRange.first << " - " << LSRange.second << std::endl;
116  std::cout << " lumi counter # " << countLumi_ << std::endl;
117  std::cout << bs << std::endl;
118  std::cout << "[BeamFitter] fit done. \n" << std::endl;
119  } else { // Fill in empty beam spot if beamfit fails
120  reco::BeamSpot bs;
122  std::cout << "\n Empty Beam spot fit" << std::endl;
123  std::cout << " for runs: " << ftmprun0 << " - " << ftmprun << std::endl;
124  std::cout << " for lumi blocks : " << LSRange.first << " - " << LSRange.second << std::endl;
125  std::cout << " lumi counter # " << countLumi_ << std::endl;
126  std::cout << bs << std::endl;
127  std::cout << "[BeamFitter] fit failed \n" << std::endl;
128  //accumulate more events
129  // dissable this for the moment
130  //resetFitNLumi_ += 1;
131  //std::cout << "reset fitNLumi " << resetFitNLumi_ << std::endl;
132  }
133 
134  if (resetFitNLumi_ > 0 && countLumi_ % resetFitNLumi_ == 0) {
135  std::vector<BSTrkParameters> theBSvector = theBeamFitter->getBSvector();
136  std::cout << "Total number of tracks accumulated = " << theBSvector.size() << std::endl;
137  std::cout << "Reset track collection for beam fit" << std::endl;
143  countLumi_ = 0;
144  // reset counter to orginal
146  }
147 }
int getNPVs()
Definition: BeamFitter.h:119
int getNTracks()
Definition: BeamFitter.h:118
bool runPVandTrkFitter()
Definition: BeamFitter.cc:412
void setRun(int run)
Definition: BeamFitter.h:116
std::vector< BSTrkParameters > getBSvector()
Definition: BeamFitter.h:92
void resetTrkVector()
Definition: BeamFitter.h:55
void setType(BeamType type)
set beam type
Definition: BeamSpot.h:124
LuminosityBlockNumber_t luminosityBlock() const
Timestamp const & endTime() const
std::time_t refBStime[2]
void setFitLSRange(int ls0, int ls1)
Definition: BeamFitter.h:112
void resetLSRange()
Definition: BeamFitter.h:57
unsigned long long TimeValue_t
Definition: Timestamp.h:28
BeamFitter * theBeamFitter
void resetPVFitter()
Definition: BeamFitter.h:69
void resetCutFlow()
Definition: BeamFitter.h:101
std::pair< int, int > getFitLSRange()
Definition: BeamFitter.h:111
void setRefTime(time_t t0, time_t t1)
Definition: BeamFitter.h:59
TimeValue_t value() const
Definition: Timestamp.h:45
reco::BeamSpot getBeamSpot()
Definition: BeamFitter.h:90
void resetRefTime()
Definition: BeamFitter.h:58

Member Data Documentation

int BeamSpotAnalyzer::beginLumiOfBSFit_
private

Definition at line 45 of file BeamSpotAnalyzer.h.

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

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

Definition at line 46 of file BeamSpotAnalyzer.h.

Referenced by BeamSpotAnalyzer(), and endLuminosityBlock().

int BeamSpotAnalyzer::fitNLumi_
private

Definition at line 37 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 36 of file BeamSpotAnalyzer.h.

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

int BeamSpotAnalyzer::Org_resetFitNLumi_
private

Definition at line 41 of file BeamSpotAnalyzer.h.

Referenced by BeamSpotAnalyzer(), and endLuminosityBlock().

int BeamSpotAnalyzer::previousLumi_
private

Definition at line 42 of file BeamSpotAnalyzer.h.

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

int BeamSpotAnalyzer::previousRun_
private

Definition at line 43 of file BeamSpotAnalyzer.h.

Referenced by BeamSpotAnalyzer(), and beginLuminosityBlock().

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

Definition at line 47 of file BeamSpotAnalyzer.h.

Referenced by beginLuminosityBlock(), and endLuminosityBlock().

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

Definition at line 51 of file BeamSpotAnalyzer.h.

Referenced by BeamSpotAnalyzer(), and endJob().

bool BeamSpotAnalyzer::runbeamwidthfit_
private

Definition at line 50 of file BeamSpotAnalyzer.h.

Referenced by BeamSpotAnalyzer(), and endJob().

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

Definition at line 49 of file BeamSpotAnalyzer.h.

Referenced by BeamSpotAnalyzer(), and endJob().