CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
BeamSpotWrite2DB Class Reference

#include <BeamSpotWrite2DB.h>

Inheritance diagram for BeamSpotWrite2DB:
edm::EDAnalyzer

Public Member Functions

 BeamSpotWrite2DB (const edm::ParameterSet &)
 
 ~BeamSpotWrite2DB ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

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
 
typedef WorkerT< EDAnalyzerWorkerType
 
- 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::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description


class: BeamSpotWrite2DB.h package: RecoVertex/BeamSpotProducer

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

version

Id:
BeamSpotWrite2DB.h,v 1.2 2009/12/18 20:45:07 wmtan Exp

Definition at line 32 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)

version

Id:
BeamSpotWrite2DB.cc,v 1.7 2010/02/20 21:01:52 wmtan Exp

Definition at line 28 of file BeamSpotWrite2DB.cc.

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

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

Definition at line 38 of file BeamSpotWrite2DB.cc.

39 {
40 }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 44 of file BeamSpotWrite2DB.cc.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 51 of file BeamSpotWrite2DB.cc.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 56 of file BeamSpotWrite2DB.cc.

References cond::service::PoolDBOutputService::appendSinceTime(), cond::service::PoolDBOutputService::beginOfTime(), gather_cfg::cout, cond::service::PoolDBOutputService::createNewIOV(), cond::service::PoolDBOutputService::currentTime(), 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(), GlobalPosition_Frontier_DevDB_cff::tag, vdt::x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

56  {
57 
58  std::cout << " Read beam spot data from text file: " << fasciiFileName << std::endl;
59  std::cout << " please see plugins/BeamSpotWrite2DB.cc for format of text file." << std::endl;
60  /*
61  std::cout << " Content of the file is expected to have this format with the first column as a keyword:" << std::endl;
62  std::cout << " x\n y\n z\n sigmaZ\n dxdz\n dydz\n beamWidthX\n beamWidthY" << std::endl;
63  for (int i =0; i<7; i++) {
64  for (int j=0; j<7; j++ ) {
65 
66  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;
67  }
68  }
69  */
70 
71  // extract from file
72  double x,y,z,sigmaZ,dxdz,dydz,beamWidthX,beamWidthY,emittanceX,emittanceY,betastar;
73  std::string tag;
74  double cov[7][7];
75  int type;
76 
77  fasciiFile >> tag >> type;
78  fasciiFile >> tag >> x;
79  fasciiFile >> tag >> y;
80  fasciiFile >> tag >> z;
81  fasciiFile >> tag >> sigmaZ;
82  fasciiFile >> tag >> dxdz;
83  fasciiFile >> tag >> dydz;
84  fasciiFile >> tag >> beamWidthX;
85  fasciiFile >> tag >> beamWidthY;
86  fasciiFile >> tag >> cov[0][0] >> cov[0][1] >> cov[0][2]>> cov[0][3] >> cov[0][4]>> cov[0][5] >> cov[0][6];
87  fasciiFile >> tag >> cov[1][0] >> cov[1][1] >> cov[1][2] >> cov[1][3]>> cov[1][4] >> cov[1][5]>> cov[1][6];
88  fasciiFile >> tag >> cov[2][0] >> cov[2][1] >> cov[2][2] >> cov[2][3]>> cov[2][4] >> cov[2][5]>> cov[2][6];
89  fasciiFile >> tag >> cov[3][0] >> cov[3][1] >> cov[3][2] >> cov[3][3]>> cov[3][4] >> cov[3][5]>> cov[3][6];
90  fasciiFile >> tag >> cov[4][0] >> cov[4][1] >> cov[4][2] >> cov[4][3]>> cov[4][4] >> cov[4][5]>> cov[4][6];
91  fasciiFile >> tag >> cov[5][0] >> cov[5][1] >> cov[5][2] >> cov[5][3]>> cov[5][4] >> cov[5][5]>> cov[5][6];
92  fasciiFile >> tag >> cov[6][0] >> cov[6][1] >> cov[6][2] >> cov[6][3]>> cov[6][4] >> cov[6][5]>> cov[6][6];
93  fasciiFile >> tag >> emittanceX;
94  fasciiFile >> tag >> emittanceY;
95  fasciiFile >> tag >> betastar;
96 
97  BeamSpotObjects *abeam = new BeamSpotObjects();
98 
99  abeam->SetType(type);
100  abeam->SetPosition(x,y,z);
101  abeam->SetSigmaZ(sigmaZ);
102  abeam->Setdxdz(dxdz);
103  abeam->Setdydz(dydz);
104  abeam->SetBeamWidthX(beamWidthX);
105  abeam->SetBeamWidthY(beamWidthY);
106  abeam->SetEmittanceX( emittanceX );
107  abeam->SetEmittanceY( emittanceY );
108  abeam->SetBetaStar( betastar );
109 
110  for (int i=0; i<7; ++i) {
111  for (int j=0; j<7; ++j) {
112  abeam->SetCovariance(i,j,cov[i][j]);
113  }
114  }
115 
116  std::cout << " write results to DB..." << std::endl;
117 
119  if( poolDbService.isAvailable() ) {
120  std::cout << "poolDBService available"<<std::endl;
121  if ( poolDbService->isNewTagRequest( "BeamSpotObjectsRcd" ) ) {
122  std::cout << "new tag requested" << std::endl;
123  poolDbService->createNewIOV<BeamSpotObjects>( abeam, poolDbService->beginOfTime(),poolDbService->endOfTime(),
124  "BeamSpotObjectsRcd" );
125  }
126  else {
127  std::cout << "no new tag requested" << std::endl;
128  poolDbService->appendSinceTime<BeamSpotObjects>( abeam, poolDbService->currentTime(),
129  "BeamSpotObjectsRcd" );
130  }
131 
132  }
133 
134  std::cout << "[BeamSpotWrite2DB] endJob done \n" << std::endl;
135 }
type
Definition: HCALResponse.h:22
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
double double double z
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:47
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
tuple cout
Definition: gather_cfg.py:121
x
Definition: VDTMath.h:216
void SetPosition(double x, double y, double z)
set XYZ position

Member Data Documentation

std::ifstream BeamSpotWrite2DB::fasciiFile
private

Definition at line 43 of file BeamSpotWrite2DB.h.

Referenced by BeamSpotWrite2DB(), and endJob().

std::string BeamSpotWrite2DB::fasciiFileName
private

Definition at line 44 of file BeamSpotWrite2DB.h.

Referenced by BeamSpotWrite2DB(), and endJob().