CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DetNaming.cc
Go to the documentation of this file.
2 
4 
8 
9 #include <boost/foreach.hpp>
10 
11 #include <TString.h>
12 
13 #include <vector>
14 #include <string>
15 #include <map>
16 
18 {
19  detMap_[DetId::Ecal] = "Ecal";
20  subDetMap_[DetId::Ecal][EcalBarrel] = "EcalBarrel";
21  subDetMap_[DetId::Ecal][EcalEndcap] = "EcalEndcap";
22  subDetMap_[DetId::Ecal][EcalPreshower] = "EcalPreshower";
23  subDetMap_[DetId::Ecal][EcalTriggerTower] = "EcalTriggerTower";
24  subDetMap_[DetId::Ecal][EcalLaserPnDiode] = "EcalLaserPnDiode";
25 
26  detMap_[DetId::Hcal] = "Hcal";
27  subDetMap_[DetId::Hcal][HcalEmpty] = "HcalEmpty";
28  subDetMap_[DetId::Hcal][HcalBarrel] = "HcalBarrel";
29  subDetMap_[DetId::Hcal][HcalEndcap] = "HcalEndcap";
30  subDetMap_[DetId::Hcal][HcalOuter] = "HcalOuter";
31  subDetMap_[DetId::Hcal][HcalForward] = "HcalForward";
32  subDetMap_[DetId::Hcal][HcalTriggerTower] = "HcalTriggerTower";
33  subDetMap_[DetId::Hcal][HcalOther] = "HcalOther";
34 }
35 
37 {
38  if ( detMap_.find(detId.det()) != detMap_.end() &&
39  subDetMap_.find(detId.det()) != subDetMap_.end() &&
40  subDetMap_[detId.det()].find(detId.subdetId()) != subDetMap_[detId.det()].end() ) {
41  return Form("H_%s_%s", detMap_[detId.det()].data(), subDetMap_[detId.det()][detId.subdetId()].data());
42  } else {
43  throw cms::Exception("DetNaming")
44  << "Invalid detId = " << detId.rawId() << " !!\n";
45  return std::string();
46  }
47 }
48 
49 std::vector<std::string> DetNaming::getAllKeys()
50 {
51  std::vector<std::string> keys;
52  keys.push_back("H__");
53  BOOST_FOREACH(TMyMainMap::value_type& entry, detMap_) {
54  BOOST_FOREACH(TMySubMap::mapped_type::value_type& subEntry, subDetMap_[entry.first]) {
55  std::string name = Form("H_%s_%s", entry.second.data(), subEntry.second.data());
56  keys.push_back(name);
57  }
58  }
59 
60  return keys;
61 }
62 
63 
64 
TMySubMap subDetMap_
Definition: DetNaming.h:26
TMyMainMap detMap_
Definition: DetNaming.h:25
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
Definition: DetId.h:18
std::vector< std::string > getAllKeys()
Definition: DetNaming.cc:49
std::string getKey(const DetId &)
Definition: DetNaming.cc:36
list entry
Definition: mps_splice.py:62
Detector det() const
get the detector field from this detid
Definition: DetId.h:35