test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BeamSpotFakeConditions.cc
Go to the documentation of this file.
1 //
2 
3 #include <iostream>
4 #include <fstream>
5 #include <sstream>
6 #include <cstring>
7 #include <string>
8 #include <vector>
9 #include <memory>
10 
11 #include <boost/shared_ptr.hpp>
12 
13 #include <TClass.h>
14 
23 
26 
28 public:
29  typedef boost::shared_ptr<BeamSpotObjects> ReturnType;
31  virtual ~BeamSpotFakeConditions();
33 private:
34  void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &key,const edm::IOVSyncValue &syncValue,edm::ValidityInterval &oValidity) override;
39  double cov[7][7];
40  int type;
41 
42 };
43 
45 {
46  setWhatProduced(this);
47  findingRecord<BeamSpotObjectsRcd>();
48  getDataFromFile_ = params.getParameter<bool>("getDataFromFile");
49  if (getDataFromFile_) {
50  inputFilename_ = params.getParameter<edm::FileInPath>("InputFilename");
51  std::ifstream fasciiFile(inputFilename_.fullPath().c_str() );
52  fasciiFile >> tag >> type;
53  fasciiFile >> tag >> x;
54  fasciiFile >> tag >> y;
55  fasciiFile >> tag >> z;
56  fasciiFile >> tag >> sigmaZ;
57  fasciiFile >> tag >> dxdz;
58  fasciiFile >> tag >> dydz;
59  fasciiFile >> tag >> beamWidthX;
60  fasciiFile >> tag >> beamWidthY;
61  fasciiFile >> tag >> cov[0][0] >> cov[0][1] >> cov[0][2]>> cov[0][3] >> cov[0][4]>> cov[0][5] >> cov[0][6]
62  ;
63  fasciiFile >> tag >> cov[1][0] >> cov[1][1] >> cov[1][2] >> cov[1][3]>> cov[1][4] >> cov[1][5]>> cov[1][6]
64  ;
65  fasciiFile >> tag >> cov[2][0] >> cov[2][1] >> cov[2][2] >> cov[2][3]>> cov[2][4] >> cov[2][5]>> cov[2][6
66  ];
67  fasciiFile >> tag >> cov[3][0] >> cov[3][1] >> cov[3][2] >> cov[3][3]>> cov[3][4] >> cov[3][5]>> cov[3][6
68  ];
69  fasciiFile >> tag >> cov[4][0] >> cov[4][1] >> cov[4][2] >> cov[4][3]>> cov[4][4] >> cov[4][5]>> cov[4][6]
70  ;
71  fasciiFile >> tag >> cov[5][0] >> cov[5][1] >> cov[5][2] >> cov[5][3]>> cov[5][4] >> cov[5][5]>> cov[5][6]
72  ;
73  fasciiFile >> tag >> cov[6][0] >> cov[6][1] >> cov[6][2] >> cov[6][3]>> cov[6][4] >> cov[6][5]>> cov[6][6]
74  ;
75  fasciiFile >> tag >> emittanceX;
76  fasciiFile >> tag >> emittanceY;
77  fasciiFile >> tag >> betastar;
78 
79  }
80  // input values by hand
81  else {
82  x = params.getParameter<double>( "X0" );
83  y = params.getParameter<double>( "Y0" );
84  z = params.getParameter<double>( "Z0" );
85  dxdz = params.getParameter<double>( "dxdz" );
86  dydz = params.getParameter<double>( "dydz" );
87  sigmaZ = params.getParameter<double>( "sigmaZ" );
88  beamWidthX = params.getParameter<double>( "widthX" );
89  beamWidthY = params.getParameter<double>( "widthY" );
90  emittanceX = params.getParameter<double>( "emittanceX" );
91  emittanceY = params.getParameter<double>( "emittanceY" );
92  betastar = params.getParameter<double>( "betaStar" );
93 
94  // first set all elements (esp. off-diagonal elements to zero)
95  for (int i=0; i<7; i++ ) {
96  for (int j=0; j<7; j++) cov[i][j] = 0.0;
97  }
98 
99  // we ignore correlations when values are given by hand
100  cov[0][0] = pow( params.getParameter<double>( "errorX0" ), 2 );
101  cov[1][1] = pow( params.getParameter<double>( "errorY0" ), 2 );
102  cov[2][2] = pow( params.getParameter<double>( "errorZ0" ), 2 );
103  cov[3][3] = pow( params.getParameter<double>( "errorSigmaZ" ), 2 );
104  cov[4][4] = pow( params.getParameter<double>( "errordxdz" ), 2 );
105  cov[5][5] = pow( params.getParameter<double>( "errordydz" ), 2 );
106  cov[6][6] = pow( params.getParameter<double>( "errorWidth" ), 2 );
107 
108  }
109 }
110 
112 
115 
116 
117  BeamSpotObjects *adummy = new BeamSpotObjects();
118 
119  adummy->SetPosition( x, y , z );
120  adummy->SetSigmaZ( sigmaZ);
121  adummy->Setdxdz( dxdz );
122  adummy->Setdydz( dydz );
123  adummy->SetBeamWidthX( beamWidthX );
124  adummy->SetBeamWidthY( beamWidthY );
125  for (int i=0; i<7; i++ ) {
126  for (int j=0; j<7; j++) {
127 
128  adummy->SetCovariance( i, j, cov[i][j] );
129  }
130  }
131  adummy->SetEmittanceX( emittanceX );
132  adummy->SetEmittanceY( emittanceY );
133  adummy->SetBetaStar( betastar);
134 
135  return ReturnType(adummy);
136 }
137 
139  const edm::IOVSyncValue &syncValue,
140  edm::ValidityInterval &oValidity){
143 }
144 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
JetCorrectorParameters::Record record
Definition: classes.h:7
void SetSigmaZ(double val)
set sigma Z, RMS bunch length
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:97
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
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 setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &key, const edm::IOVSyncValue &syncValue, edm::ValidityInterval &oValidity) override
static const IOVSyncValue & beginOfTime()
void SetEmittanceX(double val)
set emittance
int j
Definition: DBlmapReader.cc:9
void Setdxdz(double val)
set dxdz slope, crossing angle
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
void SetBetaStar(double val)
set beta star
boost::shared_ptr< BeamSpotObjects > ReturnType
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:92
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
BeamSpotFakeConditions(const edm::ParameterSet &params)
std::string fullPath() const
Definition: FileInPath.cc:184
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
ReturnType produce(const BeamSpotObjectsRcd &record)
void SetPosition(double x, double y, double z)
set XYZ position