3 #include <boost/cstdint.hpp>
6 #include "CLHEP/Random/RandGauss.h"
7 #include "CLHEP/Random/RandFlat.h"
15 double computeSigma(
const double &
value,
const double & perCentError) {
16 return (perCentError/100)*
value;
23 edm::LogInfo(
"SiStripLorentzAngleGenerator") <<
"[SiStripLorentzAngleGenerator::SiStripLorentzAngleGenerator]";
28 edm::LogInfo(
"SiStripLorentzAngleGenerator") <<
"[SiStripLorentzAngleGenerator::~SiStripLorentzAngleGenerator]";
32 if( uniform )
hallMobility_ = CLHEP::RandFlat::shoot(meanMin, meanMax);
33 else if( sigma>0 )
hallMobility_ = CLHEP::RandGauss::shoot(meanMin, sigma);
38 if( estimatedValuesMax.size() != 0 ) {
39 std::vector<double>::const_iterator
min = estimatedValuesMin.begin();
40 std:: vector<double>::const_iterator
max = estimatedValuesMax.begin();
41 std::vector<bool>::iterator uniformIt = uniform.begin();
42 for( ; min != estimatedValuesMin.end(); ++
min, ++
max, ++uniformIt ) {
43 if( *min != *max ) *uniformIt =
true;
54 std::vector<double> TIB_EstimatedValuesMin(
_pset.
getParameter<std::vector<double> >(
"TIB_EstimatedValuesMin"));
55 std::vector<double> TIB_EstimatedValuesMax(
_pset.
getParameter<std::vector<double> >(
"TIB_EstimatedValuesMax"));
56 std::vector<double> TOB_EstimatedValuesMin(
_pset.
getParameter<std::vector<double> >(
"TOB_EstimatedValuesMin"));
57 std::vector<double> TOB_EstimatedValuesMax(
_pset.
getParameter<std::vector<double> >(
"TOB_EstimatedValuesMax"));
58 std::vector<double> TIB_PerCent_Errs(
_pset.
getParameter<std::vector<double> >(
"TIB_PerCent_Errs"));
59 std::vector<double> TOB_PerCent_Errs(
_pset.
getParameter<std::vector<double> >(
"TOB_PerCent_Errs"));
62 if( (TIB_EstimatedValuesMax.size() != 0 && (TIB_EstimatedValuesMin.size() != TIB_EstimatedValuesMax.size())) ||
63 (TOB_EstimatedValuesMax.size() != 0 && (TOB_EstimatedValuesMin.size() != TOB_EstimatedValuesMax.size())) ) {
64 std::cout <<
"ERROR: size of min and max values is different" << std::endl;
65 std::cout <<
"TIB_EstimatedValuesMin.size() = " << TIB_EstimatedValuesMin.size() <<
", TIB_EstimatedValuesMax.size() " << TIB_EstimatedValuesMax.size() << std::endl;
66 std::cout <<
"TOB_EstimatedValuesMin.size() = " << TOB_EstimatedValuesMin.size() <<
", TOB_EstimatedValuesMax.size() " << TOB_EstimatedValuesMax.size() << std::endl;
68 std::vector<bool> uniformTIB(TIB_EstimatedValuesMin.size(),
false);
69 std::vector<bool> uniformTOB(TOB_EstimatedValuesMin.size(),
false);
71 setUniform(TIB_EstimatedValuesMin, TIB_EstimatedValuesMax, uniformTIB);
72 setUniform(TOB_EstimatedValuesMin, TOB_EstimatedValuesMax, uniformTOB);
77 std::vector<double> StdDevs_TIB(TIB_EstimatedValuesMin.size(), 0);
78 std::vector<double> StdDevs_TOB(TOB_EstimatedValuesMin.size(), 0);
79 transform(TIB_EstimatedValuesMin.begin(), TIB_EstimatedValuesMin.end(), TIB_PerCent_Errs.begin(), StdDevs_TIB.begin(), computeSigma);
80 transform(TOB_EstimatedValuesMin.begin(), TOB_EstimatedValuesMin.end(), TOB_PerCent_Errs.begin(), StdDevs_TOB.begin(), computeSigma);
83 double TIBmeanValueMin = std::accumulate( TIB_EstimatedValuesMin.begin(), TIB_EstimatedValuesMin.end(), 0.)/double(TIB_EstimatedValuesMin.size());
84 double TIBmeanValueMax = std::accumulate( TIB_EstimatedValuesMax.begin(), TIB_EstimatedValuesMax.end(), 0.)/double(TIB_EstimatedValuesMax.size());
85 double TOBmeanValueMin = std::accumulate( TOB_EstimatedValuesMin.begin(), TOB_EstimatedValuesMin.end(), 0.)/double(TOB_EstimatedValuesMin.size());
86 double TOBmeanValueMax = std::accumulate( TOB_EstimatedValuesMax.begin(), TOB_EstimatedValuesMax.end(), 0.)/double(TOB_EstimatedValuesMax.size());
87 double TIBmeanPerCentError = std::accumulate( TIB_PerCent_Errs.begin(), TIB_PerCent_Errs.end(), 0.)/double(TIB_PerCent_Errs.size());
88 double TOBmeanPerCentError = std::accumulate( TOB_PerCent_Errs.begin(), TOB_PerCent_Errs.end(), 0.)/double(TOB_PerCent_Errs.size());
89 double TIBmeanStdDev = (TIBmeanPerCentError/100)*TIBmeanValueMin;
90 double TOBmeanStdDev = (TOBmeanPerCentError/100)*TOBmeanValueMin;
92 const std::vector<uint32_t> DetIds =
reader.getAllDetIds();
93 for(std::vector<uint32_t>::const_iterator detit=DetIds.begin(); detit!=DetIds.end(); detit++){
95 const int subDet = detectorId.
subdetId();
102 layerId = tTopo->
tibLayer(detectorId) -1;
103 setHallMobility( TIB_EstimatedValuesMin[layerId], TIB_EstimatedValuesMax[layerId], StdDevs_TIB[layerId], uniformTIB[layerId] );
106 layerId = tTopo->
tobLayer(detectorId) -1;
107 setHallMobility( TOB_EstimatedValuesMin[layerId], TOB_EstimatedValuesMax[layerId], StdDevs_TOB[layerId], uniformTOB[layerId] );
111 setHallMobility( TIBmeanValueMin, TIBmeanValueMax, TIBmeanStdDev, uniformTIB[0] );
114 if(tTopo->
tecRing(detectorId)<5){
116 setHallMobility( TIBmeanValueMin, TIBmeanValueMax, TIBmeanStdDev, uniformTIB[0] );
119 setHallMobility( TOBmeanValueMin, TOBmeanValueMax, TOBmeanStdDev, uniformTOB[0] );
124 edm::LogError(
"SiStripLorentzAngleGenerator")<<
" detid already exists"<<std::endl;
T getParameter(std::string const &) const
SiStripLorentzAngleGenerator(const edm::ParameterSet &, const edm::ActivityRegistry &)
tuple SiStripLorentzAngle
void setUniform(const std::vector< double > &TIB_EstimatedValuesMin, const std::vector< double > &TIB_EstimatedValuesMax, std::vector< bool > &uniformTIB)
Method used to determine whether to generate with a uniform distribution for each layer...
unsigned int tibLayer(const DetId &id) const
SiStripLorentzAngle * createObject(const TrackerTopology *tTopo)
unsigned int tecRing(const DetId &id) const
ring id
bool putLorentzAngle(const uint32_t &, float)
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
std::string fullPath() const
~SiStripLorentzAngleGenerator()
void setHallMobility(const double &meanMin, const double &meanMax, const double &sigma, const bool uniform)
unsigned int tobLayer(const DetId &id) const