CMS 3D CMS Logo

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

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

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

Classes

struct  TheBSfromDB
 

Public Member Functions

 BeamProfileHLLHC2DBReader (const edm::ParameterSet &)
 
 ~BeamProfileHLLHC2DBReader () 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< SimBeamSpotHLLHCObjects, SimBeamSpotHLLHCObjectsRcdbeamSpotToken_
 
TTree * bstree_
 
std::unique_ptr< std::ofstream > output_
 
edm::Service< TFileServicetFileService
 
struct BeamProfileHLLHC2DBReader::TheBSfromDB theBSfromDB_
 
edm::ESWatcher< SimBeamSpotHLLHCObjectsRcdwatcher_
 

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 edm::one::EDAnalyzer to retrieve and ntuplize SimBeamSpotHLLHC data from the conditions database

Implementation: [Notes on implementation]

Definition at line 44 of file BeamProfileHLLHC2DBReader.cc.

Constructor & Destructor Documentation

◆ BeamProfileHLLHC2DBReader()

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

Definition at line 77 of file BeamProfileHLLHC2DBReader.cc.

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

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

◆ ~BeamProfileHLLHC2DBReader()

BeamProfileHLLHC2DBReader::~BeamProfileHLLHC2DBReader ( )
overridedefault

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 116 of file BeamProfileHLLHC2DBReader.cc.

References beamSpotToken_, SimBeamSpotHLLHCObjects::betaCrossingPlane(), SimBeamSpotHLLHCObjects::betaSeparationPlane(), bstree_, SimBeamSpotHLLHCObjects::bunchLenght(), edm::ESWatcher< T >::check(), SimBeamSpotHLLHCObjects::crabbingAngleCrossing(), SimBeamSpotHLLHCObjects::crabbingAngleSeparation(), SimBeamSpotHLLHCObjects::crabFrequency(), SimBeamSpotHLLHCObjects::crossingAngle(), SimBeamSpotHLLHCObjects::eProton(), BeamProfileHLLHC2DBReader::TheBSfromDB::fBetaCrossingPlane, BeamProfileHLLHC2DBReader::TheBSfromDB::fBetaSeparationPlane, BeamProfileHLLHC2DBReader::TheBSfromDB::fBunchLength, BeamProfileHLLHC2DBReader::TheBSfromDB::fCrabbingAngleCrossing, BeamProfileHLLHC2DBReader::TheBSfromDB::fCrabbingAngleSeparation, BeamProfileHLLHC2DBReader::TheBSfromDB::fCrabFrequency, BeamProfileHLLHC2DBReader::TheBSfromDB::fCrossingAngle, BeamProfileHLLHC2DBReader::TheBSfromDB::fEProton, BeamProfileHLLHC2DBReader::TheBSfromDB::fHorizontalEmittance, BeamProfileHLLHC2DBReader::TheBSfromDB::fMeanX, BeamProfileHLLHC2DBReader::TheBSfromDB::fMeanY, BeamProfileHLLHC2DBReader::TheBSfromDB::fMeanZ, BeamProfileHLLHC2DBReader::TheBSfromDB::fRF800, BeamProfileHLLHC2DBReader::TheBSfromDB::fTimeOffset, BeamProfileHLLHC2DBReader::TheBSfromDB::fVerticalEmittance, edm::EventSetup::getData(), SimBeamSpotHLLHCObjects::horizontalEmittance(), iEvent, BeamProfileHLLHC2DBReader::TheBSfromDB::init(), BeamProfileHLLHC2DBReader::TheBSfromDB::ls, SimBeamSpotHLLHCObjects::meanX(), SimBeamSpotHLLHCObjects::meanY(), SimBeamSpotHLLHCObjects::meanZ(), convertSQLitetoXML_cfg::output, output_, SimBeamSpotHLLHCObjects::rf800(), BeamProfileHLLHC2DBReader::TheBSfromDB::run, theBSfromDB_, SimBeamSpotHLLHCObjects::timeOffset(), SimBeamSpotHLLHCObjects::verticalEmittance(), and watcher_.

