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
SiStripNoiseNormalizedWithApvGainBuilder Class Reference

#include <SiStripNoiseNormalizedWithApvGainBuilder.h>

Inheritance diagram for SiStripNoiseNormalizedWithApvGainBuilder:
edm::EDAnalyzer 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::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 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::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 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

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 32 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Constructor & Destructor Documentation

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_
T getUntrackedParameter(std::string const &, T const &) const
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tGeomToken_
SiStripNoiseNormalizedWithApvGainBuilder::~SiStripNoiseNormalizedWithApvGainBuilder ( )
inlineoverride

Member Function Documentation

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

Definition at line 24 of file SiStripNoiseNormalizedWithApvGainBuilder.cc.

References cond::service::PoolDBOutputService::appendSinceTime(), cond::service::PoolDBOutputService::beginOfTime(), KineDebug3::count(), cond::service::PoolDBOutputService::createNewIOV(), cond::service::PoolDBOutputService::currentTime(), electronsPerADC_, cond::service::PoolDBOutputService::endOfTime(), 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_, hgcalDigitizer_cfi::noise, StripTopology::nstrips(), getGTfromDQMFile::obj, printDebug_, printLog(), pset_, SiStripNoises::put(), SiStripNoises::setData(), StripGeomDetUnit::specificTopology(), StripTopology::stripLength(), stripLengthMode_, tGeomToken_, and tTopoToken_.

Referenced by ~SiStripNoiseNormalizedWithApvGainBuilder().

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_)
88  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->createNewIOV<SiStripNoises>(
109  obj, mydbservice->beginOfTime(), mydbservice->endOfTime(), "SiStripNoisesRcd");
110  } else {
111  mydbservice->appendSinceTime<SiStripNoises>(obj, mydbservice->currentTime(), "SiStripNoisesRcd");
112  }
113  } else {
114  edm::LogError("SiStripNoiseNormalizedWithApvGainBuilder") << "Service is unavailable" << std::endl;
115  }
116 }
edm::ESGetToken< SiStripApvGain, SiStripApvGainRcd > inputApvGainToken_
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
virtual float stripLength() const =0
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
std::vector< uint16_t > InputVector
Definition: SiStripNoises.h:50
static index getIndex(const TrackerTopology *tTopo, DetId id)
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
bool getData(T &iHolder) const
Definition: EventSetup.h:113
void appendSinceTime(T *payloadObj, cond::Time_t sinceTime, const std::string &recordName, bool withlogging=false)
bool isNewTagRequest(const std::string &recordName)
bool isAvailable() const
Definition: Service.h:40
std::pair< ContainerIterator, ContainerIterator > Range
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
void printLog(const uint32_t detId, const unsigned short strip, const double &noise) const
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
bool put(const uint32_t &detID, const InputVector &input)
Definition: DetId.h:17
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tGeomToken_
virtual int nstrips() const =0
void setData(float noise_, InputVector &vped)
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.

Referenced by ~SiStripNoiseNormalizedWithApvGainBuilder().

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.

Referenced by ~SiStripNoiseNormalizedWithApvGainBuilder().

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

Definition at line 55 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze().

55  {
56  edm::LogInfo("SiStripNoisesDummyCalculator")
57  << "detid: " << detId << " strip: " << strip << " noise: " << noise << " \t" << std::endl;
58  }

Member Data Documentation

double SiStripNoiseNormalizedWithApvGainBuilder::electronsPerADC_
private

Definition at line 64 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze().

edm::FileInPath SiStripNoiseNormalizedWithApvGainBuilder::fp_
private

Definition at line 60 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

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

Definition at line 65 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze().

bool SiStripNoiseNormalizedWithApvGainBuilder::printdebug_
private

Definition at line 61 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

uint32_t SiStripNoiseNormalizedWithApvGainBuilder::printDebug_
private

Definition at line 67 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze().

edm::ParameterSet SiStripNoiseNormalizedWithApvGainBuilder::pset_
private

Definition at line 62 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze().

bool SiStripNoiseNormalizedWithApvGainBuilder::stripLengthMode_
private

Definition at line 66 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze().

edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> SiStripNoiseNormalizedWithApvGainBuilder::tGeomToken_
private
edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> SiStripNoiseNormalizedWithApvGainBuilder::tTopoToken_
private