CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
BeamSpotRcdReader Class Reference

#include <CondTools/BeamSpot/plugins/BeamSpotRcdReader.cc>

Inheritance diagram for BeamSpotRcdReader:
edm::one::EDAnalyzer< edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Classes

struct  theBSfromDB
 

Public Member Functions

 BeamSpotRcdReader (const edm::ParameterSet &)
 
 ~BeamSpotRcdReader () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources >
 EDAnalyzer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void endJob () override
 

Private Attributes

TTree * bstree_
 
std::unique_ptr< std::ofstream > output_
 
edm::Service< TFileServicetFileService
 
struct BeamSpotRcdReader::theBSfromDB theBSfromDB_
 
edm::ESWatcher< BeamSpotObjectsRcdwatcher_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Description: simple emd::one::EDAnalyzer to retrieve and ntuplize BeamSpot data from the conditions database

Implementation: [Notes on implementation]

Definition at line 48 of file BeamSpotRcdReader.cc.

Constructor & Destructor Documentation

◆ BeamSpotRcdReader()

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

Definition at line 92 of file BeamSpotRcdReader.cc.

92  : bstree_(nullptr) {
93  //now do what ever initialization is needed
94  usesResource("TFileService");
95  std::string fileName(iConfig.getUntrackedParameter<std::string>("rawFileName"));
96  if (!fileName.empty()) {
97  output_.reset(new std::ofstream(fileName.c_str()));
98  if (!output_->good()) {
99  edm::LogError("IOproblem") << "Could not open output file " << fileName << ".";
100  output_.reset();
101  }
102  }
103 }

References MillePedeFileConverter_cfg::fileName, edm::ParameterSet::getUntrackedParameter(), output_, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~BeamSpotRcdReader()

BeamSpotRcdReader::~BeamSpotRcdReader ( )
override

Definition at line 105 of file BeamSpotRcdReader.cc.

105  {
106  // do anything here that needs to be done at desctruction time
107  // (e.g. close files, deallocate resources etc.)
108 }

Member Function Documentation

◆ analyze()

void BeamSpotRcdReader::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 130 of file BeamSpotRcdReader.cc.

130  {
131  using namespace edm;
132  std::ostringstream output;
133 
134  // initialize the ntuple
135  theBSfromDB_.init();
136 
137  if (watcher_.check(iSetup)) { // check for new IOV for this run / LS
138 
139  output << " for runs: " << iEvent.id().run() << " - " << iEvent.id().luminosityBlock() << std::endl;
140 
141  // Get BeamSpot from EventSetup:
143  iSetup.get<BeamSpotObjectsRcd>().get(beamhandle);
144  const BeamSpotObjects* mybeamspot = beamhandle.product();
145 
146  theBSfromDB_.run = iEvent.id().run();
147  theBSfromDB_.ls = iEvent.id().luminosityBlock();
148  theBSfromDB_.BSx0_ = mybeamspot->GetX();
149  theBSfromDB_.BSy0_ = mybeamspot->GetY();
150  theBSfromDB_.BSz0_ = mybeamspot->GetZ();
151  theBSfromDB_.Beamsigmaz_ = mybeamspot->GetSigmaZ();
152  theBSfromDB_.Beamdxdz_ = mybeamspot->Getdxdz();
153  theBSfromDB_.BeamWidthX_ = mybeamspot->GetBeamWidthX();
154  theBSfromDB_.BeamWidthY_ = mybeamspot->GetBeamWidthY();
155 
156  bstree_->Fill();
157 
158  output << *mybeamspot << std::endl;
159  }
160 
161  // Final output - either message logger or output file:
162  if (output_.get())
163  *output_ << output.str();
164  else
165  edm::LogInfo("") << output.str();
166 }

