CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
HcalAssistant Class Reference

#include <CaloOnlineTools/HcalOnlineDb/interface/HcalAssistant.h>

Public Member Functions

int a_to_i (char *inbuf)
 
int addQuotes ()
 
int getDepth (int _rawid)
 
int getIeta (int _rawid)
 
int getIphi (int _rawid)
 
int getListOfChannelsFromDb ()
 
std::string getRandomQuote (void)
 
int getRawId (HcalSubdetector _det, int _ieta, int _iphi, int _depth)
 
HcalSubdetector getSubdetector (std::string _det)
 
int getSubdetector (int _rawid)
 
std::string getSubdetectorString (HcalSubdetector _det)
 
std::string getUserName (void)
 
HcalZDCDetId::Section getZDCSection (std::string _section)
 
std::string getZDCSectionString (HcalZDCDetId::Section _section)
 
 HcalAssistant ()
 
virtual ~HcalAssistant ()
 

Private Member Functions

int getGeomId (HcalSubdetector _det, int _ieta, int _iphi, int _depth)
 
int getGeomId (int _rawid)
 
int getHcalDepth (int _geomId)
 
int getHcalIeta (int _geomId)
 
int getHcalIphi (int _geomId)
 
HcalSubdetector getHcalSubdetector (int _geomId)
 
int getRawId (int _geomId)
 
int getRawIdFromCmssw (int _geomId)
 
std::string getSubdetectorString (int _geomId)
 

Private Attributes

std::map< int, int > geom_to_rawid
 
bool listIsRead
 
std::vector< std::string > quotes
 
std::map< int, int > rawid_to_geom
 

Friends

class HcalChannelQualityXml
 

Detailed Description

Description: Various helper functions

Usage: <usage>

Definition at line 43 of file HcalAssistant.h.

Constructor & Destructor Documentation

◆ HcalAssistant()

HcalAssistant::HcalAssistant ( )

Definition at line 32 of file HcalAssistant.cc.

References protons_cff::time.

32  {
33  addQuotes();
34  srand(time(nullptr));
35  listIsRead = false;
36 }

◆ ~HcalAssistant()

HcalAssistant::~HcalAssistant ( )
virtual

Definition at line 38 of file HcalAssistant.cc.

38 {}

Member Function Documentation

◆ a_to_i()

int HcalAssistant::a_to_i ( char *  inbuf)

Definition at line 281 of file HcalAssistant.cc.

References mps_fire::result.

281  {
282  int result;
283  sscanf(inbuf, "%d", &result);
284  return result;
285 }

◆ addQuotes()

int HcalAssistant::addQuotes ( )

Definition at line 40 of file HcalAssistant.cc.

40  {
41  quotes.push_back("Fear is the path to the Dark Side...");
42  quotes.push_back("You don't know the power of the Dark Side...");
43  quotes.push_back("You must learn the ways of the Force!");
44  quotes.push_back("Where's the money, Lebowski?!");
45  quotes.push_back("You see what happens when you find a stranger in the Alps!!!?");
46  quotes.push_back(
47  "You hear this? This is the sound of inevitability. This is the sound of your death. Goodbye, mr. Anderson");
48  quotes.push_back("Welcome to the desert of the Real");
49  quotes.push_back("In Tyler we trust");
50  quotes.push_back("How about a little snack?..Let's have a snack now, we can get friendly later");
51  quotes.push_back("Is he human? Hey, no need for name calling!");
52  quotes.push_back("Frankly, my dear, I don't give a damn");
53  quotes.push_back("I've a feeling we're not in Kansas anymore");
54  quotes.push_back("What we've got here is failure to communicate");
55  quotes.push_back("I love the smell of napalm in the morning!");
56  quotes.push_back("I see stupid people");
57  quotes.push_back("Stella! Hey, Stella!");
58  quotes.push_back("Houston, we have a problem");
59  quotes.push_back("Mrs. Robinson, you're trying to seduce me. Aren't you?");
60  quotes.push_back("I feel the need - the need for speed!");
61  quotes.push_back("He's got emotional problems. What, beyond pacifism?");
62  return quotes.size();
63 }
std::vector< std::string > quotes
Definition: HcalAssistant.h:70

◆ getDepth()

int HcalAssistant::getDepth ( int  _rawid)

Definition at line 275 of file HcalAssistant.cc.

275 { return getHcalDepth(getGeomId(_rawid)); }
int getHcalDepth(int _geomId)
int getGeomId(HcalSubdetector _det, int _ieta, int _iphi, int _depth)

