CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
CastorAmplifier Class Reference

#include <CastorAmplifier.h>

Public Member Functions

virtual void amplify (CaloSamples &linearFrame, CLHEP::HepRandomEngine *) const
 
 CastorAmplifier (const CastorSimParameterMap *parameters, bool addNoise)
 
void setDbService (const CastorDbService *service)
 the Producer will probably update this every event More...
 
void setStartingCapId (int capId)
 
virtual ~CastorAmplifier ()
 

Private Attributes

bool addNoise_
 
const CastorDbServicetheDbService
 
const CastorSimParameterMaptheParameterMap
 
unsigned theStartingCapId
 

Detailed Description

Definition at line 13 of file CastorAmplifier.h.

Constructor & Destructor Documentation

CastorAmplifier::CastorAmplifier ( const CastorSimParameterMap parameters,
bool  addNoise 
)

Definition at line 17 of file CastorAmplifier.cc.

18  : theDbService(nullptr), theParameterMap(parameters), theStartingCapId(0), addNoise_(addNoise) {}
unsigned theStartingCapId
const CastorSimParameterMap * theParameterMap
const CastorDbService * theDbService
const bool addNoise
virtual CastorAmplifier::~CastorAmplifier ( )
inlinevirtual

Definition at line 16 of file CastorAmplifier.h.

16 {}

Member Function Documentation

void CastorAmplifier::amplify ( CaloSamples linearFrame,
CLHEP::HepRandomEngine *  engine 
) const
virtual

Definition at line 20 of file CastorAmplifier.cc.

References addNoise_, cms::cuda::assert(), CastorSimParameterMap::castorParameters(), CastorSimParameters::getNominalfCperPE(), CastorDbService::getPedestal(), CastorDbService::getPedestalWidth(), mps_fire::i, CaloSamples::id(), LogDebug, CastorPedestalWidth::makeNoise(), gpuVertexFinder::noise, EcalCondDBWriter_cfi::pedestal, CastorSimParameters::photoelectronsToAnalog(), CaloSamples::size(), theDbService, theParameterMap, and theStartingCapId.

Referenced by CastorElectronicsSim::convert().

20  {
22  assert(theDbService != nullptr);
23  HcalGenericDetId hcalGenDetId(frame.id());
24  const CastorPedestal *peds = theDbService->getPedestal(hcalGenDetId);
25  const CastorPedestalWidth *pwidths = theDbService->getPedestalWidth(hcalGenDetId);
26  if (!peds || !pwidths) {
27  edm::LogError("CastorAmplifier") << "Could not fetch HCAL/CASTOR conditions for channel " << hcalGenDetId;
28  } else {
29  double gauss[32]; // big enough
30  double noise[32]; // big enough
31  double fCperPE = parameters.photoelectronsToAnalog(frame.id());
32  double nominalfCperPE = parameters.getNominalfCperPE();
33 
34  for (int i = 0; i < frame.size(); i++) {
35  gauss[i] = CLHEP::RandGaussQ::shoot(engine, 0., 1.);
36  }
37  if (addNoise_) {
38  pwidths->makeNoise(frame.size(), gauss, noise);
39  }
40  for (int tbin = 0; tbin < frame.size(); ++tbin) {
41  int capId = (theStartingCapId + tbin) % 4;
42  double pedestal = peds->getValue(capId);
43  if (addNoise_) {
44  pedestal += noise[tbin] * (fCperPE / nominalfCperPE);
45  }
46  frame[tbin] *= fCperPE;
47  frame[tbin] += pedestal;
48  }
49  }
50  LogDebug("CastorAmplifier") << frame;
51 }
unsigned theStartingCapId
double getNominalfCperPE() const
const CastorPedestal * getPedestal(const HcalGenericDetId &fId) const
const CastorSimParameterMap * theParameterMap
const CastorDbService * theDbService
Log< level::Error, false > LogError
assert(be >=bs)
void makeNoise(unsigned fFrames, const double *fGauss, double *fNoise) const
CastorSimParameters castorParameters() const
accessors
__shared__ int noise
double photoelectronsToAnalog(const DetId &detId) const override
const CastorPedestalWidth * getPedestalWidth(const HcalGenericDetId &fId) const
#define LogDebug(id)
void CastorAmplifier::setDbService ( const CastorDbService service)
inline

the Producer will probably update this every event

Definition at line 19 of file CastorAmplifier.h.

References theDbService.

Referenced by CastorDigiProducer::initializeEvent().

19 { theDbService = service; }
const CastorDbService * theDbService
void CastorAmplifier::setStartingCapId ( int  capId)
inline

Definition at line 23 of file CastorAmplifier.h.

References theStartingCapId.

Referenced by CastorElectronicsSim::newEvent().

23 { theStartingCapId = capId; }
unsigned theStartingCapId

Member Data Documentation

bool CastorAmplifier::addNoise_
private

Definition at line 30 of file CastorAmplifier.h.

Referenced by amplify().

const CastorDbService* CastorAmplifier::theDbService
private

Definition at line 26 of file CastorAmplifier.h.

Referenced by amplify(), and setDbService().

const CastorSimParameterMap* CastorAmplifier::theParameterMap
private

Definition at line 27 of file CastorAmplifier.h.

Referenced by amplify().

unsigned CastorAmplifier::theStartingCapId
private

Definition at line 29 of file CastorAmplifier.h.

Referenced by amplify(), and setStartingCapId().