Skip to content

Commit

Permalink
Take care of Kevin's suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunanda committed Jul 10, 2018
1 parent ec638ad commit 512425c
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 97 deletions.
2 changes: 0 additions & 2 deletions Geometry/HGCalCommonData/interface/HGCalDDDConstants.h
Expand Up @@ -131,8 +131,6 @@ class HGCalDDDConstants {
std::pair<int,float> getIndex(int lay, bool reco) const;
bool isValidCell(int layindex, int wafer, int cell) const;
bool waferInLayerTest(int wafer, int lay, bool full) const;
bool waferGlobal2Local(double& xx, double& yy, int& wafer,
int& celltyp) const;

const double k_horizontalShift = 1.0;
const float dPhiMin = 0.02;
Expand Down
39 changes: 7 additions & 32 deletions Geometry/HGCalCommonData/src/HGCalDDDConstants.cc
Expand Up @@ -255,13 +255,12 @@ double HGCalDDDConstants::distFromEdgeHex(double x, double y, double z) const {
for (int k=0; k<sizew; ++k) {
double dx = std::abs(xx-hgpar_->waferPosX_[k]);
double dy = std::abs(yy-hgpar_->waferPosY_[k]);
if (dx <= rmax_ && dy <= hexside_) {
if ((dy <= 0.5*hexside_) || (dx*tan30deg_ <= (hexside_-dy))) {
wafer = k;
xx -= hgpar_->waferPosX_[k];
yy -= hgpar_->waferPosY_[k];
break;
}
if (dx <= rmax_ && dy <= hexside_ &&
((dy <= 0.5*hexside_) || (dx*tan30deg_ <= (hexside_-dy)))) {
wafer = k;
xx -= hgpar_->waferPosX_[k];
yy -= hgpar_->waferPosY_[k];
break;
}
}
if (wafer < sizew) {
Expand Down Expand Up @@ -318,7 +317,7 @@ double HGCalDDDConstants::distFromEdgeTrap(double x, double y, double z) const {
<< rr-zz/std::sinh(hgpar_->etaMinBH_+ieta*cell)
<< ":" << zz/std::sinh(hgpar_->etaMinBH_+(ieta-1)*cell)-rr;
#endif
return ((dist > rr*dphi) ? rr*dphi : dist);
return std::min(rr*dphi,dist);
}

int HGCalDDDConstants::getLayer(double z, bool reco) const {
Expand Down Expand Up @@ -1148,30 +1147,6 @@ bool HGCalDDDConstants::waferInLayerTest(int wafer, int lay, bool full) const {
return in;
}

bool HGCalDDDConstants::waferGlobal2Local(double& xx, double& yy, int& wafer,
int& celltyp) const {
std::cout << xx <<":" << yy << ":" << wafer << ":" << celltyp << ":" << hgpar_ << "\n";
int sizew = (int)(hgpar_->waferPosX_.size());
wafer = sizew;
for (int k=0; k<sizew; ++k) {
double dx = std::abs(xx-hgpar_->waferPosX_[k]);
double dy = std::abs(yy-hgpar_->waferPosY_[k]);
if (dx <= rmax_ && dy <= hexside_) {
if ((dy <= 0.5*hexside_) || (dx*tan30deg_ <= (hexside_-dy))) {
wafer = k;
celltyp = hgpar_->waferTypeT_[k];
xx -= hgpar_->waferPosX_[k];
yy -= hgpar_->waferPosY_[k];
break;
}
}
}
edm::LogVerbatim("HGCalGeom") << "WaferGlobal2Local: Global " << xx << ":"
<< yy << " wafer " << wafer << " Type "
<< celltyp << " flag " << (wafer < sizew);
return (wafer < sizew);
}

#include "FWCore/Utilities/interface/typelookup.h"

TYPELOOKUP_DATA_REG(HGCalDDDConstants);
28 changes: 14 additions & 14 deletions SimG4CMS/Calo/interface/HGCSD.h
Expand Up @@ -24,9 +24,10 @@ class HGCSD : public CaloSD, public Observer<const BeginOfJob *> {

public:

HGCSD(const std::string& , const DDCompactView &, const SensitiveDetectorCatalog &,
HGCSD(const std::string& , const DDCompactView &,
const SensitiveDetectorCatalog &,
edm::ParameterSet const &, const SimTrackManager*);
~HGCSD() override;
~HGCSD() override = default;

uint32_t setDetUnitId(const G4Step* step) override;

Expand All @@ -43,18 +44,17 @@ class HGCSD : public CaloSD, public Observer<const BeginOfJob *> {
int, int, G4ThreeVector &);
bool isItinFidVolume (const G4ThreeVector&) {return true;}

std::string nameX_;

HGCalGeometryMode::GeometryMode geom_mode_;
HGCNumberingScheme* numberingScheme_;
HGCMouseBite* mouseBite_;
double eminHit_;
ForwardSubdetector myFwdSubdet_;
double slopeMin_;
int levelT_;
bool storeAllG4Hits_, rejectMB_, waferRot_;
double mouseBiteCut_;
std::vector<double> angles_;
std::string nameX_;
HGCalGeometryMode::GeometryMode geom_mode_;
std::unique_ptr<HGCNumberingScheme> numberingScheme_;
std::unique_ptr<HGCMouseBite> mouseBite_;
double eminHit_;
ForwardSubdetector myFwdSubdet_;
double slopeMin_;
int levelT_;
bool storeAllG4Hits_, rejectMB_, waferRot_;
double mouseBiteCut_;
std::vector<double> angles_;
};

#endif // HGCSD_h
21 changes: 11 additions & 10 deletions SimG4CMS/Calo/interface/HGCScintSD.h
Expand Up @@ -24,7 +24,7 @@ class HGCScintSD : public CaloSD, public Observer<const BeginOfJob *> {
HGCScintSD(const std::string& , const DDCompactView &,
const SensitiveDetectorCatalog &, edm::ParameterSet const &,
const SimTrackManager*);
~HGCScintSD() override;
~HGCScintSD() override = default;

uint32_t setDetUnitId(const G4Step* step) override;

Expand All @@ -40,15 +40,16 @@ class HGCScintSD : public CaloSD, public Observer<const BeginOfJob *> {
uint32_t setDetUnitId(int, int, int, int, G4ThreeVector &);
bool isItinFidVolume (const G4ThreeVector&);

const HGCalDDDConstants* hgcons_;
HGCalNumberingScheme* numberingScheme_;
DetId::Detector mydet_;
std::string nameX_;
HGCalGeometryMode::GeometryMode geom_mode_;
double eminHit_, slopeMin_, distanceFromEdge_;
int levelT1_, levelT2_;
bool storeAllG4Hits_, fiducialCut_, useBirk_;
double birk1_, birk2_, birk3_, weight_;
const HGCalDDDConstants* hgcons_;
std::unique_ptr<HGCalNumberingScheme> numberingScheme_;
DetId::Detector mydet_;
std::string nameX_;
HGCalGeometryMode::GeometryMode geom_mode_;
double eminHit_, slopeMin_, distanceFromEdge_;
int levelT1_, levelT2_;
bool storeAllG4Hits_, fiducialCut_;
bool useBirk_;
double birk1_, birk2_, birk3_, weight_;
};

#endif // HGCScintSD_h
31 changes: 16 additions & 15 deletions SimG4CMS/Calo/interface/HGCalSD.h
Expand Up @@ -22,9 +22,10 @@ class HGCalSD : public CaloSD, public Observer<const BeginOfJob *> {

public:

HGCalSD(const std::string& , const DDCompactView &, const SensitiveDetectorCatalog &,
HGCalSD(const std::string& , const DDCompactView &,
const SensitiveDetectorCatalog &,
edm::ParameterSet const &, const SimTrackManager*);
~HGCalSD() override;
~HGCalSD() override = default;

uint32_t setDetUnitId(const G4Step* step) override;

Expand All @@ -40,19 +41,19 @@ class HGCalSD : public CaloSD, public Observer<const BeginOfJob *> {
uint32_t setDetUnitId(int, int, int, int, G4ThreeVector &);
bool isItinFidVolume (const G4ThreeVector&);

const HGCalDDDConstants* hgcons_;
HGCalNumberingScheme* numberingScheme_;
HGCMouseBite* mouseBite_;
DetId::Detector mydet_;
std::string nameX_;
HGCalGeometryMode::GeometryMode geom_mode_;
double eminHit_, slopeMin_;
double distanceFromEdge_, mouseBiteCut_, weight_;
int levelT1_, levelT2_;
bool storeAllG4Hits_;
bool fiducialCut_, rejectMB_, waferRot_;
const double tan30deg_;
std::vector<double> angles_;
const HGCalDDDConstants* hgcons_;
std::unique_ptr<HGCalNumberingScheme> numberingScheme_;
std::unique_ptr<HGCMouseBite> mouseBite_;
DetId::Detector mydet_;
std::string nameX_;
HGCalGeometryMode::GeometryMode geom_mode_;
double eminHit_, slopeMin_, distanceFromEdge_;
double mouseBiteCut_, weight_;
int levelT1_, levelT2_;
bool storeAllG4Hits_;
bool fiducialCut_, rejectMB_, waferRot_;
const double tan30deg_;
std::vector<double> angles_;
};

#endif // HGCalSD_h
14 changes: 6 additions & 8 deletions SimG4CMS/Calo/src/HGCSD.cc
Expand Up @@ -39,7 +39,9 @@ HGCSD::HGCSD(const std::string& name, const DDCompactView & cpv,
CaloSD(name, cpv, clg, p, manager,
(float)(p.getParameter<edm::ParameterSet>("HGCSD").getParameter<double>("TimeSliceUnit")),
p.getParameter<edm::ParameterSet>("HGCSD").getParameter<bool>("IgnoreTrackID")),
numberingScheme_(nullptr), mouseBite_(nullptr), slopeMin_(0), levelT_(99) {
slopeMin_(0), levelT_(99) {

numberingScheme_.reset(nullptr); mouseBite_.reset(nullptr);

edm::ParameterSet m_HGC = p.getParameter<edm::ParameterSet>("HGCSD");
eminHit_ = m_HGC.getParameter<double>("EminHit")*CLHEP::MeV;
Expand Down Expand Up @@ -92,11 +94,6 @@ HGCSD::HGCSD(const std::string& name, const DDCompactView & cpv,
<< " axes";
}

HGCSD::~HGCSD() {
delete numberingScheme_;
delete mouseBite_;
}

double HGCSD::getEnergyDeposit(const G4Step* aStep) {

double r = aStep->GetPreStepPoint()->GetPosition().perp();
Expand Down Expand Up @@ -197,8 +194,9 @@ void HGCSD::update(const BeginOfJob * job) {
geom_mode_ = hgcons->geomMode();
slopeMin_ = hgcons->minSlope();
levelT_ = hgcons->levelTop();
numberingScheme_ = new HGCNumberingScheme(*hgcons,nameX_);
if (rejectMB_) mouseBite_ = new HGCMouseBite(*hgcons,angles_,mouseBiteCut_,waferRot_);
numberingScheme_.reset(new HGCNumberingScheme(*hgcons,nameX_));
if (rejectMB_) mouseBite_.reset(new HGCMouseBite(*hgcons,angles_,
mouseBiteCut_,waferRot_));
} else {
edm::LogError("HGCSim") << "HCalSD : Cannot find HGCalDDDConstants for "
<< nameX_;
Expand Down
11 changes: 4 additions & 7 deletions SimG4CMS/Calo/src/HGCScintSD.cc
Expand Up @@ -41,8 +41,9 @@ HGCScintSD::HGCScintSD(const std::string& name, const DDCompactView & cpv,
CaloSD(name, cpv, clg, p, manager,
(float)(p.getParameter<edm::ParameterSet>("HGCSD").getParameter<double>("TimeSliceUnit")),
p.getParameter<edm::ParameterSet>("HGCSD").getParameter<bool>("IgnoreTrackID")),
hgcons_(nullptr), numberingScheme_(nullptr), slopeMin_(0), levelT1_(99),
levelT2_(99) {
hgcons_(nullptr), slopeMin_(0), levelT1_(99), levelT2_(99) {

numberingScheme_.reset(nullptr);

edm::ParameterSet m_HGC = p.getParameter<edm::ParameterSet>("HGCScintSD");
eminHit_ = m_HGC.getParameter<double>("EminHit")*CLHEP::MeV;
Expand Down Expand Up @@ -91,10 +92,6 @@ HGCScintSD::HGCScintSD(const std::string& name, const DDCompactView & cpv,
<< ", C1 = " << birk2_ << ", C2 = " << birk3_;
}

HGCScintSD::~HGCScintSD() {
delete numberingScheme_;
}

double HGCScintSD::getEnergyDeposit(const G4Step* aStep) {

double r = aStep->GetPreStepPoint()->GetPosition().perp();
Expand Down Expand Up @@ -218,7 +215,7 @@ void HGCScintSD::update(const BeginOfJob * job) {
<< " top Level " << levelT1_ << ":" << levelT2_;
#endif

numberingScheme_ = new HGCalNumberingScheme(*hgcons_,mydet_,nameX_);
numberingScheme_.reset(new HGCalNumberingScheme(*hgcons_,mydet_,nameX_));
} else {
throw cms::Exception("Unknown", "HGCScintSD") << "Cannot find HGCalDDDConstants for " << nameX_ << "\n";
}
Expand Down
15 changes: 6 additions & 9 deletions SimG4CMS/Calo/src/HGCalSD.cc
Expand Up @@ -39,10 +39,11 @@ HGCalSD::HGCalSD(const std::string& name, const DDCompactView & cpv,
CaloSD(name, cpv, clg, p, manager,
(float)(p.getParameter<edm::ParameterSet>("HGCSD").getParameter<double>("TimeSliceUnit")),
p.getParameter<edm::ParameterSet>("HGCSD").getParameter<bool>("IgnoreTrackID")),
hgcons_(nullptr), numberingScheme_(nullptr), mouseBite_(nullptr),
slopeMin_(0), levelT1_(99), levelT2_(99),
hgcons_(nullptr), slopeMin_(0), levelT1_(99), levelT2_(99),
tan30deg_(std::tan(30.0*CLHEP::deg)) {

numberingScheme_.reset(nullptr); mouseBite_.reset(nullptr);

edm::ParameterSet m_HGC = p.getParameter<edm::ParameterSet>("HGCSD");
eminHit_ = m_HGC.getParameter<double>("EminHit")*CLHEP::MeV;
fiducialCut_ = m_HGC.getParameter<bool>("FiducialCut");
Expand Down Expand Up @@ -92,11 +93,6 @@ HGCalSD::HGCalSD(const std::string& name, const DDCompactView & cpv,
<< angles_[0] << ", " << angles_[1];
}

HGCalSD::~HGCalSD() {
delete numberingScheme_;
delete mouseBite_;
}

double HGCalSD::getEnergyDeposit(const G4Step* aStep) {

double r = aStep->GetPreStepPoint()->GetPosition().perp();
Expand Down Expand Up @@ -227,9 +223,10 @@ void HGCalSD::update(const BeginOfJob * job) {
<< " wafer " << waferSize << ":" << mouseBite;
#endif

numberingScheme_ = new HGCalNumberingScheme(*hgcons_,mydet_,nameX_);
numberingScheme_.reset(new HGCalNumberingScheme(*hgcons_,mydet_,nameX_));
if (rejectMB_)
mouseBite_ = new HGCMouseBite(*hgcons_,angles_,mouseBiteCut_,waferRot_);
mouseBite_.reset(new HGCMouseBite(*hgcons_,angles_,mouseBiteCut_,
waferRot_));
} else {
throw cms::Exception("Unknown", "HGCalSD") << "Cannot find HGCalDDDConstants for " << nameX_ << "\n";
}
Expand Down

0 comments on commit 512425c

Please sign in to comment.