Skip to content

Commit

Permalink
Merge pull request #15835 from lgray/topic_remove_RandPoisQ
Browse files Browse the repository at this point in the history
ECAL Digitizer Optimizations
  • Loading branch information
cmsbuild committed Sep 15, 2016
2 parents f9e6e52 + 6a7907d commit 482bb46
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
8 changes: 6 additions & 2 deletions SimCalorimetry/EcalSimAlgos/interface/EcalHitResponse.h
Expand Up @@ -9,7 +9,8 @@
#include "CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbService.h"
#include "DataFormats/Provenance/interface/Timestamp.h"

#include<vector>
#include <unordered_map>
#include <vector>

typedef unsigned long long TimeValue_t;

Expand All @@ -33,6 +34,8 @@ class EcalHitResponse

typedef std::vector< unsigned int > VecInd ;

typedef std::unordered_map<uint32_t,double> CalibCache;

enum { BUNCHSPACE = 25 } ;

EcalHitResponse( const CaloVSimParameterMap* parameterMap ,
Expand Down Expand Up @@ -95,7 +98,7 @@ class EcalHitResponse

EcalSamples* findSignal( const DetId& detId ) ;

double analogSignalAmplitude( const DetId& id, float energy, CLHEP::HepRandomEngine* ) const;
double analogSignalAmplitude( const DetId& id, double energy, CLHEP::HepRandomEngine* );

double timeOfFlight( const DetId& detId ) const ;

Expand Down Expand Up @@ -135,6 +138,7 @@ class EcalHitResponse

edm::TimeValue_t m_iTime;
bool m_useLCcorrection;
CalibCache m_laserCalibCache;

VecInd m_index ;
};
Expand Down
22 changes: 15 additions & 7 deletions SimCalorimetry/EcalSimAlgos/src/EcalHitResponse.cc
Expand Up @@ -109,6 +109,8 @@ void
EcalHitResponse::setEventTime(const edm::TimeValue_t& iTime)
{
m_iTime = iTime;
//clear the laser cache for each event time
CalibCache().swap(m_laserCalibCache);
}

void
Expand Down Expand Up @@ -193,6 +195,7 @@ EcalHitResponse::run( MixCollection<PCaloHit>& hits, CLHEP::HepRandomEngine* eng
( 0 == m_hitFilter ||
m_hitFilter->accepts( hit ) ) ) putAnalogSignal( hit, engine ) ;
}

}

void
Expand Down Expand Up @@ -247,24 +250,29 @@ EcalHitResponse::findSignal( const DetId& detId )
}

double
EcalHitResponse::analogSignalAmplitude( const DetId& detId, float energy, CLHEP::HepRandomEngine* engine ) const
EcalHitResponse::analogSignalAmplitude( const DetId& detId, double energy, CLHEP::HepRandomEngine* engine )
{
const CaloSimParameters& parameters ( *params( detId ) ) ;

// OK, the "energy" in the hit could be a real energy, deposited energy,
// or pe count. This factor converts to photoelectrons

float lasercalib = 1.;
double lasercalib = 1.;
if(m_useLCcorrection == true && detId.subdetId() != 3) {
lasercalib = findLaserConstant(detId);
auto cache = m_laserCalibCache.find(detId);
if( cache != m_laserCalibCache.end() ) {
lasercalib = cache->second;
} else {
lasercalib = 1.0/findLaserConstant(detId);
m_laserCalibCache.emplace(detId,lasercalib);
}
}

double npe ( energy/lasercalib*parameters.simHitToPhotoelectrons( detId ) ) ;
double npe ( energy*lasercalib*parameters.simHitToPhotoelectrons( detId ) ) ;

// do we need to doPoisson statistics for the photoelectrons?
if( parameters.doPhotostatistics() ) {
CLHEP::RandPoissonQ randPoissonQ(*engine, npe);
npe = randPoissonQ.fire();
npe = CLHEP::RandPoissonQ::shoot(engine, npe);
}
if( 0 != m_PECorrection ) npe = m_PECorrection->correctPE( detId, npe, engine ) ;

Expand Down

0 comments on commit 482bb46

Please sign in to comment.