CMS 3D CMS Logo

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

#include <SiStripNoiseNormalizedWithApvGainBuilder.h>

Inheritance diagram for SiStripNoiseNormalizedWithApvGainBuilder:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
 SiStripNoiseNormalizedWithApvGainBuilder (const edm::ParameterSet &iConfig)
 
 ~SiStripNoiseNormalizedWithApvGainBuilder () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void fillParameters (std::map< int, std::vector< double > > &mapToFill, const std::string &parameterName) const
 Fills the parameters read from cfg and matching the name in the given map. More...
 
void fillSubDetParameter (std::map< int, std::vector< double > > &mapToFill, const std::vector< double > &v, const int subDet, const unsigned short layers) const
 
void printLog (const uint32_t detId, const unsigned short strip, const double &noise) const
 

Private Attributes

double electronsPerADC_
 
edm::FileInPath fp_
 
edm::ESGetToken< SiStripApvGain, SiStripApvGainRcdinputApvGainToken_
 
double minimumPosValue_
 
bool printdebug_
 
uint32_t printDebug_
 
edm::ParameterSet pset_
 
bool stripLengthMode_
 
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordtGeomToken_
 
edm::ESGetToken< TrackerTopology, TrackerTopologyRcdtTopoToken_
 

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 edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 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<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

Produces a noise tag using the same settings as the service used in the DummyDBWriter, but it receives a SiStripApvGain tag from the EventSetup and uses the gain values (per apv) to rescale the noise (per strip).

Definition at line 31 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Constructor & Destructor Documentation

◆ SiStripNoiseNormalizedWithApvGainBuilder()

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

Definition at line 12 of file SiStripNoiseNormalizedWithApvGainBuilder.cc.

References inputApvGainToken_, tGeomToken_, and tTopoToken_.

13  : printdebug_(iConfig.getUntrackedParameter<uint32_t>("printDebug", 1)),
14  pset_(iConfig),
15  electronsPerADC_(0.),
16  minimumPosValue_(0.),
17  stripLengthMode_(true),
18  printDebug_(0) {
19  tTopoToken_ = esConsumes<TrackerTopology, TrackerTopologyRcd>();
20  tGeomToken_ = esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>();
21  inputApvGainToken_ = esConsumes<SiStripApvGain, SiStripApvGainRcd>();
22 }
edm::ESGetToken< SiStripApvGain, SiStripApvGainRcd > inputApvGainToken_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
T getUntrackedParameter(std::string const &, T const &) const
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tGeomToken_

◆ ~SiStripNoiseNormalizedWithApvGainBuilder()

SiStripNoiseNormalizedWithApvGainBuilder::~SiStripNoiseNormalizedWithApvGainBuilder ( )
inlineoverride

Definition at line 35 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

35 {};

Member Function Documentation

◆ analyze()

void SiStripNoiseNormalizedWithApvGainBuilder::analyze ( const edm::Event evt,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 24 of file SiStripNoiseNormalizedWithApvGainBuilder.cc.

References cond::service::PoolDBOutputService::appendOneIOV(), cond::service::PoolDBOutputService::beginOfTime(), submitPVResolutionJobs::count, cond::service::PoolDBOutputService::createOneIOV(), cond::service::PoolDBOutputService::currentTime(), electronsPerADC_, PedestalClient_cfi::gain, GeomDet::geographicalId(), edm::EventSetup::getData(), SiStripFakeAPVParameters::getIndex(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), inputApvGainToken_, pileupCalc::inputRange, edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), dqmiolumiharvest::j, minimumPosValue_, hgchebackDigitizer_cfi::noise, StripTopology::nstrips(), getGTfromDQMFile::obj, printDebug_, printLog(), pset_, StripGeomDetUnit::specificTopology(), StripTopology::stripLength(), stripLengthMode_, tGeomToken_, and tTopoToken_.

