CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
 
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::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
 
bool registeredToConsumeMany (TypeID const &, 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::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
 
template<class Record >
void dump (const edm::Event &, const edm::EventSetup &, const edm::ESGetToken< BeamSpotOnlineObjects, Record > &)
 

Private Attributes

TTree * bstree_
 
edm::ESWatcher
< BeamSpotOnlineHLTObjectsRcd
hlt_watcher_
 
const edm::ESGetToken
< BeamSpotOnlineObjects,
BeamSpotOnlineHLTObjectsRcd
hltToken
 
bool isHLT_
 
edm::ESWatcher
< BeamSpotOnlineLegacyObjectsRcd
legacy_watcher_
 
const edm::ESGetToken
< BeamSpotOnlineObjects,
BeamSpotOnlineLegacyObjectsRcd
legacyToken
 
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< B > consumes (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 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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
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...
 
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 ( 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 getUntrackedParameter(std::string const &, T const &) const
Log< level::Error, false > LogError
const edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineLegacyObjectsRcd > legacyToken
const edm::ESGetToken< BeamSpotOnlineObjects, BeamSpotOnlineHLTObjectsRcd > hltToken
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::unique_ptr< std::ofstream > output_
BeamSpotOnlineRecordsReader::~BeamSpotOnlineRecordsReader ( )
overridedefault

Member Function Documentation

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
void BeamSpotOnlineRecordsReader::beginJob ( void  )
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_
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
edm::Service< TFileService > tFileService
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_, BeamSpotOnlineRecordsReader::theBSOfromDB::BeamWidthX_, BeamSpotOnlineRecordsReader::theBSOfromDB::BeamWidthY_, bstree_, BeamSpotOnlineRecordsReader::theBSOfromDB::BSx0_, BeamSpotOnlineRecordsReader::theBSOfromDB::BSy0_, BeamSpotOnlineRecordsReader::theBSOfromDB::BSz0_, BeamSpotObjects::GetBeamWidthX(), BeamSpotObjects::GetBeamWidthY(), edm::EventSetup::getData(), BeamSpotObjects::Getdxdz(), BeamSpotOnlineObjects::GetLastAnalyzedFill(), BeamSpotOnlineObjects::GetLastAnalyzedLumi(), BeamSpotOnlineObjects::GetLastAnalyzedRun(), BeamSpotObjects::GetSigmaZ(), BeamSpotObjects::GetX(), BeamSpotObjects::GetY(), BeamSpotObjects::GetZ(), edm::EventBase::id(), BeamSpotOnlineRecordsReader::theBSOfromDB::init(), BeamSpotOnlineRecordsReader::theBSOfromDB::lastAnalyzedFill_, BeamSpotOnlineRecordsReader::theBSOfromDB::lastAnalyzedLumi_, BeamSpotOnlineRecordsReader::theBSOfromDB::lastAnalyzedRun_, BeamSpotOnlineRecordsReader::theBSOfromDB::ls, edm::EventID::luminosityBlock(), convertSQLitetoXML_cfg::output, output_, edm::EventID::run(), BeamSpotOnlineRecordsReader::theBSOfromDB::run, and theBSOfromDB_.

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->GetX();
164  theBSOfromDB_.BSy0_ = mybeamspot->GetY();
165  theBSOfromDB_.BSz0_ = mybeamspot->GetZ();
166  theBSOfromDB_.Beamsigmaz_ = mybeamspot->GetSigmaZ();
167  theBSOfromDB_.Beamdxdz_ = mybeamspot->Getdxdz();
168  theBSOfromDB_.BeamWidthX_ = mybeamspot->GetBeamWidthX();
169  theBSOfromDB_.BeamWidthY_ = mybeamspot->GetBeamWidthY();
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 }
RunNumber_t run() const
Definition: EventID.h:38
struct BeamSpotOnlineRecordsReader::theBSOfromDB theBSOfromDB_
double GetY() const
get Y beam position
double GetSigmaZ() const
get sigma Z, RMS bunch length
double GetBeamWidthX() const
get average transverse beam width
int GetLastAnalyzedLumi() const
Getters Methods.
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39
double GetBeamWidthY() const
get average transverse beam width
bool getData(T &iHolder) const
Definition: EventSetup.h:128
double GetZ() const
get Z beam position
double Getdxdz() const
get dxdz slope, crossing angle in XZ
Log< level::Info, false > LogInfo
double GetX() const
get X beam position
edm::EventID id() const
Definition: EventBase.h:59
std::unique_ptr< std::ofstream > output_
void BeamSpotOnlineRecordsReader::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 206 of file BeamSpotOnlineRecordsReader.cc.

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

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

Member Data Documentation

TTree* BeamSpotOnlineRecordsReader::bstree_
private

Definition at line 80 of file BeamSpotOnlineRecordsReader.cc.

Referenced by beginJob(), and dump().

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

Definition at line 87 of file BeamSpotOnlineRecordsReader.cc.

Referenced by analyze().

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

Definition at line 82 of file BeamSpotOnlineRecordsReader.cc.

Referenced by analyze().

bool BeamSpotOnlineRecordsReader::isHLT_
private

Definition at line 86 of file BeamSpotOnlineRecordsReader.cc.

Referenced by analyze(), and BeamSpotOnlineRecordsReader().

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

Definition at line 88 of file BeamSpotOnlineRecordsReader.cc.

Referenced by analyze().

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

Definition at line 83 of file BeamSpotOnlineRecordsReader.cc.

Referenced by analyze().

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

Definition at line 89 of file BeamSpotOnlineRecordsReader.cc.

Referenced by BeamSpotOnlineRecordsReader(), and dump().

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

Definition at line 79 of file BeamSpotOnlineRecordsReader.cc.

Referenced by beginJob().

struct BeamSpotOnlineRecordsReader::theBSOfromDB BeamSpotOnlineRecordsReader::theBSOfromDB_
private

Referenced by beginJob(), and dump().