File indexing completed on 2024-08-05 04:32:11
0001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0002 #include "Geometry/HGCalCommonData/interface/HGCalCassette.h"
0003 #include <algorithm>
0004 #include <sstream>
0005
0006
0007
0008 void HGCalCassette::setParameter(int cassette, const std::vector<double>& shifts, bool both) {
0009 cassette_ = cassette;
0010 typeHE_ = (cassette_ >= 12);
0011 shifts_.insert(shifts_.end(), shifts.begin(), shifts.end());
0012 if (both)
0013 shiftsScnt_.insert(shiftsScnt_.end(), shifts.begin(), shifts.end());
0014 #ifdef EDM_ML_DEBUG
0015 edm::LogVerbatim("HGCalGeom") << "# of cassettes = " << cassette_ << " Type " << typeHE_;
0016 for (uint32_t j1 = 0; j1 < shifts.size(); j1 += 12) {
0017 std::ostringstream st1;
0018 if (j1 == 0) {
0019 if (both)
0020 st1 << " Shifts|ShiftsScnt:";
0021 else
0022 st1 << " Shifts:";
0023 } else {
0024 if (both)
0025 st1 << " ";
0026 else
0027 st1 << " ";
0028 }
0029 uint32_t j2 = std::min((j1 + 12), static_cast<uint32_t>(shifts.size()));
0030 for (uint32_t j = j1; j < j2; ++j)
0031 st1 << ":" << shifts[j];
0032 edm::LogVerbatim("HGCalGeom") << st1.str();
0033 }
0034 #endif
0035 }
0036
0037 void HGCalCassette::setParameterScint(const std::vector<double>& shifts) {
0038 shiftsScnt_.insert(shiftsScnt_.end(), shifts.begin(), shifts.end());
0039 #ifdef EDM_ML_DEBUG
0040 for (uint32_t j1 = 0; j1 < shifts.size(); j1 += 12) {
0041 std::ostringstream st1;
0042 if (j1 == 0) {
0043 st1 << " ShiftsScnt:";
0044 } else {
0045 st1 << " ";
0046 }
0047 uint32_t j2 = std::min((j1 + 12), static_cast<uint32_t>(shifts.size()));
0048 for (uint32_t j = j1; j < j2; ++j)
0049 st1 << ":" << shifts[j];
0050 edm::LogVerbatim("HGCalGeom") << st1.str();
0051 }
0052 #endif
0053 }
0054
0055 std::pair<double, double> HGCalCassette::getShift(int layer, int zside, int cassette, bool scnt) const {
0056 int locc = (zside < 0) ? (cassette - 1) : (typeHE_ ? positHE_[cassette - 1] : positEE_[cassette - 1]);
0057 int loc = 2 * (cassette_ * (layer - 1) + locc);
0058 std::pair<double, double> xy = (typeHE_ && scnt) ? (std::make_pair(-zside * shiftsScnt_[loc], shiftsScnt_[loc + 1]))
0059 : (std::make_pair(-zside * shifts_[loc], shifts_[loc + 1]));
0060 #ifdef EDM_ML_DEBUG
0061 edm::LogVerbatim("HGCalGeom") << "HGCalCassette::getShift: Layer " << layer << " zside " << zside << " type "
0062 << typeHE_ << " cassette " << cassette << " Loc " << locc << ":" << loc << " shift "
0063 << xy.first << ":" << xy.second;
0064 #endif
0065 return xy;
0066 }
0067
0068 int HGCalCassette::cassetteIndex(int det, int layer, int side, int cassette) {
0069 int zs = (side > 0) ? factor_ : 0;
0070 return (((zs + det) * factor_ + layer) * factor_ + cassette);
0071 }
0072
0073 int HGCalCassette::cassetteType(int det, int zside, int cassette) {
0074 int type = (zside < 0) ? cassette : ((det == 0) ? (1 + positEE_[cassette - 1]) : (1 + positHE_[cassette - 1]));
0075 return type;
0076 }