CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
SiStripGainESProducerTemplate< TDependentRecord, TInputRecord > Class Template Reference

#include <SiStripGainESProducerTemplate.h>

Inheritance diagram for SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >:
edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Member Functions

std::unique_ptr< SiStripGainproduce (const TDependentRecord &)
 
 SiStripGainESProducerTemplate (const edm::ParameterSet &)
 
 ~SiStripGainESProducerTemplate () override
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
 ~ESProducer ()(false) override
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval) override
 overrides DataProxyProvider method More...
 
 ~ESProxyFactoryProducer () noexcept(false) override
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
 DataProxyProvider ()
 
const ComponentDescriptiondescription () const
 
bool isUsingRecord (const EventSetupRecordKey &) const
 
const KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey) const
 
void resetProxies (const EventSetupRecordKey &iRecordType)
 
void resetProxiesIfTransient (const EventSetupRecordKey &iRecordType)
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider () noexcept(false)
 

Private Member Functions

void fillApvGain (const SiStripGainRcd &a, const std::pair< std::string, std::string > &recordLabelPair, std::vector< edm::ESHandle< SiStripApvGain > > &pDD)
 
double getNFactor (const int apvGainIndex)
 
SiStripGainSiStripGainNormalizationFunction (const TDependentRecord &iRecord)
 

Private Attributes

std::vector< std::pair< std::string, std::string > > apvgain_
 
std::vector< edm::ParameterSetapvGainLabels_
 
bool automaticMode_
 
SiStripGaingain_
 
std::vector< double > norm_
 
std::vector< edm::ESHandle< SiStripApvGain > > pDD
 
bool printdebug_
 

Additional Inherited Members

- Public Types inherited from edm::eventsetup::DataProxyProvider
typedef std::vector< std::pair< DataKey, edm::propagate_const< std::shared_ptr< DataProxy > > > > KeyedProxies
 
typedef std::vector< EventSetupRecordKeyKeys
 
typedef std::map< EventSetupRecordKey, KeyedProxiesRecordProxies
 
- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::ESProducer
 ESProducer (const ESProducer &)=delete
 
ESProducer const & operator= (const ESProducer &)=delete
 
template<typename T >
void setWhatProduced (T *iThis, const es::Label &iLabel=es::Label())
 
template<typename T >
void setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
void setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
void setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel=es::Label())
 
- Protected Member Functions inherited from edm::ESProxyFactoryProducer
template<class TFactory >
void registerFactory (std::unique_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const eventsetup::EventSetupRecordKey &iRecord, std::unique_ptr< eventsetup::ProxyFactoryBase > iFactory, const std::string &iLabel=std::string())
 
void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList) override
 override DataProxyProvider method More...
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
void eraseAll (const EventSetupRecordKey &iRecordKey)
 deletes all the Proxies in aStream More...
 
void invalidateProxies (const EventSetupRecordKey &iRecordKey)
 
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &)
 

Detailed Description

template<typename TDependentRecord, typename TInputRecord>
class SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >

Definition at line 25 of file SiStripGainESProducerTemplate.h.

Constructor & Destructor Documentation

template<typename TDependentRecord , typename TInputRecord >
SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::SiStripGainESProducerTemplate ( const edm::ParameterSet iConfig)

Definition at line 49 of file SiStripGainESProducerTemplate.h.

References SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::apvgain_, SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::apvGainLabels_, SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::automaticMode_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::norm_, SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::printdebug_, edm::ESProducer::setWhatProduced(), and AlCaHLTBitMon_QueryRunRegistry::string.

50 {
51  setWhatProduced(this);
52 
53  automaticMode_ = iConfig.getParameter<bool>("AutomaticNormalization");
54  printdebug_ = iConfig.getUntrackedParameter<bool>("printDebug", false);
55  apvGainLabels_ = iConfig.getParameter<std::vector<edm::ParameterSet> >("APVGain");
56 
57  // Fill the vector of apv labels
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.));
62  }
63  bool badNorm = false;
64  std::vector<double>::const_iterator it = norm_.begin();
65  for( ; it != norm_.end(); ++it ) {
66  if( *it <= 0 ) badNorm = true;
67  }
68 
69  if(!automaticMode_ && badNorm ){
70  edm::LogError("SiStripGainESProducer") << "[SiStripGainESProducer] - ERROR: negative or zero Normalization factor provided. Assuming 1 for such factor" << std::endl;
71  norm_ = std::vector<double>(norm_.size(), 1.);
72  }
73 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
std::vector< edm::ParameterSet > apvGainLabels_
std::vector< std::pair< std::string, std::string > > apvgain_
template<typename TDependentRecord , typename TInputRecord >
SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::~SiStripGainESProducerTemplate ( )
inlineoverride

