1 #ifndef CalibTracker_SiStripESProducers_SiStripGainESProducerTemplate_h 2 #define CalibTracker_SiStripESProducers_SiStripGainESProducerTemplate_h 24 template<
typename TDependentRecord,
typename TInputRecord>
30 std::unique_ptr<SiStripGain>
produce(
const TDependentRecord&);
38 std::vector<std::pair<std::string, std::string> >
apvgain_;
43 std::vector<edm::ESHandle<SiStripApvGain> >
pDD;
48 template<
typename TDependentRecord,
typename TInputRecord>
58 std::vector<edm::ParameterSet>::const_iterator gainPSetIt = apvGainLabels_.begin();
59 for( ; gainPSetIt != apvGainLabels_.end(); ++gainPSetIt ) {
60 apvgain_.push_back( std::make_pair(gainPSetIt->getParameter<
std::string>(
"Record"), gainPSetIt->getUntrackedParameter<
std::string>(
"Label",
"")) );
61 norm_.push_back(gainPSetIt->getUntrackedParameter<
double>(
"NormalizationFactor", 1.));
64 std::vector<double>::const_iterator it =
norm_.begin();
65 for( ; it !=
norm_.end(); ++it ) {
66 if( *it <= 0 ) badNorm =
true;
70 edm::LogError(
"SiStripGainESProducer") <<
"[SiStripGainESProducer] - ERROR: negative or zero Normalization factor provided. Assuming 1 for such factor" << std::endl;
75 template<
typename TDependentRecord,
typename TInputRecord>
82 template<
typename TDependentRecord,
typename TInputRecord>
92 else edm::LogError(
"SiStripGainESProducer::SiStripGainNormalizationFunction") <<
"ERROR: unrecognized record name " << recordName << std::endl
93 <<
"please specify one of: SiStripApvGainRcd, SiStripApvGain2Rcd, SiStripApvGain3Rcd" << std::endl;
96 template<
typename TDependentRecord,
typename TInputRecord>
137 edm::LogError(
"SiStripGainESProducer") <<
"[SiStripGainNormalizationFunction] - ERROR: asking for a pair of records different from <SiStripGainRcd,SiStripApvGainRcd> and <SiStripGainSimRcd,SiStripApvGainSimRcd>" << std::endl;
141 template<
typename TDependentRecord,
typename TInputRecord>
147 std::vector<uint32_t> DetIds;
148 pDD[apvGainIndex]->getDetIds(DetIds);
150 double SumOfGains=0.;
153 for(std::vector<uint32_t>::const_iterator detit=DetIds.begin(); detit!=DetIds.end(); detit++){
159 for(std::vector<float>::const_iterator apvit=detRange.first; apvit!=detRange.second; apvit++){
161 SumOfGains+=(*apvit);
164 edm::LogInfo(
"SiStripGainESProducer::produce()")<<
"detid/component: " << *detit <<
"/"<<iComp<<
" gain factor " <<*apvit ;
170 if(SumOfGains>0 && NGains>0){
171 NFactor=SumOfGains/
NGains;
174 edm::LogError(
"SiStripGainESProducer::produce() - ERROR: empty set of gain values received. Cannot compute normalization factor. Assuming 1 for such factor") << std::endl;
181 NFactor=
norm_[apvGainIndex];
184 if (
printdebug_)
edm::LogInfo(
"SiStripGainESProducer")<<
" putting A SiStrip Gain object in eventSetup with normalization factor " << NFactor ;
void multiply(const SiStripApvGain &apvgain, const double &factor, const std::pair< std::string, std::string > &recordLabelPair)
T getParameter(std::string const &) const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
T getUntrackedParameter(std::string const &, T const &) const
std::vector< edm::ESHandle< SiStripApvGain > > pDD
std::vector< double > norm_
void fillApvGain(const SiStripGainRcd &a, const std::pair< std::string, std::string > &recordLabelPair, std::vector< edm::ESHandle< SiStripApvGain > > &pDD)
~SiStripGainESProducerTemplate() override
U second(std::pair< T, U > const &p)
std::vector< edm::ParameterSet > apvGainLabels_
const DepRecordT getRecord() const
double getNFactor(const int apvGainIndex)
std::pair< ContainerIterator, ContainerIterator > Range
SiStripGainESProducerTemplate(const edm::ParameterSet &)
std::vector< std::pair< std::string, std::string > > apvgain_
std::unique_ptr< SiStripGain > produce(const TDependentRecord &)
SiStripGain * SiStripGainNormalizationFunction(const TDependentRecord &iRecord)