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::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
 
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)
 
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_
 
double minimumPosValue_
 
bool printdebug_
 
uint32_t printDebug_
 
edm::ParameterSet pset_
 
bool stripLengthMode_
 

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

Constructor & Destructor Documentation

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

Member Function Documentation

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

Definition at line 22 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(), muonCSCDigis_cfi::gain, edm::EventSetup::get(), SiStripApvGain::getApvGain(), SiStripApvGain::getDetIds(), SiStripFakeAPVParameters::getIndex(), edm::ParameterSet::getParameter(), SiStripApvGain::getRange(), edm::ParameterSet::getUntrackedParameter(), estimatePileup::inputRange, edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), minimumPosValue_, GetRecoTauVFromDQM_MC_cff::obj, printDebug_, printLog(), edm::ESHandle< T >::product(), pset_, SiStripNoises::put(), matplotRender::reader, SiStripNoises::setData(), and stripLengthMode_.

Referenced by ~SiStripNoiseNormalizedWithApvGainBuilder().

23 {
24  //Retrieve tracker topology from geometry
26  iSetup.get<IdealGeometryRecord>().get(tTopoHandle);
27  const TrackerTopology* const tTopo = tTopoHandle.product();
28 
29  // Read the gain from the given tag
30  edm::ESHandle<SiStripApvGain> inputApvGain;
31  iSetup.get<SiStripApvGainRcd>().get( inputApvGain );
32  std::vector<uint32_t> inputDetIds;
33  inputApvGain->getDetIds(inputDetIds);
34 
35  // Prepare the new object
37 
38 
39  stripLengthMode_ = pset_.getParameter<bool>("StripLengthMode");
40 
41  //parameters for random noise generation. not used if Strip length mode is chosen
42  SiStripFakeAPVParameters meanNoise{pset_, "MeanNoise"};
43  SiStripFakeAPVParameters sigmaNoise{pset_, "SigmaNoise"};
44  minimumPosValue_ = pset_.getParameter<double>("MinPositiveNoise");
45 
46  //parameters for strip length proportional noise generation. not used if random mode is chosen
47  SiStripFakeAPVParameters noiseStripLengthLinearSlope{pset_, "NoiseStripLengthSlope"};
48  SiStripFakeAPVParameters noiseStripLengthLinearQuote{pset_, "NoiseStripLengthQuote"};
49  electronsPerADC_ = pset_.getParameter<double>("electronPerAdc");
50 
51  printDebug_ = pset_.getUntrackedParameter<uint32_t>("printDebug", 5);
52 
54  unsigned int count = 0;
55  const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >& DetInfos = reader->getAllData();
56  for(std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >::const_iterator it = DetInfos.begin(); it != DetInfos.end(); it++) {
57 
58  // Find if this DetId is in the input tag and if so how many are the Apvs for which it contains information
59  SiStripApvGain::Range inputRange(inputApvGain->getRange(it->first));
60 
61  //Generate Noises for det detid
62  SiStripNoises::InputVector theSiStripVector;
63  float noise = 0.;
64  uint32_t detId = it->first;
66  unsigned short nApvs = it->second.nApvs;
67 
68  if(stripLengthMode_) {
69  // Use strip length
70  double linearSlope = noiseStripLengthLinearSlope.get(sl);
71  double linearQuote = noiseStripLengthLinearQuote.get(sl);
72  double stripLength = it->second.stripLength;
73  for( unsigned short j=0; j<nApvs; ++j ) {
74 
75  double gain = inputApvGain->getApvGain(j, inputRange);
76 
77  for( unsigned short stripId = 0; stripId < 128; ++stripId ) {
78  noise = ( ( linearSlope*stripLength + linearQuote) / electronsPerADC_ ) * gain;
79  if( count<printDebug_ ) printLog(detId, stripId+128*j, noise);
80  obj->setData(noise, theSiStripVector);
81  }
82  }
83  }
84  else {
85  // Use random generator
86  double meanN = meanNoise.get(sl);
87  double sigmaN = sigmaNoise.get(sl);
88  for( unsigned short j=0; j<nApvs; ++j ) {
89 
90  double gain = inputApvGain->getApvGain(j, inputRange);
91 
92  for( unsigned short stripId = 0; stripId < 128; ++stripId ) {
93  noise = ( CLHEP::RandGauss::shoot(meanN, sigmaN) ) * gain;
94  if( noise<=minimumPosValue_ ) noise = minimumPosValue_;
95  if( count<printDebug_ ) printLog(detId, stripId+128*j, noise);
96  obj->setData(noise, theSiStripVector);
97  }
98  }
99  }
100  ++count;
101 
102  if ( ! obj->put(it->first,theSiStripVector) ) {
103  edm::LogError("SiStripNoisesFakeESSource::produce ")<<" detid already exists"<<std::endl;
104  }
105  }
106 
107  //End now write data in DB
109 
110  if( mydbservice.isAvailable() ){
111  if( mydbservice->isNewTagRequest("SiStripNoisesRcd") ){
112  mydbservice->createNewIOV<SiStripNoises>(obj,mydbservice->beginOfTime(),mydbservice->endOfTime(),"SiStripNoisesRcd");
113  }
114  else {
115  mydbservice->appendSinceTime<SiStripNoises>(obj,mydbservice->currentTime(),"SiStripNoisesRcd");
116  }
117  }
118  else {
119  edm::LogError("SiStripNoiseNormalizedWithApvGainBuilder")<<"Service is unavailable"<<std::endl;
120  }
121 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
static float getApvGain(uint16_t apv, const Range &range)
std::vector< uint16_t > InputVector
Definition: SiStripNoises.h:53
static index getIndex(const TrackerTopology *tTopo, DetId id)
void getDetIds(std::vector< uint32_t > &DetIds_) const
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:46
std::pair< ContainerIterator, ContainerIterator > Range
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)
inputRange
Get input source.
T get() const
Definition: EventSetup.h:63
const Range getRange(const uint32_t detID) const
T const * product() const
Definition: ESHandle.h:86
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 50 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze().

51  {
52  edm::LogInfo("SiStripNoisesDummyCalculator") << "detid: " << detId << " strip: " << strip << " noise: " << noise << " \t" << std::endl;
53  }

Member Data Documentation

double SiStripNoiseNormalizedWithApvGainBuilder::electronsPerADC_
private

Definition at line 59 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze().

edm::FileInPath SiStripNoiseNormalizedWithApvGainBuilder::fp_
private

Definition at line 55 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

double SiStripNoiseNormalizedWithApvGainBuilder::minimumPosValue_
private

Definition at line 60 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze().

bool SiStripNoiseNormalizedWithApvGainBuilder::printdebug_
private

Definition at line 56 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

uint32_t SiStripNoiseNormalizedWithApvGainBuilder::printDebug_
private

Definition at line 62 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze().

edm::ParameterSet SiStripNoiseNormalizedWithApvGainBuilder::pset_
private

Definition at line 57 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze().

bool SiStripNoiseNormalizedWithApvGainBuilder::stripLengthMode_
private

Definition at line 61 of file SiStripNoiseNormalizedWithApvGainBuilder.h.

Referenced by analyze().