Member Function Documentation

template<typename TDependentRecord , typename TInputRecord >
void SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::fillApvGain ( const SiStripGainRcd a,
const std::pair< std::string, std::string > &  recordLabelPair,
std::vector< edm::ESHandle< SiStripApvGain > > &  pDD 
)
private

Definition at line 83 of file SiStripGainESProducerTemplate.h.

References edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::getRecord(), SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::pDD, align_cfg::recordName, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::SiStripGainNormalizationFunction().

84 {
85  // Put in an empty ApvGain and fill it
87  std::string recordName( recordLabelPair.first );
88  std::string labelName( recordLabelPair.second );
89  if( recordName == "SiStripApvGainRcd" ) a.getRecord<SiStripApvGainRcd>().get( labelName, pDD.back() );
90  else if( recordName == "SiStripApvGain2Rcd" ) a.getRecord<SiStripApvGain2Rcd>().get( labelName, pDD.back() );
91  else if( recordName == "SiStripApvGain3Rcd" ) a.getRecord<SiStripApvGain3Rcd>().get( labelName, pDD.back() );
92  else edm::LogError("SiStripGainESProducer::SiStripGainNormalizationFunction") << "ERROR: unrecognized record name " << recordName << std::endl
93  << "please specify one of: SiStripApvGainRcd, SiStripApvGain2Rcd, SiStripApvGain3Rcd" << std::endl;
94 }
std::vector< edm::ESHandle< SiStripApvGain > > pDD
template<typename TDependentRecord , typename TInputRecord >
double SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::getNFactor ( const int  apvGainIndex)
private

Definition at line 142 of file SiStripGainESProducerTemplate.h.

References SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::automaticMode_, NGains, SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::norm_, SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::pDD, and SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::printdebug_.

Referenced by SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::SiStripGainNormalizationFunction(), and SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::~SiStripGainESProducerTemplate().

142  {
143  double NFactor=0.;
144 
145  if(automaticMode_ || printdebug_ ){
146 
147  std::vector<uint32_t> DetIds;
148  pDD[apvGainIndex]->getDetIds(DetIds);
149 
150  double SumOfGains=0.;
151  int NGains=0;
152 
153  for(std::vector<uint32_t>::const_iterator detit=DetIds.begin(); detit!=DetIds.end(); detit++){
154 
155  SiStripApvGain::Range detRange = pDD[apvGainIndex]->getRange(*detit);
156 
157  int iComp=0;
158 
159  for(std::vector<float>::const_iterator apvit=detRange.first; apvit!=detRange.second; apvit++){
160 
161  SumOfGains+=(*apvit);
162  NGains++;
163  if (printdebug_)
164  edm::LogInfo("SiStripGainESProducer::produce()")<< "detid/component: " << *detit <<"/"<<iComp<< " gain factor " <<*apvit ;
165  iComp++;
166  }
167  }
168 
169  if(automaticMode_){
170  if(SumOfGains>0 && NGains>0){
171  NFactor=SumOfGains/NGains;
172  }
173  else{
174  edm::LogError("SiStripGainESProducer::produce() - ERROR: empty set of gain values received. Cannot compute normalization factor. Assuming 1 for such factor") << std::endl;
175  NFactor=1.;
176  }
177  }
178  }
179 
180  if(!automaticMode_){
181  NFactor=norm_[apvGainIndex];
182  }
183 
184  if (printdebug_) edm::LogInfo("SiStripGainESProducer")<< " putting A SiStrip Gain object in eventSetup with normalization factor " << NFactor ;
185  return NFactor;
186 }
std::vector< edm::ESHandle< SiStripApvGain > > pDD
std::pair< ContainerIterator, ContainerIterator > Range
constexpr int NGains
template<typename TDependentRecord , typename TInputRecord >
std::unique_ptr< SiStripGain > SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::produce ( const TDependentRecord &  iRecord)
template<typename TDependentRecord , typename TInputRecord >
SiStripGain * SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::SiStripGainNormalizationFunction ( const TDependentRecord &  iRecord)
private

