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::one::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks, edm::one::SharedResources > edm::one::EDAnalyzerBase 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::one::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks, edm::one::SharedResources >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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_
 
double meanGain_
 
double minimumPosValue_
 
bool printdebug_
 
double sigmaGain_
 
edm::ESWatcher< TrackerDigiGeometryRecordtkDigiGeomRcdWatcher_
 
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordtkGeomToken_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from ConditionDBWriter< SiStripApvGain >
static void fillPSetDescription (edm::ParameterSetDescription &desc)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 31 of file SiStripGainRandomCalculator.h.

Constructor & Destructor Documentation

◆ SiStripGainRandomCalculator()

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

Definition at line 20 of file SiStripGainRandomCalculator.cc.

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

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

◆ ~SiStripGainRandomCalculator()

SiStripGainRandomCalculator::~SiStripGainRandomCalculator ( )
override

Definition at line 39 of file SiStripGainRandomCalculator.cc.

39  {
40  edm::LogInfo("SiStripGainRandomCalculator::~SiStripGainRandomCalculator");
41 }
Log< level::Info, false > LogInfo

Member Function Documentation

◆ algoAnalyze()

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

Reimplemented from ConditionDBWriter< SiStripApvGain >.

Definition at line 43 of file SiStripGainRandomCalculator.cc.

References edm::ESWatcher< T >::check(), createTree::dd, detid_apvs_, beamvalidation::exit(), edm::EventSetup::getData(), AlCaHLTBitMon_ParallelJobs::p, printdebug_, nano_mu_digi_cff::rawId, tkDigiGeomRcdWatcher_, and tkGeomToken_.

43  {
44  if (tkDigiGeomRcdWatcher_.check(iSetup)) {
45  const auto& dd = iSetup.getData(tkGeomToken_);
46  edm::LogInfo("SiStripGainRandomCalculator::algoAnalyze - got new geometry ") << std::endl;
47 
48  detid_apvs_.clear();
49 
50  edm::LogInfo("SiStripGainCalculator") << " There are " << dd.detUnits().size() << " detectors" << std::endl;
51 
52  for (const auto& it : dd.detUnits()) {
53  if (dynamic_cast<const StripGeomDetUnit*>(it) != nullptr) {
54  uint32_t detid = (it->geographicalId()).rawId();
55  const StripTopology& p = dynamic_cast<const StripGeomDetUnit*>(it)->specificTopology();
56  unsigned short NAPVs = p.nstrips() / 128;
57  if (NAPVs < 1 || NAPVs > 6) {
58  edm::LogError("SiStripGainCalculator")
59  << " Problem with Number of strips in detector.. " << p.nstrips() << " Exiting program" << endl;
60  exit(1);
61  }
62  detid_apvs_.push_back(pair<uint32_t, unsigned short>(detid, NAPVs));
63  if (printdebug_)
64  edm::LogInfo("SiStripGainCalculator") << "detid " << detid << " apvs " << NAPVs;
65  }
66  }
67  }
68 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
Log< level::Error, false > LogError
string dd
Definition: createTree.py:154
edm::ESWatcher< TrackerDigiGeometryRecord > tkDigiGeomRcdWatcher_
Log< level::Info, false > LogInfo
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
std::vector< std::pair< uint32_t, unsigned short > > detid_apvs_
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken_
def exit(msg="")

◆ getNewObject()

std::unique_ptr< SiStripApvGain > SiStripGainRandomCalculator::getNewObject ( )
overrideprivatevirtual

Implements ConditionDBWriter< SiStripApvGain >.

Definition at line 70 of file SiStripGainRandomCalculator.cc.

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

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

Member Data Documentation

◆ detid_apvs_

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

◆ meanGain_

double SiStripGainRandomCalculator::meanGain_
private

Definition at line 42 of file SiStripGainRandomCalculator.h.

Referenced by getNewObject(), and SiStripGainRandomCalculator().

◆ minimumPosValue_

double SiStripGainRandomCalculator::minimumPosValue_
private

Definition at line 44 of file SiStripGainRandomCalculator.h.

Referenced by getNewObject(), and SiStripGainRandomCalculator().

◆ printdebug_

bool SiStripGainRandomCalculator::printdebug_
private

◆ sigmaGain_

double SiStripGainRandomCalculator::sigmaGain_
private

Definition at line 43 of file SiStripGainRandomCalculator.h.

Referenced by getNewObject(), and SiStripGainRandomCalculator().

◆ tkDigiGeomRcdWatcher_

edm::ESWatcher<TrackerDigiGeometryRecord> SiStripGainRandomCalculator::tkDigiGeomRcdWatcher_
private

Definition at line 50 of file SiStripGainRandomCalculator.h.

Referenced by algoAnalyze().

◆ tkGeomToken_

edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> SiStripGainRandomCalculator::tkGeomToken_
private

Definition at line 49 of file SiStripGainRandomCalculator.h.

Referenced by algoAnalyze(), and SiStripGainRandomCalculator().