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 23 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(), fp_, edm::FileInPath::fullPath(), 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().

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

Referenced by analyze().

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().