24  {
25  const auto& tTopo = iSetup.getData(tTopoToken_);
26  const auto& tGeom = iSetup.getData(tGeomToken_);
27  // Read the gain from the given tag
28  const auto& inputApvGain = iSetup.getData(inputApvGainToken_);
29  std::vector<uint32_t> inputDetIds;
30  inputApvGain.getDetIds(inputDetIds);
31 
32  // Prepare the new object
34 
35  stripLengthMode_ = pset_.getParameter<bool>("StripLengthMode");
36 
37  //parameters for random noise generation. not used if Strip length mode is chosen
38  SiStripFakeAPVParameters meanNoise{pset_, "MeanNoise"};
39  SiStripFakeAPVParameters sigmaNoise{pset_, "SigmaNoise"};
40  minimumPosValue_ = pset_.getParameter<double>("MinPositiveNoise");
41 
42  //parameters for strip length proportional noise generation. not used if random mode is chosen
43  SiStripFakeAPVParameters noiseStripLengthLinearSlope{pset_, "NoiseStripLengthSlope"};
44  SiStripFakeAPVParameters noiseStripLengthLinearQuote{pset_, "NoiseStripLengthQuote"};
45  electronsPerADC_ = pset_.getParameter<double>("electronPerAdc");
46 
47  printDebug_ = pset_.getUntrackedParameter<uint32_t>("printDebug", 5);
48 
49  unsigned int count = 0;
50  for (const auto det : tGeom.detUnits()) {
51  const StripGeomDetUnit* stripDet = dynamic_cast<const StripGeomDetUnit*>(det);
52  if (stripDet != nullptr) {
53  const DetId detId = stripDet->geographicalId();
54  // Find if this DetId is in the input tag and if so how many are the Apvs for which it contains information
55  SiStripApvGain::Range inputRange(inputApvGain.getRange(detId));
56 
57  //Generate Noises for det detid
58  SiStripNoises::InputVector theSiStripVector;
59  float noise = 0.;
61  unsigned short nApvs = stripDet->specificTopology().nstrips() / 128;
62 
63  if (stripLengthMode_) {
64  // Use strip length
65  double linearSlope = noiseStripLengthLinearSlope.get(sl);
66  double linearQuote = noiseStripLengthLinearQuote.get(sl);
67  double stripLength = stripDet->specificTopology().stripLength();
68  for (unsigned short j = 0; j < nApvs; ++j) {
69  double gain = inputApvGain.getApvGain(j, inputRange);
70 
71  for (unsigned short stripId = 0; stripId < 128; ++stripId) {
72  noise = ((linearSlope * stripLength + linearQuote) / electronsPerADC_) * gain;
73  if (count < printDebug_)
74  printLog(detId, stripId + 128 * j, noise);
75  obj.setData(noise, theSiStripVector);
76  }
77  }
78  } else {
79  // Use random generator
80  double meanN = meanNoise.get(sl);
81  double sigmaN = sigmaNoise.get(sl);
82  for (unsigned short j = 0; j < nApvs; ++j) {
83  double gain = inputApvGain.getApvGain(j, inputRange);
84 
85  for (unsigned short stripId = 0; stripId < 128; ++stripId) {
86  noise = (CLHEP::RandGauss::shoot(meanN, sigmaN)) * gain;
87  if (noise <= minimumPosValue_)
89  if (count < printDebug_)
90  printLog(detId, stripId + 128 * j, noise);
91  obj.setData(noise, theSiStripVector);
92  }
93  }
94  }
95  ++count;
96 
97  if (!obj.put(detId, theSiStripVector)) {
98  edm::LogError("SiStripNoisesFakeESSource::produce ") << " detid already exists" << std::endl;
99  }
100  }
101  }
102 
103  //End now write data in DB
105 
106  if (mydbservice.isAvailable()) {
107  if (mydbservice->isNewTagRequest("SiStripNoisesRcd")) {
108  mydbservice->createOneIOV<SiStripNoises>(obj, mydbservice->beginOfTime(), "SiStripNoisesRcd");
109  } else {
110  mydbservice->appendOneIOV<SiStripNoises>(obj, mydbservice->currentTime(), "SiStripNoisesRcd");
111  }
112  } else {
113  edm::LogError("SiStripNoiseNormalizedWithApvGainBuilder") << "Service is unavailable" << std::endl;
114  }
115 }
edm::ESGetToken< SiStripApvGain, SiStripApvGainRcd > inputApvGainToken_
virtual int nstrips() const =0
void printLog(const uint32_t detId, const unsigned short strip, const double &noise) const
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
std::vector< uint16_t > InputVector
Definition: SiStripNoises.h:50
static index getIndex(const TrackerTopology *tTopo, DetId id)
Log< level::Error, false > LogError
void createOneIOV(const T &payload, cond::Time_t firstSinceTime, const std::string &recordName)
T getUntrackedParameter(std::string const &, T const &) const
void appendOneIOV(const T &payload, cond::Time_t sinceTime, const std::string &recordName)
virtual float stripLength() const =0
bool isNewTagRequest(const std::string &recordName)
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
std::pair< ContainerIterator, ContainerIterator > Range
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
Definition: DetId.h:17
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tGeomToken_
bool isAvailable() const
Definition: Service.h:40

