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_ = {{kCTCsizeIndividual_, kSplit_v8_Individual_},
17  {kCTCsizeVeryFine_, kSplit_v8_VeryFine_},
18  {kCTCsizeFine_, kSplit_v8_Fine_},
19  {kCTCsizeMid_, kSplit_v8_Mid_},
20  {kCTCsizeCoarse_, kSplit_v8_Coarse_}};
21 
22 const std::map<int, int> HGCalCoarseTriggerCellMapping::kSplit_v9_ = {
23  {kCTCsizeIndividual_, kSplit_v9_Individual_},
24  {kCTCsizeVeryFine_, kSplit_v9_VeryFine_},
25  {kCTCsizeFine_, kSplit_v9_Fine_},
26  {kCTCsizeMid_, kSplit_v9_Mid_},
27  {kCTCsizeCoarse_, kSplit_v9_Coarse_},
28 };
29 
30 const std::map<int, int> HGCalCoarseTriggerCellMapping::kSplit_v9_Scin_ = {
31  {kCTCsizeIndividual_, kSplit_v9_Scin_Individual_},
32  {kCTCsizeVeryFine_, kSplit_v9_Scin_VeryFine_},
33  {kCTCsizeFine_, kSplit_v9_Scin_Fine_},
34  {kCTCsizeMid_, kSplit_v9_Scin_Mid_},
35  {kCTCsizeCoarse_, kSplit_v9_Scin_Coarse_},
36 };
37 
41  throw cms::Exception("HGCTriggerParameterError")
42  << "Coarse Trigger Cell should be of size " << kCTCsizeIndividual_ << " or " << kCTCsizeVeryFine_ << " or "
43  << kCTCsizeFine_ << " or " << kCTCsizeMid_ << " or " << kCTCsizeCoarse_;
44  }
45 }
46 
48  uint32_t representativeid = 0;
49  //Firstly get coarse trigger cell Id
50  uint32_t ctcId = getCoarseTriggerCellId(tcid);
51  //Get list of the constituent TCs, and choose (arbitrarily) the first one
52  representativeid = getConstituentTriggerCells(ctcId).at(0);
53  if (triggerTools_.getTriggerGeometry()->validTriggerCell(representativeid)) {
54  return representativeid;
55  } else {
56  return tcid;
57  }
58 }
59 
61  unsigned int layer = triggerTools_.layerWithOffset(detid);
62  int thickness = triggerTools_.thicknessIndex(detid, true);
63 
65 
66  DetId tc_Id(detid);
67  if (tc_Id.det() == DetId::Forward) { //V8
68 
69  HGCalDetId tc_IdV8(detid);
70 
71  if (triggerTools_.isScintillator(detid)) {
72  return detid; //stc not available in scintillator for v8
73  } else {
74  int tcSplit = (tc_IdV8.cell() & kSplit_.at(ctcSize));
75  detid = (detid & ~(HGCalDetId::kHGCalCellMask)) | tcSplit;
76  return detid;
77  }
78 
79  }
80 
81  else if (tc_Id.det() == DetId::HGCalTrigger || tc_Id.det() == DetId::HGCalHSc) { //V9
82  if (triggerTools_.isScintillator(detid)) {
83  HGCScintillatorDetId tc_IdV9(detid);
84 
85  int tcSplit = (((tc_IdV9.ietaAbs() - 1) << HGCScintillatorDetId::kHGCalRadiusOffset) | (tc_IdV9.iphi() - 1)) &
87 
88  detid = (detid & kHGCalScinCellMaskInv_) | tcSplit;
89 
90  return detid;
91 
92  } else {
93  HGCalTriggerDetId tc_IdV9(detid);
94 
95  int uPrime = 0;
96  int vPrime = 0;
97  int rocnum = detIdToROC_.getROCNumber(tc_IdV9.triggerCellU(), tc_IdV9.triggerCellV(), 1);
98 
99  if (rocnum == kRoc0deg_) {
100  uPrime = tc_IdV9.triggerCellU();
101  vPrime = tc_IdV9.triggerCellV() - tc_IdV9.triggerCellU();
102 
103  } else if (rocnum == kRoc120deg_) {
104  uPrime = tc_IdV9.triggerCellU() - tc_IdV9.triggerCellV() - 1;
105  vPrime = tc_IdV9.triggerCellV();
106 
107  } else if (rocnum == kRoc240deg_) {
108  uPrime = tc_IdV9.triggerCellV() - kRotate4_;
109  vPrime = kRotate7_ - tc_IdV9.triggerCellU();
110  }
111 
112  int tcSplit = (rocnum << kRocShift_) | ((uPrime << kUShift_ | vPrime) & kSplit_v9_.at(ctcSize));
113  detid = (detid & kHGCalCellMaskV9Inv_) | tcSplit;
114  return detid;
115  }
116 
117  } else {
118  return 0;
119  }
120 }
121 
122 std::vector<uint32_t> HGCalCoarseTriggerCellMapping::getConstituentTriggerCells(uint32_t ctcId) const {
123  int thickness = triggerTools_.thicknessIndex(ctcId, true);
124  unsigned int layer = triggerTools_.layerWithOffset(ctcId);
126 
127  std::vector<uint32_t> output_ids;
128  DetId tc_Id(ctcId);
129 
130  if (tc_Id.det() == DetId::Forward) { //V8
131 
132  if (triggerTools_.isScintillator(ctcId)) {
133  output_ids.emplace_back(ctcId); //stc not available in scintillator for v8
134  } else {
135  int splitInv = ~(kSTCidMaskInv_ | kSplit_.at(ctcSize));
136  for (int i = 0; i < splitInv + 1; i++) {
137  if ((i & splitInv) != i)
138  continue;
139 
140  output_ids.emplace_back(ctcId | i);
141  }
142  }
143  } else if (tc_Id.det() == DetId::HGCalTrigger || tc_Id.det() == DetId::HGCalHSc) { //V9
144 
145  if (triggerTools_.isScintillator(ctcId)) {
146  int splitInv = ~(kHGCalScinCellMaskInv_ | kSplit_v9_Scin_.at(ctcSize));
147  for (int i = 0; i < splitInv + 1; i++) {
148  if ((i & splitInv) != i)
149  continue;
150 
151  HGCScintillatorDetId prime = (ctcId | i);
152  unsigned outid = (ctcId & kHGCalScinCellMaskInv_) |
153  (((prime.iradiusAbs() + 1) << HGCScintillatorDetId::kHGCalRadiusOffset) | (prime.iphi() + 1));
154 
156  output_ids.emplace_back(outid);
157  }
158  }
159 
160  } else {
161  int splitInv = ~(kSTCidMaskInv_v9_ | kSplit_v9_.at(ctcSize));
162  for (int i = 0; i < splitInv + 1; i++) {
163  if ((i & splitInv) != i)
164  continue;
165  int uPrime = ((ctcId | i) >> kUShift_) & kUMask_;
166  int vPrime = ((ctcId | i) >> kVShift_) & kVMask_;
167  int rocnum = (ctcId >> kRocShift_) & kRocMask_;
168 
169  int u = 0;
170  int v = 0;
171 
172  if (rocnum == kRoc0deg_) {
173  u = uPrime;
174  v = vPrime + u;
175  } else if (rocnum == kRoc120deg_) {
176  u = uPrime + vPrime + 1;
177  v = vPrime;
178  } else if (rocnum == kRoc240deg_) {
179  u = kRotate7_ - vPrime;
180  v = uPrime + kRotate4_;
181  }
182 
183  uint32_t outid = ctcId & kHGCalCellMaskV9Inv_;
186 
188  output_ids.emplace_back(outid);
189  }
190  }
191  }
192  }
193  return output_ids;
194 }
195 
197  std::vector<uint32_t> constituentTCs = getConstituentTriggerCells(ctcId);
198  Basic3DVector<float> average_vector(0., 0., 0.);
199 
200  for (const auto constituent : constituentTCs) {
201  average_vector += triggerTools_.getTCPosition(constituent).basicVector();
202  }
203 
204  GlobalPoint average_point(average_vector / constituentTCs.size());
205  return average_point;
206 }
HGCSiliconDetIdToROC::getROCNumber
int getROCNumber(HGCalTriggerDetId const &id) const
Definition: HGCSiliconDetIdToROC.h:19
hgcalConcentratorProducer_cfi.ctcSize
ctcSize
Definition: hgcalConcentratorProducer_cfi.py:35
HGCalCoarseTriggerCellMapping::kCTCsizeCoarse_
static constexpr int kCTCsizeCoarse_
Definition: HGCalCoarseTriggerCellMapping.h:19
HGCScintillatorDetId::iradiusAbs
int iradiusAbs() const
Definition: HGCScintillatorDetId.h:54
DetId::HGCalTrigger
Definition: DetId.h:35
mps_fire.i
i
Definition: mps_fire.py:428
HGCScintillatorDetId::iphi
int iphi() const
get the phi index
Definition: HGCScintillatorDetId.cc:58
HGCalCoarseTriggerCellMapping::HGCalCoarseTriggerCellMapping
HGCalCoarseTriggerCellMapping(const std::vector< unsigned > &ctcSize)
Definition: HGCalCoarseTriggerCellMapping.cc:4
HGCalCoarseTriggerCellMapping::kUShift_
static constexpr int kUShift_
Definition: HGCalCoarseTriggerCellMapping.h:55
HGCalCoarseTriggerCellMapping::kCTCsizeVeryFine_
static constexpr int kCTCsizeVeryFine_
Definition: HGCalCoarseTriggerCellMapping.h:22
HGCalCoarseTriggerCellMapping::kSplit_
static const std::map< int, int > kSplit_
Definition: HGCalCoarseTriggerCellMapping.h:26
HGCalCoarseTriggerCellMapping::ctcSize_
std::vector< unsigned > ctcSize_
Definition: HGCalCoarseTriggerCellMapping.h:68
HGCalCoarseTriggerCellMapping::kRoc120deg_
static constexpr int kRoc120deg_
Definition: HGCalCoarseTriggerCellMapping.h:63
DetId::det
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
HGCalCoarseTriggerCellMapping::kSTCidMaskInv_
static constexpr int kSTCidMaskInv_
Definition: HGCalCoarseTriggerCellMapping.h:29
HGCalCoarseTriggerCellMapping::kHGCalScinCellMaskInv_
static constexpr int kHGCalScinCellMaskInv_
Definition: HGCalCoarseTriggerCellMapping.h:60
HGCalCoarseTriggerCellMapping::kSplit_v9_
static const std::map< int, int > kSplit_v9_
Definition: HGCalCoarseTriggerCellMapping.h:27
HGCalTriggerTools::thicknessIndex
int thicknessIndex(const DetId &, bool tc=false) const
Definition: HGCalTriggerTools.cc:233
HGCalCoarseTriggerCellMapping::getConstituentTriggerCells
std::vector< uint32_t > getConstituentTriggerCells(uint32_t ctcId) const
Definition: HGCalCoarseTriggerCellMapping.cc:122
HGCalCoarseTriggerCellMapping::checkSizeValidity
void checkSizeValidity(int ctcSize) const
Definition: HGCalCoarseTriggerCellMapping.cc:38
HGCalCoarseTriggerCellMapping::kUMask_
static constexpr int kUMask_
Definition: HGCalCoarseTriggerCellMapping.h:57
HGCalTriggerTools::isScintillator
bool isScintillator(const DetId &id) const
Definition: HGCalTriggerTools.h:46
findQualityFiles.v
v
Definition: findQualityFiles.py:179
HGCalCoarseTriggerCellMapping::kNThicknesses_
static constexpr int kNThicknesses_
Definition: HGCalCoarseTriggerCellMapping.h:36
HGCalCoarseTriggerCellMapping::getCoarseTriggerCellId
uint32_t getCoarseTriggerCellId(uint32_t detid) const
Definition: HGCalCoarseTriggerCellMapping.cc:60
HGCalCoarseTriggerCellMapping::kRotate7_
static constexpr int kRotate7_
Definition: HGCalCoarseTriggerCellMapping.h:54
HGCalCoarseTriggerCellMapping::kCTCsizeFine_
static constexpr int kCTCsizeFine_
Definition: HGCalCoarseTriggerCellMapping.h:21
DetId
Definition: DetId.h:17
HGCalTriggerTools::getTriggerGeometry
const HGCalTriggerGeometryBase * getTriggerGeometry() const
Definition: HGCalTriggerTools.h:69
HGCalTriggerDetId::triggerCellU
int triggerCellU() const
get the cell #'s in u,v or in x,y
Definition: HGCalTriggerDetId.h:62
Calorimetry_cff.thickness
thickness
Definition: Calorimetry_cff.py:115
HGCalTriggerDetId::kHGCalCellVOffset
static const int kHGCalCellVOffset
Definition: HGCalTriggerDetId.h:93
HGCScintillatorDetId::ietaAbs
int ietaAbs() const
Definition: HGCScintillatorDetId.h:56
HGCalCoarseTriggerCellMapping::kRocMask_
static constexpr int kRocMask_
Definition: HGCalCoarseTriggerCellMapping.h:52
HGCalCoarseTriggerCellMapping::kVMask_
static constexpr int kVMask_
Definition: HGCalCoarseTriggerCellMapping.h:58
HGCalTriggerTools::layerWithOffset
unsigned layerWithOffset(const DetId &) const
Definition: HGCalTriggerTools.cc:134
Point3DBase< float, GlobalTag >
HGCalTriggerTools::getTCPosition
GlobalPoint getTCPosition(const DetId &id) const
Definition: HGCalTriggerTools.cc:54
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
HGCalTriggerDetId
Definition: HGCalTriggerDetId.h:26
HGCalTriggerDetId::triggerCellV
int triggerCellV() const
Definition: HGCalTriggerDetId.h:63
HGCalCoarseTriggerCellMapping::kSplit_v9_Scin_
static const std::map< int, int > kSplit_v9_Scin_
Definition: HGCalCoarseTriggerCellMapping.h:28
HGCScintillatorDetId::kHGCalRadiusOffset
static const int kHGCalRadiusOffset
Definition: HGCScintillatorDetId.h:83
HGCalCoarseTriggerCellMapping::kCTCsizeIndividual_
static constexpr int kCTCsizeIndividual_
Definition: HGCalCoarseTriggerCellMapping.h:23
HGCalTriggerGeometryBase::validTriggerCell
virtual bool validTriggerCell(const unsigned trigger_cell_id) const =0
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
HGCalCoarseTriggerCellMapping::kCTCsizeMid_
static constexpr int kCTCsizeMid_
Definition: HGCalCoarseTriggerCellMapping.h:20
HGCalCoarseTriggerCellMapping::kRotate4_
static constexpr int kRotate4_
Definition: HGCalCoarseTriggerCellMapping.h:53
HGCalTriggerDetId::kHGCalCellVMask
static const int kHGCalCellVMask
Definition: HGCalTriggerDetId.h:94
HGCalCoarseTriggerCellMapping::getCoarseTriggerCellPosition
GlobalPoint getCoarseTriggerCellPosition(uint32_t ctcId) const
Definition: HGCalCoarseTriggerCellMapping.cc:196
PV3DBase::basicVector
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
HGCalDetId
Definition: HGCalDetId.h:8
HGCalCoarseTriggerCellMapping.h
HGCalDetId::kHGCalCellMask
static const int kHGCalCellMask
Definition: HGCalDetId.h:11
std
Definition: JetResolutionObject.h:76
HGCScintillatorDetId
Definition: HGCScintillatorDetId.h:23
DetId::HGCalHSc
Definition: DetId.h:34
HGCalCoarseTriggerCellMapping::kRoc240deg_
static constexpr int kRoc240deg_
Definition: HGCalCoarseTriggerCellMapping.h:64
HGCalCoarseTriggerCellMapping::kHGCalCellMaskV9Inv_
static constexpr int kHGCalCellMaskV9Inv_
Definition: HGCalCoarseTriggerCellMapping.h:59
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
HGCalCoarseTriggerCellMapping::detIdToROC_
HGCSiliconDetIdToROC detIdToROC_
Definition: HGCalCoarseTriggerCellMapping.h:67
Exception
Definition: hltDiff.cc:245
HGCalCoarseTriggerCellMapping::triggerTools_
HGCalTriggerTools triggerTools_
Definition: HGCalCoarseTriggerCellMapping.h:66
HGCalCoarseTriggerCellMapping::kRoc0deg_
static constexpr int kRoc0deg_
Definition: HGCalCoarseTriggerCellMapping.h:62
HGCalTriggerDetId::kHGCalCellUMask
static const int kHGCalCellUMask
Definition: HGCalTriggerDetId.h:92
HGCalCoarseTriggerCellMapping::kRocShift_
static constexpr int kRocShift_
Definition: HGCalCoarseTriggerCellMapping.h:51
HGCalCoarseTriggerCellMapping::kSTCidMaskInv_v9_
static constexpr int kSTCidMaskInv_v9_
Definition: HGCalCoarseTriggerCellMapping.h:30
HGCalCoarseTriggerCellMapping::kNHGCalLayersMax_
static constexpr int kNHGCalLayersMax_
Definition: HGCalCoarseTriggerCellMapping.h:37
HGCalCoarseTriggerCellMapping::kVShift_
static constexpr int kVShift_
Definition: HGCalCoarseTriggerCellMapping.h:56
DetId::Forward
Definition: DetId.h:30
HGCalCoarseTriggerCellMapping::getRepresentativeDetId
uint32_t getRepresentativeDetId(uint32_t tcid) const
Definition: HGCalCoarseTriggerCellMapping.cc:47
HGCalDetId::cell
int cell() const
get the absolute value of the cell #'s in x and y
Definition: HGCalDetId.h:37
Basic3DVector< float >
HGCalTriggerDetId::kHGCalCellUOffset
static const int kHGCalCellUOffset
Definition: HGCalTriggerDetId.h:91
HGCalTriggerDetId.h