CMS 3D CMS Logo

APVGainHelpers.cc
Go to the documentation of this file.
3 
6 
16 int APVGain::subdetectorId(uint32_t det_id) { return DetId(det_id).subdetId(); };
17 
31  std::string d = tag.substr(0, 3);
32  if (d == "TIB")
33  return 3;
34  if (d == "TID")
35  return 4;
36  if (d == "TOB")
37  return 5;
38  if (d == "TEC")
39  return 6;
40  return 0;
41 };
42 
49 int APVGain::subdetectorSide(uint32_t det_id, const TrackerTopology* topo) { return topo->side(det_id); }
50 
61  std::size_t m = tag.find("minus");
62  std::size_t p = tag.find("plus");
63  if (m != std::string::npos)
64  return 1;
65  if (p != std::string::npos)
66  return 2;
67  return 0;
68 }
69 
76 int APVGain::thickness(uint32_t det_id) {
78  SiStripDetId siStripDetId(det_id);
79  if (siStripDetId.subdetId() == SiStripDetId::TOB) {
80  return 2; // so it is TOB (thick)
81  }
82  if (siStripDetId.moduleGeometry() == SiStripModuleGeometry::W5 ||
83  siStripDetId.moduleGeometry() == SiStripModuleGeometry::W6 ||
84  siStripDetId.moduleGeometry() == SiStripModuleGeometry::W7) {
85  return 2; // so it is TEC ring 5-7 (thick)
86  }
87  return 1; // so it is TEC ring 1-4 or TIB or TID (thin)
88  } else {
89  return 0;
90  }
91 }
92 
103  std::size_t thin = tag.find("thin");
104  std::size_t thick = tag.find("thick");
105  if (thin != std::string::npos)
106  return 1;
107  if (thick != std::string::npos)
108  return 2;
109  return 0;
110 }
111 
119 int APVGain::subdetectorPlane(uint32_t det_id, const TrackerTopology* topo) {
120  if (topo) {
122  return topo->tibLayer(det_id);
123  else if (APVGain::subdetectorId(det_id) == StripSubdetector::TID)
124  return (2 * topo->tidSide(det_id) - 3) * topo->tidWheel(det_id);
125  else if (APVGain::subdetectorId(det_id) == StripSubdetector::TOB)
126  return topo->tobLayer(det_id);
127  else if (APVGain::subdetectorId(det_id) == StripSubdetector::TEC)
128  return (2 * topo->tecSide(det_id) - 3) * topo->tecWheel(det_id);
129  }
130  return 0;
131 };
132 
139  std::size_t p = (tag.find("layer") != std::string::npos) ? tag.find("layer") : tag.find("wheel");
140  if (p != std::string::npos) {
141  std::size_t start = tag.find('_', p + 1) + 1;
142  std::size_t stop = tag.find('_', start);
143  std::string plane = tag.substr(start, stop - start);
144  return atoi(plane.c_str());
145  }
146  return 0;
147 };
148 
151 std::vector<APVGain::MonitorElement*> APVGain::FetchMonitor(std::vector<APVGain::APVmon> histos,
152  uint32_t det_id,
153  const TrackerTopology* topo) {
154  std::vector<MonitorElement*> found = std::vector<MonitorElement*>();
155  int sThick = APVGain::thickness(det_id);
156  int sId = APVGain::subdetectorId(det_id);
157  int sPlane = APVGain::subdetectorPlane(det_id, topo);
158  int sSide = APVGain::subdetectorSide(det_id, topo);
159  auto it = histos.begin();
160 
161  LogDebug("APVGainHelpers") << "sId: " << sId << " sPlane: " << sPlane << " sSide: " << sSide << std::endl;
162 
163  while (it != histos.end()) {
164  std::string tag = (*it).getMonitor()->getName();
165  int subdetectorThickness = (*it).getThickness();
166  int subdetectorId = (*it).getSubdetectorId();
167  int subdetectorSide = (*it).getSubdetectorSide();
168  int subdetectorPlane = (*it).getSubdetectorPlane();
169 
170  bool match = (subdetectorId == 0 || subdetectorId == sId) &&
171  (subdetectorPlane == 0 || subdetectorPlane == sPlane) &&
172  (subdetectorSide == 0 || subdetectorSide == sSide) &&
173  (subdetectorThickness == 0 || subdetectorThickness == sThick);
174 
175  if (match) {
176  found.emplace_back((*it).getMonitor());
177  LogDebug("APVGainHelpers") << det_id << " found: " << tag << std::endl;
178  (*it).printAll();
179  }
180  it++;
181  }
182  return found;
183 }
184 
187 std::vector<unsigned int> APVGain::FetchIndices(std::map<unsigned int, APVloc> theMap,
188  uint32_t det_id,
189  const TrackerTopology* topo) {
190  std::vector<unsigned int> found_indices = std::vector<unsigned int>();
191 
192  int sThick = APVGain::thickness(det_id);
193  int sId = APVGain::subdetectorId(det_id);
194  int sPlane = APVGain::subdetectorPlane(det_id, topo);
195  int sSide = APVGain::subdetectorSide(det_id, topo);
196 
197  for (auto& element : theMap) {
198  int subdetectorThickness = element.second.m_thickness;
199  int subdetectorId = element.second.m_subdetectorId;
200  int subdetectorSide = element.second.m_subdetectorSide;
201  int subdetectorPlane = element.second.m_subdetectorPlane;
202 
203  bool match = (subdetectorId == 0 || subdetectorId == sId) &&
204  (subdetectorPlane == 0 || subdetectorPlane == sPlane) &&
205  (subdetectorSide == 0 || subdetectorSide == sSide) &&
206  (subdetectorThickness == 0 || subdetectorThickness == sThick);
207 
208  if (match) {
209  found_indices.push_back(element.first);
210  }
211  }
212  return found_indices;
213 }
214 
215 std::vector<std::pair<std::string, std::string>> APVGain::monHnames(std::vector<std::string> VH,
216  bool allPlanes,
217  const char* tag) {
218  std::vector<std::pair<std::string, std::string>> out;
219 
220  // total number of measurement layers/wheels in the Strips Tracker
221  // 4(TIB) + 6(TOB) + 3(TID+) + 3(TID-) + 9(TEC+) + 9(TEC-)
222  constexpr int countOfPlanes = 34;
223 
224  int re = (allPlanes) ? countOfPlanes + VH.size() : VH.size();
225  out.reserve(re);
226 
227  std::string Tag = tag;
228  if (Tag.length())
229  Tag = "__" + Tag;
230 
231  std::string h_tag = "";
232  std::string h_tit = "";
233 
234  if (allPlanes) {
235  // Names of monitoring histogram for TIB layers
236  constexpr int TIBlayers = 4; //number of TIB layers.
237  for (int i = 1; i <= TIBlayers; i++) {
238  h_tag = "TIB_layer_" + std::to_string(i) + Tag;
239  h_tit = h_tag;
240  std::replace(h_tit.begin(), h_tit.end(), '_', ' ');
241  out.push_back(std::pair<std::string, std::string>(h_tag, h_tit));
242  }
243  // Names of monitoring histogram for TOB layers
244  constexpr int TOBlayers = 6; //number of TOB layers
245  for (int i = 1; i <= TOBlayers; i++) {
246  h_tag = "TOB_layer_" + std::to_string(i) + Tag;
247  h_tit = h_tag;
248  std::replace(h_tit.begin(), h_tit.end(), '_', ' ');
249  out.push_back(std::pair<std::string, std::string>(h_tag, h_tit));
250  }
251  // Names of monitoring histogram for TID wheels
252  constexpr int TIDwheels = 3; //number of TID wheels
253  for (int i = -TIDwheels; i <= TIDwheels; i++) {
254  if (i == 0)
255  continue;
256  if (i < 0)
257  h_tag = "TIDminus_wheel_" + std::to_string(i) + Tag;
258  else
259  h_tag = "TIDplus_wheel_" + std::to_string(i) + Tag;
260  h_tit = h_tag;
261  std::replace(h_tit.begin(), h_tit.end(), '_', ' ');
262  out.push_back(std::pair<std::string, std::string>(h_tag, h_tit));
263  }
264  // Names of monitoring histogram for TEC wheels
265  constexpr int TECwheels = 9; //number of TEC wheels
266  for (int i = -TECwheels; i <= TECwheels; i++) {
267  if (i == 0)
268  continue;
269  if (i < 0)
270  h_tag = "TECminus_wheel_" + std::to_string(i) + Tag;
271  else
272  h_tag = "TECplus_wheel_" + std::to_string(i) + Tag;
273  h_tit = h_tag;
274  std::replace(h_tit.begin(), h_tit.end(), '_', ' ');
275  out.push_back(std::pair<std::string, std::string>(h_tag, h_tit));
276  }
277  }
278 
279  for (unsigned int i = 0; i < VH.size(); i++) {
280  h_tag = VH[i] + Tag;
281  h_tit = h_tag;
282  std::replace(h_tit.begin(), h_tit.end(), '_', ' ');
283  out.push_back(std::pair<std::string, std::string>(h_tag, h_tit));
284  }
285 
286  return out;
287 }
TrackerTopology::side
unsigned int side(const DetId &id) const
Definition: TrackerTopology.cc:28
SiStripDetId::moduleGeometry
SiStripModuleGeometry moduleGeometry() const
Definition: SiStripDetId.h:109
mps_fire.i
i
Definition: mps_fire.py:428
start
Definition: start.py:1
SiStripModuleGeometry::W7
APVGain::FetchIndices
std::vector< unsigned int > FetchIndices(std::map< unsigned int, APVloc >, uint32_t, const TrackerTopology *topo=nullptr)
Definition: APVGainHelpers.cc:187
TrackerTopology
Definition: TrackerTopology.h:16
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
SiStripDetId.h
APVGain::subdetectorPlane
int subdetectorPlane(uint32_t, const TrackerTopology *)
Definition: APVGainHelpers.cc:119
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
SiStripModuleGeometry::W6
TrackerTopology::tidWheel
unsigned int tidWheel(const DetId &id) const
Definition: TrackerTopology.h:201
DetId
Definition: DetId.h:17
SiStripModuleGeometry::W5
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
StripSubdetector::TIB
static constexpr auto TIB
Definition: StripSubdetector.h:16
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
APVGain::subdetectorSide
int subdetectorSide(uint32_t, const TrackerTopology *)
Definition: APVGainHelpers.cc:49
APVGain::FetchMonitor
std::vector< MonitorElement * > FetchMonitor(std::vector< APVmon >, uint32_t, const TrackerTopology *topo=nullptr)
Definition: APVGainHelpers.cc:151
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
TrackerTopology::tidSide
unsigned int tidSide(const DetId &id) const
Definition: TrackerTopology.h:190
SiStripDetId::TOB
static constexpr auto TOB
Definition: SiStripDetId.h:39
APVGain::thickness
int thickness(uint32_t)
Definition: APVGainHelpers.cc:76
combine.histos
histos
Definition: combine.py:4
TrackerTopology::tobLayer
unsigned int tobLayer(const DetId &id) const
Definition: TrackerTopology.h:147
StripSubdetector::TEC
static constexpr auto TEC
Definition: StripSubdetector.h:19
DetId.h
StripSubdetector::TOB
static constexpr auto TOB
Definition: StripSubdetector.h:18
SiStripDetId::TIB
static constexpr auto TIB
Definition: SiStripDetId.h:37
APVGain::monHnames
std::vector< std::pair< std::string, std::string > > monHnames(std::vector< std::string >, bool, const char *tag)
Definition: APVGainHelpers.cc:215
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
ztail.d
d
Definition: ztail.py:151
SiStripDetId
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:18
TrackerTopology::tecWheel
unsigned int tecWheel(const DetId &id) const
Definition: TrackerTopology.h:198
APVGainHelpers.h
StripSubdetector.h
StripSubdetector::TID
static constexpr auto TID
Definition: StripSubdetector.h:17
APVGain::subdetectorId
int subdetectorId(uint32_t)
Definition: APVGainHelpers.cc:16
TrackerTopology::tibLayer
unsigned int tibLayer(const DetId &id) const
Definition: TrackerTopology.h:150
python.rootplot.root2matplotlib.replace
def replace(string, replacements)
Definition: root2matplotlib.py:444
TrackerTopology::tecSide
unsigned int tecSide(const DetId &id) const
Definition: TrackerTopology.h:184