CMS 3D CMS Logo

BeamSpotWrite2DB.cc
Go to the documentation of this file.
1 
12 // C++ standard
13 #include <string>
14 // CMS
18 
20 
25 
27  fasciiFileName = iConfig.getUntrackedParameter<std::string>("OutputFileName");
28 
29  fasciiFile.open(fasciiFileName.c_str());
30 }
31 
33 
35 
37 
39  std::cout << " Read beam spot data from text file: " << fasciiFileName << std::endl;
40  std::cout << " please see plugins/BeamSpotWrite2DB.cc for format of text file." << std::endl;
41  /*
42  std::cout << " Content of the file is expected to have this format with the first column as a keyword:" << std::endl;
43  std::cout << " x\n y\n z\n sigmaZ\n dxdz\n dydz\n beamWidthX\n beamWidthY" << std::endl;
44  for (int i =0; i<7; i++) {
45  for (int j=0; j<7; j++ ) {
46 
47  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;
48  }
49  }
50  */
51 
52  // extract from file
53  double x, y, z, sigmaZ, dxdz, dydz, beamWidthX, beamWidthY, emittanceX, emittanceY, betastar;
55  double cov[7][7];
56  int type;
57 
58  fasciiFile >> tag >> type;
59  fasciiFile >> tag >> x;
60  fasciiFile >> tag >> y;
61  fasciiFile >> tag >> z;
62  fasciiFile >> tag >> sigmaZ;
63  fasciiFile >> tag >> dxdz;
64  fasciiFile >> tag >> dydz;
65  fasciiFile >> tag >> beamWidthX;
66  fasciiFile >> tag >> beamWidthY;
67  fasciiFile >> tag >> cov[0][0] >> cov[0][1] >> cov[0][2] >> cov[0][3] >> cov[0][4] >> cov[0][5] >> cov[0][6];
68  fasciiFile >> tag >> cov[1][0] >> cov[1][1] >> cov[1][2] >> cov[1][3] >> cov[1][4] >> cov[1][5] >> cov[1][6];
69  fasciiFile >> tag >> cov[2][0] >> cov[2][1] >> cov[2][2] >> cov[2][3] >> cov[2][4] >> cov[2][5] >> cov[2][6];
70  fasciiFile >> tag >> cov[3][0] >> cov[3][1] >> cov[3][2] >> cov[3][3] >> cov[3][4] >> cov[3][5] >> cov[3][6];
71  fasciiFile >> tag >> cov[4][0] >> cov[4][1] >> cov[4][2] >> cov[4][3] >> cov[4][4] >> cov[4][5] >> cov[4][6];
72  fasciiFile >> tag >> cov[5][0] >> cov[5][1] >> cov[5][2] >> cov[5][3] >> cov[5][4] >> cov[5][5] >> cov[5][6];
73  fasciiFile >> tag >> cov[6][0] >> cov[6][1] >> cov[6][2] >> cov[6][3] >> cov[6][4] >> cov[6][5] >> cov[6][6];
76  fasciiFile >> tag >> betastar;
77 
78  BeamSpotObjects* abeam = new BeamSpotObjects();
79 
80  abeam->SetType(type);
81  abeam->SetPosition(x, y, z);
82  abeam->SetSigmaZ(sigmaZ);
83  abeam->Setdxdz(dxdz);
84  abeam->Setdydz(dydz);
85  abeam->SetBeamWidthX(beamWidthX);
86  abeam->SetBeamWidthY(beamWidthY);
87  abeam->SetEmittanceX(emittanceX);
88  abeam->SetEmittanceY(emittanceY);
89  abeam->SetBetaStar(betastar);
90 
91  for (int i = 0; i < 7; ++i) {
92  for (int j = 0; j < 7; ++j) {
93  abeam->SetCovariance(i, j, cov[i][j]);
94  }
95  }
96 
97  std::cout << " write results to DB..." << std::endl;
98 
100  if (poolDbService.isAvailable()) {
101  std::cout << "poolDBService available" << std::endl;
102  if (poolDbService->isNewTagRequest("BeamSpotObjectsRcd")) {
103  std::cout << "new tag requested" << std::endl;
104  poolDbService->createNewIOV<BeamSpotObjects>(
105  abeam, poolDbService->beginOfTime(), poolDbService->endOfTime(), "BeamSpotObjectsRcd");
106  } else {
107  std::cout << "no new tag requested" << std::endl;
108  poolDbService->appendSinceTime<BeamSpotObjects>(abeam, poolDbService->currentTime(), "BeamSpotObjectsRcd");
109  }
110  }
111 
112  std::cout << "[BeamSpotWrite2DB] endJob done \n" << std::endl;
113 }
114 
115 //define this as a plug-in
BeamSpotWrite2DB::~BeamSpotWrite2DB
~BeamSpotWrite2DB() override
Definition: BeamSpotWrite2DB.cc:32
DDAxes::y
BeamSpotWrite2DB::beginJob
void beginJob() override
Definition: BeamSpotWrite2DB.cc:36
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
BeamSpotWrite2DB::endJob
void endJob() override
Definition: BeamSpotWrite2DB.cc:38
BeamSpotObjects::SetBetaStar
void SetBetaStar(double val)
set beta star
Definition: BeamSpotObjects.h:64
BeamSpotPI::sigmaZ
Definition: BeamSpotPayloadInspectorHelper.h:35
cond::service::PoolDBOutputService::beginOfTime
cond::Time_t beginOfTime() const
Definition: PoolDBOutputService.cc:215
BeamSpotWrite2DB::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: BeamSpotWrite2DB.cc:34
gather_cfg.cout
cout
Definition: gather_cfg.py:144
cond::service::PoolDBOutputService::appendSinceTime
void appendSinceTime(const T *payloadObj, cond::Time_t sinceTime, const std::string &recordName)
Definition: PoolDBOutputService.h:141
BeamSpotObjects::SetBeamWidthY
void SetBeamWidthY(double val)
set average transverse beam width Y
Definition: BeamSpotObjects.h:50
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
DDAxes::x
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
BeamSpotObjects::SetSigmaZ
void SetSigmaZ(double val)
set sigma Z, RMS bunch length
Definition: BeamSpotObjects.h:42
BeamSpotWrite2DB
Definition: BeamSpotWrite2DB.h:30
MakerMacros.h
BeamSpotObjects.h
PoolDBOutputService.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
BeamSpotFakeParameters_cfi.emittanceX
emittanceX
Definition: BeamSpotFakeParameters_cfi.py:17
BeamSpot.h
cond::service::PoolDBOutputService::createNewIOV
void createNewIOV(const T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t, const std::string &recordName)
Definition: PoolDBOutputService.h:116
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
Service.h
BeamSpotWrite2DB::fasciiFile
std::ifstream fasciiFile
Definition: BeamSpotWrite2DB.h:40
DDAxes::z
BeamSpotPI::dxdz
Definition: BeamSpotPayloadInspectorHelper.h:36
BeamSpotObjects::SetEmittanceY
void SetEmittanceY(double val)
set emittance
Definition: BeamSpotObjects.h:62
BeamSpotFakeParameters_cfi.emittanceY
emittanceY
Definition: BeamSpotFakeParameters_cfi.py:18
BeamSpotObjects::SetPosition
void SetPosition(double x, double y, double z)
set XYZ position
Definition: BeamSpotObjects.h:36
BeamSpotWrite2DB::BeamSpotWrite2DB
BeamSpotWrite2DB(const edm::ParameterSet &)
Definition: BeamSpotWrite2DB.cc:26
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
BeamSpotObjects::SetType
void SetType(int type)
set beam type
Definition: BeamSpotObjects.h:58
edm::ParameterSet
Definition: ParameterSet.h:47
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
BeamSpotObjects::SetEmittanceX
void SetEmittanceX(double val)
set emittance
Definition: BeamSpotObjects.h:60
BeamSpotObjects::SetCovariance
void SetCovariance(int i, int j, double val)
set i,j element of the full covariance matrix 7x7
Definition: BeamSpotObjects.h:56
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:39
BeamSpotWrite2DB.h
BeamSpotPI::dydz
Definition: BeamSpotPayloadInspectorHelper.h:37
edm::Service< cond::service::PoolDBOutputService >
iEvent
int iEvent
Definition: GenABIO.cc:224
BeamSpotObjects
Definition: BeamSpotObjects.h:20
edm::EventSetup
Definition: EventSetup.h:57
BeamSpotObjects::Setdxdz
void Setdxdz(double val)
set dxdz slope, crossing angle
Definition: BeamSpotObjects.h:44
cond::service::PoolDBOutputService::endOfTime
cond::Time_t endOfTime() const
Definition: PoolDBOutputService.cc:213
BeamSpotWrite2DB::fasciiFileName
std::string fasciiFileName
Definition: BeamSpotWrite2DB.h:41
BeamSpotObjects::SetBeamWidthX
void SetBeamWidthX(double val)
set average transverse beam width X
Definition: BeamSpotObjects.h:48
cond::service::PoolDBOutputService::isNewTagRequest
bool isNewTagRequest(const std::string &recordName)
Definition: PoolDBOutputService.cc:128
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
BSFitter.h
edm::Event
Definition: Event.h:73
BeamSpotObjects::Setdydz
void Setdydz(double val)
set dydz slope, crossing angle in XZ
Definition: BeamSpotObjects.h:46
cond::service::PoolDBOutputService::currentTime
cond::Time_t currentTime() const
Definition: PoolDBOutputService.cc:217