77 #include "CLHEP/Random/RandFlat.h" 78 #include "CLHEP/Random/RandGauss.h" 82 void setUniform(
const std::vector<double>& estimatedValuesMin,
83 const std::vector<double>& estimatedValuesMax,
84 std::vector<bool>& uniform) {
85 if (!estimatedValuesMax.empty()) {
86 std::vector<double>::const_iterator
min = estimatedValuesMin.begin();
87 std::vector<double>::const_iterator
max = estimatedValuesMax.begin();
88 std::vector<bool>::iterator uniformIt = uniform.begin();
89 for (; min != estimatedValuesMin.end(); ++
min, ++
max, ++uniformIt) {
96 double computeSigma(
const double&
value,
const double& perCentError) {
return (perCentError / 100) *
value; }
104 float hallMobility(
const double& meanMin,
const double& meanMax,
const double& sigma,
const bool uniform) {
106 return CLHEP::RandFlat::shoot(meanMin, meanMax);
107 }
else if (sigma > 0) {
108 return CLHEP::RandGauss::shoot(meanMin, sigma);
117 findingRecord<SiStripLorentzAngleRcd>();
127 if (((!m_TIB_EstimatedValuesMax.empty()) && (m_TIB_EstimatedValuesMin.size() != m_TIB_EstimatedValuesMax.size())) ||
128 ((!m_TOB_EstimatedValuesMax.empty()) && (m_TOB_EstimatedValuesMin.size() != m_TOB_EstimatedValuesMax.size()))) {
129 std::cout <<
"ERROR: size of min and max values is different" << std::endl;
130 std::cout <<
"TIB_EstimatedValuesMin.size() = " << m_TIB_EstimatedValuesMin.size()
131 <<
", TIB_EstimatedValuesMax.size() " << m_TIB_EstimatedValuesMax.size() << std::endl;
132 std::cout <<
"TOB_EstimatedValuesMin.size() = " << m_TOB_EstimatedValuesMin.size()
133 <<
", TOB_EstimatedValuesMax.size() " << m_TOB_EstimatedValuesMax.size() << std::endl;
136 m_uniformTIB = std::vector<bool>(m_TIB_EstimatedValuesMin.size(),
false);
137 m_uniformTOB = std::vector<bool>(m_TOB_EstimatedValuesMin.size(),
false);
138 setUniform(m_TIB_EstimatedValuesMin, m_TIB_EstimatedValuesMax,
m_uniformTIB);
139 setUniform(m_TOB_EstimatedValuesMin, m_TOB_EstimatedValuesMax, m_uniformTOB);
142 m_StdDevs_TIB = std::vector<double>(m_TIB_EstimatedValuesMin.size(), 0);
143 m_StdDevs_TOB = std::vector<double>(m_TOB_EstimatedValuesMin.size(), 0);
144 transform(m_TIB_EstimatedValuesMin.begin(),
145 m_TIB_EstimatedValuesMin.end(),
146 m_TIB_PerCent_Errs.begin(),
149 transform(m_TOB_EstimatedValuesMin.begin(),
150 m_TOB_EstimatedValuesMin.end(),
151 m_TOB_PerCent_Errs.begin(),
152 m_StdDevs_TOB.begin(),
156 m_TIBmeanValueMin = std::accumulate(m_TIB_EstimatedValuesMin.begin(), m_TIB_EstimatedValuesMin.end(), 0.) /
157 double(m_TIB_EstimatedValuesMin.size());
158 m_TIBmeanValueMax = std::accumulate(m_TIB_EstimatedValuesMax.begin(), m_TIB_EstimatedValuesMax.end(), 0.) /
159 double(m_TIB_EstimatedValuesMax.size());
160 m_TOBmeanValueMin = std::accumulate(m_TOB_EstimatedValuesMin.begin(), m_TOB_EstimatedValuesMin.end(), 0.) /
161 double(m_TOB_EstimatedValuesMin.size());
162 m_TOBmeanValueMax = std::accumulate(m_TOB_EstimatedValuesMax.begin(), m_TOB_EstimatedValuesMax.end(), 0.) /
163 double(m_TOB_EstimatedValuesMax.size());
165 std::accumulate(m_TIB_PerCent_Errs.begin(), m_TIB_PerCent_Errs.end(), 0.) / double(m_TIB_PerCent_Errs.size());
167 std::accumulate(m_TOB_PerCent_Errs.begin(), m_TOB_PerCent_Errs.end(), 0.) / double(m_TOB_PerCent_Errs.size());
188 auto lorentzAngle = std::make_unique<SiStripLorentzAngle>();
192 const int subDet = detectorId.
subdetId();
197 const int layerId = tTopo.tibLayer(detectorId) - 1;
203 const int layerId = tTopo.tobLayer(detectorId) - 1;
213 if (tTopo.tecRing(detectorId) < 5) {
222 if (!lorentzAngle->putLorentzAngle(detId, mobi)) {
223 edm::LogError(
"SiStripLorentzAngleFakeESSource::produce ") <<
" detid already exists";
T getParameter(std::string const &) const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
static constexpr auto TEC
SiStripLorentzAngleFakeESSource(const edm::ParameterSet &)
std::vector< double > m_TIB_EstimatedValuesMin
std::vector< double > m_StdDevs_TOB
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &iov, edm::ValidityInterval &iValidity) override
edm::ESGetToken< GeometricDet, IdealGeometryRecord > m_geomDetToken
static const IOVSyncValue & endOfTime()
std::vector< double > m_TOB_EstimatedValuesMin
std::vector< bool > m_uniformTIB
double m_TOBmeanPerCentError
std::vector< bool > m_uniformTOB
std::vector< double > m_TOB_PerCent_Errs
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
static const IOVSyncValue & beginOfTime()
double m_TIBmeanPerCentError
const DepRecordT getRecord() const
std::vector< uint32_t > getSiStripDetIds(const GeometricDet &geomDet)
std::vector< double > m_TOB_EstimatedValuesMax
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
std::vector< double > m_StdDevs_TIB
static constexpr auto TOB
ReturnType produce(const SiStripLorentzAngleRcd &)
static constexpr auto TIB
std::vector< double > m_TIB_EstimatedValuesMax
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > m_tTopoToken
std::unique_ptr< SiStripLorentzAngle > ReturnType
~SiStripLorentzAngleFakeESSource() override
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
static constexpr auto TID
std::vector< double > m_TIB_PerCent_Errs