CMS 3D CMS Logo

HGCalCoarseTriggerCellMapping.cc
Go to the documentation of this file.
3 
5  : ctcSize_(!ctcSize.empty() ? ctcSize
7  if (ctcSize_.size() != (kNHGCalLayersMax_ + 1) * kNThicknesses_) {
8  throw cms::Exception("HGCTriggerParameterError")
9  << "Inconsistent size of coarse trigger cell size vector " << ctcSize_.size();
10  }
11 
12  for (auto ctc : ctcSize_)
13  checkSizeValidity(ctc);
14 }
15 
16 const std::map<int, int> HGCalCoarseTriggerCellMapping::kSplit_ = {
17  {kCTCsizeIndividual_, kSplit_Individual_},
18  {kCTCsizeVeryFine_, kSplit_VeryFine_},
19  {kCTCsizeFine_, kSplit_Fine_},
20  {kCTCsizeMid_, kSplit_Mid_},
21  {kCTCsizeCoarse_, kSplit_Coarse_},
22 };
23 
24 const std::map<int, int> HGCalCoarseTriggerCellMapping::kSplit_Scin_ = {
25  {kCTCsizeIndividual_, kSplit_Scin_Individual_},
26  {kCTCsizeVeryFine_, kSplit_Scin_VeryFine_},
27  {kCTCsizeFine_, kSplit_Scin_Fine_},
28  {kCTCsizeMid_, kSplit_Scin_Mid_},
29  {kCTCsizeCoarse_, kSplit_Scin_Coarse_},
30 };
31 
35  throw cms::Exception("HGCTriggerParameterError")
36  << "Coarse Trigger Cell should be of size " << kCTCsizeIndividual_ << " or " << kCTCsizeVeryFine_ << " or "
37  << kCTCsizeFine_ << " or " << kCTCsizeMid_ << " or " << kCTCsizeCoarse_;
38  }
39 }
40 
42  uint32_t representativeid = 0;
43  //Firstly get coarse trigger cell Id
44  uint32_t ctcId = getCoarseTriggerCellId(tcid);
45  //Get list of the constituent TCs, and choose (arbitrarily) the first one
46  representativeid = getConstituentTriggerCells(ctcId).at(0);
47  if (triggerTools_.getTriggerGeometry()->validTriggerCell(representativeid)) {
48  return representativeid;
49  } else {
50  return tcid;
51  }
52 }
53 
55  unsigned int layer = triggerTools_.layerWithOffset(detid);
57 
59 
60  DetId tc_Id(detid);
61  if (tc_Id.det() == DetId::HGCalTrigger || tc_Id.det() == DetId::HGCalHSc) {
62  if (triggerTools_.isScintillator(detid)) {
63  HGCScintillatorDetId tc_Id(detid);
64 
65  int tcSplit = (((tc_Id.ietaAbs() - 1) << HGCScintillatorDetId::kHGCalRadiusOffset) | (tc_Id.iphi() - 1)) &
67 
68  detid = (detid & kHGCalScinCellMaskInv_) | tcSplit;
69 
70  return detid;
71 
72  } else {
73  HGCalTriggerDetId tc_Id(detid);
74 
75  int uPrime = 0;
76  int vPrime = 0;
77  int rocnum = detIdToROC_.getROCNumber(tc_Id.triggerCellU(), tc_Id.triggerCellV(), 1);
78 
79  if (rocnum == kRoc0deg_) {
80  uPrime = tc_Id.triggerCellU();
81  vPrime = tc_Id.triggerCellV() - tc_Id.triggerCellU();
82 
83  } else if (rocnum == kRoc120deg_) {
84  uPrime = tc_Id.triggerCellU() - tc_Id.triggerCellV() - 1;
85  vPrime = tc_Id.triggerCellV();
86 
87  } else if (rocnum == kRoc240deg_) {
88  uPrime = tc_Id.triggerCellV() - kRotate4_;
89  vPrime = kRotate7_ - tc_Id.triggerCellU();
90  }
91 
92  int tcSplit = (rocnum << kRocShift_) | ((uPrime << kUShift_ | vPrime) & kSplit_.at(ctcSize));
93  detid = (detid & kHGCalCellMaskInv_) | tcSplit;
94  return detid;
95  }
96 
97  } else {
98  return 0;
99  }
100 }
101 
102 std::vector<uint32_t> HGCalCoarseTriggerCellMapping::getConstituentTriggerCells(uint32_t ctcId) const {
104  unsigned int layer = triggerTools_.layerWithOffset(ctcId);
106 
107  std::vector<uint32_t> output_ids;
108  DetId tc_Id(ctcId);
109 
110  if (tc_Id.det() == DetId::HGCalTrigger || tc_Id.det() == DetId::HGCalHSc) {
111  if (triggerTools_.isScintillator(ctcId)) {
112  int splitInv = ~(kHGCalScinCellMaskInv_ | kSplit_Scin_.at(ctcSize));
113  for (int i = 0; i < splitInv + 1; i++) {
114  if ((i & splitInv) != i)
115  continue;
116 
117  HGCScintillatorDetId prime = (ctcId | i);
118  unsigned outid = (ctcId & kHGCalScinCellMaskInv_) |
119  (((prime.iradiusAbs() + 1) << HGCScintillatorDetId::kHGCalRadiusOffset) | (prime.iphi() + 1));
120 
122  output_ids.emplace_back(outid);
123  }
124  }
125 
126  } else {
127  int splitInv = ~(kSTCidMaskInv_ | kSplit_.at(ctcSize));
128  for (int i = 0; i < splitInv + 1; i++) {
129  if ((i & splitInv) != i)
130  continue;
131  int uPrime = ((ctcId | i) >> kUShift_) & kUMask_;
132  int vPrime = ((ctcId | i) >> kVShift_) & kVMask_;
133  int rocnum = (ctcId >> kRocShift_) & kRocMask_;
134 
135  int u = 0;
136  int v = 0;
137 
138  if (rocnum == kRoc0deg_) {
139  u = uPrime;
140  v = vPrime + u;
141  } else if (rocnum == kRoc120deg_) {
142  u = uPrime + vPrime + 1;
143  v = vPrime;
144  } else if (rocnum == kRoc240deg_) {
145  u = kRotate7_ - vPrime;
146  v = uPrime + kRotate4_;
147  }
148 
149  uint32_t outid = ctcId & kHGCalCellMaskInv_;
152 
154  output_ids.emplace_back(outid);
155  }
156  }
157  }
158  }
159  return output_ids;
160 }
161 
163  std::vector<uint32_t> constituentTCs = getConstituentTriggerCells(ctcId);
164  Basic3DVector<float> average_vector(0., 0., 0.);
165 
166  for (const auto constituent : constituentTCs) {
167  average_vector += triggerTools_.getTCPosition(constituent).basicVector();
168  }
169 
170  GlobalPoint average_point(average_vector / constituentTCs.size());
171  return average_point;
172 }
static const std::map< int, int > kSplit_
std::vector< uint32_t > getConstituentTriggerCells(uint32_t ctcId) const
uint32_t getRepresentativeDetId(uint32_t tcid) const
bool isScintillator(const DetId &id) const
int thicknessIndex(const DetId &) const
const HGCalTriggerGeometryBase * getTriggerGeometry() const
int triggerCellU() const
get the cell #&#39;s in u,v or in x,y
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
uint32_t getCoarseTriggerCellId(uint32_t detid) const
static const int kHGCalCellVOffset
static const std::map< int, int > kSplit_Scin_
virtual bool validTriggerCell(const unsigned trigger_cell_id) const =0
int iphi() const
get the phi index
GlobalPoint getTCPosition(const DetId &id) const
int getROCNumber(HGCalTriggerDetId const &id) const
static const int kHGCalRadiusOffset
GlobalPoint getCoarseTriggerCellPosition(uint32_t ctcId) const
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
static const int kHGCalCellVMask
unsigned layerWithOffset(const DetId &) const
Definition: DetId.h:17
int triggerCellV() const
static const int kHGCalCellUOffset
static const int kHGCalCellUMask
HGCalCoarseTriggerCellMapping(const std::vector< unsigned > &ctcSize)