References BeamSpotRcdReader::theBSfromDB::Beamdxdz_, BeamSpotRcdReader::theBSfromDB::Beamsigmaz_, BeamSpotRcdReader::theBSfromDB::BeamWidthX_, BeamSpotRcdReader::theBSfromDB::BeamWidthY_, bstree_, BeamSpotRcdReader::theBSfromDB::BSx0_, BeamSpotRcdReader::theBSfromDB::BSy0_, BeamSpotRcdReader::theBSfromDB::BSz0_, edm::ESWatcher< T >::check(), edm::EventSetup::get(), get, BeamSpotObjects::GetBeamWidthX(), BeamSpotObjects::GetBeamWidthY(), BeamSpotObjects::Getdxdz(), BeamSpotObjects::GetSigmaZ(), BeamSpotObjects::GetX(), BeamSpotObjects::GetY(), BeamSpotObjects::GetZ(), iEvent, BeamSpotRcdReader::theBSfromDB::init(), BeamSpotRcdReader::theBSfromDB::ls, convertSQLitetoXML_cfg::output, output_, edm::ESHandle< T >::product(), BeamSpotRcdReader::theBSfromDB::run, theBSfromDB_, and watcher_.

◆ beginJob()

void BeamSpotRcdReader::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 169 of file BeamSpotRcdReader.cc.

169  {
170  bstree_ = tFileService->make<TTree>("BSNtuple", "BeamSpot analyzer ntuple");
171 
172  //Tree Branches
173  bstree_->Branch("run", &theBSfromDB_.run, "run/I");
174  bstree_->Branch("ls", &theBSfromDB_.ls, "ls/I");
175  bstree_->Branch("BSx0", &theBSfromDB_.BSx0_, "BSx0/F");
176  bstree_->Branch("BSy0", &theBSfromDB_.BSy0_, "BSy0/F");
177  bstree_->Branch("BSz0", &theBSfromDB_.BSz0_, "BSz0/F");
178  bstree_->Branch("Beamsigmaz", &theBSfromDB_.Beamsigmaz_, "Beamsigmaz/F");
179  bstree_->Branch("Beamdxdz", &theBSfromDB_.Beamdxdz_, "Beamdxdz/F");
180  bstree_->Branch("BeamWidthX", &theBSfromDB_.BeamWidthX_, "BeamWidthX/F");
181  bstree_->Branch("BeamWidthY", &theBSfromDB_.BeamWidthY_, "BeamWidthY/F");
182 }

References BeamSpotRcdReader::theBSfromDB::Beamdxdz_, BeamSpotRcdReader::theBSfromDB::Beamsigmaz_, BeamSpotRcdReader::theBSfromDB::BeamWidthX_, BeamSpotRcdReader::theBSfromDB::BeamWidthY_, bstree_, BeamSpotRcdReader::theBSfromDB::BSx0_, BeamSpotRcdReader::theBSfromDB::BSy0_, BeamSpotRcdReader::theBSfromDB::BSz0_, BeamSpotRcdReader::theBSfromDB::ls, TFileService::make(), BeamSpotRcdReader::theBSfromDB::run, tFileService, and theBSfromDB_.

◆ endJob()

void BeamSpotRcdReader::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 185 of file BeamSpotRcdReader.cc.

185 {}

◆ fillDescriptions()

void BeamSpotRcdReader::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 188 of file BeamSpotRcdReader.cc.

188  {
189  //The following says we do not know what parameters are allowed so do no validation
190  // Please change this to state exactly what you do use, even if it is no parameters
192  desc.setUnknown();
193  descriptions.addDefault(desc);
194 }

References edm::ConfigurationDescriptions::addDefault(), and submitPVResolutionJobs::desc.

Member Data Documentation

◆ bstree_

TTree* BeamSpotRcdReader::bstree_
private

Definition at line 74 of file BeamSpotRcdReader.cc.

Referenced by analyze(), and beginJob().

◆ output_

std::unique_ptr<std::ofstream> BeamSpotRcdReader::output_
private

Definition at line 78 of file BeamSpotRcdReader.cc.

Referenced by analyze(), and BeamSpotRcdReader().

◆ tFileService

edm::Service<TFileService> BeamSpotRcdReader::tFileService
private

