CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
BeamSpotWrite2DB Class Reference

#include <BeamSpotWrite2DB.h>

Inheritance diagram for BeamSpotWrite2DB:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 BeamSpotWrite2DB (const edm::ParameterSet &)
 
 ~BeamSpotWrite2DB ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- 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 & itemsToGetFromEvent () 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)
 

Private Member Functions

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

Private Attributes

std::ifstream fasciiFile
 
std::string fasciiFileName
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- 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


class: BeamSpotWrite2DB.h package: RecoVertex/BeamSpotProducer

author: Francisco Yumiceva, Fermilab (yumic.nosp@m.eva@.nosp@m.fnal..nosp@m.gov)


Definition at line 31 of file BeamSpotWrite2DB.h.

Constructor & Destructor Documentation

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

class: BeamSpotWrite2DB.cc package: RecoVertex/BeamSpotProducer

author: Francisco Yumiceva, Fermilab (yumic.nosp@m.eva@.nosp@m.fnal..nosp@m.gov)


Definition at line 27 of file BeamSpotWrite2DB.cc.

References fasciiFile, fasciiFileName, edm::ParameterSet::getUntrackedParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

28 {
29 
30  fasciiFileName = iConfig.getUntrackedParameter<std::string>("OutputFileName");
31 
32  fasciiFile.open(fasciiFileName.c_str());
33 
34 }
T getUntrackedParameter(std::string const &, T const &) const
std::ifstream fasciiFile
std::string fasciiFileName
BeamSpotWrite2DB::~BeamSpotWrite2DB ( )

Definition at line 37 of file BeamSpotWrite2DB.cc.

38 {
39 }

Member Function Documentation

void BeamSpotWrite2DB::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Definition at line 43 of file BeamSpotWrite2DB.cc.

44 {
45 }
void BeamSpotWrite2DB::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 50 of file BeamSpotWrite2DB.cc.

51 {
52 }
void BeamSpotWrite2DB::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 55 of file BeamSpotWrite2DB.cc.

References cond::service::PoolDBOutputService::appendSinceTime(), cond::service::PoolDBOutputService::beginOfTime(), gather_cfg::cout, cond::service::PoolDBOutputService::createNewIOV(), cond::service::PoolDBOutputService::currentTime(), DEFINE_FWK_MODULE, BeamSpotFakeParameters_cfi::dxdz, BeamSpotFakeParameters_cfi::dydz, BeamSpotFakeParameters_cfi::emittanceX, BeamSpotFakeParameters_cfi::emittanceY, cond::service::PoolDBOutputService::endOfTime(), fasciiFile, fasciiFileName, i, edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), j, BeamSpotObjects::SetBeamWidthX(), BeamSpotObjects::SetBeamWidthY(), BeamSpotObjects::SetBetaStar(), BeamSpotObjects::SetCovariance(), BeamSpotObjects::Setdxdz(), BeamSpotObjects::Setdydz(), BeamSpotObjects::SetEmittanceX(), BeamSpotObjects::SetEmittanceY(), BeamSpotObjects::SetPosition(), BeamSpotObjects::SetSigmaZ(), BeamSpotObjects::SetType(), fftjetvertexadder_cfi::sigmaZ, AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, x, y, and z.

