CMS 3D CMS Logo

HGCalCassette.cc
Go to the documentation of this file.
3 #include <algorithm>
4 #include <sstream>
5 
6 //#define EDM_ML_DEBUG
7 
8 void HGCalCassette::setParameter(int cassette, const std::vector<double>& shifts, bool both) {
9  cassette_ = cassette;
10  typeHE_ = (cassette_ >= 12);
11  shifts_.insert(shifts_.end(), shifts.begin(), shifts.end());
12  if (both)
13  shiftsScnt_.insert(shiftsScnt_.end(), shifts.begin(), shifts.end());
14 #ifdef EDM_ML_DEBUG
15  edm::LogVerbatim("HGCalGeom") << "# of cassettes = " << cassette_ << " Type " << typeHE_;
16  for (uint32_t j1 = 0; j1 < shifts.size(); j1 += 12) {
17  std::ostringstream st1;
18  if (j1 == 0) {
19  if (both)
20  st1 << " Shifts|ShiftsScnt:";
21  else
22  st1 << " Shifts:";
23  } else {
24  if (both)
25  st1 << " ";
26  else
27  st1 << " ";
28  }
29  uint32_t j2 = std::min((j1 + 12), static_cast<uint32_t>(shifts.size()));
30  for (uint32_t j = j1; j < j2; ++j)
31  st1 << ":" << shifts[j];
32  edm::LogVerbatim("HGCalGeom") << st1.str();
33  }
34 #endif
35 }
36 
37 void HGCalCassette::setParameterScint(const std::vector<double>& shifts) {
38  shiftsScnt_.insert(shiftsScnt_.end(), shifts.begin(), shifts.end());
39 #ifdef EDM_ML_DEBUG
40  for (uint32_t j1 = 0; j1 < shifts.size(); j1 += 12) {
41  std::ostringstream st1;
42  if (j1 == 0) {
43  st1 << " ShiftsScnt:";
44  } else {
45  st1 << " ";
46  }
47  uint32_t j2 = std::min((j1 + 12), static_cast<uint32_t>(shifts.size()));
48  for (uint32_t j = j1; j < j2; ++j)
49  st1 << ":" << shifts[j];
50  edm::LogVerbatim("HGCalGeom") << st1.str();
51  }
52 #endif
53 }
54 
55 std::pair<double, double> HGCalCassette::getShift(int layer, int zside, int cassette, bool scnt) const {
56  int locc = (zside < 0) ? (cassette - 1) : (typeHE_ ? positHE_[cassette - 1] : positEE_[cassette - 1]);
57  int loc = 2 * (cassette_ * (layer - 1) + locc);
58  std::pair<double, double> xy = (typeHE_ && scnt) ? (std::make_pair(-zside * shiftsScnt_[loc], shiftsScnt_[loc + 1]))
59  : (std::make_pair(-zside * shifts_[loc], shifts_[loc + 1]));
60 #ifdef EDM_ML_DEBUG
61  edm::LogVerbatim("HGCalGeom") << "HGCalCassette::getShift: Layer " << layer << " zside " << zside << " type "
62  << typeHE_ << " cassette " << cassette << " Loc " << locc << ":" << loc << " shift "
63  << xy.first << ":" << xy.second;
64 #endif
65  return xy;
66 }
67 
68 int HGCalCassette::cassetteIndex(int det, int layer, int side, int cassette) {
69  int zs = (side > 0) ? factor_ : 0;
70  return (((zs + det) * factor_ + layer) * factor_ + cassette);
71 }
72 
73 int HGCalCassette::cassetteType(int det, int zside, int cassette) {
74  int type = (zside < 0) ? cassette : ((det == 0) ? (1 + positEE_[cassette - 1]) : (1 + positHE_[cassette - 1]));
75  return type;
76 }
Log< level::Info, true > LogVerbatim
static int cassetteIndex(int det, int layer, int zside, int cassette)
static constexpr int32_t factor_
Definition: HGCalCassette.h:25
std::pair< double, double > getShift(int layer, int zside, int cassette, bool scnt=false) const
static constexpr int positHE_[12]
Definition: HGCalCassette.h:21
int zside(DetId const &)
void setParameterScint(const std::vector< double > &shifts)
static constexpr int positEE_[6]
Definition: HGCalCassette.h:20
std::vector< double > shifts_
Definition: HGCalCassette.h:24
void setParameter(int cassette, const std::vector< double > &shifts, bool both=true)
Definition: HGCalCassette.cc:8
std::vector< double > shiftsScnt_
Definition: HGCalCassette.h:24
static int cassetteType(int det, int zside, int cassette)