CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
SiStripGainRandomCalculator Class Reference

#include <SiStripGainRandomCalculator.h>

Inheritance diagram for SiStripGainRandomCalculator:
ConditionDBWriter< SiStripApvGain > edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 SiStripGainRandomCalculator (const edm::ParameterSet &)
 
 ~SiStripGainRandomCalculator () override
 
- Public Member Functions inherited from ConditionDBWriter< SiStripApvGain >
 ConditionDBWriter (const edm::ParameterSet &iConfig)
 
 ~ConditionDBWriter () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void algoAnalyze (const edm::Event &, const edm::EventSetup &) override
 
std::unique_ptr< SiStripApvGaingetNewObject () override
 

Private Attributes

std::vector< std::pair< uint32_t, unsigned short > > detid_apvs_
 
unsigned long long m_cacheID_
 
double meanGain_
 
double minimumPosValue_
 
bool printdebug_
 
double sigmaGain_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from ConditionDBWriter< SiStripApvGain >
void setDoStore (const bool doStore)
 When set to false the payload will not be written to the db. More...
 
void storeOnDbNow ()
 
cond::Time_t timeOfLastIOV ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 27 of file SiStripGainRandomCalculator.h.

Constructor & Destructor Documentation

SiStripGainRandomCalculator::SiStripGainRandomCalculator ( const edm::ParameterSet iConfig)
explicit

Definition at line 23 of file SiStripGainRandomCalculator.cc.

References detid_apvs_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), meanGain_, minimumPosValue_, printdebug_, and sigmaGain_.

25  edm::LogInfo("SiStripGainRandomCalculator::SiStripGainRandomCalculator");
26 
27  // std::string Mode=iConfig.getParameter<std::string>("Mode");
28  // if (Mode==std::string("Gaussian")) GaussianMode_=true;
29  // else if (IOVMode==std::string("Constant")) ConstantMode_=true;
30  // else edm::LogError("SiStripGainRandomCalculator::SiStripGainRandomCalculator(): ERROR - unknown generation mode...will not store anything on the DB") << std::endl;
31 
32  detid_apvs_.clear();
33 
34  meanGain_ = iConfig.getParameter<double>("MeanGain");
35  sigmaGain_ = iConfig.getParameter<double>("SigmaGain");
36  minimumPosValue_ = iConfig.getParameter<double>("MinPositiveGain");
37  printdebug_ = iConfig.getUntrackedParameter<bool>("printDebug", false);
38 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::pair< uint32_t, unsigned short > > detid_apvs_
SiStripGainRandomCalculator::~SiStripGainRandomCalculator ( )
override

Definition at line 40 of file SiStripGainRandomCalculator.cc.

40  {
41  edm::LogInfo("SiStripGainRandomCalculator::~SiStripGainRandomCalculator");
42 }

Member Function Documentation

