Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phase2-hgx309 Add possibility of adding shift due to cassette positioning #37604

Merged
merged 2 commits into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Geometry/HGCalCommonData/interface/HGCalCassette.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef Geometry_HGCalCommonData_HGCalCassette_h
#define Geometry_HGCalCommonData_HGCalCassette_h

#include <cmath>
#include <cstdint>
#include <vector>

class HGCalCassette {
public:
HGCalCassette(int cassette, const std::vector<double>& shifts) { setParameter(cassette, shifts); }
HGCalCassette() {}

void setParameter(int cassette, const std::vector<double>& shifts);
std::pair<double, double> getShift(int layer, int zside, int cassette);

private:
const std::vector<int> positEE_ = {2, 1, 0, 5, 4, 3};
const std::vector<int> positHE_ = {5, 4, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6};
int cassette_;
bool typeHE_;
std::vector<double> shifts_;
std::vector<double> cos_, sin_;
};

#endif
3 changes: 2 additions & 1 deletion Geometry/HGCalCommonData/interface/HGCalGeometryMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ namespace HGCalGeometryMode {
TrapezoidFile = 7,
Hexagon8Module = 8,
TrapezoidModule = 9,
Hexagon8ModuleOrient = 10,
Hexagon8Cassette = 10,
TrapezoidCassette = 11,
};
enum WaferMode { Polyhedra = 0, ExtrudedPolygon = 1 };
} // namespace HGCalGeometryMode
Expand Down
43 changes: 43 additions & 0 deletions Geometry/HGCalCommonData/src/HGCalCassette.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "Geometry/HGCalCommonData/interface/HGCalCassette.h"
#include "DataFormats/Math/interface/angle_units.h"
#include <sstream>

#define EDM_ML_DEBUG

void HGCalCassette::setParameter(int cassette, const std::vector<double>& shifts) {
cassette_ = cassette;
typeHE_ = (cassette_ >= 12);
shifts_.insert(shifts_.end(), shifts.begin(), shifts.end());
double dphi = angle_units::piRadians / cassette_;
for (int k = 0; k < cassette_; ++k) {
double angle = (2 * k - 1) * dphi;
cos_.emplace_back(std::cos(angle));
sin_.emplace_back(std::sin(angle));
}
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCalGeom") << "# of cassettes = " << cassette_ << " Type " << typeHE_ << " dPhi " << dphi;
std::ostringstream st1;
st1 << " Shifts:";
for (const auto& s : shifts_)
st1 << ":" << s;
edm::LogVerbatim("HGCalGeom") << st1.str();
std::ostringstream st2;
st2 << " Cos|Sin:";
for (int k = 0; k < cassette_; ++k)
st2 << " " << cos_[k] << ":" << sin_[k];
edm::LogVerbatim("HGCalGeom") << st2.str();
#endif
}

std::pair<double, double> HGCalCassette::getShift(int layer, int zside, int cassette) {
int locc = (zside < 0) ? (cassette - 1) : (typeHE_ ? positHE_[cassette - 1] : positEE_[cassette - 1]);
int loc = cassette_ * (layer - 1) + locc;
std::pair<double, double> xy = std::make_pair(shifts_[loc] * cos_[locc], shifts_[loc] * sin_[locc]);
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCalGeom") << "HGCalCassette::getShift: Layer " << layer << " zside " << zside << " cassette "
<< cassette << " Loc " << locc << ":" << loc << " shift " << xy.first << ":"
<< xy.second;
#endif
return xy;
}
3 changes: 2 additions & 1 deletion Geometry/HGCalCommonData/src/HGCalGeometryMode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ HGCalStringToEnumParser<HGCalGeometryMode::GeometryMode>::HGCalStringToEnumParse
enumMap["HGCalGeometryMode::TrapezoidFile"] = HGCalGeometryMode::TrapezoidFile;
enumMap["HGCalGeometryMode::Hexagon8Module"] = HGCalGeometryMode::Hexagon8Module;
enumMap["HGCalGeometryMode::TrapezoidModule"] = HGCalGeometryMode::TrapezoidModule;
enumMap["HGCalGeometryMode::Hexagon8ModuleOrient"] = HGCalGeometryMode::Hexagon8ModuleOrient;
enumMap["HGCalGeometryMode::Hexagon8Cassette"] = HGCalGeometryMode::Hexagon8Cassette;
enumMap["HGCalGeometryMode::TrapezoidCassette"] = HGCalGeometryMode::TrapezoidCassette;
}

template <>
Expand Down