CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 35 of file HcalAssistant.h.

Constructor & Destructor Documentation

HcalAssistant::HcalAssistant ( )

Definition at line 33 of file HcalAssistant.cc.

34 {
35  addQuotes();
36  srand(time(0));
37  listIsRead = false;
38 }
HcalAssistant::~HcalAssistant ( )
virtual

Definition at line 41 of file HcalAssistant.cc.

42 {
43 }

Member Function Documentation

int HcalAssistant::a_to_i ( char *  inbuf)

Definition at line 303 of file HcalAssistant.cc.

References query::result.

303  {
304  int result;
305  sscanf(inbuf,"%d",&result);
306  return result;
307 }
tuple result
Definition: query.py:137
int HcalAssistant::addQuotes ( )

Definition at line 46 of file HcalAssistant.cc.

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

Definition at line 290 of file HcalAssistant.cc.

290  {
291  return getHcalDepth( getGeomId(_rawid) );
292 }
int getHcalDepth(int _geomId)
int getGeomId(HcalSubdetector _det, int _ieta, int _iphi, int _depth)
int HcalAssistant::getGeomId ( HcalSubdetector  _det,
int  _ieta,
int  _iphi,
int  _depth 
)
private

Definition at line 87 of file HcalAssistant.cc.

References funct::abs().

