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=default
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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
 

Private Attributes

const edm::ESGetToken< BeamSpotObjects, BeamSpotObjectsRcdbeamSpotToken_
 
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
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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 84 of file BeamSpotRcdReader.cc.

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

85  : beamSpotToken_(esConsumes()), bstree_(nullptr) {
86  //now do what ever initialization is needed
87  usesResource("TFileService");
88  std::string fileName(iConfig.getUntrackedParameter<std::string>("rawFileName"));
89  if (!fileName.empty()) {
90  output_ = std::make_unique<std::ofstream>(fileName.c_str());
91  if (!output_->good()) {
92  edm::LogError("IOproblem") << "Could not open output file " << fileName << ".";
93  output_.reset();
94  }
95  }
96 }
std::unique_ptr< std::ofstream > output_
Log< level::Error, false > LogError
const edm::ESGetToken< BeamSpotObjects, BeamSpotObjectsRcd > beamSpotToken_
T getUntrackedParameter(std::string const &, T const &) const

◆ ~BeamSpotRcdReader()

BeamSpotRcdReader::~BeamSpotRcdReader ( )
overridedefault

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 118 of file BeamSpotRcdReader.cc.

References BeamSpotRcdReader::theBSfromDB::Beamdxdz_, BeamSpotRcdReader::theBSfromDB::Beamsigmaz_, beamSpotToken_, BeamSpotObjects::beamWidthX(), BeamSpotRcdReader::theBSfromDB::BeamWidthX_, BeamSpotObjects::beamWidthY(), BeamSpotRcdReader::theBSfromDB::BeamWidthY_, bstree_, BeamSpotRcdReader::theBSfromDB::BSx0_, BeamSpotRcdReader::theBSfromDB::BSy0_, BeamSpotRcdReader::theBSfromDB::BSz0_, edm::ESWatcher< T >::check(), BeamSpotObjects::dxdz(), edm::EventSetup::getData(), iEvent, BeamSpotRcdReader::theBSfromDB::init(), BeamSpotRcdReader::theBSfromDB::ls, convertSQLitetoXML_cfg::output, output_, BeamSpotRcdReader::theBSfromDB::run, BeamSpotObjects::sigmaZ(), theBSfromDB_, watcher_, BeamSpotObjects::x(), BeamSpotObjects::y(), and BeamSpotObjects::z().

118  {
119  using namespace edm;
120  std::ostringstream output;
121 
122  // initialize the ntuple
123  theBSfromDB_.init();
124 
125  if (watcher_.check(iSetup)) { // check for new IOV for this run / LS
126 
127  output << " for runs: " << iEvent.id().run() << " - " << iEvent.id().luminosityBlock() << std::endl;
128 
129  // Get BeamSpot from EventSetup:
130  const BeamSpotObjects* mybeamspot = &iSetup.getData(beamSpotToken_);
131 
132  theBSfromDB_.run = iEvent.id().run();
133  theBSfromDB_.ls = iEvent.id().luminosityBlock();
134  theBSfromDB_.BSx0_ = mybeamspot->x();
135  theBSfromDB_.BSy0_ = mybeamspot->y();
136  theBSfromDB_.BSz0_ = mybeamspot->z();
137  theBSfromDB_.Beamsigmaz_ = mybeamspot->sigmaZ();
138  theBSfromDB_.Beamdxdz_ = mybeamspot->dxdz();
139  theBSfromDB_.BeamWidthX_ = mybeamspot->beamWidthX();
140  theBSfromDB_.BeamWidthY_ = mybeamspot->beamWidthY();
141 
142  bstree_->Fill();
143 
144  output << *mybeamspot << std::endl;
145  }
146 
147  // Final output - either message logger or output file:
148  if (output_.get())
149  *output_ << output.str();
150  else
151  edm::LogInfo("BeamSpotRcdReader") << output.str();
152 }
double z() const
get Z beam position
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
edm::ESWatcher< BeamSpotObjectsRcd > watcher_
struct BeamSpotRcdReader::theBSfromDB theBSfromDB_
double beamWidthX() const
get average transverse beam width
std::unique_ptr< std::ofstream > output_
const edm::ESGetToken< BeamSpotObjects, BeamSpotObjectsRcd > beamSpotToken_
int iEvent
Definition: GenABIO.cc:224
double x() const
get X beam position
double beamWidthY() const
get average transverse beam width
Log< level::Info, false > LogInfo
double y() const
get Y beam position
double sigmaZ() const
get sigma Z, RMS bunch length
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
HLT enums.
double dxdz() const
get dxdz slope, crossing angle in XZ

◆ beginJob()

void BeamSpotRcdReader::beginJob ( )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 155 of file BeamSpotRcdReader.cc.

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

155  {
156  bstree_ = tFileService->make<TTree>("BSNtuple", "BeamSpot analyzer ntuple");
157 
158  //Tree Branches
159  bstree_->Branch("run", &theBSfromDB_.run, "run/I");
160  bstree_->Branch("ls", &theBSfromDB_.ls, "ls/I");
161  bstree_->Branch("BSx0", &theBSfromDB_.BSx0_, "BSx0/F");
162  bstree_->Branch("BSy0", &theBSfromDB_.BSy0_, "BSy0/F");
163  bstree_->Branch("BSz0", &theBSfromDB_.BSz0_, "BSz0/F");
164  bstree_->Branch("Beamsigmaz", &theBSfromDB_.Beamsigmaz_, "Beamsigmaz/F");
165  bstree_->Branch("Beamdxdz", &theBSfromDB_.Beamdxdz_, "Beamdxdz/F");
166  bstree_->Branch("BeamWidthX", &theBSfromDB_.BeamWidthX_, "BeamWidthX/F");
167  bstree_->Branch("BeamWidthY", &theBSfromDB_.BeamWidthY_, "BeamWidthY/F");
168 }
struct BeamSpotRcdReader::theBSfromDB theBSfromDB_
edm::Service< TFileService > tFileService
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64

◆ fillDescriptions()

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

Member Data Documentation

◆ beamSpotToken_

const edm::ESGetToken<BeamSpotObjects, BeamSpotObjectsRcd> BeamSpotRcdReader::beamSpotToken_
private

Definition at line 72 of file BeamSpotRcdReader.cc.

Referenced by analyze().

◆ 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().