70 #include "CLHEP/Random/RandFlat.h" 71 #include "CLHEP/Random/RandGauss.h" 75 void setUniform(
const std::vector<double>& estimatedValuesMin,
const std::vector<double>& estimatedValuesMax, std::vector<bool>& uniform) {
76 if ( ! estimatedValuesMax.empty() ) {
77 std::vector<double>::const_iterator
min = estimatedValuesMin.begin();
78 std::vector<double>::const_iterator
max = estimatedValuesMax.begin();
79 std::vector<bool>::iterator uniformIt = uniform.begin();
80 for ( ; min != estimatedValuesMin.end(); ++
min, ++
max, ++uniformIt ) {
81 if ( *min != *max ) *uniformIt =
true;
86 double computeSigma(
const double &
value,
const double & perCentError)
88 return (perCentError/100)*
value;
97 float hallMobility(
const double& meanMin,
const double& meanMax,
const double& sigma,
const bool uniform )
100 return CLHEP::RandFlat::shoot(meanMin, meanMax);
101 }
else if ( sigma > 0 ) {
102 return CLHEP::RandGauss::shoot(meanMin, sigma);
112 findingRecord<SiStripLorentzAngleRcd>();
122 if ( ( ( ! m_TIB_EstimatedValuesMax.empty() ) && ( m_TIB_EstimatedValuesMin.size() != m_TIB_EstimatedValuesMax.size() ) )
123 || ( ( ! m_TOB_EstimatedValuesMax.empty() ) && ( m_TOB_EstimatedValuesMin.size() != m_TOB_EstimatedValuesMax.size() ) ) )
125 std::cout <<
"ERROR: size of min and max values is different" << std::endl;
126 std::cout <<
"TIB_EstimatedValuesMin.size() = " << m_TIB_EstimatedValuesMin.size() <<
", TIB_EstimatedValuesMax.size() " << m_TIB_EstimatedValuesMax.size() << std::endl;
127 std::cout <<
"TOB_EstimatedValuesMin.size() = " << m_TOB_EstimatedValuesMin.size() <<
", TOB_EstimatedValuesMax.size() " << m_TOB_EstimatedValuesMax.size() << std::endl;
130 m_uniformTIB = std::vector<bool>(m_TIB_EstimatedValuesMin.size(),
false);
131 m_uniformTOB = std::vector<bool>(m_TOB_EstimatedValuesMin.size(),
false);
132 setUniform(m_TIB_EstimatedValuesMin, m_TIB_EstimatedValuesMax,
m_uniformTIB);
133 setUniform(m_TOB_EstimatedValuesMin, m_TOB_EstimatedValuesMax, m_uniformTOB);
136 m_StdDevs_TIB = std::vector<double>(m_TIB_EstimatedValuesMin.size(), 0);
137 m_StdDevs_TOB = std::vector<double>(m_TOB_EstimatedValuesMin.size(), 0);
138 transform(m_TIB_EstimatedValuesMin.begin(), m_TIB_EstimatedValuesMin.end(), m_TIB_PerCent_Errs.begin(),
m_StdDevs_TIB.begin(), computeSigma);
139 transform(m_TOB_EstimatedValuesMin.begin(), m_TOB_EstimatedValuesMin.end(), m_TOB_PerCent_Errs.begin(), m_StdDevs_TOB.begin(), computeSigma);
142 m_TIBmeanValueMin = std::accumulate(m_TIB_EstimatedValuesMin.begin(), m_TIB_EstimatedValuesMin.end(), 0.)/double(m_TIB_EstimatedValuesMin.size());
143 m_TIBmeanValueMax = std::accumulate(m_TIB_EstimatedValuesMax.begin(), m_TIB_EstimatedValuesMax.end(), 0.)/double(m_TIB_EstimatedValuesMax.size());
144 m_TOBmeanValueMin = std::accumulate(m_TOB_EstimatedValuesMin.begin(), m_TOB_EstimatedValuesMin.end(), 0.)/double(m_TOB_EstimatedValuesMin.size());
145 m_TOBmeanValueMax = std::accumulate(m_TOB_EstimatedValuesMax.begin(), m_TOB_EstimatedValuesMax.end(), 0.)/double(m_TOB_EstimatedValuesMax.size());
146 m_TIBmeanPerCentError = std::accumulate(m_TIB_PerCent_Errs.begin(), m_TIB_PerCent_Errs.end(), 0.)/double(m_TIB_PerCent_Errs.size());
147 m_TOBmeanPerCentError = std::accumulate(m_TOB_PerCent_Errs.begin(), m_TOB_PerCent_Errs.end(), 0.)/double(m_TOB_PerCent_Errs.size());
168 auto lorentzAngle = std::make_unique<SiStripLorentzAngle>();
171 for (
const auto& detId : reader->getAllDetIds() ) {
173 const int subDet = detectorId.
subdetId();
178 const int layerId = tTopo->
tibLayer(detectorId) -1;
181 const int layerId = tTopo->
tobLayer(detectorId) -1;
188 if ( tTopo->
tecRing(detectorId) < 5 ) {
197 if ( ! lorentzAngle->putLorentzAngle(detId, mobi) ) {
198 edm::LogError(
"SiStripLorentzAngleFakeESSource::produce ") <<
" detid already exists";
T getParameter(std::string const &) const
SiStripLorentzAngleFakeESSource(const edm::ParameterSet &)
std::vector< double > m_TIB_EstimatedValuesMin
std::vector< double > m_StdDevs_TOB
unsigned int tibLayer(const DetId &id) const
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &iov, edm::ValidityInterval &iValidity) override
unsigned int tecRing(const DetId &id) const
ring id
static const IOVSyncValue & endOfTime()
std::vector< double > m_TOB_EstimatedValuesMin
std::vector< bool > m_uniformTIB
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
double m_TOBmeanPerCentError
std::vector< bool > m_uniformTOB
std::vector< double > m_TOB_PerCent_Errs
static const IOVSyncValue & beginOfTime()
double m_TIBmeanPerCentError
const DepRecordT getRecord() const
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
ReturnType produce(const SiStripLorentzAngleRcd &)
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
std::vector< double > m_TIB_EstimatedValuesMax
std::unique_ptr< SiStripLorentzAngle > ReturnType
~SiStripLorentzAngleFakeESSource() override
unsigned int tobLayer(const DetId &id) const
std::vector< double > m_TIB_PerCent_Errs