Skip to content

Commit

Permalink
Merge pull request #4050 from bsunanda/Phase2-hcx1
Browse files Browse the repository at this point in the history
Phase2 hcx1
  • Loading branch information
cmsbuild committed Jun 3, 2014
2 parents 0715781 + 200e1dd commit 5440902
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 195 deletions.
14 changes: 9 additions & 5 deletions Geometry/HcalCommonData/interface/HcalDDDRecConstants.h
Expand Up @@ -27,7 +27,6 @@ class HcalDDDRecConstants {

public:

HcalDDDRecConstants();
HcalDDDRecConstants(const DDCompactView& cpv,
const HcalDDDSimConstants& hcons);
~HcalDDDRecConstants();
Expand All @@ -45,6 +44,12 @@ class HcalDDDRecConstants {
double df=0) : ieta(eta), nPhi(nf),depthStart(0), etaMin(et1),
etaMax(et2), phi0(fi0), dphi(df) {}
};
struct HcalActiveLength {
int ieta, depth;
double eta, thick;
HcalActiveLength(int ie=0, int d=0, double et=0,
double t=0) : ieta(ie), depth(d), eta(et), thick(t) {}
};

std::vector<std::pair<double,double> > getConstHBHE(const int type) const {
if (type == 0) return gconsHB;
Expand All @@ -68,16 +73,15 @@ class HcalDDDRecConstants {
std::vector<double> getPhiOffs() const {return phioff;}
std::vector<double> getPhiTable() const {return phibin;}
std::vector<double> getPhiTableHF() const {return phibinHF;}
std::vector<HcalActiveLength> getThickActive(const int type) const;
std::string getTopoMode() const {return modeTopo;}
std::vector<HcalCellType> HcalCellTypes(HcalSubdetector) const;
void initialize(const DDCompactView& cpv,
const HcalDDDSimConstants& hcons);
unsigned int numberOfCells(HcalSubdetector) const;
unsigned int nCells(HcalSubdetector) const;
unsigned int nCells() const;

private:
void checkInitialized() const;
void initialize(const DDCompactView& cpv);
void loadSpecPars(const DDFilteredView& fv);
void loadSimConst();
std::vector<double> getDDDArray(const char *, const DDsvalues_type &,
Expand All @@ -87,7 +91,7 @@ class HcalDDDRecConstants {

bool tobeInitialized;
static const int nEtaMax=100;
const HcalDDDSimConstants *hcons;
const HcalDDDSimConstants & hcons;
std::string modeTopo; // Mode for topology
std::vector<double> phioff; // Phi offset for barrel, endcap, forward
std::vector<int> etaGroup; // Eta Grouping
Expand Down
5 changes: 1 addition & 4 deletions Geometry/HcalCommonData/interface/HcalDDDSimConstants.h
Expand Up @@ -26,7 +26,6 @@ class HcalDDDSimConstants {

public:

HcalDDDSimConstants();
HcalDDDSimConstants( const DDCompactView& cpv );
~HcalDDDSimConstants();

Expand Down Expand Up @@ -54,7 +53,6 @@ class HcalDDDSimConstants {
std::vector<HcalCellType> HcalCellTypes() const;
std::vector<HcalCellType> HcalCellTypes(HcalSubdetector, int ieta=-1,
int depth=-1) const;
void initialize(const DDCompactView& cpv);
int getMaxDepth(const int type) const {return maxDepth[type];}
unsigned int numberOfCells(HcalSubdetector) const;
int phiNumber(int phi, int unit) const;
Expand All @@ -63,7 +61,7 @@ class HcalDDDSimConstants {
int unitPhi(double dphi) const;

private:
void checkInitialized() const;
void initialize(const DDCompactView& cpv);
void loadSpecPars(const DDFilteredView& fv);
void loadGeometry(const DDFilteredView& fv);
std::vector<double> getDDDArray(const std::string &,
Expand All @@ -77,7 +75,6 @@ class HcalDDDSimConstants {
void printTileHB(int eta, int depth) const;
void printTileHE(int eta, int depth) const;

bool tobeInitialized;
static const int nEtaMax=100;
static const int nDepthMax=9;
int maxDepth[4]; // Maximum depths in HB/HE/HF/HO
Expand Down
161 changes: 87 additions & 74 deletions Geometry/HcalCommonData/src/HcalDDDRecConstants.cc
Expand Up @@ -14,19 +14,13 @@

//#define DebugLog

HcalDDDRecConstants::HcalDDDRecConstants() : tobeInitialized(true), hcons(0) {

#ifdef DebugLog
std::cout << "HcalDDDRecConstants::HcalDDDRecConstants() constructor" << std::endl;
#endif
}

HcalDDDRecConstants::HcalDDDRecConstants(const DDCompactView& cpv, const HcalDDDSimConstants& hconst) : tobeInitialized(true), hcons(0) {
HcalDDDRecConstants::HcalDDDRecConstants(const DDCompactView& cpv, const HcalDDDSimConstants& hconst) : hcons(hconst) {

#ifdef DebugLog
std::cout << "HcalDDDRecConstants::HcalDDDRecConstants (const DDCompactView& cpv, const HcalDDDSimConstants& hconst) constructor" << std::endl;
#endif
initialize(cpv, hconst);
initialize(cpv);
}

HcalDDDRecConstants::~HcalDDDRecConstants() {
Expand All @@ -36,7 +30,6 @@ HcalDDDRecConstants::~HcalDDDRecConstants() {
std::vector<HcalDDDRecConstants::HcalEtaBin>
HcalDDDRecConstants::getEtaBins(const int itype) const {

checkInitialized();
std::vector<HcalDDDRecConstants::HcalEtaBin> bins;
unsigned int type = (itype == 0) ? 0 : 1;
unsigned int lymax = (type == 0) ? 17 : 19;
Expand Down Expand Up @@ -96,11 +89,10 @@ HcalDDDRecConstants::getEtaBins(const int itype) const {
return bins;
}

HcalDDDRecConstants::HcalID HcalDDDRecConstants::getHCID(int subdet,int ieta,
int iphi, int lay,
int idepth) const {
HcalDDDRecConstants::HcalID
HcalDDDRecConstants::getHCID(int subdet,int ieta, int iphi, int lay,
int idepth) const {

checkInitialized();
int eta(ieta), phi(iphi), depth(idepth);
if ((subdet == static_cast<int>(HcalOuter)) ||
((subdet == static_cast<int>(HcalBarrel)) && (lay > 17))) {
Expand All @@ -119,8 +111,8 @@ HcalDDDRecConstants::HcalID HcalDDDRecConstants::getHCID(int subdet,int ieta,
phi0 = (phi0-1)/phiGroup[eta-1];
}
++phi0;
unit = hcons->unitPhi(phibin[eta-1]);
phi = hcons->phiNumber(phi0,unit);
unit = hcons.unitPhi(phibin[eta-1]);
phi = hcons.phiNumber(phi0,unit);
depth = layerGroup[eta-1][lay-1];
if (eta == iEtaMin[1]) {
if (subdet == static_cast<int>(HcalBarrel)) {
Expand All @@ -144,9 +136,44 @@ HcalDDDRecConstants::HcalID HcalDDDRecConstants::getHCID(int subdet,int ieta,
return HcalDDDRecConstants::HcalID(subdet,eta,phi,depth);
}

std::vector<HcalCellType> HcalDDDRecConstants::HcalCellTypes(HcalSubdetector subdet) const {
std::vector<HcalDDDRecConstants::HcalActiveLength>
HcalDDDRecConstants::getThickActive(const int type) const {

std::vector<HcalDDDRecConstants::HcalActiveLength> actives;
std::vector<HcalDDDRecConstants::HcalEtaBin> bins = getEtaBins(type);
#ifdef DebugLog
unsigned int kount(0);
#endif
for (unsigned int k=0; k<bins.size(); ++k) {
int ieta = bins[k].ieta;
double eta = 0.5*(bins[k].etaMin+bins[k].etaMax);
double theta = 2*atan(exp(-eta));
double scale = 1.0/((type == 0) ? sin(theta) : cos(theta));
int depth = bins[k].depthStart;
for (unsigned int i = 0; i < bins[k].layer.size(); ++i) {
double thick(0);
for (int j = bins[k].layer[i].first; j <= bins[k].layer[i].second; ++j) {
if (type == 0 || j > 1)
thick += ((type == 0) ? gconsHB[j-1].second : gconsHE[j-1].second);
}
thick *= (2.*scale);
HcalDDDRecConstants::HcalActiveLength active(ieta,depth,eta,thick);
actives.push_back(active);
++depth;
#ifdef DebugLog
kount++;
std::cout << "getThickActive: [" << kount << "] eta:" << active.ieta
<< ":" << active.eta << " depth " << active.depth << " thick "
<< active.thick << std::endl;
#endif
}
}
return actives;
}

std::vector<HcalCellType>
HcalDDDRecConstants::HcalCellTypes(HcalSubdetector subdet) const {

checkInitialized();
if (subdet == HcalBarrel || subdet == HcalEndcap) {
std::vector<HcalCellType> cells;
int isub = (subdet == HcalBarrel) ? 0 : 1;
Expand All @@ -165,7 +192,7 @@ std::vector<HcalCellType> HcalDDDRecConstants::HcalCellTypes(HcalSubdetector sub
int ieta = etabins[bin].ieta;
for (int keta=etaSimValu[ieta-1].first; keta<=etaSimValu[ieta-1].second;
++keta) {
std::vector<HcalCellType> cells = hcons->HcalCellTypes(subdet,keta,-1);
std::vector<HcalCellType> cells = hcons.HcalCellTypes(subdet,keta,-1);
for (unsigned int ic=0; ic<cells.size(); ++ic) {
for (unsigned int il=0; il<etabins[bin].layer.size(); ++il) {
if (cells[ic].depthSegment() >= etabins[bin].layer[il].first &&
Expand All @@ -183,7 +210,7 @@ std::vector<HcalCellType> HcalDDDRecConstants::HcalCellTypes(HcalSubdetector sub
}
}
}
int unit = hcons->unitPhi(etabins[bin].dphi);
int unit = hcons.unitPhi(etabins[bin].dphi);
for (unsigned int il=0; il<etabins[bin].layer.size(); ++il) {
int depth = etabins[bin].depthStart + (int)(il);
temp[il].setEta(ieta,etabins[bin].etaMin,etabins[bin].etaMax);
Expand All @@ -200,46 +227,12 @@ std::vector<HcalCellType> HcalDDDRecConstants::HcalCellTypes(HcalSubdetector sub
#endif
return cells;
} else {
return hcons->HcalCellTypes(subdet,-1,-1);
}
}

void HcalDDDRecConstants::initialize(const DDCompactView& cpv,
const HcalDDDSimConstants& hconst) {
if (tobeInitialized) {
tobeInitialized = false;
hcons = &(hconst);
std::string attribute = "OnlyForHcalRecNumbering";
std::string value = "any";
DDValue val(attribute, value, 0.0);

DDSpecificsFilter filter;
filter.setCriteria(val, DDSpecificsFilter::not_equals,
DDSpecificsFilter::AND, true, // compare strings
true // use merged-specifics or simple-specifics
);
DDFilteredView fv(cpv);
fv.addFilter(filter);
bool ok = fv.firstChild();

if (ok) {
//Load the SpecPars
loadSpecPars(fv);

//Load the Sim Constants
loadSimConst();
} else {
edm::LogError("HCalGeom") << "HcalDDDRecConstants: cannot get filtered "
<< " view for " << attribute << " not matching "
<< value;
throw cms::Exception("DDException") << "HcalDDDRecConstants: cannot match " << attribute << " to " << value;
}
return hcons.HcalCellTypes(subdet,-1,-1);
}
}

unsigned int HcalDDDRecConstants::numberOfCells(HcalSubdetector subdet) const {

checkInitialized();
if (subdet == HcalBarrel || subdet == HcalEndcap) {
unsigned int num = 0;
std::vector<HcalCellType> cellTypes = HcalCellTypes(subdet);
Expand All @@ -256,14 +249,13 @@ unsigned int HcalDDDRecConstants::numberOfCells(HcalSubdetector subdet) const {
#endif
return num;
} else {
return hcons->numberOfCells(subdet);
return hcons.numberOfCells(subdet);
}

}

unsigned int HcalDDDRecConstants::nCells(HcalSubdetector subdet) const {

checkInitialized();
if (subdet == HcalBarrel || subdet == HcalEndcap) {
int isub = (subdet == HcalBarrel) ? 0 : 1;
std::vector<HcalDDDRecConstants::HcalEtaBin> etabins = getEtaBins(isub);
Expand All @@ -282,16 +274,37 @@ unsigned int HcalDDDRecConstants::nCells(HcalSubdetector subdet) const {
}

unsigned int HcalDDDRecConstants::nCells() const {
checkInitialized();
return (nCells(HcalBarrel)+nCells(HcalEndcap)+nCells(HcalOuter)+nCells(HcalForward));
}

void HcalDDDRecConstants::checkInitialized() const {
if (tobeInitialized) {
edm::LogError("HcalGeom") << "HcalDDDRecConstants : to be initialized correctly";
throw cms::Exception("DDException") << "HcalDDDRecConstants: to be initialized";
void HcalDDDRecConstants::initialize(const DDCompactView& cpv) {

std::string attribute = "OnlyForHcalRecNumbering";
std::string value = "any";
DDValue val(attribute, value, 0.0);

DDSpecificsFilter filter;
filter.setCriteria(val, DDSpecificsFilter::not_equals,
DDSpecificsFilter::AND, true, // compare strings
true // use merged-specifics or simple-specifics
);
DDFilteredView fv(cpv);
fv.addFilter(filter);
bool ok = fv.firstChild();

if (ok) {
//Load the SpecPars
loadSpecPars(fv);

//Load the Sim Constants
loadSimConst();
} else {
edm::LogError("HCalGeom") << "HcalDDDRecConstants: cannot get filtered "
<< " view for " << attribute << " not matching "
<< value;
throw cms::Exception("DDException") << "HcalDDDRecConstants: cannot match " << attribute << " to " << value;
}
}
}

void HcalDDDRecConstants::loadSpecPars(const DDFilteredView& fv) {

Expand Down Expand Up @@ -344,7 +357,7 @@ void HcalDDDRecConstants::loadSpecPars(const DDFilteredView& fv) {
void HcalDDDRecConstants::loadSimConst() {

for (int i=0; i<4; ++i) {
std::pair<int,int> ieta = hcons->getiEtaRange(i);
std::pair<int,int> ieta = hcons.getiEtaRange(i);
iEtaMin[i] = ieta.first;
iEtaMax[i] = ieta.second;
maxDepth[i]= 0;
Expand All @@ -353,7 +366,7 @@ void HcalDDDRecConstants::loadSimConst() {
maxDepth[3] = 4;

// First eta table
std::vector<double> etas = hcons->getEtaTable();
std::vector<double> etas = hcons.getEtaTable();
etaTable.clear(); ietaMap.clear(); etaSimValu.clear();
int ieta(0), ietaHB(0), ietaHE(0);
etaTable.push_back(etas[ieta]);
Expand All @@ -378,21 +391,21 @@ void HcalDDDRecConstants::loadSimConst() {
}
iEtaMin[1] = ietaHE;
iEtaMax[0] = ietaHB;
etaTableHF = hcons->getEtaTableHF();
etaTableHF = hcons.getEtaTableHF();

// Then Phi bins
ieta = 0;
phibin.clear(); phiUnitS.clear();
for (int i=0; i<nEta; ++i) {
double dphi = phiGroup[i]*hcons->getPhiBin(ieta);
double dphi = phiGroup[i]*hcons.getPhiBin(ieta);
phibin.push_back(dphi);
ieta += etaGroup[i];
}
for (unsigned int i=1; i<etas.size(); ++i) {
int unit = hcons->unitPhi(hcons->getPhiBin(i-1));
int unit = hcons.unitPhi(hcons.getPhiBin(i-1));
phiUnitS.push_back(unit);
}
phibinHF = hcons->getPhiTableHF();
phibinHF = hcons.getPhiTableHF();
#ifdef DebugLog
std::cout << "Modified eta/deltaphi table for " << nEta << " bins" << std::endl;
for (int i=0; i<nEta; ++i)
Expand All @@ -414,8 +427,8 @@ void HcalDDDRecConstants::loadSimConst() {
#endif

//Phi offsets for barrel and endcap & special constants
phioff = hcons->getPhiOffs();
nOff = hcons->getNOff();
phioff = hcons.getPhiOffs();
nOff = hcons.getNOff();

//Now the depths
for (int i=0; i<nEta; ++i) {
Expand Down Expand Up @@ -443,10 +456,10 @@ void HcalDDDRecConstants::loadSimConst() {
#endif

//Now the geometry constants
std::pair<int,int> nmodz = hcons->getModHalfHBHE(0);
std::pair<int,int> nmodz = hcons.getModHalfHBHE(0);
nModule[0] = nmodz.first;
nHalves[0] = nmodz.second;
gconsHB = hcons->getConstHBHE(0);
gconsHB = hcons.getConstHBHE(0);
for (unsigned int i=0; i<gconsHB.size(); ++i) {
gconsHB[i].first /= CLHEP::cm;
gconsHB[i].second /= CLHEP::cm;
Expand All @@ -458,10 +471,10 @@ void HcalDDDRecConstants::loadSimConst() {
std::cout << "rHB[" << i << "] = " << gconsHB[i].first << " +- "
<< gconsHB[i].second << std::endl;
#endif
nmodz = hcons->getModHalfHBHE(1);
nmodz = hcons.getModHalfHBHE(1);
nModule[1] = nmodz.first;
nHalves[1] = nmodz.second;
gconsHE= hcons->getConstHBHE(1);
gconsHE= hcons.getConstHBHE(1);
for (unsigned int i=0; i<gconsHE.size(); ++i) {
gconsHE[i].first /= CLHEP::cm;
gconsHE[i].second /= CLHEP::cm;
Expand Down

0 comments on commit 5440902

Please sign in to comment.