CMS 3D CMS Logo

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

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

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

Classes

struct  TheBSfromDB
 

Public Member Functions

 BeamProfile2DBReader (const edm::ParameterSet &)
 
 ~BeamProfile2DBReader () 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 noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept 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 noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~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< SimBeamSpotObjects, SimBeamSpotObjectsRcdbeamSpotToken_
 
TTree * bstree_
 
std::unique_ptr< std::ofstream > output_
 
edm::Service< TFileServicetFileService
 
struct BeamProfile2DBReader::TheBSfromDB theBSfromDB_
 
edm::ESWatcher< SimBeamSpotObjectsRcdwatcher_
 

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 SimBeamSpot data from the conditions database

Implementation: [Notes on implementation]

Definition at line 44 of file BeamProfile2DBReader.cc.

Constructor & Destructor Documentation

◆ BeamProfile2DBReader()

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

Definition at line 79 of file BeamProfile2DBReader.cc.

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

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

◆ ~BeamProfile2DBReader()

BeamProfile2DBReader::~BeamProfile2DBReader ( )
overridedefault

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 120 of file BeamProfile2DBReader.cc.

References SimBeamSpotObjects::alpha(), beamSpotToken_, SimBeamSpotObjects::betaStar(), bstree_, edm::ESWatcher< T >::check(), SimBeamSpotObjects::emittance(), BeamProfile2DBReader::TheBSfromDB::fAlpha, BeamProfile2DBReader::TheBSfromDB::fbetastar, BeamProfile2DBReader::TheBSfromDB::femittance, BeamProfile2DBReader::TheBSfromDB::fMeanX, BeamProfile2DBReader::TheBSfromDB::fMeanY, BeamProfile2DBReader::TheBSfromDB::fMeanZ, BeamProfile2DBReader::TheBSfromDB::fPhi, BeamProfile2DBReader::TheBSfromDB::fSigmaX, BeamProfile2DBReader::TheBSfromDB::fSigmaY, BeamProfile2DBReader::TheBSfromDB::fSigmaZ, BeamProfile2DBReader::TheBSfromDB::fTimeOffset, BeamProfile2DBReader::TheBSfromDB::fX0, BeamProfile2DBReader::TheBSfromDB::fY0, BeamProfile2DBReader::TheBSfromDB::fZ0, edm::EventSetup::getData(), iEvent, BeamProfile2DBReader::TheBSfromDB::init(), BeamProfile2DBReader::TheBSfromDB::ls, SimBeamSpotObjects::meanX(), SimBeamSpotObjects::meanY(), SimBeamSpotObjects::meanZ(), convertSQLitetoXML_cfg::output, output_, SimBeamSpotObjects::phi(), BeamProfile2DBReader::TheBSfromDB::run, SimBeamSpotObjects::sigmaX(), SimBeamSpotObjects::sigmaY(), SimBeamSpotObjects::sigmaZ(), theBSfromDB_, SimBeamSpotObjects::timeOffset(), watcher_, SimBeamSpotObjects::x(), SimBeamSpotObjects::y(), and SimBeamSpotObjects::z().

120  {
121  using namespace edm;
122  std::ostringstream output;
123 
124  // initialize the ntuple
125  theBSfromDB_.init();
126 
127  if (watcher_.check(iSetup)) { // check for new IOV for this run / LS
128 
129  output << " for runs: " << iEvent.id().run() << " - " << iEvent.id().luminosityBlock() << std::endl;
130 
131  // Get SimBeamSpot from EventSetup:
132  const SimBeamSpotObjects* mybeamspot = &iSetup.getData(beamSpotToken_);
133 
134  theBSfromDB_.run = iEvent.id().run();
135  theBSfromDB_.ls = iEvent.id().luminosityBlock();
136  theBSfromDB_.fX0 = mybeamspot->x();
137  theBSfromDB_.fY0 = mybeamspot->y();
138  theBSfromDB_.fZ0 = mybeamspot->z();
139  theBSfromDB_.fMeanX = mybeamspot->meanX();
140  theBSfromDB_.fMeanY = mybeamspot->meanY();
141  theBSfromDB_.fMeanZ = mybeamspot->meanZ();
142  theBSfromDB_.fSigmaX = mybeamspot->sigmaX();
143  theBSfromDB_.fSigmaY = mybeamspot->sigmaY();
144  theBSfromDB_.fSigmaZ = mybeamspot->sigmaZ();
145  theBSfromDB_.fbetastar = mybeamspot->betaStar();
146  theBSfromDB_.femittance = mybeamspot->emittance();
147  theBSfromDB_.fPhi = mybeamspot->phi();
148  theBSfromDB_.fAlpha = mybeamspot->alpha();
149  theBSfromDB_.fTimeOffset = mybeamspot->timeOffset();
150  bstree_->Fill();
151  output << *mybeamspot << std::endl;
152  }
153 
154  // Final output - either message logger or output file:
155  if (output_.get())
156  *output_ << output.str();
157  else
158  edm::LogInfo("BeamProfile2DBReader") << output.str();
159 }
double sigmaZ() const
struct BeamProfile2DBReader::TheBSfromDB theBSfromDB_
double sigmaX() const
get sigmaX, sigmaY, sigmaZ
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
double meanX() const
get meanX, meanY, meanZ position
double alpha() const
std::unique_ptr< std::ofstream > output_
int iEvent
Definition: GenABIO.cc:224
edm::ESWatcher< SimBeamSpotObjectsRcd > watcher_
const edm::ESGetToken< SimBeamSpotObjects, SimBeamSpotObjectsRcd > beamSpotToken_
Log< level::Info, false > LogInfo
double timeOffset() const
double meanY() const
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
double meanZ() const
double emittance() const
HLT enums.
double phi() const
get Phi, Alpha and TimeOffset
double betaStar() const
get BetaStar and Emittance
Definition: output.py:1
double x() const
get X, Y, Z position