55  {
56 
57  std::cout << " Read beam spot data from text file: " << fasciiFileName << std::endl;
58  std::cout << " please see plugins/BeamSpotWrite2DB.cc for format of text file." << std::endl;
59  /*
60  std::cout << " Content of the file is expected to have this format with the first column as a keyword:" << std::endl;
61  std::cout << " x\n y\n z\n sigmaZ\n dxdz\n dydz\n beamWidthX\n beamWidthY" << std::endl;
62  for (int i =0; i<7; i++) {
63  for (int j=0; j<7; j++ ) {
64 
65  std::cout << " cov["<<i<<"]["<<j<<"] cov["<<i<<"]["<<j<<"] cov["<<i<<"]["<<j<<"] cov["<<i<<"]["<<j<<"] cov["<<i<<"]["<<j<<"] cov["<<j<<"]["<<j<<"] cov["<<i<<"]["<<j<<"]" << std::endl;
66  }
67  }
68  */
69 
70  // extract from file
71  double x,y,z,sigmaZ,dxdz,dydz,beamWidthX,beamWidthY,emittanceX,emittanceY,betastar;
73  double cov[7][7];
74  int type;
75 
76  fasciiFile >> tag >> type;
77  fasciiFile >> tag >> x;
78  fasciiFile >> tag >> y;
79  fasciiFile >> tag >> z;
80  fasciiFile >> tag >> sigmaZ;
81  fasciiFile >> tag >> dxdz;
82  fasciiFile >> tag >> dydz;
83  fasciiFile >> tag >> beamWidthX;
84  fasciiFile >> tag >> beamWidthY;
85  fasciiFile >> tag >> cov[0][0] >> cov[0][1] >> cov[0][2]>> cov[0][3] >> cov[0][4]>> cov[0][5] >> cov[0][6];
86  fasciiFile >> tag >> cov[1][0] >> cov[1][1] >> cov[1][2] >> cov[1][3]>> cov[1][4] >> cov[1][5]>> cov[1][6];
87  fasciiFile >> tag >> cov[2][0] >> cov[2][1] >> cov[2][2] >> cov[2][3]>> cov[2][4] >> cov[2][5]>> cov[2][6];
88  fasciiFile >> tag >> cov[3][0] >> cov[3][1] >> cov[3][2] >> cov[3][3]>> cov[3][4] >> cov[3][5]>> cov[3][6];
89  fasciiFile >> tag >> cov[4][0] >> cov[4][1] >> cov[4][2] >> cov[4][3]>> cov[4][4] >> cov[4][5]>> cov[4][6];
90  fasciiFile >> tag >> cov[5][0] >> cov[5][1] >> cov[5][2] >> cov[5][3]>> cov[5][4] >> cov[5][5]>> cov[5][6];
91  fasciiFile >> tag >> cov[6][0] >> cov[6][1] >> cov[6][2] >> cov[6][3]>> cov[6][4] >> cov[6][5]>> cov[6][6];
92  fasciiFile >> tag >> emittanceX;
93  fasciiFile >> tag >> emittanceY;
94  fasciiFile >> tag >> betastar;
95 
96  BeamSpotObjects *abeam = new BeamSpotObjects();
97 
98  abeam->SetType(type);
99  abeam->SetPosition(x,y,z);
100  abeam->SetSigmaZ(sigmaZ);
101  abeam->Setdxdz(dxdz);
102  abeam->Setdydz(dydz);
103  abeam->SetBeamWidthX(beamWidthX);
104  abeam->SetBeamWidthY(beamWidthY);
105  abeam->SetEmittanceX( emittanceX );
106  abeam->SetEmittanceY( emittanceY );
107  abeam->SetBetaStar( betastar );
108 
109  for (int i=0; i<7; ++i) {
110  for (int j=0; j<7; ++j) {
111  abeam->SetCovariance(i,j,cov[i][j]);
112  }
113  }
114 
115  std::cout << " write results to DB..." << std::endl;
116 
118  if( poolDbService.isAvailable() ) {
119  std::cout << "poolDBService available"<<std::endl;
120  if ( poolDbService->isNewTagRequest( "BeamSpotObjectsRcd" ) ) {
121  std::cout << "new tag requested" << std::endl;
122  poolDbService->createNewIOV<BeamSpotObjects>( abeam, poolDbService->beginOfTime(),poolDbService->endOfTime(),
123  "BeamSpotObjectsRcd" );
124  }
125  else {
126  std::cout << "no new tag requested" << std::endl;
127  poolDbService->appendSinceTime<BeamSpotObjects>( abeam, poolDbService->currentTime(),
128  "BeamSpotObjectsRcd" );
129  }
130 
131  }
132 
133  std::cout << "[BeamSpotWrite2DB] endJob done \n" << std::endl;
134 }
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
std::ifstream fasciiFile
std::string fasciiFileName
void SetSigmaZ(double val)
set sigma Z, RMS bunch length
void SetCovariance(int i, int j, double val)
set i,j element of the full covariance matrix 7x7
void Setdydz(double val)
set dydz slope, crossing angle in XZ
void appendSinceTime(T *payloadObj, cond::Time_t sinceTime, const std::string &recordName, bool withlogging=false)
bool isNewTagRequest(const std::string &recordName)
void SetEmittanceX(double val)
set emittance
bool isAvailable() const
Definition: Service.h:46
int j
Definition: DBlmapReader.cc:9
void Setdxdz(double val)
set dxdz slope, crossing angle
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
void SetBetaStar(double val)
set beta star
void SetType(int type)
set beam type
void SetEmittanceY(double val)
set emittance
void SetBeamWidthX(double val)
set average transverse beam width X
void SetBeamWidthY(double val)
set average transverse beam width Y
void SetPosition(double x, double y, double z)
set XYZ position

Member Data Documentation

std::ifstream BeamSpotWrite2DB::fasciiFile
private

Definition at line 42 of file BeamSpotWrite2DB.h.

Referenced by BeamSpotWrite2DB(), and endJob().

std::string BeamSpotWrite2DB::fasciiFileName
private

Definition at line 43 of file BeamSpotWrite2DB.h.

Referenced by BeamSpotWrite2DB(), and endJob().