Definition at line 73 of file BeamSpotRcdReader.cc.

Referenced by beginJob().

◆ theBSfromDB_

struct BeamSpotRcdReader::theBSfromDB BeamSpotRcdReader::theBSfromDB_
private

Referenced by analyze(), and beginJob().

◆ watcher_

edm::ESWatcher<BeamSpotObjectsRcd> BeamSpotRcdReader::watcher_
private

Definition at line 77 of file BeamSpotRcdReader.cc.

Referenced by analyze().

edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
BeamSpotObjects::GetBeamWidthY
double GetBeamWidthY() const
get average transverse beam width
Definition: BeamSpotObjects.h:77
BeamSpotRcdReader::theBSfromDB::init
void init()
Definition: BeamSpotRcdReader.cc:114
BeamSpotRcdReader::output_
std::unique_ptr< std::ofstream > output_
Definition: BeamSpotRcdReader.cc:78
BeamSpotObjects::Getdxdz
double Getdxdz() const
get dxdz slope, crossing angle in XZ
Definition: BeamSpotObjects.h:79
BeamSpotRcdReader::theBSfromDB::BSy0_
float BSy0_
Definition: BeamSpotRcdReader.cc:64
BeamSpotRcdReader::theBSfromDB::Beamdxdz_
float Beamdxdz_
Definition: BeamSpotRcdReader.cc:67
BeamSpotRcdReader::bstree_
TTree * bstree_
Definition: BeamSpotRcdReader.cc:74
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
BeamSpotObjects::GetSigmaZ
double GetSigmaZ() const
get sigma Z, RMS bunch length
Definition: BeamSpotObjects.h:73
edm
HLT enums.
Definition: AlignableModifier.h:19
BeamSpotObjects::GetZ
double GetZ() const
get Z beam position
Definition: BeamSpotObjects.h:71
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
edm::ESHandle
Definition: DTSurvey.h:22
BeamSpotRcdReader::theBSfromDB::ls
int ls
Definition: BeamSpotRcdReader.cc:62
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
BeamSpotRcdReader::theBSfromDB::BeamWidthY_
float BeamWidthY_
Definition: BeamSpotRcdReader.cc:69
BeamSpotObjects::GetY
double GetY() const
get Y beam position
Definition: BeamSpotObjects.h:69
iEvent
int iEvent
Definition: GenABIO.cc:224
BeamSpotRcdReader::theBSfromDB::BSz0_
float BSz0_
Definition: BeamSpotRcdReader.cc:65
BeamSpotRcdReader::theBSfromDB::run
int run
Definition: BeamSpotRcdReader.cc:61
BeamSpotObjectsRcd
Definition: BeamSpotObjectsRcd.h:24
BeamSpotObjects
Definition: BeamSpotObjects.h:20
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
get
#define get
BeamSpotRcdReader::tFileService
edm::Service< TFileService > tFileService
Definition: BeamSpotRcdReader.cc:73
BeamSpotObjects::GetBeamWidthX
double GetBeamWidthX() const
get average transverse beam width
Definition: BeamSpotObjects.h:75
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
BeamSpotRcdReader::watcher_
edm::ESWatcher< BeamSpotObjectsRcd > watcher_
Definition: BeamSpotRcdReader.cc:77
BeamSpotRcdReader::theBSfromDB::BSx0_
float BSx0_
Definition: BeamSpotRcdReader.cc:63
BeamSpotRcdReader::theBSfromDB::BeamWidthX_
float BeamWidthX_
Definition: BeamSpotRcdReader.cc:68
BeamSpotRcdReader::theBSfromDB_
struct BeamSpotRcdReader::theBSfromDB theBSfromDB_
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
BeamSpotObjects::GetX
double GetX() const
get X beam position
Definition: BeamSpotObjects.h:67
BeamSpotRcdReader::theBSfromDB::Beamsigmaz_
float Beamsigmaz_
Definition: BeamSpotRcdReader.cc:66
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64