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)
 
int getSubdetector (int _rawid)
 
HcalSubdetector getSubdetector (std::string _det)
 
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.

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

References protons_cff::time.

◆ ~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.

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

References mps_fire::result.

◆ 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 }

◆ getDepth()

int HcalAssistant::getDepth ( int  _rawid)

Definition at line 275 of file HcalAssistant.cc.

275 { return getHcalDepth(getGeomId(_rawid)); }

◆ getGeomId() [1/2]

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

Definition at line 77 of file HcalAssistant.cc.

77  {
78  int _geomId = _det + 10 * _depth + 100 * _iphi + 10000 * abs(_ieta);
79  if (_ieta < 0) {
80  _geomId = -_geomId;
81  }
82  return _geomId;
83 }

References funct::abs().

◆ 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 }

◆ getHcalDepth()

int HcalAssistant::getHcalDepth ( int  _geomId)
private

Definition at line 95 of file HcalAssistant.cc.

95  {
96  int _depth = abs(_geomId % 100) / 10;
97  return _depth;
98 }

References funct::abs().

◆ 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.

90  {
91  int _iphi = abs(_geomId % 10000) / 100;
92  return _iphi;
93 }

References funct::abs().

◆ getHcalSubdetector()

HcalSubdetector HcalAssistant::getHcalSubdetector ( int  _geomId)
private

Definition at line 100 of file HcalAssistant.cc.

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 }

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

◆ getIeta()

int HcalAssistant::getIeta ( int  _rawid)

Definition at line 271 of file HcalAssistant.cc.

271 { return getHcalIeta(getGeomId(_rawid)); }

◆ getIphi()

int HcalAssistant::getIphi ( int  _rawid)

Definition at line 273 of file HcalAssistant.cc.

273 { return getHcalIphi(getGeomId(_rawid)); }

◆ getListOfChannelsFromDb()

int HcalAssistant::getListOfChannelsFromDb ( )

Definition at line 200 of file HcalAssistant.cc.

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 }

References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, SiStripCommissioningClient_cfg::conn, MillePedeFileConverter_cfg::e, AlCaHLTBitMon_QueryRunRegistry::string, and toolbox::toString().

◆ 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 }

◆ 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 }

◆ 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 }

◆ getRawIdFromCmssw()

int HcalAssistant::getRawIdFromCmssw ( int  _geomId)
private

Definition at line 254 of file HcalAssistant.cc.

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 }

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

◆ getSubdetector() [1/2]

int HcalAssistant::getSubdetector ( int  _rawid)

Definition at line 269 of file HcalAssistant.cc.

269 { return getHcalSubdetector(getGeomId(_rawid)); }

◆ getSubdetector() [2/2]

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

Definition at line 140 of file HcalAssistant.cc.

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 }

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

◆ getSubdetectorString() [1/2]

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

Definition at line 155 of file HcalAssistant.cc.

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 }

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

Referenced by EMap::EMap().

◆ getSubdetectorString() [2/2]

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

Definition at line 118 of file HcalAssistant.cc.

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 }

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

◆ getUserName()

std::string HcalAssistant::getUserName ( void  )

Definition at line 71 of file HcalAssistant.cc.

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

References AlCaHLTBitMon_QueryRunRegistry::string.

◆ getZDCSection()

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

Definition at line 187 of file HcalAssistant.cc.

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 }

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

◆ getZDCSectionString()

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

Definition at line 172 of file HcalAssistant.cc.

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 }

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

Referenced by EMap::EMap().

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.

HcalAssistant::rawid_to_geom
std::map< int, int > rawid_to_geom
Definition: HcalAssistant.h:72
HcalOther
Definition: HcalAssistant.h:38
HcalAssistant::getHcalDepth
int getHcalDepth(int _geomId)
Definition: HcalAssistant.cc:95
HcalAssistant::getRawId
int getRawId(HcalSubdetector _det, int _ieta, int _iphi, int _depth)
Definition: HcalAssistant.cc:277
HcalZDCDetId::HAD
Definition: HcalZDCDetId.h:23
SiStripCommissioningClient_cfg.conn
conn
Definition: SiStripCommissioningClient_cfg.py:5
protons_cff.time
time
Definition: protons_cff.py:39
HcalBarrel
Definition: HcalAssistant.h:33
HcalEmpty
Definition: HcalAssistant.h:32
HcalAssistant::getHcalIphi
int getHcalIphi(int _geomId)
Definition: HcalAssistant.cc:90
HcalAssistant::addQuotes
int addQuotes()
Definition: HcalAssistant.cc:40
HcalAssistant::getGeomId
int getGeomId(HcalSubdetector _det, int _ieta, int _iphi, int _depth)
Definition: HcalAssistant.cc:77
HcalAssistant::getHcalSubdetector
HcalSubdetector getHcalSubdetector(int _geomId)
Definition: HcalAssistant.cc:100
toolbox::toString
std::string toString(const char *format,...)
Definition: xdaq_compat.cc:4
query
Definition: query.py:1
HcalOuter
Definition: HcalAssistant.h:35
HcalAssistant::quotes
std::vector< std::string > quotes
Definition: HcalAssistant.h:70
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HcalAssistant::geom_to_rawid
std::map< int, int > geom_to_rawid
Definition: HcalAssistant.h:71
HcalZDCDetId::RPD
Definition: HcalZDCDetId.h:23
HcalZDCDetId::Unknown
Definition: HcalZDCDetId.h:23
HcalAssistant::getSubdetector
HcalSubdetector getSubdetector(std::string _det)
Definition: HcalAssistant.cc:140
HcalDetId
Definition: HcalDetId.h:12
HcalAssistant::listIsRead
bool listIsRead
Definition: HcalAssistant.h:73
ConnectionManager
Definition: ConnectionManager.h:14
HcalAssistant::getSubdetectorString
std::string getSubdetectorString(HcalSubdetector _det)
Definition: HcalAssistant.cc:155
HcalForward
Definition: HcalAssistant.h:36
HcalEndcap
Definition: HcalAssistant.h:34
HcalTriggerTower
Definition: HcalAssistant.h:37
HcalZDCDetId::LUM
Definition: HcalZDCDetId.h:23
mps_fire.result
result
Definition: mps_fire.py:311
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
HcalZDCDetId::EM
Definition: HcalZDCDetId.h:23
HcalAssistant::getHcalIeta
int getHcalIeta(int _geomId)
Definition: HcalAssistant.cc:85
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37