CMS 3D CMS Logo

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

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

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

Classes

struct  theBSOfromDB
 

Public Member Functions

 BeamSpotOnlineRecordsReader (const edm::ParameterSet &)
 
 ~BeamSpotOnlineRecordsReader () override
 
- 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
 
template<class Record >
void dump (const edm::Event &, const edm::EventSetup &, const edm::ESGetToken< BeamSpotOnlineObjects, Record > &)
 

Private Attributes

TTree * bstree_
 
edm::ESWatcher< BeamSpotOnlineHLTObjectsRcdhlt_watcher_
 
const edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineHLTObjectsRcdhltToken
 
bool isHLT_
 
edm::ESWatcher< BeamSpotOnlineLegacyObjectsRcdlegacy_watcher_
 
const edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineLegacyObjectsRcdlegacyToken
 
std::unique_ptr< std::ofstream > output_
 
edm::Service< TFileServicetFileService
 
struct BeamSpotOnlineRecordsReader::theBSOfromDB theBSOfromDB_
 

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: EDAnalyzer to read the BeamSpotOnlineHLTObjectsRcd or BeamSpotOnlineLegacyObjectsRcd and dump it into a txt and root file

Implementation: [Notes on implementation]

Definition at line 50 of file BeamSpotOnlineRecordsReader.cc.

Constructor & Destructor Documentation

◆ BeamSpotOnlineRecordsReader()

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

Definition at line 95 of file BeamSpotOnlineRecordsReader.cc.

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

96  : bstree_(nullptr), hltToken(esConsumes()), legacyToken(esConsumes()) {
97  //now do what ever initialization is needed
98  isHLT_ = iConfig.getParameter<bool>("isHLT");
99  usesResource("TFileService");
100  std::string fileName(iConfig.getUntrackedParameter<std::string>("rawFileName"));
101  if (!fileName.empty()) {
102  output_ = std::make_unique<std::ofstream>(fileName.c_str());
103  if (!output_->good()) {
104  edm::LogError("IOproblem") << "Could not open output file " << fileName << ".";
105  output_.reset();
106  }
107  }
108 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Log< level::Error, false > LogError
const edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineLegacyObjectsRcd > legacyToken
T getUntrackedParameter(std::string const &, T const &) const
const edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineHLTObjectsRcd > hltToken
std::unique_ptr< std::ofstream > output_

◆ ~BeamSpotOnlineRecordsReader()

BeamSpotOnlineRecordsReader::~BeamSpotOnlineRecordsReader ( )
overridedefault

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 135 of file BeamSpotOnlineRecordsReader.cc.

References edm::ESWatcher< T >::check(), hlt_watcher_, hltToken, iEvent, isHLT_, legacy_watcher_, and legacyToken.

135  {
136  using namespace edm;
137 
138  if (isHLT_) {
139  if (hlt_watcher_.check(iSetup)) {
140  dump<BeamSpotOnlineHLTObjectsRcd>(iEvent, iSetup, hltToken);
141  } // check for new IOV for this run / LS
142  } else {
143  if (legacy_watcher_.check(iSetup)) {
144  dump<BeamSpotOnlineLegacyObjectsRcd>(iEvent, iSetup, legacyToken);
145  } // check for new IOV for this run / LS
146  }
147 }
edm::ESWatcher< BeamSpotOnlineLegacyObjectsRcd > legacy_watcher_
edm::ESWatcher< BeamSpotOnlineHLTObjectsRcd > hlt_watcher_
const edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineLegacyObjectsRcd > legacyToken
int iEvent
Definition: GenABIO.cc:224
const edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineHLTObjectsRcd > hltToken
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
HLT enums.

◆ beginJob()

void BeamSpotOnlineRecordsReader::beginJob ( )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 187 of file BeamSpotOnlineRecordsReader.cc.

References BeamSpotOnlineRecordsReader::theBSOfromDB::Beamdxdz_, BeamSpotOnlineRecordsReader::theBSOfromDB::Beamsigmaz_, BeamSpotOnlineRecordsReader::theBSOfromDB::BeamWidthX_, BeamSpotOnlineRecordsReader::theBSOfromDB::BeamWidthY_, bstree_, BeamSpotOnlineRecordsReader::theBSOfromDB::BSx0_, BeamSpotOnlineRecordsReader::theBSOfromDB::BSy0_, BeamSpotOnlineRecordsReader::theBSOfromDB::BSz0_, BeamSpotOnlineRecordsReader::theBSOfromDB::lastAnalyzedFill_, BeamSpotOnlineRecordsReader::theBSOfromDB::lastAnalyzedLumi_, BeamSpotOnlineRecordsReader::theBSOfromDB::lastAnalyzedRun_, BeamSpotOnlineRecordsReader::theBSOfromDB::ls, TFileService::make(), BeamSpotOnlineRecordsReader::theBSOfromDB::run, tFileService, and theBSOfromDB_.

187  {
188  bstree_ = tFileService->make<TTree>("BSONtuple", "BeamSpotOnline analyzer ntuple");
189 
190  //Tree Branches
191  bstree_->Branch("run", &theBSOfromDB_.run, "run/I");
192  bstree_->Branch("ls", &theBSOfromDB_.ls, "ls/I");
193  bstree_->Branch("BSx0", &theBSOfromDB_.BSx0_, "BSx0/F");
194  bstree_->Branch("BSy0", &theBSOfromDB_.BSy0_, "BSy0/F");
195  bstree_->Branch("BSz0", &theBSOfromDB_.BSz0_, "BSz0/F");
196  bstree_->Branch("Beamsigmaz", &theBSOfromDB_.Beamsigmaz_, "Beamsigmaz/F");
197  bstree_->Branch("Beamdxdz", &theBSOfromDB_.Beamdxdz_, "Beamdxdz/F");
198  bstree_->Branch("BeamWidthX", &theBSOfromDB_.BeamWidthX_, "BeamWidthX/F");
199  bstree_->Branch("BeamWidthY", &theBSOfromDB_.BeamWidthY_, "BeamWidthY/F");
200  bstree_->Branch("LastAnalyzedLumi", &theBSOfromDB_.lastAnalyzedLumi_, "LastAnalyzedLumi/I");
201  bstree_->Branch("LastAnalyzedRun", &theBSOfromDB_.lastAnalyzedRun_, "LastAnalyzedRun/I");
202  bstree_->Branch("LastAnalyzedFill", &theBSOfromDB_.lastAnalyzedFill_, "LastAnalyzedFill/I");
203 }
struct BeamSpotOnlineRecordsReader::theBSOfromDB theBSOfromDB_
edm::Service< TFileService > tFileService
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64

◆ dump()

template<class Record >
void BeamSpotOnlineRecordsReader::dump ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const edm::ESGetToken< BeamSpotOnlineObjects, Record > &  token 
)
private

