test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::auto_ptr< SiStripGainproduce (const TDependentRecord &)
 
 SiStripGainESProducerTemplate (const edm::ParameterSet &)
 
 ~SiStripGainESProducerTemplate ()
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
virtual ~ESProducer ()
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
virtual void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval)
 overrides DataProxyProvider method More...
 
virtual ~ESProxyFactoryProducer ()
 
- 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 ()
 

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, boost::shared_ptr
< DataProxy > > > 
KeyedProxies
 
typedef std::vector
< EventSetupRecordKey
Keys
 
typedef std::map
< EventSetupRecordKey,
KeyedProxies
RecordProxies
 
- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::ESProducer
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::auto_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const eventsetup::EventSetupRecordKey &iRecord, std::auto_ptr< eventsetup::ProxyFactoryBase > &iFactory, const std::string &iLabel=std::string())
 
virtual void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList)
 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 26 of file SiStripGainESProducerTemplate.h.

Constructor & Destructor Documentation

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

Definition at line 50 of file SiStripGainESProducerTemplate.h.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

51 {
52  setWhatProduced(this);
53 
54  automaticMode_ = iConfig.getParameter<bool>("AutomaticNormalization");
55  printdebug_ = iConfig.getUntrackedParameter<bool>("printDebug", false);
56  apvGainLabels_ = iConfig.getParameter<std::vector<edm::ParameterSet> >("APVGain");
57 
58  // Fill the vector of apv labels
59  std::vector<edm::ParameterSet>::const_iterator gainPSetIt = apvGainLabels_.begin();
60  for( ; gainPSetIt != apvGainLabels_.end(); ++gainPSetIt ) {
61  apvgain_.push_back( std::make_pair(gainPSetIt->getParameter<std::string>("Record"), gainPSetIt->getUntrackedParameter<std::string>("Label", "")) );
62  norm_.push_back(gainPSetIt->getUntrackedParameter<double>("NormalizationFactor", 1.));
63  }
64  bool badNorm = false;
65  std::vector<double>::const_iterator it = norm_.begin();
66  for( ; it != norm_.end(); ++it ) {
67  if( *it <= 0 ) badNorm = true;
68  }
69 
70  if(!automaticMode_ && badNorm ){
71  edm::LogError("SiStripGainESProducer") << "[SiStripGainESProducer] - ERROR: negative or zero Normalization factor provided. Assuming 1 for such factor" << std::endl;
72  norm_ = std::vector<double>(norm_.size(), 1.);
73  }
74 }
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 ( )
inline

Definition at line 29 of file SiStripGainESProducerTemplate.h.

29 {};

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 84 of file SiStripGainESProducerTemplate.h.

References edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::getRecord(), ecalTPGAnalyzer_cfg::recordName, and AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 143 of file SiStripGainESProducerTemplate.h.

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

Definition at line 77 of file SiStripGainESProducerTemplate.h.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

78 {
79  std::auto_ptr<SiStripGain> ptr(SiStripGainNormalizationFunction(iRecord));
80  return ptr;
81 }
SiStripGain * SiStripGainNormalizationFunction(const TDependentRecord &iRecord)
template<typename TDependentRecord , typename TInputRecord >
SiStripGain * SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::SiStripGainNormalizationFunction ( const TDependentRecord &  iRecord)
private

Definition at line 98 of file SiStripGainESProducerTemplate.h.

References a, edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::getRecord(), i, SiStripGain::multiply(), and edm::second().

99 {
100  // First clean up the pDD vector otherwise it will contain old handles referring to products no more in the es
101  pDD.clear();
102 
103  if(typeid(TDependentRecord)==typeid(SiStripGainRcd) && typeid(TInputRecord)==typeid(SiStripApvGainRcd)){
104 
105  const SiStripGainRcd& a = dynamic_cast<const SiStripGainRcd&>(iRecord);
106 
107  fillApvGain( a, apvgain_[0], pDD );
108  // Create a new gain object and insert the ApvGain
109  SiStripGain * gain = new SiStripGain( *(pDD[0].product()), getNFactor(0), apvgain_[0] );
110 
111  if( apvgain_.size() > 1 ) {
112  for( unsigned int i=1; i<apvgain_.size(); ++i ) {
113  fillApvGain( a, apvgain_[i], pDD );
114  // Add the new ApvGain to the gain object
115  gain->multiply(*(pDD[i].product()), getNFactor(i), apvgain_[i]);
116  }
117  }
118  return gain;
119 
120  }else if(typeid(TDependentRecord)==typeid(SiStripGainSimRcd) && typeid(TInputRecord)==typeid(SiStripApvGainSimRcd)){
121 
122  const SiStripGainSimRcd& a = dynamic_cast<const SiStripGainSimRcd&>(iRecord);
123 
124  pDD.push_back(edm::ESHandle<SiStripApvGain>());
126  SiStripGain * gain = new SiStripGain( *(pDD[0].product()), getNFactor(0), apvgain_[0] );
127 
128  if( apvgain_.size() > 1 ) {
129  for( unsigned int i=1; i<apvgain_.size(); ++i ) {
130  pDD.push_back(edm::ESHandle<SiStripApvGain>());
132  gain->multiply(*(pDD[i].product()), getNFactor(i), apvgain_[i]);
133  }
134  }
135  return gain;
136  }
137 
138  edm::LogError("SiStripGainESProducer") << "[SiStripGainNormalizationFunction] - ERROR: asking for a pair of records different from <SiStripGainRcd,SiStripApvGainRcd> and <SiStripGainSimRcd,SiStripApvGainSimRcd>" << std::endl;
139  return new SiStripGain();
140 }
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
int i
Definition: DBlmapReader.cc:9
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

Definition at line 39 of file SiStripGainESProducerTemplate.h.

template<typename TDependentRecord , typename TInputRecord >
std::vector<edm::ParameterSet> SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::apvGainLabels_
private

Definition at line 38 of file SiStripGainESProducerTemplate.h.

template<typename TDependentRecord , typename TInputRecord >
bool SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::automaticMode_
private

Definition at line 41 of file SiStripGainESProducerTemplate.h.

template<typename TDependentRecord , typename TInputRecord >
SiStripGain* SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::gain_
private

Definition at line 43 of file SiStripGainESProducerTemplate.h.

template<typename TDependentRecord , typename TInputRecord >
std::vector<double> SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::norm_
private

Definition at line 40 of file SiStripGainESProducerTemplate.h.

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

Definition at line 44 of file SiStripGainESProducerTemplate.h.

template<typename TDependentRecord , typename TInputRecord >
bool SiStripGainESProducerTemplate< TDependentRecord, TInputRecord >::printdebug_
private

Definition at line 42 of file SiStripGainESProducerTemplate.h.