◆ beginJob()

void BeamProfile2DBReader::beginJob ( )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 162 of file BeamProfile2DBReader.cc.

References bstree_, BeamProfile2DBReader::TheBSfromDB::fAlpha, BeamProfile2DBReader::TheBSfromDB::fbetastar, BeamProfile2DBReader::TheBSfromDB::femittance, BeamProfile2DBReader::TheBSfromDB::fMeanX, BeamProfile2DBReader::TheBSfromDB::fMeanY, BeamProfile2DBReader::TheBSfromDB::fMeanZ, BeamProfile2DBReader::TheBSfromDB::fPhi, BeamProfile2DBReader::TheBSfromDB::fSigmaX, BeamProfile2DBReader::TheBSfromDB::fSigmaY, BeamProfile2DBReader::TheBSfromDB::fSigmaZ, BeamProfile2DBReader::TheBSfromDB::fTimeOffset, BeamProfile2DBReader::TheBSfromDB::fX0, BeamProfile2DBReader::TheBSfromDB::fY0, BeamProfile2DBReader::TheBSfromDB::fZ0, BeamProfile2DBReader::TheBSfromDB::ls, TFileService::make(), BeamProfile2DBReader::TheBSfromDB::run, tFileService, and theBSfromDB_.

162  {
163  bstree_ = tFileService->make<TTree>("BSNtuple", "SimBeamSpot analyzer ntuple");
164 
165  //Tree Branches
166  bstree_->Branch("run", &theBSfromDB_.run, "run/I");
167  bstree_->Branch("ls", &theBSfromDB_.ls, "ls/I");
168  bstree_->Branch("BSx0", &theBSfromDB_.fX0, "BSx0/F");
169  bstree_->Branch("BSy0", &theBSfromDB_.fY0, "BSy0/F");
170  bstree_->Branch("BSz0", &theBSfromDB_.fZ0, "BSz0/F");
171  bstree_->Branch("BSmeanX", &theBSfromDB_.fMeanX, "BSmeanX/F");
172  bstree_->Branch("BSmeanY", &theBSfromDB_.fMeanY, "BSmeanY/F");
173  bstree_->Branch("BSmeanZ", &theBSfromDB_.fMeanZ, "BSmeanZ/F");
174  bstree_->Branch("Beamsigmax", &theBSfromDB_.fSigmaX, "Beamsigmax/F");
175  bstree_->Branch("Beamsigmay", &theBSfromDB_.fSigmaY, "Beamsigmay/F");
176  bstree_->Branch("Beamsigmaz", &theBSfromDB_.fSigmaZ, "Beamsigmaz/F");
177  bstree_->Branch("BetaStar", &theBSfromDB_.fbetastar, "BetaStar/F");
178  bstree_->Branch("Emittance", &theBSfromDB_.femittance, "Emittance/F");
179  bstree_->Branch("Phi", &theBSfromDB_.fPhi, "Phi/F");
180  bstree_->Branch("Alpha", &theBSfromDB_.fAlpha, "Alpha/F");
181  bstree_->Branch("TimeOffset", &theBSfromDB_.fTimeOffset, "TimeOffset/F");
182 }
struct BeamProfile2DBReader::TheBSfromDB theBSfromDB_
edm::Service< TFileService > tFileService
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64

◆ fillDescriptions()

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

Member Data Documentation

◆ beamSpotToken_

const edm::ESGetToken<SimBeamSpotObjects, SimBeamSpotObjectsRcd> BeamProfile2DBReader::beamSpotToken_
private

Definition at line 67 of file BeamProfile2DBReader.cc.

Referenced by analyze().

◆ bstree_

TTree* BeamProfile2DBReader::bstree_
private

Definition at line 69 of file BeamProfile2DBReader.cc.

Referenced by analyze(), and beginJob().

◆ output_

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

Definition at line 73 of file BeamProfile2DBReader.cc.

Referenced by analyze(), and BeamProfile2DBReader().

◆ tFileService

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

Definition at line 68 of file BeamProfile2DBReader.cc.

Referenced by beginJob().

◆ theBSfromDB_

struct BeamProfile2DBReader::TheBSfromDB BeamProfile2DBReader::theBSfromDB_
private

Referenced by analyze(), and beginJob().

◆ watcher_

edm::ESWatcher<SimBeamSpotObjectsRcd> BeamProfile2DBReader::watcher_
private

Definition at line 72 of file BeamProfile2DBReader.cc.

Referenced by analyze().