◆ fillParameters()

void SiStripNoiseNormalizedWithApvGainBuilder::fillParameters ( std::map< int, std::vector< double > > &  mapToFill,
const std::string &  parameterName 
) const
private

Fills the parameters read from cfg and matching the name in the given map.

◆ fillSubDetParameter()

void SiStripNoiseNormalizedWithApvGainBuilder::fillSubDetParameter ( std::map< int, std::vector< double > > &  mapToFill,
const std::vector< double > &  v,
const int  subDet,
const unsigned short  layers 
) const
private

Fills the map with the paramters for the given subdetector.
Each vector "v" holds the parameters for the layers/rings, if the vector has only one parameter all the layers/rings get that parameter.
The only other possibility is that the number of parameters equals the number of layers, otherwise an exception of type "Configuration" will be thrown.

◆ printLog()

void SiStripNoiseNormalizedWithApvGainBuilder::printLog ( const uint32_t  detId,
const unsigned short  strip,
const double &  noise 
) const
inlineprivate

Definition at line 54 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

References hgchebackDigitizer_cfi::noise, and digitizers_cfi::strip.

Referenced by analyze().

54  {
55  edm::LogInfo("SiStripNoisesDummyCalculator")
56  << "detid: " << detId << " strip: " << strip << " noise: " << noise << " \t" << std::endl;
57  }
Log< level::Info, false > LogInfo

Member Data Documentation

◆ electronsPerADC_

double SiStripNoiseNormalizedWithApvGainBuilder::electronsPerADC_
private

Definition at line 63 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze().

◆ fp_

edm::FileInPath SiStripNoiseNormalizedWithApvGainBuilder::fp_
private

Definition at line 59 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

◆ inputApvGainToken_

edm::ESGetToken<SiStripApvGain, SiStripApvGainRcd> SiStripNoiseNormalizedWithApvGainBuilder::inputApvGainToken_
private

◆ minimumPosValue_

double SiStripNoiseNormalizedWithApvGainBuilder::minimumPosValue_
private

Definition at line 64 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze().

◆ printdebug_

bool SiStripNoiseNormalizedWithApvGainBuilder::printdebug_
private

Definition at line 60 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

◆ printDebug_

uint32_t SiStripNoiseNormalizedWithApvGainBuilder::printDebug_
private

Definition at line 66 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze().

◆ pset_

edm::ParameterSet SiStripNoiseNormalizedWithApvGainBuilder::pset_
private

Definition at line 61 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze().

◆ stripLengthMode_

bool SiStripNoiseNormalizedWithApvGainBuilder::stripLengthMode_
private

Definition at line 65 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze().

◆ tGeomToken_

edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> SiStripNoiseNormalizedWithApvGainBuilder::tGeomToken_
private

◆ tTopoToken_

edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> SiStripNoiseNormalizedWithApvGainBuilder::tTopoToken_
private