CMS 3D CMS Logo

APVGainHelpers.cc
Go to the documentation of this file.
3 
5 
15 int APVGain::subdetectorId(uint32_t det_id) { return DetId(det_id).subdetId(); };
16 
30  std::string d = tag.substr(0, 3);
31  if (d == "TIB")
32  return 3;
33  if (d == "TID")
34  return 4;
35  if (d == "TOB")
36  return 5;
37  if (d == "TEC")
38  return 6;
39  return 0;
40 };
41 
48 int APVGain::subdetectorSide(uint32_t det_id, const TrackerTopology* topo) { return topo->side(det_id); }
49 
60  std::size_t m = tag.find("minus");
61  std::size_t p = tag.find("plus");
62  if (m != std::string::npos)
63  return 1;
64  if (p != std::string::npos)
65  return 2;
66  return 0;
67 }
68 
76 int APVGain::subdetectorPlane(uint32_t det_id, const TrackerTopology* topo) {
77  if (topo) {
79  return topo->tibLayer(det_id);
81  return (2 * topo->tidSide(det_id) - 3) * topo->tidWheel(det_id);
83  return topo->tobLayer(det_id);
85  return (2 * topo->tecSide(det_id) - 3) * topo->tecWheel(det_id);
86  }
87  return 0;
88 };
89 
96  std::size_t p = (tag.find("layer") != std::string::npos) ? tag.find("layer") : tag.find("wheel");
97  if (p != std::string::npos) {
98  std::size_t start = tag.find("_", p + 1) + 1;
99  std::size_t stop = tag.find('_', start);
100  std::string plane = tag.substr(start, stop - start);
101  return atoi(plane.c_str());
102  }
103  return 0;
104 };
105 
108 std::vector<APVGain::MonitorElement*> APVGain::FetchMonitor(std::vector<APVGain::APVmon> histos,
109  uint32_t det_id,
110  const TrackerTopology* topo) {
111  std::vector<MonitorElement*> found = std::vector<MonitorElement*>();
112  int sId = APVGain::subdetectorId(det_id);
113  int sPlane = APVGain::subdetectorPlane(det_id, topo);
114  int sSide = APVGain::subdetectorSide(det_id, topo);
115  auto it = histos.begin();
116 
117  LogDebug("APVGainHelpers") << "sId: " << sId << " sPlane: " << sPlane << " sSide: " << sSide << std::endl;
118 
119  while (it != histos.end()) {
120  std::string tag = (*it).getMonitor()->getName();
121  int subdetectorId = (*it).getSubdetectorId();
122  int subdetectorSide = (*it).getSubdetectorSide();
123  int subdetectorPlane = (*it).getSubdetectorPlane();
124 
125  bool match = (subdetectorId == 0 || subdetectorId == sId) &&
126  (subdetectorPlane == 0 || subdetectorPlane == sPlane) &&
127  (subdetectorSide == 0 || subdetectorSide == sSide);
128 
129  if (match) {
130  found.emplace_back((*it).getMonitor());
131  LogDebug("APVGainHelpers") << det_id << " found: " << tag << std::endl;
132  (*it).printAll();
133  }
134  it++;
135  }
136  return found;
137 }
138 
141 std::vector<unsigned int> APVGain::FetchIndices(std::map<unsigned int, APVloc> theMap,
142  uint32_t det_id,
143  const TrackerTopology* topo) {
144  std::vector<unsigned int> found_indices = std::vector<unsigned int>();
145 
146  int sId = APVGain::subdetectorId(det_id);
147  int sPlane = APVGain::subdetectorPlane(det_id, topo);
148  int sSide = APVGain::subdetectorSide(det_id, topo);
149 
150  for (auto& element : theMap) {
151  int subdetectorId = element.second.m_subdetectorId;
152  int subdetectorSide = element.second.m_subdetectorSide;
153  int subdetectorPlane = element.second.m_subdetectorPlane;
154 
155  bool match = (subdetectorId == 0 || subdetectorId == sId) &&
156  (subdetectorPlane == 0 || subdetectorPlane == sPlane) &&
157  (subdetectorSide == 0 || subdetectorSide == sSide);
158 
159  if (match) {
160  found_indices.push_back(element.first);
161  }
162  }
163  return found_indices;
164 }
165 
166 std::vector<std::pair<std::string, std::string>> APVGain::monHnames(std::vector<std::string> VH,
167  bool allPlanes,
168  const char* tag) {
169  std::vector<std::pair<std::string, std::string>> out;
170 
171  // total number of measurement layers/wheels in the Strips Tracker
172  // 4(TIB) + 6(TOB) + 3(TID+) + 3(TID-) + 9(TEC+) + 9(TEC-)
173  constexpr int countOfPlanes = 34;
174 
175  int re = (allPlanes) ? countOfPlanes + VH.size() : VH.size();
176  out.reserve(re);
177 
178  std::string Tag = tag;
179  if (Tag.length())
180  Tag = "__" + Tag;
181 
182  std::string h_tag = "";
183  std::string h_tit = "";
184 
185  if (allPlanes) {
186  // Names of monitoring histogram for TIB layers
187  constexpr int TIBlayers = 4; //number of TIB layers.
188  for (int i = 1; i <= TIBlayers; i++) {
189  h_tag = "TIB_layer_" + std::to_string(i) + Tag;
190  h_tit = h_tag;
191  std::replace(h_tit.begin(), h_tit.end(), '_', ' ');
192  out.push_back(std::pair<std::string, std::string>(h_tag, h_tit));
193  }
194  // Names of monitoring histogram for TOB layers
195  constexpr int TOBlayers = 6; //number of TOB layers
196  for (int i = 1; i <= TOBlayers; i++) {
197  h_tag = "TOB_layer_" + std::to_string(i) + Tag;
198  h_tit = h_tag;
199  std::replace(h_tit.begin(), h_tit.end(), '_', ' ');
200  out.push_back(std::pair<std::string, std::string>(h_tag, h_tit));
201  }
202  // Names of monitoring histogram for TID wheels
203  constexpr int TIDwheels = 3; //number of TID wheels
204  for (int i = -TIDwheels; i <= TIDwheels; i++) {
205  if (i == 0)
206  continue;
207  if (i < 0)
208  h_tag = "TIDminus_wheel_" + std::to_string(i) + Tag;
209  else
210  h_tag = "TIDplus_wheel_" + std::to_string(i) + Tag;
211  h_tit = h_tag;
212  std::replace(h_tit.begin(), h_tit.end(), '_', ' ');
213  out.push_back(std::pair<std::string, std::string>(h_tag, h_tit));
214  }
215  // Names of monitoring histogram for TEC wheels
216  constexpr int TECwheels = 9; //number of TEC wheels
217  for (int i = -TECwheels; i <= TECwheels; i++) {
218  if (i == 0)
219  continue;
220  if (i < 0)
221  h_tag = "TECminus_wheel_" + std::to_string(i) + Tag;
222  else
223  h_tag = "TECplus_wheel_" + std::to_string(i) + Tag;
224  h_tit = h_tag;
225  std::replace(h_tit.begin(), h_tit.end(), '_', ' ');
226  out.push_back(std::pair<std::string, std::string>(h_tag, h_tit));
227  }
228  }
229 
230  for (unsigned int i = 0; i < VH.size(); i++) {
231  h_tag = VH[i] + Tag;
232  h_tit = h_tag;
233  std::replace(h_tit.begin(), h_tit.end(), '_', ' ');
234  out.push_back(std::pair<std::string, std::string>(h_tag, h_tit));
235  }
236 
237  return out;
238 }
TrackerTopology::side
unsigned int side(const DetId &id) const
Definition: TrackerTopology.cc:28
mps_fire.i
i
Definition: mps_fire.py:355
start
Definition: start.py:1
APVGain::FetchIndices
std::vector< unsigned int > FetchIndices(std::map< unsigned int, APVloc >, uint32_t, const TrackerTopology *topo=nullptr)
Definition: APVGainHelpers.cc:141
TrackerTopology
Definition: TrackerTopology.h:16
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
APVGain::subdetectorPlane
int subdetectorPlane(uint32_t, const TrackerTopology *)
Definition: APVGainHelpers.cc:76
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
TrackerTopology::tidWheel
unsigned int tidWheel(const DetId &id) const
Definition: TrackerTopology.h:201
DetId
Definition: DetId.h:17
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:670
APVGain::subdetectorSide
int subdetectorSide(uint32_t, const TrackerTopology *)
Definition: APVGainHelpers.cc:48
APVGain::FetchMonitor
std::vector< MonitorElement * > FetchMonitor(std::vector< APVmon >, uint32_t, const TrackerTopology *topo=nullptr)
Definition: APVGainHelpers.cc:108
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
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
APVGain::monHnames
std::vector< std::pair< std::string, std::string > > monHnames(std::vector< std::string >, bool, const char *tag)
Definition: APVGainHelpers.cc:166
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
ztail.d
d
Definition: ztail.py:151
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:15
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