void SiStripGainRandomCalculator::algoAnalyze ( const edm::Event event,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Reimplemented from ConditionDBWriter< SiStripApvGain >.

Definition at line 44 of file SiStripGainRandomCalculator.cc.

References detid_apvs_, TrackerGeometry::detUnits(), beamvalidation::exit(), edm::EventSetup::get(), m_cacheID_, StripTopology::nstrips(), AlCaHLTBitMon_ParallelJobs::p, and printdebug_.

44  {
45  unsigned long long cacheID = iSetup.get<TrackerDigiGeometryRecord>().cacheIdentifier();
46 
47  if (m_cacheID_ != cacheID) {
48  m_cacheID_ = cacheID;
49 
51 
52  iSetup.get<TrackerDigiGeometryRecord>().get(pDD);
53  edm::LogInfo("SiStripGainRandomCalculator::algoAnalyze - got new geometry ") << std::endl;
54 
55  detid_apvs_.clear();
56 
57  edm::LogInfo("SiStripGainCalculator") << " There are " << pDD->detUnits().size() << " detectors" << std::endl;
58 
59  for (const auto& it : pDD->detUnits()) {
60  if (dynamic_cast<const StripGeomDetUnit*>(it) != nullptr) {
61  uint32_t detid = (it->geographicalId()).rawId();
62  const StripTopology& p = dynamic_cast<const StripGeomDetUnit*>(it)->specificTopology();
63  unsigned short NAPVs = p.nstrips() / 128;
64  if (NAPVs < 1 || NAPVs > 6) {
65  edm::LogError("SiStripGainCalculator")
66  << " Problem with Number of strips in detector.. " << p.nstrips() << " Exiting program" << endl;
67  exit(1);
68  }
69  detid_apvs_.push_back(pair<uint32_t, unsigned short>(detid, NAPVs));
70  if (printdebug_)
71  edm::LogInfo("SiStripGainCalculator") << "detid " << detid << " apvs " << NAPVs;
72  }
73  }
74  }
75 }
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
virtual int nstrips() const =0
std::vector< std::pair< uint32_t, unsigned short > > detid_apvs_
T get() const
Definition: EventSetup.h:73
def exit(msg="")
std::unique_ptr< SiStripApvGain > SiStripGainRandomCalculator::getNewObject ( )
overrideprivatevirtual

Implements ConditionDBWriter< SiStripApvGain >.

Definition at line 77 of file SiStripGainRandomCalculator.cc.

References gather_cfg::cout, detid_apvs_, PedestalClient_cfi::gain, dqmiolumiharvest::j, meanGain_, minimumPosValue_, getGTfromDQMFile::obj, printdebug_, FastTimerService_cff::range, and sigmaGain_.

77  {
78  std::cout << "SiStripGainRandomCalculator::getNewObject called" << std::endl;
79 
80  auto obj = std::make_unique<SiStripApvGain>();
81 
82  for (std::vector<pair<uint32_t, unsigned short> >::const_iterator it = detid_apvs_.begin(); it != detid_apvs_.end();
83  it++) {
84  //Generate Gain for det detid
85  std::vector<float> theSiStripVector;
86  for (unsigned short j = 0; j < it->second; j++) {
87  float gain;
88 
89  // if(sigmaGain_/meanGain_ < 0.00001) gain = meanGain_;
90  // else{
91  gain = CLHEP::RandGauss::shoot(meanGain_, sigmaGain_);
92  if (gain <= minimumPosValue_)
93  gain = minimumPosValue_;
94  // }
95 
96  if (printdebug_)
97  edm::LogInfo("SiStripGainCalculator") << "detid " << it->first << " \t"
98  << " apv " << j << " \t" << gain << " \t" << std::endl;
99  theSiStripVector.push_back(gain);
100  }
101 
102  SiStripApvGain::Range range(theSiStripVector.begin(), theSiStripVector.end());
103  if (!obj->put(it->first, range))
104  edm::LogError("SiStripGainCalculator") << "[SiStripGainCalculator::beginJob] detid already exists" << std::endl;
105  }
106 
107  return obj;
108 }
std::pair< ContainerIterator, ContainerIterator > Range
std::vector< std::pair< uint32_t, unsigned short > > detid_apvs_

Member Data Documentation

std::vector<std::pair<uint32_t, unsigned short> > SiStripGainRandomCalculator::detid_apvs_
private
unsigned long long SiStripGainRandomCalculator::m_cacheID_
private

Definition at line 43 of file SiStripGainRandomCalculator.h.

Referenced by algoAnalyze().

double SiStripGainRandomCalculator::meanGain_
private

Definition at line 38 of file SiStripGainRandomCalculator.h.

Referenced by getNewObject(), and SiStripGainRandomCalculator().

double SiStripGainRandomCalculator::minimumPosValue_
private

Definition at line 40 of file SiStripGainRandomCalculator.h.

Referenced by getNewObject(), and SiStripGainRandomCalculator().

bool SiStripGainRandomCalculator::printdebug_
private
double SiStripGainRandomCalculator::sigmaGain_
private

Definition at line 39 of file SiStripGainRandomCalculator.h.

Referenced by getNewObject(), and SiStripGainRandomCalculator().