Skip to content

Commit

Permalink
Takes care of half cell positions
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunanda committed Mar 11, 2016
1 parent 5770125 commit 71187f3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
22 changes: 14 additions & 8 deletions Geometry/HGCalCommonData/src/HGCalGeomParameters.cc
Expand Up @@ -12,6 +12,7 @@
#include "DetectorDescription/Core/interface/DDFilteredView.h"
#include "DetectorDescription/RegressionTest/interface/DDErrorDetection.h"
#include "Geometry/HGCalCommonData/interface/HGCalParameters.h"
#include "DataFormats/Math/interface/Point3D.h"
#include "CLHEP/Units/GlobalPhysicalConstants.h"
#include "CLHEP/Units/GlobalSystemOfUnits.h"
#include <unordered_set>
Expand Down Expand Up @@ -384,17 +385,30 @@ void HGCalGeomParameters::loadGeometryHexagon(const DDFilteredView& _fv,
if (ktr == wafertype.end()) wafertype[wafer] = type;
bool newc(false);
std::map<int,HGCalGeomParameters::cellParameters>::iterator itr;
double cellsize = php.cellSize_[0];
if (type == 1) {
itr = cellsf.find(cell);
newc= (itr == cellsf.end());
} else {
itr = cellsc.find(cell);
newc= (itr == cellsc.end());
cellsize = php.cellSize_[1];
}
if (newc) {
bool half = (name.find("Half") != std::string::npos);
double xx = k_ScaleFromDDD*fv2.translation().X();
double yy = k_ScaleFromDDD*fv2.translation().Y();
if (half) {
math::XYZPointD p1(-2.0*cellsize/9.0,0,0);
math::XYZPointD p2 = fv2.rotation()(p1);
xx += (k_ScaleFromDDD*(p2.X()));
yy += (k_ScaleFromDDD*(p2.Y()));
#ifdef DebugLog
std::cout << "Type " << type << " Cell " << cellx << " local "
<< xx << ":" << yy << " new " << p1 << ":" << p2
<< std::endl;
#endif
}
HGCalGeomParameters::cellParameters cp(half,wafer,GlobalPoint(xx,yy,0));
if (type == 1) {
cellsf[cell] = cp;
Expand Down Expand Up @@ -489,10 +503,6 @@ void HGCalGeomParameters::loadGeometryHexagon(const DDFilteredView& _fv,
double yy = (itr->second).xyz.y();
int waf= (itr->second).wafer;
std::pair<double,double> xy = cellPosition(wafers,itrf,waf,xx,yy);
if ((itr->second).half) {
if (xy.first > 0) xy.first -= 0.001;
else xy.first += 0.001;
}
php.cellFineX_.push_back(xy.first);
php.cellFineY_.push_back(xy.second);
}
Expand All @@ -510,10 +520,6 @@ void HGCalGeomParameters::loadGeometryHexagon(const DDFilteredView& _fv,
double yy = (itr->second).xyz.y();
int waf= (itr->second).wafer;
std::pair<double,double> xy = cellPosition(wafers,itrf,waf,xx,yy);
if ((itr->second).half) {
if (xy.first > 0) xy.first -= 0.001;
else xy.first += 0.001;
}
php.cellCoarseX_.push_back(xy.first);
php.cellCoarseY_.push_back(xy.second);
}
Expand Down
7 changes: 5 additions & 2 deletions Geometry/HGCalCommonData/test/HGCalNumberingTester.cc
Expand Up @@ -99,6 +99,7 @@ void HGCalNumberingTester::analyze( const edm::Event& iEvent, const edm::EventSe
<< " Sectors = " << hgdc.sectors() << std::endl;
std::pair<int,int> kxy, lxy;
std::pair<float,float> xy;
std::string flg;
HGCalParameters::hgtrap mytr = hgdc.getModule(0,hexType_,reco_);
bool halfCell(false);
if (!hexType_) halfCell = ((mytr.alpha) > 0);
Expand All @@ -109,19 +110,21 @@ void HGCalNumberingTester::analyze( const edm::Event& iEvent, const edm::EventSe
kxy = hgdc.assignCell(localx,localy,i+1,subsec,reco_);
xy = hgdc.locateCell(kxy.second,i+1,kxy.first,reco_);
lxy = hgdc.assignCell(xy.first,xy.second,i+1,0,reco_);
flg = (kxy == lxy) ? " " : " ***** Error *****";
std::cout << "Input: (" << localx << "," << localy << "," << i+1
<< ", " << subsec << "), assignCell o/p (" << kxy.first << ", "
<< kxy.second << ") locateCell o/p (" << xy.first << ", "
<< xy.second << ")," << " final (" << lxy.first << ", "
<< lxy.second << ")" << std::endl;
<< lxy.second << ")" << flg << std::endl;
kxy = hgdc.assignCell(-localx,-localy,i+1,subsec,reco_);
xy = hgdc.locateCell(kxy.second,i+1,kxy.first,reco_);
lxy = hgdc.assignCell(xy.first,xy.second,i+1,0,reco_);
flg = (kxy == lxy) ? " " : " ***** Error *****";
std::cout << "Input: (" <<-localx << "," <<-localy << "," << i+1
<< ", " << subsec << "), assignCell o/p (" << kxy.first << ", "
<< kxy.second << ") locateCell o/p (" << xy.first << ", "
<< xy.second << ")," << " final (" << lxy.first << ", "
<< lxy.second << ")" << std::endl;
<< lxy.second << ")" << flg << std::endl;
if (k == 0 && i==0) {
std::vector<int> ncells = hgdc.numberCells(i+1,reco_);
std::cout << "Layer " << i+1 << " with " << ncells.size() << " rows\n";
Expand Down

0 comments on commit 71187f3

Please sign in to comment.