Definition at line 97 of file SiStripGainESProducerTemplate.h.

References a, SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::apvgain_, SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::fillApvGain(), muonCSCDigis_cfi::gain, SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::getNFactor(), edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::getRecord(), mps_fire::i, SiStripGain::multiply(), SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::pDD, and edm::second().

Referenced by SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::produce(), and SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::~SiStripGainESProducerTemplate().

98 {
99  // First clean up the pDD vector otherwise it will contain old handles referring to products no more in the es
100  pDD.clear();
101 
102  if(typeid(TDependentRecord)==typeid(SiStripGainRcd) && typeid(TInputRecord)==typeid(SiStripApvGainRcd)){
103 
104  const SiStripGainRcd& a = dynamic_cast<const SiStripGainRcd&>(iRecord);
105 
106  fillApvGain( a, apvgain_[0], pDD );
107  // Create a new gain object and insert the ApvGain
108  SiStripGain * gain = new SiStripGain( *(pDD[0].product()), getNFactor(0), apvgain_[0] );
109 
110  if( apvgain_.size() > 1 ) {
111  for( unsigned int i=1; i<apvgain_.size(); ++i ) {
112  fillApvGain( a, apvgain_[i], pDD );
113  // Add the new ApvGain to the gain object
114  gain->multiply(*(pDD[i].product()), getNFactor(i), apvgain_[i]);
115  }
116  }
117  return gain;
118 
119  }else if(typeid(TDependentRecord)==typeid(SiStripGainSimRcd) && typeid(TInputRecord)==typeid(SiStripApvGainSimRcd)){
120 
121  const SiStripGainSimRcd& a = dynamic_cast<const SiStripGainSimRcd&>(iRecord);
122 
123  pDD.push_back(edm::ESHandle<SiStripApvGain>());
125  SiStripGain * gain = new SiStripGain( *(pDD[0].product()), getNFactor(0), apvgain_[0] );
126 
127  if( apvgain_.size() > 1 ) {
128  for( unsigned int i=1; i<apvgain_.size(); ++i ) {
129  pDD.push_back(edm::ESHandle<SiStripApvGain>());
131  gain->multiply(*(pDD[i].product()), getNFactor(i), apvgain_[i]);
132  }
133  }
134  return gain;
135  }
136 
137  edm::LogError("SiStripGainESProducer") << "[SiStripGainNormalizationFunction] - ERROR: asking for a pair of records different from <SiStripGainRcd,SiStripApvGainRcd> and <SiStripGainSimRcd,SiStripApvGainSimRcd>" << std::endl;
138  return new SiStripGain();
139 }
void multiply(const SiStripApvGain &apvgain, const double &factor, const std::pair< std::string, std::string > &recordLabelPair)
Used to input additional gain values that will be multiplied to the first one.
Definition: SiStripGain.cc:17
std::vector< edm::ESHandle< SiStripApvGain > > pDD
void fillApvGain(const SiStripGainRcd &a, const std::pair< std::string, std::string > &recordLabelPair, std::vector< edm::ESHandle< SiStripApvGain > > &pDD)
U second(std::pair< T, U > const &p)
double getNFactor(const int apvGainIndex)
std::vector< std::pair< std::string, std::string > > apvgain_
double a
Definition: hdecay.h:121

Member Data Documentation

template<typename TDependentRecord , typename TInputRecord >
std::vector<std::pair<std::string, std::string> > SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::apvgain_
private
template<typename TDependentRecord , typename TInputRecord >
std::vector<edm::ParameterSet> SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::apvGainLabels_
private
template<typename TDependentRecord , typename TInputRecord >
bool SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::automaticMode_
private
template<typename TDependentRecord , typename TInputRecord >
SiStripGain* SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::gain_
private

Definition at line 42 of file SiStripGainESProducerTemplate.h.

template<typename TDependentRecord , typename TInputRecord >
std::vector<double> SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::norm_
private
template<typename TDependentRecord , typename TInputRecord >
std::vector<edm::ESHandle<SiStripApvGain> > SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::pDD
private
template<typename TDependentRecord , typename TInputRecord >
bool SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::printdebug_
private