72 #include "CLHEP/Random/RandFlat.h" 73 #include "CLHEP/Random/RandGauss.h" 77 void setUniform(
const std::vector<double>& estimatedValuesMin,
const std::vector<double>& estimatedValuesMax, std::vector<bool>& uniform) {
78 if ( ! estimatedValuesMax.empty() ) {
79 std::vector<double>::const_iterator
min = estimatedValuesMin.begin();
80 std::vector<double>::const_iterator
max = estimatedValuesMax.begin();
81 std::vector<bool>::iterator uniformIt = uniform.begin();
82 for ( ; min != estimatedValuesMin.end(); ++
min, ++
max, ++uniformIt ) {
83 if ( *min != *max ) *uniformIt =
true;
88 double computeSigma(
const double &
value,
const double & perCentError)
90 return (perCentError/100)*
value;
99 float hallMobility(
const double& meanMin,
const double& meanMax,
const double& sigma,
const bool uniform )
102 return CLHEP::RandFlat::shoot(meanMin, meanMax);
103 }
else if ( sigma > 0 ) {
104 return CLHEP::RandGauss::shoot(meanMin, sigma);
114 findingRecord<SiStripLorentzAngleRcd>();
124 if ( ( ( ! m_TIB_EstimatedValuesMax.empty() ) && ( m_TIB_EstimatedValuesMin.size() != m_TIB_EstimatedValuesMax.size() ) )
125 || ( ( ! m_TOB_EstimatedValuesMax.empty() ) && ( m_TOB_EstimatedValuesMin.size() != m_TOB_EstimatedValuesMax.size() ) ) )
127 std::cout <<
"ERROR: size of min and max values is different" << std::endl;
128 std::cout <<
"TIB_EstimatedValuesMin.size() = " << m_TIB_EstimatedValuesMin.size() <<
", TIB_EstimatedValuesMax.size() " << m_TIB_EstimatedValuesMax.size() << std::endl;
129 std::cout <<
"TOB_EstimatedValuesMin.size() = " << m_TOB_EstimatedValuesMin.size() <<
", TOB_EstimatedValuesMax.size() " << m_TOB_EstimatedValuesMax.size() << std::endl;
132 m_uniformTIB = std::vector<bool>(m_TIB_EstimatedValuesMin.size(),
false);
133 m_uniformTOB = std::vector<bool>(m_TOB_EstimatedValuesMin.size(),
false);
134 setUniform(m_TIB_EstimatedValuesMin, m_TIB_EstimatedValuesMax,
m_uniformTIB);
135 setUniform(m_TOB_EstimatedValuesMin, m_TOB_EstimatedValuesMax, m_uniformTOB);
138 m_StdDevs_TIB = std::vector<double>(m_TIB_EstimatedValuesMin.size(), 0);
139 m_StdDevs_TOB = std::vector<double>(m_TOB_EstimatedValuesMin.size(), 0);
140 transform(m_TIB_EstimatedValuesMin.begin(), m_TIB_EstimatedValuesMin.end(), m_TIB_PerCent_Errs.begin(),
m_StdDevs_TIB.begin(), computeSigma);
141 transform(m_TOB_EstimatedValuesMin.begin(), m_TOB_EstimatedValuesMin.end(), m_TOB_PerCent_Errs.begin(), m_StdDevs_TOB.begin(), computeSigma);
144 m_TIBmeanValueMin = std::accumulate(m_TIB_EstimatedValuesMin.begin(), m_TIB_EstimatedValuesMin.end(), 0.)/double(m_TIB_EstimatedValuesMin.size());
145 m_TIBmeanValueMax = std::accumulate(m_TIB_EstimatedValuesMax.begin(), m_TIB_EstimatedValuesMax.end(), 0.)/double(m_TIB_EstimatedValuesMax.size());
146 m_TOBmeanValueMin = std::accumulate(m_TOB_EstimatedValuesMin.begin(), m_TOB_EstimatedValuesMin.end(), 0.)/double(m_TOB_EstimatedValuesMin.size());
147 m_TOBmeanValueMax = std::accumulate(m_TOB_EstimatedValuesMax.begin(), m_TOB_EstimatedValuesMax.end(), 0.)/double(m_TOB_EstimatedValuesMax.size());
148 m_TIBmeanPerCentError = std::accumulate(m_TIB_PerCent_Errs.begin(), m_TIB_PerCent_Errs.end(), 0.)/double(m_TIB_PerCent_Errs.size());
149 m_TOBmeanPerCentError = std::accumulate(m_TOB_PerCent_Errs.begin(), m_TOB_PerCent_Errs.end(), 0.)/double(m_TOB_PerCent_Errs.size());
176 for (
const auto& detId :
reader.getAllDetIds() ) {
178 const int subDet = detectorId.
subdetId();
183 const int layerId = tTopo->
tibLayer(detectorId) -1;
186 const int layerId = tTopo->
tobLayer(detectorId) -1;
193 if ( tTopo->
tecRing(detectorId) < 5 ) {
202 if ( ! lorentzAngle->putLorentzAngle(detId, mobi) ) {
203 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
const DepRecordT & getRecord() const
std::vector< bool > m_uniformTOB
std::vector< double > m_TOB_PerCent_Errs
static const IOVSyncValue & beginOfTime()
double m_TIBmeanPerCentError
std::vector< double > m_TOB_EstimatedValuesMax
std::vector< double > m_StdDevs_TIB
std::shared_ptr< SiStripLorentzAngle > ReturnType
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
ReturnType produce(const SiStripLorentzAngleRcd &)
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
std::vector< double > m_TIB_EstimatedValuesMax
std::string fullPath() const
~SiStripLorentzAngleFakeESSource() override
unsigned int tobLayer(const DetId &id) const
std::vector< double > m_TIB_PerCent_Errs