Skip to content

Commit

Permalink
Move the masks into PCaloHit.h which is used in ECalSD as well as in …
Browse files Browse the repository at this point in the history
…the digitization code
  • Loading branch information
Sunanda committed Jul 28, 2017
1 parent 84dc1fd commit eab6ca8
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
1 change: 0 additions & 1 deletion SimCalorimetry/EcalSimAlgos/BuildFile.xml
Expand Up @@ -3,7 +3,6 @@
<use name="DataFormats/EcalDetId"/>
<use name="SimCalorimetry/CaloSimAlgos"/>
<use name="SimGeneral/NoiseGenerators"/>
<use name="SimG4CMS/Calo"/>
<use name="CondFormats/EcalObjects"/>
<use name="CalibCalorimetry/EcalLaserCorrection"/>
<use name="CalibFormats/CaloObjects"/>
Expand Down
7 changes: 4 additions & 3 deletions SimCalorimetry/EcalSimAlgos/src/EBHitResponse.cc
Expand Up @@ -8,6 +8,7 @@
#include "CLHEP/Random/RandPoissonQ.h"
#include "CLHEP/Random/RandGaussQ.h"
#include "DataFormats/EcalDetId/interface/EBDetId.h"
#include "SimDataFormats/CaloHit/interface/PCaloHit.h"
#include "FWCore/Utilities/interface/isFinite.h"
#include "FWCore/Utilities/interface/Exception.h"

Expand Down Expand Up @@ -124,7 +125,7 @@ EBHitResponse::putAPDSignal( const DetId& detId ,
double
EBHitResponse::apdSignalAmplitude( const PCaloHit& hit, CLHEP::HepRandomEngine* engine ) const
{
int iddepth = (hit.depth() & 0x3);
int iddepth = (hit.depth() & PCaloHit::kEcalDepthIdMask);
assert( 1 == iddepth || 2 == iddepth ) ;

double npe ( hit.energy()*( 2 == iddepth ?
Expand Down Expand Up @@ -228,7 +229,7 @@ void
EBHitResponse::add( const PCaloHit& hit, CLHEP::HepRandomEngine* engine )
{
if (!edm::isNotFinite( hit.time() ) && ( 0 == hitFilter() || hitFilter()->accepts( hit ) ) ) {
int iddepth = (hit.depth() & 0x3);
int iddepth = (hit.depth() & PCaloHit::kEcalDepthIdMask);
if ( 0 == iddepth ) // for now take only nonAPD hits
{
if( !m_apdOnly ) putAnalogSignal( hit, engine ) ;
Expand Down Expand Up @@ -270,7 +271,7 @@ EBHitResponse::run( MixCollection<PCaloHit>& hits, CLHEP::HepRandomEngine* engin
( 0 == hitFilter() ||
hitFilter()->accepts( hit ) ) )
{
int iddepth = (hit.depth() & 0x3);
int iddepth = (hit.depth() & PCaloHit::kEcalDepthIdMask);
if( 0 == iddepth ) // for now take only nonAPD hits
{
if( !m_apdOnly ) putAnalogSignal( hit, engine ) ;
Expand Down
6 changes: 3 additions & 3 deletions SimCalorimetry/EcalSimAlgos/src/EcalTimeMapDigitizer.cc
Expand Up @@ -4,7 +4,7 @@
#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
#include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
#include "Geometry/CaloGeometry/interface/TruncatedPyramid.h"
#include "SimG4CMS/Calo/interface/ECalSD.h"
#include "SimDataFormats/CaloHit/interface/PCaloHit.h"
//#include "FWCore/ServiceRegistry/interface/Service.h"
//#include "FWCore/Utilities/interface/RandomNumberGenerator.h"
//#include "CLHEP/Random/RandPoissonQ.h"
Expand Down Expand Up @@ -93,8 +93,8 @@ EcalTimeMapDigitizer::add(const std::vector<PCaloHit> & hits, int bunchCrossing)
continue;

//Just consider only the hits belonging to the specified time layer
int depth2 = (((*it).depth() >> ECalSD::kEcalDepthOffset) &
ECalSD::kEcalDepthMask);
int depth2 = (((*it).depth() >> PCaloHit::kEcalDepthOffset) &
PCaloHit::kEcalDepthMask);

if (depth2 != m_timeLayerId) continue;

Expand Down
4 changes: 4 additions & 0 deletions SimDataFormats/CaloHit/interface/PCaloHit.h
Expand Up @@ -64,6 +64,10 @@ class PCaloHit {
bool operator==(const PCaloHit &d) const
{ return (myEnergy == d.myEnergy && detId == d.detId); }

static const int kEcalDepthIdMask = 0x3;
static const int kEcalDepthMask = 0x1FFF;
static const int kEcalDepthOffset = 3;
static const int kEcalDepthRefz = 0X4;

protected:
float myEnergy;
Expand Down
3 changes: 0 additions & 3 deletions SimG4CMS/Calo/interface/ECalSD.h
Expand Up @@ -41,9 +41,6 @@ class ECalSD : public CaloSD {
void setNumberingScheme(EcalNumberingScheme*);
virtual int getTrackID(G4Track*);
virtual uint16_t getDepth(G4Step*);
static const int kEcalDepthMask = 0x1FFF;
static const int kEcalDepthOffset = 3;
static const int kEcalDepthRefz = 0X4;

private:
void initMap(G4String, const DDCompactView &);
Expand Down
7 changes: 4 additions & 3 deletions SimG4CMS/Calo/src/ECalSD.cc
Expand Up @@ -19,6 +19,7 @@
#include "Geometry/EcalCommonData/interface/EcalBaseNumber.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "SimDataFormats/CaloHit/interface/PCaloHit.h"

#include "G4LogicalVolumeStore.hh"
#include "G4LogicalVolume.hh"
Expand Down Expand Up @@ -269,12 +270,12 @@ uint16_t ECalSD::getDepth(G4Step * aStep) {
if (storeRL) {
auto ite = xtalLMap.find(lv);
uint16_t depth1 = (ite == xtalLMap.end()) ? 0 : (((ite->second) >= 0) ? 0 :
kEcalDepthRefz);
PCaloHit::kEcalDepthRefz);
uint16_t depth2 = getRadiationLength(aStep);
depth |= (((depth2&kEcalDepthMask) << kEcalDepthOffset) | depth1);
depth |= (((depth2&PCaloHit::kEcalDepthMask) << PCaloHit::kEcalDepthOffset) | depth1);
} else if (storeLayerTimeSim) {
uint16_t depth2 = getLayerIDForTimeSim(aStep);
depth |= ((depth2&kEcalDepthMask) << kEcalDepthOffset);
depth |= ((depth2&PCaloHit::kEcalDepthMask) << PCaloHit::kEcalDepthOffset);
}
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("EcalSim") << "ECalSD::Depth " << std::hex << depth1 << ":"
Expand Down

0 comments on commit eab6ca8

Please sign in to comment.