Definition at line 150 of file BeamSpotOnlineRecordsReader.cc.

References BeamSpotOnlineRecordsReader::theBSOfromDB::Beamdxdz_, BeamSpotOnlineRecordsReader::theBSOfromDB::Beamsigmaz_, BeamSpotObjects::beamWidthX(), BeamSpotOnlineRecordsReader::theBSOfromDB::BeamWidthX_, BeamSpotObjects::beamWidthY(), BeamSpotOnlineRecordsReader::theBSOfromDB::BeamWidthY_, bstree_, BeamSpotOnlineRecordsReader::theBSOfromDB::BSx0_, BeamSpotOnlineRecordsReader::theBSOfromDB::BSy0_, BeamSpotOnlineRecordsReader::theBSOfromDB::BSz0_, BeamSpotObjects::dxdz(), edm::EventSetup::getData(), iEvent, BeamSpotOnlineRecordsReader::theBSOfromDB::init(), BeamSpotOnlineObjects::lastAnalyzedFill(), BeamSpotOnlineRecordsReader::theBSOfromDB::lastAnalyzedFill_, BeamSpotOnlineObjects::lastAnalyzedLumi(), BeamSpotOnlineRecordsReader::theBSOfromDB::lastAnalyzedLumi_, BeamSpotOnlineObjects::lastAnalyzedRun(), BeamSpotOnlineRecordsReader::theBSOfromDB::lastAnalyzedRun_, BeamSpotOnlineRecordsReader::theBSOfromDB::ls, convertSQLitetoXML_cfg::output, output_, BeamSpotOnlineRecordsReader::theBSOfromDB::run, BeamSpotObjects::sigmaZ(), theBSOfromDB_, unpackBuffers-CaloStage2::token, BeamSpotObjects::x(), BeamSpotObjects::y(), and BeamSpotObjects::z().