87  {
88  int _geomId =
89  _det
90  + 10 * _depth
91  + 100 * _iphi
92  +10000 * abs(_ieta);
93  if (_ieta<0){
94  _geomId = -_geomId;
95  }
96  return _geomId;
97 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int HcalAssistant::getGeomId ( int  _rawid)
private

Definition at line 222 of file HcalAssistant.cc.

222  {
223  if (listIsRead){
224  std::map<int,int>::const_iterator _geomId = rawid_to_geom.find(_rawid);
225  if (_geomId!=rawid_to_geom.end()){
226  return _geomId->second;
227  }
228  else return -1;
229  }
230  else return -1;
231 }
std::map< int, int > rawid_to_geom
Definition: HcalAssistant.h:66
int HcalAssistant::getHcalDepth ( int  _geomId)
private

Definition at line 112 of file HcalAssistant.cc.

References funct::abs().

112  {
113  int _depth = abs( _geomId % 100 ) / 10;
114  return _depth;
115 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int HcalAssistant::getHcalIeta ( int  _geomId)
private

Definition at line 100 of file HcalAssistant.cc.

100  {
101  int _ieta = _geomId/10000;
102  return _ieta;
103 }
int HcalAssistant::getHcalIphi ( int  _geomId)
private

Definition at line 106 of file HcalAssistant.cc.

References funct::abs().

106  {
107  int _iphi = abs( _geomId % 10000 )/100;
108  return _iphi;
109 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HcalSubdetector HcalAssistant::getHcalSubdetector ( int  _geomId)
private

Definition at line 118 of file HcalAssistant.cc.

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

118  {
119  int _det = abs(_geomId) % 10;
120  if (_det==1) return HcalBarrel;
121  else if (_det==2) return HcalEndcap;
122  else if (_det==3) return HcalOuter;
123  else if (_det==4) return HcalForward;
124  else if (_det==5) return HcalTriggerTower;
125  else if (_det==0) return HcalEmpty;
126  else return HcalOther;
127 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int HcalAssistant::getIeta ( int  _rawid)

Definition at line 278 of file HcalAssistant.cc.

278  {
279  return getHcalIeta( getGeomId(_rawid) );
280 }
int getGeomId(HcalSubdetector _det, int _ieta, int _iphi, int _depth)
int getHcalIeta(int _geomId)
int HcalAssistant::getIphi ( int  _rawid)

Definition at line 284 of file HcalAssistant.cc.

284  {
285  return getHcalIphi( getGeomId(_rawid) );
286 }
int getGeomId(HcalSubdetector _det, int _ieta, int _iphi, int _depth)
int getHcalIphi(int _geomId)
int HcalAssistant::getListOfChannelsFromDb ( )

Definition at line 185 of file HcalAssistant.cc.

References ecal_dqm_sourceclient-live_cfg::cerr, ConnectionManager::connect(), ConnectionManager::disconnect(), alignCSCRings::e, ConnectionManager::getStatement(), o2o::query, AlCaHLTBitMon_QueryRunRegistry::string, and toolbox::toString().

185  {
186  int _n_channels = 0;
187  static ConnectionManager conn;
188  conn.connect();
189  std::string query = "select ";
190  query += " channel_map_id,subdet,ieta,iphi,depth ";
191  query += "from ";
192  query += " cms_hcl_hcal_cond.hcal_channels ";
193  query += "where ";
194  query += " subdet='HB' or subdet='HE' or subdet='HF' or subdet='HO' ";
195  try {
196  oracle::occi::Statement* stmt = conn.getStatement(query);
197  oracle::occi::ResultSet *rs = stmt->executeQuery();
198  geom_to_rawid.clear();
199  rawid_to_geom.clear();
200  while (rs->next()) {
201  _n_channels++;
202  int _rawid = rs->getInt(1);
203  int _geomId = getGeomId( getSubdetector(rs->getString(2)),
204  rs->getInt(3),
205  rs->getInt(4),
206  rs->getInt(5)
207  );
208  geom_to_rawid.insert(std::pair<int, int>(_geomId, _rawid));
209  rawid_to_geom.insert(std::pair<int, int>(_rawid, _geomId));
210  }
211  listIsRead = true;
212  }
213  catch (SQLException& e) {
214  std::cerr << ::toolbox::toString("Oracle exception : %s",e.getMessage().c_str()) << std::endl;
215  XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::toolbox::toString("Oracle exception : %s",e.getMessage().c_str()));
216  }
217  conn.disconnect();
218  return _n_channels;
219 }
oracle::occi::Statement * getStatement(const std::string &query)
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
int getGeomId(HcalSubdetector _det, int _ieta, int _iphi, int _depth)
std::map< int, int > geom_to_rawid
Definition: HcalAssistant.h:65
std::string toString(const char *format,...)
Definition: xdaq_compat.cc:4
std::map< int, int > rawid_to_geom
Definition: HcalAssistant.h:66
HcalSubdetector getSubdetector(std::string _det)
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
tuple query
Definition: o2o.py:269
std::string HcalAssistant::getRandomQuote ( void  )

Definition at line 72 of file HcalAssistant.cc.

References rand().

72  {
73  int _quotes_array_size = quotes.size();
74  int _num = rand()%_quotes_array_size;
75  return quotes[_num];
76 }
Signal rand(Signal arg)
Definition: vlib.cc:442
std::vector< std::string > quotes
Definition: HcalAssistant.h:64
int HcalAssistant::getRawId ( HcalSubdetector  _det,
int  _ieta,
int  _iphi,
int  _depth 
)

Definition at line 296 of file HcalAssistant.cc.

296  {
297  return getRawId( getGeomId(_det, _ieta, _iphi, _depth) );
298 }
int getRawId(HcalSubdetector _det, int _ieta, int _iphi, int _depth)
int getGeomId(HcalSubdetector _det, int _ieta, int _iphi, int _depth)
int HcalAssistant::getRawId ( int  _geomId)
private

Definition at line 235 of file HcalAssistant.cc.

235  {
236  if (listIsRead){
237  std::map<int,int>::const_iterator _rawid = geom_to_rawid.find(_geomId);
238  if (_rawid!=geom_to_rawid.end()){
239  return _rawid->second;
240  }
241  else return -1;
242  }
243  else return -1;
244 }
std::map< int, int > geom_to_rawid
Definition: HcalAssistant.h:65
int HcalAssistant::getRawIdFromCmssw ( int  _geomId)
private

Definition at line 247 of file HcalAssistant.cc.

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

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

Definition at line 145 of file HcalAssistant.cc.

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

145  {
146  if ( _det.find("HB") != std::string::npos ) return HcalBarrel;
147  else if ( _det.find("HE") != std::string::npos ) return HcalEndcap;
148  else if ( _det.find("HF") != std::string::npos ) return HcalForward;
149  else if ( _det.find("HO") != std::string::npos ) return HcalOuter;
150  else if ( _det.find("HT") != std::string::npos ) return HcalTriggerTower;
151  else return HcalOther;
152 }
int HcalAssistant::getSubdetector ( int  _rawid)

Definition at line 273 of file HcalAssistant.cc.

273  {
274  return getHcalSubdetector( getGeomId(_rawid) );
275 }
HcalSubdetector getHcalSubdetector(int _geomId)
int getGeomId(HcalSubdetector _det, int _ieta, int _iphi, int _depth)
std::string HcalAssistant::getSubdetectorString ( HcalSubdetector  _det)

Definition at line 154 of file HcalAssistant.cc.

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

Referenced by EMap::EMap().

154  {
155  std::string sDet;
156  if ( _det==HcalBarrel) sDet = "HB";
157  else if ( _det==HcalEndcap) sDet = "HE";
158  else if ( _det==HcalForward) sDet = "HF";
159  else if ( _det==HcalOuter) sDet = "HO";
160  else if ( _det==HcalTriggerTower) sDet = "HT";
161  else sDet = "other";
162  return sDet;
163 }
std::string HcalAssistant::getSubdetectorString ( int  _geomId)
private

Definition at line 130 of file HcalAssistant.cc.

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

130  {
131  int _det = abs(_geomId) % 10;
132  std::string s_det = "";
133  if (_det==1) s_det = "HB";
134  else if (_det==2) s_det = "HE";
135  else if (_det==3) s_det = "HO";
136  else if (_det==4) s_det = "HF";
137  else if (_det==5) s_det = "HT";
138  else if (_det==6) s_det = "ZDC";
139  else if (_det==0) s_det = "Empty";
140  else s_det = "Other";
141  return s_det;
142 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::string HcalAssistant::getUserName ( void  )

Definition at line 79 of file HcalAssistant.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

79  {
80  struct passwd * _pwd = getpwuid(geteuid());
81  std::string _name(_pwd->pw_name);
82  return _name;
83 }
HcalZDCDetId::Section HcalAssistant::getZDCSection ( std::string  _section)

Definition at line 176 of file HcalAssistant.cc.

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

176  {
177  if ( _section.find("ZDC EM") != std::string::npos ) return HcalZDCDetId::EM;
178  else if ( _section.find("ZDC HAD") != std::string::npos ) return HcalZDCDetId::HAD;
179  else if ( _section.find("ZDC LUM") != std::string::npos ) return HcalZDCDetId::LUM;
180  else return HcalZDCDetId::Unknown;
181 }
std::string HcalAssistant::getZDCSectionString ( HcalZDCDetId::Section  _section)

Definition at line 166 of file HcalAssistant.cc.

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

Referenced by EMap::EMap().

166  {
167  std::string zdcSection;
168  if ( _section==HcalZDCDetId::EM) zdcSection = "ZDC EM";
169  else if ( _section==HcalZDCDetId::HAD) zdcSection = "ZDC HAD";
170  else if ( _section==HcalZDCDetId::LUM) zdcSection = "ZDC LUM";
171  else zdcSection = "UNKNOWN";
172  return zdcSection;
173 }

Friends And Related Function Documentation

friend class HcalChannelQualityXml
friend

Definition at line 39 of file HcalAssistant.h.

Member Data Documentation

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

Definition at line 65 of file HcalAssistant.h.

bool HcalAssistant::listIsRead
private

Definition at line 67 of file HcalAssistant.h.

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

Definition at line 64 of file HcalAssistant.h.

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

Definition at line 66 of file HcalAssistant.h.