CMS 3D CMS Logo

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 <TClass.h>
12 
21 
24 
26 public:
27  typedef std::unique_ptr<BeamSpotObjects> ReturnType;
29  ~BeamSpotFakeConditions() override;
31 
32 private:
34  const edm::IOVSyncValue &syncValue,
35  edm::ValidityInterval &oValidity) override;
40  double cov[7][7];
41  int type;
42 };
43 
45  setWhatProduced(this);
46  findingRecord<BeamSpotObjectsRcd>();
47  getDataFromFile_ = params.getParameter<bool>("getDataFromFile");
48  if (getDataFromFile_) {
49  inputFilename_ = params.getParameter<edm::FileInPath>("InputFilename");
50  std::ifstream fasciiFile(inputFilename_.fullPath().c_str());
51  fasciiFile >> tag >> type;
52  fasciiFile >> tag >> x;
53  fasciiFile >> tag >> y;
54  fasciiFile >> tag >> z;
55  fasciiFile >> tag >> sigmaZ;
56  fasciiFile >> tag >> dxdz;
57  fasciiFile >> tag >> dydz;
58  fasciiFile >> tag >> beamWidthX;
59  fasciiFile >> tag >> beamWidthY;
60  fasciiFile >> tag >> cov[0][0] >> cov[0][1] >> cov[0][2] >> cov[0][3] >> cov[0][4] >> cov[0][5] >> cov[0][6];
61  fasciiFile >> tag >> cov[1][0] >> cov[1][1] >> cov[1][2] >> cov[1][3] >> cov[1][4] >> cov[1][5] >> cov[1][6];
62  fasciiFile >> tag >> cov[2][0] >> cov[2][1] >> cov[2][2] >> cov[2][3] >> cov[2][4] >> cov[2][5] >> cov[2][6];
63  fasciiFile >> tag >> cov[3][0] >> cov[3][1] >> cov[3][2] >> cov[3][3] >> cov[3][4] >> cov[3][5] >> cov[3][6];
64  fasciiFile >> tag >> cov[4][0] >> cov[4][1] >> cov[4][2] >> cov[4][3] >> cov[4][4] >> cov[4][5] >> cov[4][6];
65  fasciiFile >> tag >> cov[5][0] >> cov[5][1] >> cov[5][2] >> cov[5][3] >> cov[5][4] >> cov[5][5] >> cov[5][6];
66  fasciiFile >> tag >> cov[6][0] >> cov[6][1] >> cov[6][2] >> cov[6][3] >> cov[6][4] >> cov[6][5] >> cov[6][6];
67  fasciiFile >> tag >> emittanceX;
68  fasciiFile >> tag >> emittanceY;
69  fasciiFile >> tag >> betastar;
70 
71  }
72  // input values by hand
73  else {
74  x = params.getParameter<double>("X0");
75  y = params.getParameter<double>("Y0");
76  z = params.getParameter<double>("Z0");
77  dxdz = params.getParameter<double>("dxdz");
78  dydz = params.getParameter<double>("dydz");
79  sigmaZ = params.getParameter<double>("sigmaZ");
80  beamWidthX = params.getParameter<double>("widthX");
81  beamWidthY = params.getParameter<double>("widthY");
82  emittanceX = params.getParameter<double>("emittanceX");
83  emittanceY = params.getParameter<double>("emittanceY");
84  betastar = params.getParameter<double>("betaStar");
85 
86  // first set all elements (esp. off-diagonal elements to zero)
87  for (int i = 0; i < 7; i++) {
88  for (int j = 0; j < 7; j++)
89  cov[i][j] = 0.0;
90  }
91 
92  // we ignore correlations when values are given by hand
93  cov[0][0] = pow(params.getParameter<double>("errorX0"), 2);
94  cov[1][1] = pow(params.getParameter<double>("errorY0"), 2);
95  cov[2][2] = pow(params.getParameter<double>("errorZ0"), 2);
96  cov[3][3] = pow(params.getParameter<double>("errorSigmaZ"), 2);
97  cov[4][4] = pow(params.getParameter<double>("errordxdz"), 2);
98  cov[5][5] = pow(params.getParameter<double>("errordydz"), 2);
99  cov[6][6] = pow(params.getParameter<double>("errorWidth"), 2);
100  }
101 }
102 
104 
106  ReturnType adummy = std::make_unique<BeamSpotObjects>();
107 
108  adummy->SetPosition(x, y, z);
109  adummy->SetSigmaZ(sigmaZ);
110  adummy->Setdxdz(dxdz);
111  adummy->Setdydz(dydz);
112  adummy->SetBeamWidthX(beamWidthX);
113  adummy->SetBeamWidthY(beamWidthY);
114  for (int i = 0; i < 7; i++) {
115  for (int j = 0; j < 7; j++) {
116  adummy->SetCovariance(i, j, cov[i][j]);
117  }
118  }
119  adummy->SetEmittanceX(emittanceX);
120  adummy->SetEmittanceY(emittanceY);
121  adummy->SetBetaStar(betastar);
122 
123  return adummy;
124 }
125 
127  const edm::IOVSyncValue &syncValue,
128  edm::ValidityInterval &oValidity) {
130 }
131 
BeamSpotFakeConditions
Definition: BeamSpotFakeConditions.cc:25
BeamSpotFakeConditions::setIntervalFor
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &key, const edm::IOVSyncValue &syncValue, edm::ValidityInterval &oValidity) override
Definition: BeamSpotFakeConditions.cc:126
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
BeamSpotFakeConditions::tag
std::string tag
Definition: BeamSpotFakeConditions.cc:39
BeamSpotFakeConditions::dydz
double dydz
Definition: BeamSpotFakeConditions.cc:38
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
BeamSpotFakeConditions::betastar
double betastar
Definition: BeamSpotFakeConditions.cc:38
BeamSpotFakeConditions::sigmaZ
double sigmaZ
Definition: BeamSpotFakeConditions.cc:38
BeamSpotFakeConditions::BeamSpotFakeConditions
BeamSpotFakeConditions(const edm::ParameterSet &params)
Definition: BeamSpotFakeConditions.cc:44
BeamSpotFakeConditions::beamWidthY
double beamWidthY
Definition: BeamSpotFakeConditions.cc:38
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
edm::ValidityInterval
Definition: ValidityInterval.h:28
BeamSpotFakeConditions::y
double y
Definition: BeamSpotFakeConditions.cc:38
ESProducer.h
BeamSpotFakeConditions::cov
double cov[7][7]
Definition: BeamSpotFakeConditions.cc:40
edm::EventSetupRecordIntervalFinder
Definition: EventSetupRecordIntervalFinder.h:33
BeamSpotFakeConditions::dxdz
double dxdz
Definition: BeamSpotFakeConditions.cc:38
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
edm::FileInPath
Definition: FileInPath.h:61
MakerMacros.h
BeamSpotObjects.h
BeamSpotObjectsRcd.h
BeamSpotFakeConditions::produce
ReturnType produce(const BeamSpotObjectsRcd &record)
Definition: BeamSpotFakeConditions.cc:105
BeamSpotFakeConditions::inputFilename_
edm::FileInPath inputFilename_
Definition: BeamSpotFakeConditions.cc:36
BeamSpotFakeConditions::emittanceX
double emittanceX
Definition: BeamSpotFakeConditions.cc:38
BeamSpotFakeConditions::beamWidthX
double beamWidthX
Definition: BeamSpotFakeConditions.cc:38
edm::IOVSyncValue
Definition: IOVSyncValue.h:31
DEFINE_FWK_EVENTSETUP_SOURCE
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:91
EventSetupRecordIntervalFinder.h
BeamSpotFakeConditions::ReturnType
std::unique_ptr< BeamSpotObjects > ReturnType
Definition: BeamSpotFakeConditions.cc:27
FileInPath.h
BeamSpotFakeConditions::~BeamSpotFakeConditions
~BeamSpotFakeConditions() override
Definition: BeamSpotFakeConditions.cc:103
SourceFactory.h
edm::ParameterSet
Definition: ParameterSet.h:47
edm::IOVSyncValue::endOfTime
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
BeamSpotFakeConditions::x
double x
Definition: BeamSpotFakeConditions.cc:38
BeamSpotFakeConditions::emittanceY
double emittanceY
Definition: BeamSpotFakeConditions.cc:38
BeamSpotObjectsRcd
Definition: BeamSpotObjectsRcd.h:24
AlCaHarvesting_cff.record
record
Definition: AlCaHarvesting_cff.py:42
BeamSpotFakeConditions::getDataFromFile_
bool getDataFromFile_
Definition: BeamSpotFakeConditions.cc:37
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond::ValidityInterval
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
BeamSpotFakeConditions::z
double z
Definition: BeamSpotFakeConditions.cc:38
edm::IOVSyncValue::beginOfTime
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
Exception.h
edm::ESProducer
Definition: ESProducer.h:104
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
BeamSpotFakeConditions::type
int type
Definition: BeamSpotFakeConditions.cc:41
ParameterSet.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
crabWrapper.key
key
Definition: crabWrapper.py:19
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:161