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 ()
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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::vector< ModuleDescription const * > &modules, 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 updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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

virtual void analyze (const edm::Event &, const edm::EventSetup &) override
 
virtual void beginJob () override
 
virtual void endJob () override
 

Private Attributes

TTree * bstree_
 
std::auto_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)
 
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 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)
 

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 ( const edm::ParameterSet iConfig)
explicit

Definition at line 94 of file BeamSpotRcdReader.cc.

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

94  :
95  bstree_(0)
96 {
97  //now do what ever initialization is needed
98  usesResource("TFileService");
99  std::string fileName(iConfig.getUntrackedParameter<std::string>("rawFileName"));
100  if (fileName.size()) {
101  output_.reset(new std::ofstream(fileName.c_str()));
102  if (!output_->good()) {
103  edm::LogError("IOproblem") << "Could not open output file " << fileName << ".";
104  output_.reset();
105  }
106  }
107 }
T getUntrackedParameter(std::string const &, T const &) const
std::auto_ptr< std::ofstream > output_
BeamSpotRcdReader::~BeamSpotRcdReader ( )

Definition at line 110 of file BeamSpotRcdReader.cc.

111 {
112 
113  // do anything here that needs to be done at desctruction time
114  // (e.g. close files, deallocate resources etc.)
115 
116 }

Member Function Documentation

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

Definition at line 145 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_, edm::ESWatcher< T >::check(), edm::EventSetup::get(), BeamSpotObjects::GetBeamWidthX(), BeamSpotObjects::GetBeamWidthY(), BeamSpotObjects::Getdxdz(), BeamSpotObjects::GetSigmaZ(), BeamSpotObjects::GetX(), BeamSpotObjects::GetY(), BeamSpotObjects::GetZ(), edm::EventBase::id(), BeamSpotRcdReader::theBSfromDB::init(), BeamSpotRcdReader::theBSfromDB::ls, edm::EventID::luminosityBlock(), convertSQLitetoXML_cfg::output, output_, edm::ESHandle< T >::product(), edm::EventID::run(), BeamSpotRcdReader::theBSfromDB::run, theBSfromDB_, and watcher_.

146 {
147  using namespace edm;
148  std::ostringstream output;
149 
150  // initialize the ntuple
151  theBSfromDB_.init();
152 
153  if (watcher_.check(iSetup)) { // check for new IOV for this run / LS
154 
155  output << " for runs: " << iEvent.id().run() << " - " << iEvent.id().luminosityBlock() << std::endl;
156 
157  // Get BeamSpot from EventSetup:
159  iSetup.get<BeamSpotObjectsRcd>().get(beamhandle);
160  const BeamSpotObjects *mybeamspot = beamhandle.product();
161 
162  theBSfromDB_.run = iEvent.id().run();
163  theBSfromDB_.ls = iEvent.id().luminosityBlock();
164  theBSfromDB_.BSx0_ = mybeamspot->GetX();
165  theBSfromDB_.BSy0_ = mybeamspot->GetY();
166  theBSfromDB_.BSz0_ = mybeamspot->GetZ();
167  theBSfromDB_.Beamsigmaz_ = mybeamspot->GetSigmaZ();
168  theBSfromDB_.Beamdxdz_ = mybeamspot->Getdxdz();
169  theBSfromDB_.BeamWidthX_ = mybeamspot->GetBeamWidthX();
170  theBSfromDB_.BeamWidthY_ = mybeamspot->GetBeamWidthY();
171 
172  bstree_->Fill();
173 
174  output << *mybeamspot << std::endl;
175 
176  }
177 
178  // Final output - either message logger or output file:
179  if (output_.get()) *output_ << output.str();
180  else edm::LogInfo("") << output.str();
181 }
RunNumber_t run() const
Definition: EventID.h:39
double GetY() const
get Y beam position
edm::ESWatcher< BeamSpotObjectsRcd > watcher_
struct BeamSpotRcdReader::theBSfromDB theBSfromDB_
double GetSigmaZ() const
get sigma Z, RMS bunch length
double GetBeamWidthX() const
get average transverse beam width
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
double GetBeamWidthY() const
get average transverse beam width
std::auto_ptr< std::ofstream > output_
double GetZ() const
get Z beam position
double Getdxdz() const
get dxdz slope, crossing angle in XZ
double GetX() const
get X beam position
const T & get() const
Definition: EventSetup.h:56
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
edm::EventID id() const
Definition: EventBase.h:60
HLT enums.
T const * product() const
Definition: ESHandle.h:86
void BeamSpotRcdReader::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 186 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_.

187 {
188  bstree_ = tFileService->make<TTree>("BSNtuple","BeamSpot analyzer ntuple");
189 
190  //Tree Branches
191  bstree_->Branch("run",&theBSfromDB_.run,"run/I");
192  bstree_->Branch("ls",&theBSfromDB_.ls,"ls/I");
193  bstree_->Branch("BSx0",&theBSfromDB_.BSx0_,"BSx0/F");
194  bstree_->Branch("BSy0",&theBSfromDB_.BSy0_,"BSy0/F");
195  bstree_->Branch("BSz0",&theBSfromDB_.BSz0_,"BSz0/F");
196  bstree_->Branch("Beamsigmaz",&theBSfromDB_.Beamsigmaz_ ,"Beamsigmaz/F");
197  bstree_->Branch("Beamdxdz",&theBSfromDB_.Beamdxdz_,"Beamdxdz/F");
198  bstree_->Branch("BeamWidthX",&theBSfromDB_.BeamWidthX_,"BeamWidthX/F");
199  bstree_->Branch("BeamWidthY",&theBSfromDB_.BeamWidthY_,"BeamWidthY/F");
200 
201 }
struct BeamSpotRcdReader::theBSfromDB theBSfromDB_
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
edm::Service< TFileService > tFileService
void BeamSpotRcdReader::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 205 of file BeamSpotRcdReader.cc.

206 {
207 }
void BeamSpotRcdReader::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 211 of file BeamSpotRcdReader.cc.

References edm::ConfigurationDescriptions::addDefault(), DEFINE_FWK_MODULE, and edm::ParameterSetDescription::setUnknown().

211  {
212  //The following says we do not know what parameters are allowed so do no validation
213  // Please change this to state exactly what you do use, even if it is no parameters
215  desc.setUnknown();
216  descriptions.addDefault(desc);
217 }
void addDefault(ParameterSetDescription const &psetDescription)

Member Data Documentation

TTree* BeamSpotRcdReader::bstree_
private

Definition at line 76 of file BeamSpotRcdReader.cc.

Referenced by analyze(), and beginJob().

std::auto_ptr<std::ofstream> BeamSpotRcdReader::output_
private

Definition at line 80 of file BeamSpotRcdReader.cc.

Referenced by analyze(), and BeamSpotRcdReader().

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

Definition at line 75 of file BeamSpotRcdReader.cc.

Referenced by beginJob().

struct BeamSpotRcdReader::theBSfromDB BeamSpotRcdReader::theBSfromDB_
private

Referenced by analyze(), and beginJob().

edm::ESWatcher<BeamSpotObjectsRcd> BeamSpotRcdReader::watcher_
private

Definition at line 79 of file BeamSpotRcdReader.cc.

Referenced by analyze().