◆ getGeomId() [1/2]

int HcalAssistant::getGeomId ( HcalSubdetector  _det,
int  _ieta,
int  _iphi,
int  _depth 
)
private

Definition at line 77 of file HcalAssistant.cc.

References funct::abs().

77  {
78  int _geomId = _det + 10 * _depth + 100 * _iphi + 10000 * abs(_ieta);
79  if (_ieta < 0) {
80  _geomId = -_geomId;
81  }
82  return _geomId;
83 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ getGeomId() [2/2]

int HcalAssistant::getGeomId ( int  _rawid)
private

Definition at line 232 of file HcalAssistant.cc.

232  {
233  if (listIsRead) {
234  std::map<int, int>::const_iterator _geomId = rawid_to_geom.find(_rawid);
235  if (_geomId != rawid_to_geom.end()) {
236  return _geomId->second;
237  } else
238  return -1;
239  } else
240  return -1;
241 }
std::map< int, int > rawid_to_geom
Definition: HcalAssistant.h:72

◆ getHcalDepth()

int HcalAssistant::getHcalDepth ( int  _geomId)
private

Definition at line 95 of file HcalAssistant.cc.

References funct::abs().

95  {
96  int _depth = abs(_geomId % 100) / 10;
97  return _depth;
98 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ getHcalIeta()

int HcalAssistant::getHcalIeta ( int  _geomId)
private

Definition at line 85 of file HcalAssistant.cc.

85  {
86  int _ieta = _geomId / 10000;
87  return _ieta;
88 }

◆ getHcalIphi()

int HcalAssistant::getHcalIphi ( int  _geomId)
private

Definition at line 90 of file HcalAssistant.cc.

References funct::abs().

90  {
91  int _iphi = abs(_geomId % 10000) / 100;
92  return _iphi;
93 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ getHcalSubdetector()

HcalSubdetector HcalAssistant::getHcalSubdetector ( int  _geomId)
private

Definition at line 100 of file HcalAssistant.cc.

References funct::abs(), HcalBarrel, HcalEmpty, HcalEndcap, HcalForward, HcalOther, HcalOuter, and HcalTriggerTower.

100  {
101  int _det = abs(_geomId) % 10;
102  if (_det == 1)
103  return HcalBarrel;
104  else if (_det == 2)
105  return HcalEndcap;
106  else if (_det == 3)
107  return HcalOuter;
108  else if (_det == 4)
109  return HcalForward;
110  else if (_det == 5)
111  return HcalTriggerTower;
112  else if (_det == 0)
113  return HcalEmpty;
114  else
115  return HcalOther;
116 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ getIeta()

int HcalAssistant::getIeta ( int  _rawid)

Definition at line 271 of file HcalAssistant.cc.

271 { return getHcalIeta(getGeomId(_rawid)); }
int getGeomId(HcalSubdetector _det, int _ieta, int _iphi, int _depth)
int getHcalIeta(int _geomId)

◆ getIphi()

int HcalAssistant::getIphi ( int  _rawid)

Definition at line 273 of file HcalAssistant.cc.

273 { return getHcalIphi(getGeomId(_rawid)); }
int getGeomId(HcalSubdetector _det, int _ieta, int _iphi, int _depth)
int getHcalIphi(int _geomId)

◆ getListOfChannelsFromDb()

int HcalAssistant::getListOfChannelsFromDb ( )

Definition at line 200 of file HcalAssistant.cc.

References DMR_cfg::cerr, getInfo::conn, MillePedeFileConverter_cfg::e, AlCaHLTBitMon_QueryRunRegistry::string, and toolbox::toString().

200  {
201  int _n_channels = 0;
202  static ConnectionManager conn;
203  conn.connect();
204  std::string query = "select ";
205  query += " channel_map_id,subdet,ieta,iphi,depth ";
206  query += "from ";
207  query += " cms_hcl_hcal_cond.hcal_channels ";
208  query += "where ";
209  query += " subdet='HB' or subdet='HE' or subdet='HF' or subdet='HO' ";
210  try {
211  oracle::occi::Statement* stmt = conn.getStatement(query);
212  oracle::occi::ResultSet* rs = stmt->executeQuery();
213  geom_to_rawid.clear();
214  rawid_to_geom.clear();
215  while (rs->next()) {
216  _n_channels++;
217  int _rawid = rs->getInt(1);
218  int _geomId = getGeomId(getSubdetector(rs->getString(2)), rs->getInt(3), rs->getInt(4), rs->getInt(5));
219  geom_to_rawid.insert(std::pair<int, int>(_geomId, _rawid));
220  rawid_to_geom.insert(std::pair<int, int>(_rawid, _geomId));
221  }
222  listIsRead = true;
223  } catch (SQLException& e) {
224  std::cerr << ::toolbox::toString("Oracle exception : %s", e.getMessage().c_str()) << std::endl;
225  XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,
226  ::toolbox::toString("Oracle exception : %s", e.getMessage().c_str()));
227  }
228  conn.disconnect();
229  return _n_channels;
230 }
Definition: query.py:1
int getGeomId(HcalSubdetector _det, int _ieta, int _iphi, int _depth)
std::string toString(const char *format,...)
Definition: xdaq_compat.cc:4
HcalSubdetector getSubdetector(std::string _det)
conn
Definition: getInfo.py:9
std::map< int, int > geom_to_rawid
Definition: HcalAssistant.h:71
std::map< int, int > rawid_to_geom
Definition: HcalAssistant.h:72

◆ getRandomQuote()

std::string HcalAssistant::getRandomQuote ( void  )

Definition at line 65 of file HcalAssistant.cc.

65  {
66  int _quotes_array_size = quotes.size();
67  int _num = rand() % _quotes_array_size;
68  return quotes[_num];
69 }
std::vector< std::string > quotes
Definition: HcalAssistant.h:70

◆ getRawId() [1/2]

int HcalAssistant::getRawId ( HcalSubdetector  _det,
int  _ieta,
int  _iphi,
int  _depth 
)

Definition at line 277 of file HcalAssistant.cc.

277  {
278  return getRawId(getGeomId(_det, _ieta, _iphi, _depth));
279 }
int getRawId(HcalSubdetector _det, int _ieta, int _iphi, int _depth)
int getGeomId(HcalSubdetector _det, int _ieta, int _iphi, int _depth)

◆ getRawId() [2/2]

int HcalAssistant::getRawId ( int  _geomId)
private

Definition at line 243 of file HcalAssistant.cc.

243  {
244  if (listIsRead) {
245  std::map<int, int>::const_iterator _rawid = geom_to_rawid.find(_geomId);
246  if (_rawid != geom_to_rawid.end()) {
247  return _rawid->second;
248  } else
249  return -1;
250  } else
251  return -1;
252 }
std::map< int, int > geom_to_rawid
Definition: HcalAssistant.h:71

◆ getRawIdFromCmssw()

int HcalAssistant::getRawIdFromCmssw ( int  _geomId)
private

Definition at line 254 of file HcalAssistant.cc.

References DetId::rawId(), and AlCaHLTBitMon_QueryRunRegistry::string.

254  {
255  std::string s_det = getSubdetectorString(_geomId);
256  if (s_det.find("HB") != std::string::npos || s_det.find("HE") != std::string::npos ||
257  s_det.find("HF") != std::string::npos || s_det.find("HO") != std::string::npos ||
258  s_det.find("HT") != std::string::npos) {
259  HcalDetId _id(getSubdetector(s_det), getHcalIeta(_geomId), getHcalIphi(_geomId), getHcalDepth(_geomId));
260  return _id.rawId();
261  } else if (s_det.find("ZDC") != std::string::npos) {
262  // FIXME: implement for ZDC channels
263  return -1;
264  } else {
265  return -1;
266  }
267 }
std::string getSubdetectorString(HcalSubdetector _det)
int getHcalDepth(int _geomId)
int getHcalIeta(int _geomId)
HcalSubdetector getSubdetector(std::string _det)
int getHcalIphi(int _geomId)

◆ getSubdetector() [1/2]

HcalSubdetector HcalAssistant::getSubdetector ( std::string  _det)

Definition at line 140 of file HcalAssistant.cc.

References HcalBarrel, HcalEndcap, HcalForward, HcalOther, HcalOuter, and HcalTriggerTower.

140  {
141  if (_det.find("HB") != std::string::npos)
142  return HcalBarrel;
143  else if (_det.find("HE") != std::string::npos)
144  return HcalEndcap;
145  else if (_det.find("HF") != std::string::npos)
146  return HcalForward;
147  else if (_det.find("HO") != std::string::npos)
148  return HcalOuter;
149  else if (_det.find("HT") != std::string::npos)
150  return HcalTriggerTower;
151  else
152  return HcalOther;
153 }

◆ getSubdetector() [2/2]

int HcalAssistant::getSubdetector ( int  _rawid)

Definition at line 269 of file HcalAssistant.cc.

269 { return getHcalSubdetector(getGeomId(_rawid)); }
HcalSubdetector getHcalSubdetector(int _geomId)
int getGeomId(HcalSubdetector _det, int _ieta, int _iphi, int _depth)

◆ getSubdetectorString() [1/2]

std::string HcalAssistant::getSubdetectorString ( HcalSubdetector  _det)

Definition at line 155 of file HcalAssistant.cc.

References HcalBarrel, HcalEndcap, HcalForward, HcalOuter, HcalTriggerTower, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by EMap::EMap().

155  {
156  std::string sDet;
157  if (_det == HcalBarrel)
158  sDet = "HB";
159  else if (_det == HcalEndcap)
160  sDet = "HE";
161  else if (_det == HcalForward)
162  sDet = "HF";
163  else if (_det == HcalOuter)
164  sDet = "HO";
165  else if (_det == HcalTriggerTower)
166  sDet = "HT";
167  else
168  sDet = "other";
169  return sDet;
170 }

◆ getSubdetectorString() [2/2]

std::string HcalAssistant::getSubdetectorString ( int  _geomId)
private

Definition at line 118 of file HcalAssistant.cc.

References funct::abs(), and AlCaHLTBitMon_QueryRunRegistry::string.

118  {
119  int _det = abs(_geomId) % 10;
120  std::string s_det = "";
121  if (_det == 1)
122  s_det = "HB";
123  else if (_det == 2)
124  s_det = "HE";
125  else if (_det == 3)
126  s_det = "HO";
127  else if (_det == 4)
128  s_det = "HF";
129  else if (_det == 5)
130  s_det = "HT";
131  else if (_det == 6)
132  s_det = "ZDC";
133  else if (_det == 0)
134  s_det = "Empty";
135  else
136  s_det = "Other";
137  return s_det;
138 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ getUserName()

std::string HcalAssistant::getUserName ( void  )

Definition at line 71 of file HcalAssistant.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

71  {
72  struct passwd* _pwd = getpwuid(geteuid());
73  std::string _name(_pwd->pw_name);
74  return _name;
75 }

◆ getZDCSection()

HcalZDCDetId::Section HcalAssistant::getZDCSection ( std::string  _section)

Definition at line 187 of file HcalAssistant.cc.

References HcalZDCDetId::EM, HcalZDCDetId::HAD, HcalZDCDetId::LUM, HcalZDCDetId::RPD, and HcalZDCDetId::Unknown.

187  {
188  if (_section.find("ZDC EM") != std::string::npos)
189  return HcalZDCDetId::EM;
190  else if (_section.find("ZDC HAD") != std::string::npos)
191  return HcalZDCDetId::HAD;
192  else if (_section.find("ZDC LUM") != std::string::npos)
193  return HcalZDCDetId::LUM;
194  else if (_section.find("ZDC RPD") != std::string::npos)
195  return HcalZDCDetId::RPD;
196  else
197  return HcalZDCDetId::Unknown;
198 }

◆ getZDCSectionString()

std::string HcalAssistant::getZDCSectionString ( HcalZDCDetId::Section  _section)

Definition at line 172 of file HcalAssistant.cc.

References HcalZDCDetId::EM, HcalZDCDetId::HAD, HcalZDCDetId::LUM, HcalZDCDetId::RPD, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by EMap::EMap().

172  {
173  std::string zdcSection;
174  if (_section == HcalZDCDetId::EM)
175  zdcSection = "ZDC EM";
176  else if (_section == HcalZDCDetId::HAD)
177  zdcSection = "ZDC HAD";
178  else if (_section == HcalZDCDetId::LUM)
179  zdcSection = "ZDC LUM";
180  else if (_section == HcalZDCDetId::RPD)
181  zdcSection = "ZDC RPD";
182  else
183  zdcSection = "UNKNOWN";
184  return zdcSection;
185 }

Friends And Related Function Documentation

◆ HcalChannelQualityXml

friend class HcalChannelQualityXml
friend

Definition at line 45 of file HcalAssistant.h.

Member Data Documentation

◆ geom_to_rawid

std::map<int, int> HcalAssistant::geom_to_rawid
private

Definition at line 71 of file HcalAssistant.h.

◆ listIsRead

bool HcalAssistant::listIsRead
private

Definition at line 73 of file HcalAssistant.h.

◆ quotes

std::vector<std::string> HcalAssistant::quotes
private

Definition at line 70 of file HcalAssistant.h.

◆ rawid_to_geom

std::map<int, int> HcalAssistant::rawid_to_geom
private

Definition at line 72 of file HcalAssistant.h.