CMS 3D CMS Logo

BeamSpotWrite2Txt.h
Go to the documentation of this file.
1 #ifndef RecoVertex_BeamSpotProducer_BeamSpotWrite2Txt_h
2 #define RecoVertex_BeamSpotProducer_BeamSpotWrite2Txt_h
3 
4 #include <fstream>
5 
7 
8 namespace beamspot {
9 
12  int run ;
13  char beginTimeOfFit[32];
14  char endTimeOfFit [32];
17  std::time_t reftime[2] ;
18  };
19 
20  void dumpBeamSpotTxt(std::string const& fileName, bool append, BeamSpotContainer const& bsContainer){
21 
22  std::ofstream outFile;
23 
24  if (!append)
25  outFile.open(fileName.c_str());
26  else
27  outFile.open(fileName.c_str(), std::ios::app);
28 
29  outFile << "Runnumber " << bsContainer.run << std::endl;
30  outFile << "BeginTimeOfFit " << bsContainer.beginTimeOfFit << " " << bsContainer.reftime[0] << std::endl;
31  outFile << "EndTimeOfFit " << bsContainer.endTimeOfFit << " " << bsContainer.reftime[1] << std::endl;
32  outFile << "LumiRange " << bsContainer.beginLumiOfFit << " - " << bsContainer.endLumiOfFit << std::endl;
33  outFile << "Type " << bsContainer.beamspot.type() << std::endl;
34  outFile << "X0 " << bsContainer.beamspot.x0() << std::endl;
35  outFile << "Y0 " << bsContainer.beamspot.y0() << std::endl;
36  outFile << "Z0 " << bsContainer.beamspot.z0() << std::endl;
37  outFile << "sigmaZ0 " << bsContainer.beamspot.sigmaZ() << std::endl;
38  outFile << "dxdz " << bsContainer.beamspot.dxdz() << std::endl;
39  outFile << "dydz " << bsContainer.beamspot.dydz() << std::endl;
40  outFile << "BeamWidthX " << bsContainer.beamspot.BeamWidthX() << std::endl;
41  outFile << "BeamWidthY " << bsContainer.beamspot.BeamWidthY() << std::endl;
42  for (int i = 0; i<6; ++i) {
43  outFile << "Cov("<<i<<",j) ";
44  for (int j=0; j<7; ++j) {
45  outFile << bsContainer.beamspot.covariance(i,j) << " ";
46  }
47  outFile << std::endl;
48  }
49  // Uncertainties on sigmaX and sigmaY are set to be equal. Legacy from a distant past
50  outFile << "Cov(6,j) 0 0 0 0 0 0 " << bsContainer.beamspot.covariance(6,6) << std::endl;
51  outFile << "EmittanceX " << bsContainer.beamspot.emittanceX() << std::endl;
52  outFile << "EmittanceY " << bsContainer.beamspot.emittanceY() << std::endl;
53  outFile << "BetaStar " << bsContainer.beamspot.betaStar() << std::endl;
54 
55  outFile.close();
56  }
57 
58 } // end namespace beamspot
59 
60 
61 #endif
double z0() const
z coordinate
Definition: BeamSpot.h:68
double emittanceX() const
additional information
Definition: BeamSpot.h:136
double betaStar() const
Definition: BeamSpot.h:138
double dydz() const
dydz slope
Definition: BeamSpot.h:84
double emittanceY() const
Definition: BeamSpot.h:137
double BeamWidthX() const
beam width X
Definition: BeamSpot.h:86
double dxdz() const
dxdz slope
Definition: BeamSpot.h:82
double sigmaZ() const
sigma z
Definition: BeamSpot.h:80
double BeamWidthY() const
beam width Y
Definition: BeamSpot.h:88
double covariance(int i, int j) const
(i,j)-th element of error matrix
Definition: BeamSpot.h:112
void dumpBeamSpotTxt(std::string const &fileName, bool append, BeamSpotContainer const &bsContainer)
double y0() const
y coordinate
Definition: BeamSpot.h:66
BeamType type() const
return beam type
Definition: BeamSpot.h:129
double x0() const
x coordinate
Definition: BeamSpot.h:64