152  {
153  std::ostringstream output;
154  // initialize the ntuple
156  output << " for runs: " << iEvent.id().run() << " - " << iEvent.id().luminosityBlock() << std::endl;
157 
158  // Get BeamSpot from EventSetup:
159  const BeamSpotOnlineObjects* mybeamspot = &iSetup.getData(token);
160 
161  theBSOfromDB_.run = iEvent.id().run();
162  theBSOfromDB_.ls = iEvent.id().luminosityBlock();
163  theBSOfromDB_.BSx0_ = mybeamspot->x();
164  theBSOfromDB_.BSy0_ = mybeamspot->y();
165  theBSOfromDB_.BSz0_ = mybeamspot->z();
166  theBSOfromDB_.Beamsigmaz_ = mybeamspot->sigmaZ();
167  theBSOfromDB_.Beamdxdz_ = mybeamspot->dxdz();
168  theBSOfromDB_.BeamWidthX_ = mybeamspot->beamWidthX();
169  theBSOfromDB_.BeamWidthY_ = mybeamspot->beamWidthY();
173 
174  bstree_->Fill();
175 
176  output << *mybeamspot << std::endl;
177 
178  // Final output - either message logger or output file:
179  if (output_.get()) {
180  *output_ << output.str();
181  } else {
182  edm::LogInfo("BeamSpotOnlineRecordsReader") << output.str();
183  }
184 }
int lastAnalyzedLumi() const
Getters Methods.
double z() const
get Z beam position
struct BeamSpotOnlineRecordsReader::theBSOfromDB theBSOfromDB_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
double beamWidthX() const
get average transverse beam width
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
double dxdz() const
get dxdz slope, crossing angle in XZ
std::unique_ptr< std::ofstream > output_

◆ fillDescriptions()

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

Definition at line 206 of file BeamSpotOnlineRecordsReader.cc.

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

206  {
208  desc.add<bool>("isHLT", true);
209  desc.addUntracked<std::string>("rawFileName", "");
210  descriptions.addDefault(desc);
211 }
void addDefault(ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ bstree_

TTree* BeamSpotOnlineRecordsReader::bstree_
private

Definition at line 80 of file BeamSpotOnlineRecordsReader.cc.

Referenced by beginJob(), and dump().

◆ hlt_watcher_

edm::ESWatcher<BeamSpotOnlineHLTObjectsRcd> BeamSpotOnlineRecordsReader::hlt_watcher_
private

Definition at line 87 of file BeamSpotOnlineRecordsReader.cc.

Referenced by analyze().

◆ hltToken

const edm::ESGetToken<BeamSpotOnlineObjects, BeamSpotOnlineHLTObjectsRcd> BeamSpotOnlineRecordsReader::hltToken
private

Definition at line 82 of file BeamSpotOnlineRecordsReader.cc.

Referenced by analyze().

◆ isHLT_

bool BeamSpotOnlineRecordsReader::isHLT_
private

Definition at line 86 of file BeamSpotOnlineRecordsReader.cc.

Referenced by analyze(), and BeamSpotOnlineRecordsReader().

◆ legacy_watcher_

edm::ESWatcher<BeamSpotOnlineLegacyObjectsRcd> BeamSpotOnlineRecordsReader::legacy_watcher_
private

Definition at line 88 of file BeamSpotOnlineRecordsReader.cc.

Referenced by analyze().

◆ legacyToken

const edm::ESGetToken<BeamSpotOnlineObjects, BeamSpotOnlineLegacyObjectsRcd> BeamSpotOnlineRecordsReader::legacyToken
private

Definition at line 83 of file BeamSpotOnlineRecordsReader.cc.

Referenced by analyze().

◆ output_

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

Definition at line 89 of file BeamSpotOnlineRecordsReader.cc.

Referenced by BeamSpotOnlineRecordsReader(), and dump().

◆ tFileService

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

Definition at line 79 of file BeamSpotOnlineRecordsReader.cc.

Referenced by beginJob().

◆ theBSOfromDB_

struct BeamSpotOnlineRecordsReader::theBSOfromDB BeamSpotOnlineRecordsReader::theBSOfromDB_
private

Referenced by beginJob(), and dump().