116  {
117  using namespace edm;
118  std::ostringstream output;
119 
120  // initialize the ntuple
121  theBSfromDB_.init();
122 
123  if (watcher_.check(iSetup)) { // check for new IOV for this run / LS
124 
125  output << " for runs: " << iEvent.id().run() << " - " << iEvent.id().luminosityBlock() << std::endl;
126 
127  // Get SimBeamSpotHLLHCObjects from EventSetup:
128  const SimBeamSpotHLLHCObjects* mybeamspot = &iSetup.getData(beamSpotToken_);
129 
130  theBSfromDB_.run = iEvent.id().run();
131  theBSfromDB_.ls = iEvent.id().luminosityBlock();
132  theBSfromDB_.fMeanX = mybeamspot->meanX();
133  theBSfromDB_.fMeanY = mybeamspot->meanY();
134  theBSfromDB_.fMeanZ = mybeamspot->meanZ();
135  theBSfromDB_.fEProton = mybeamspot->eProton();
136  theBSfromDB_.fCrabFrequency = mybeamspot->crabFrequency();
137  theBSfromDB_.fRF800 = mybeamspot->rf800();
138  theBSfromDB_.fCrossingAngle = mybeamspot->crossingAngle();
145  theBSfromDB_.fBunchLength = mybeamspot->bunchLenght();
146  theBSfromDB_.fTimeOffset = mybeamspot->timeOffset();
147  bstree_->Fill();
148  output << *mybeamspot << std::endl;
149  }
150 
151  // Final output - either message logger or output file:
152  if (output_.get())
153  *output_ << output.str();
154  else
155  edm::LogInfo("BeamProfileHLLHC2DBReader") << output.str();
156 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
double eProton() const
get EProton, fCrabFrequency, RF800
std::unique_ptr< std::ofstream > output_
int iEvent
Definition: GenABIO.cc:224
double meanX() const
get meanX, meanY, meanZ position
double crossingAngle() const
set Crossing and Crabbing angles
Log< level::Info, false > LogInfo
double betaCrossingPlane() const
get BetaStar and Emittance
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
struct BeamProfileHLLHC2DBReader::TheBSfromDB theBSfromDB_
HLT enums.
double bunchLenght() const
get BunchLength and TimeOffset
Definition: output.py:1
edm::ESWatcher< SimBeamSpotHLLHCObjectsRcd > watcher_
const edm::ESGetToken< SimBeamSpotHLLHCObjects, SimBeamSpotHLLHCObjectsRcd > beamSpotToken_

◆ beginJob()

void BeamProfileHLLHC2DBReader::beginJob ( )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 159 of file BeamProfileHLLHC2DBReader.cc.

References bstree_, BeamProfileHLLHC2DBReader::TheBSfromDB::fBetaCrossingPlane, BeamProfileHLLHC2DBReader::TheBSfromDB::fBetaSeparationPlane, BeamProfileHLLHC2DBReader::TheBSfromDB::fBunchLength, BeamProfileHLLHC2DBReader::TheBSfromDB::fCrabbingAngleCrossing, BeamProfileHLLHC2DBReader::TheBSfromDB::fCrabbingAngleSeparation, BeamProfileHLLHC2DBReader::TheBSfromDB::fCrabFrequency, BeamProfileHLLHC2DBReader::TheBSfromDB::fCrossingAngle, BeamProfileHLLHC2DBReader::TheBSfromDB::fEProton, BeamProfileHLLHC2DBReader::TheBSfromDB::fHorizontalEmittance, BeamProfileHLLHC2DBReader::TheBSfromDB::fMeanX, BeamProfileHLLHC2DBReader::TheBSfromDB::fMeanY, BeamProfileHLLHC2DBReader::TheBSfromDB::fMeanZ, BeamProfileHLLHC2DBReader::TheBSfromDB::fRF800, BeamProfileHLLHC2DBReader::TheBSfromDB::fTimeOffset, BeamProfileHLLHC2DBReader::TheBSfromDB::fVerticalEmittance, BeamProfileHLLHC2DBReader::TheBSfromDB::ls, TFileService::make(), BeamProfileHLLHC2DBReader::TheBSfromDB::run, tFileService, and theBSfromDB_.

159  {
160  bstree_ = tFileService->make<TTree>("BSNtuple", "SimBeamSpotHLLHC analyzer ntuple");
161 
162  //Tree Branches
163  bstree_->Branch("run", &theBSfromDB_.run, "run/I");
164  bstree_->Branch("ls", &theBSfromDB_.ls, "ls/I");
165  bstree_->Branch("MeanX", &theBSfromDB_.fMeanX, "MeanX/F");
166  bstree_->Branch("MeanY", &theBSfromDB_.fMeanY, "MeanY/F");
167  bstree_->Branch("MeanZ", &theBSfromDB_.fMeanZ, "MeanZ/F");
168  bstree_->Branch("EProton", &theBSfromDB_.fEProton, "EProton/F");
169  bstree_->Branch("CrabFrequency", &theBSfromDB_.fCrabFrequency, "CrabFrequency/F");
170  bstree_->Branch("RF800", &theBSfromDB_.fRF800, "RF800/O");
171  bstree_->Branch("CrossingAngle", &theBSfromDB_.fCrossingAngle, "CrossingAngle/F");
172  bstree_->Branch("CrabbingAngleCrossing", &theBSfromDB_.fCrabbingAngleCrossing, "CrabbingAngleCrossing/F");
173  bstree_->Branch("CrabbingAngleSeparation", &theBSfromDB_.fCrabbingAngleSeparation, "CrabbingAngleSeparation/F");
174  bstree_->Branch("BetaCrossingPlane", &theBSfromDB_.fBetaCrossingPlane, "BetaCrossingPlane/F");
175  bstree_->Branch("BetaSeparationPlane", &theBSfromDB_.fBetaSeparationPlane, "BetaSeparationPlane/F");
176  bstree_->Branch("HorizontalEmittance", &theBSfromDB_.fHorizontalEmittance, "HorizontalEmittance/F");
177  bstree_->Branch("VerticalEmittance", &theBSfromDB_.fVerticalEmittance, "VerticalEmittance/F");
178  bstree_->Branch("BunchLength", &theBSfromDB_.fBunchLength, "BunchLength/F");
179  bstree_->Branch("TimeOffset", &theBSfromDB_.fTimeOffset, "TimeOffset/F");
180 }
edm::Service< TFileService > tFileService
struct BeamProfileHLLHC2DBReader::TheBSfromDB theBSfromDB_
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64

◆ fillDescriptions()

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

Member Data Documentation

◆ beamSpotToken_

const edm::ESGetToken<SimBeamSpotHLLHCObjects, SimBeamSpotHLLHCObjectsRcd> BeamProfileHLLHC2DBReader::beamSpotToken_
private

Definition at line 67 of file BeamProfileHLLHC2DBReader.cc.

Referenced by analyze().

◆ bstree_

TTree* BeamProfileHLLHC2DBReader::bstree_
private

Definition at line 69 of file BeamProfileHLLHC2DBReader.cc.

Referenced by analyze(), and beginJob().

◆ output_

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

Definition at line 73 of file BeamProfileHLLHC2DBReader.cc.

Referenced by analyze(), and BeamProfileHLLHC2DBReader().

◆ tFileService

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

Definition at line 68 of file BeamProfileHLLHC2DBReader.cc.

Referenced by beginJob().

◆ theBSfromDB_

struct BeamProfileHLLHC2DBReader::TheBSfromDB BeamProfileHLLHC2DBReader::theBSfromDB_
private

Referenced by analyze(), and beginJob().

◆ watcher_

edm::ESWatcher<SimBeamSpotHLLHCObjectsRcd> BeamProfileHLLHC2DBReader::watcher_
private

Definition at line 72 of file BeamProfileHLLHC2DBReader.cc.

Referenced by analyze().