76 #include "CLHEP/Random/RandFlat.h"
77 #include "CLHEP/Random/RandGauss.h"
81 void setUniform(
const std::vector<double>& estimatedValuesMin,
82 const std::vector<double>& estimatedValuesMax,
83 std::vector<bool>& uniform) {
84 if (!estimatedValuesMax.empty()) {
85 std::vector<double>::const_iterator
min = estimatedValuesMin.begin();
86 std::vector<double>::const_iterator
max = estimatedValuesMax.begin();
87 std::vector<bool>::iterator uniformIt = uniform.begin();
88 for (; min != estimatedValuesMin.end(); ++
min, ++
max, ++uniformIt) {
95 double computeSigma(
const double&
value,
const double& perCentError) {
return (perCentError / 100) *
value; }
103 float hallMobility(
const double& meanMin,
const double& meanMax,
const double& sigma,
const bool uniform) {
105 return CLHEP::RandFlat::shoot(meanMin, meanMax);
106 }
else if (sigma > 0) {
107 return CLHEP::RandGauss::shoot(meanMin, sigma);
118 findingRecord<SiStripLorentzAngleRcd>();
128 if (((!m_TIB_EstimatedValuesMax.empty()) && (m_TIB_EstimatedValuesMin.size() != m_TIB_EstimatedValuesMax.size())) ||
129 ((!m_TOB_EstimatedValuesMax.empty()) && (m_TOB_EstimatedValuesMin.size() != m_TOB_EstimatedValuesMax.size()))) {
130 std::cout <<
"ERROR: size of min and max values is different" << std::endl;
131 std::cout <<
"TIB_EstimatedValuesMin.size() = " << m_TIB_EstimatedValuesMin.size()
132 <<
", TIB_EstimatedValuesMax.size() " << m_TIB_EstimatedValuesMax.size() << std::endl;
133 std::cout <<
"TOB_EstimatedValuesMin.size() = " << m_TOB_EstimatedValuesMin.size()
134 <<
", TOB_EstimatedValuesMax.size() " << m_TOB_EstimatedValuesMax.size() << std::endl;
137 m_uniformTIB = std::vector<bool>(m_TIB_EstimatedValuesMin.size(),
false);
138 m_uniformTOB = std::vector<bool>(m_TOB_EstimatedValuesMin.size(),
false);
139 setUniform(m_TIB_EstimatedValuesMin, m_TIB_EstimatedValuesMax,
m_uniformTIB);
140 setUniform(m_TOB_EstimatedValuesMin, m_TOB_EstimatedValuesMax, m_uniformTOB);
143 m_StdDevs_TIB = std::vector<double>(m_TIB_EstimatedValuesMin.size(), 0);
144 m_StdDevs_TOB = std::vector<double>(m_TOB_EstimatedValuesMin.size(), 0);
145 transform(m_TIB_EstimatedValuesMin.begin(),
146 m_TIB_EstimatedValuesMin.end(),
147 m_TIB_PerCent_Errs.begin(),
150 transform(m_TOB_EstimatedValuesMin.begin(),
151 m_TOB_EstimatedValuesMin.end(),
152 m_TOB_PerCent_Errs.begin(),
153 m_StdDevs_TOB.begin(),
157 m_TIBmeanValueMin = std::accumulate(m_TIB_EstimatedValuesMin.begin(), m_TIB_EstimatedValuesMin.end(), 0.) /
158 double(m_TIB_EstimatedValuesMin.size());
159 m_TIBmeanValueMax = std::accumulate(m_TIB_EstimatedValuesMax.begin(), m_TIB_EstimatedValuesMax.end(), 0.) /
160 double(m_TIB_EstimatedValuesMax.size());
161 m_TOBmeanValueMin = std::accumulate(m_TOB_EstimatedValuesMin.begin(), m_TOB_EstimatedValuesMin.end(), 0.) /
162 double(m_TOB_EstimatedValuesMin.size());
163 m_TOBmeanValueMax = std::accumulate(m_TOB_EstimatedValuesMax.begin(), m_TOB_EstimatedValuesMax.end(), 0.) /
164 double(m_TOB_EstimatedValuesMax.size());
166 std::accumulate(m_TIB_PerCent_Errs.begin(), m_TIB_PerCent_Errs.end(), 0.) / double(m_TIB_PerCent_Errs.size());
168 std::accumulate(m_TOB_PerCent_Errs.begin(), m_TOB_PerCent_Errs.end(), 0.) / double(m_TOB_PerCent_Errs.size());
184 using namespace edm::es;
189 auto lorentzAngle = std::make_unique<SiStripLorentzAngle>();
193 const int subDet = detectorId.
subdetId();
198 const int layerId = tTopo.tibLayer(detectorId) - 1;
204 const int layerId = tTopo.tobLayer(detectorId) - 1;
214 if (tTopo.tecRing(detectorId) < 5) {
223 if (!lorentzAngle->putLorentzAngle(detId, mobi)) {
224 edm::LogError(
"SiStripLorentzAngleFakeESSource::produce ") <<
" detid already exists";
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
Log< level::Error, false > LogError
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 &)
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
static constexpr auto TIB
T getParameter(std::string const &) const
std::vector< double > m_TIB_EstimatedValuesMax
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > m_tTopoToken
std::unique_ptr< SiStripLorentzAngle > ReturnType
~SiStripLorentzAngleFakeESSource() override
static constexpr auto TID
std::vector< double > m_TIB_PerCent_Errs