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 36 of file HcalAssistant.h.

Constructor & Destructor Documentation

HcalAssistant::HcalAssistant ( )

Definition at line 30 of file HcalAssistant.cc.

References cond::rpcobgas::time.

31 {
32  addQuotes();
33  srand(time(0));
34  listIsRead = false;
35 }
HcalAssistant::~HcalAssistant ( )
virtual

Definition at line 38 of file HcalAssistant.cc.

39 {
40 }

Member Function Documentation

int HcalAssistant::a_to_i ( char *  inbuf)

Definition at line 300 of file HcalAssistant.cc.

References query::result.

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

Definition at line 43 of file HcalAssistant.cc.

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

Definition at line 287 of file HcalAssistant.cc.

287  {
288  return getHcalDepth( getGeomId(_rawid) );
289 }
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 84 of file HcalAssistant.cc.

References abs.

84  {
85  int _geomId =
86  _det
87  + 10 * _depth
88  + 100 * _iphi
89  +10000 * abs(_ieta);
90  if (_ieta<0){
91  _geomId = -_geomId;
92  }
93  return _geomId;
94 }
#define abs(x)
Definition: mlp_lapack.h:159
#define _depth
Definition: Pythia6jets.h:5
int HcalAssistant::getGeomId ( int  _rawid)
private

Definition at line 219 of file HcalAssistant.cc.

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

Definition at line 109 of file HcalAssistant.cc.

References _depth, and abs.

109  {
110  int _depth = abs( _geomId % 100 ) / 10;
111  return _depth;
112 }
#define abs(x)
Definition: mlp_lapack.h:159
#define _depth
Definition: Pythia6jets.h:5
int HcalAssistant::getHcalIeta ( int  _geomId)
private

Definition at line 97 of file HcalAssistant.cc.

97  {
98  int _ieta = _geomId/10000;
99  return _ieta;
100 }
int HcalAssistant::getHcalIphi ( int  _geomId)
private

Definition at line 103 of file HcalAssistant.cc.

References abs.

103  {
104  int _iphi = abs( _geomId % 10000 )/100;
105  return _iphi;
106 }
#define abs(x)
Definition: mlp_lapack.h:159
HcalSubdetector HcalAssistant::getHcalSubdetector ( int  _geomId)
private

Definition at line 115 of file HcalAssistant.cc.

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

115  {
116  int _det = abs(_geomId) % 10;
117  if (_det==1) return HcalBarrel;
118  else if (_det==2) return HcalEndcap;
119  else if (_det==3) return HcalOuter;
120  else if (_det==4) return HcalForward;
121  else if (_det==5) return HcalTriggerTower;
122  else if (_det==0) return HcalEmpty;
123  else return HcalOther;
124 }
#define abs(x)
Definition: mlp_lapack.h:159
int HcalAssistant::getIeta ( int  _rawid)

Definition at line 275 of file HcalAssistant.cc.

275  {
276  return getHcalIeta( getGeomId(_rawid) );
277 }
int getGeomId(HcalSubdetector _det, int _ieta, int _iphi, int _depth)
int getHcalIeta(int _geomId)
int HcalAssistant::getIphi ( int  _rawid)

Definition at line 281 of file HcalAssistant.cc.

281  {
282  return getHcalIphi( getGeomId(_rawid) );
283 }
int getGeomId(HcalSubdetector _det, int _ieta, int _iphi, int _depth)
int getHcalIphi(int _geomId)
int HcalAssistant::getListOfChannelsFromDb ( )

Definition at line 182 of file HcalAssistant.cc.

References dtNoiseDBValidation_cfg::cerr, results_mgr::conn, ConnectionManager::connect(), ConnectionManager::disconnect(), alignCSCRings::e, ConnectionManager::getStatement(), o2o::query, AlCaHLTBitMon_QueryRunRegistry::string, and toString().

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

Definition at line 69 of file HcalAssistant.cc.

References rand().

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

Definition at line 293 of file HcalAssistant.cc.

293  {
294  return getRawId( getGeomId(_det, _ieta, _iphi, _depth) );
295 }
#define _depth
Definition: Pythia6jets.h:5
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 232 of file HcalAssistant.cc.

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

Definition at line 244 of file HcalAssistant.cc.

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

244  {
245  std::string s_det = getSubdetectorString(_geomId);
246  if ( s_det.find("HB") != std::string::npos ||
247  s_det.find("HE") != std::string::npos ||
248  s_det.find("HF") != std::string::npos ||
249  s_det.find("HO") != std::string::npos ||
250  s_det.find("HT") != std::string::npos )
251  {
252  HcalDetId _id( getSubdetector(s_det),
253  getHcalIeta(_geomId),
254  getHcalIphi(_geomId),
255  getHcalDepth(_geomId)
256  );
257  return _id.rawId();
258  }
259  else if ( s_det.find("ZDC") != std::string::npos )
260  {
261  // FIXME: implement for ZDC channels
262  return -1;
263  }
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)
HcalSubdetector HcalAssistant::getSubdetector ( std::string  _det)

Definition at line 142 of file HcalAssistant.cc.

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

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

Definition at line 270 of file HcalAssistant.cc.

270  {
271  return getHcalSubdetector( getGeomId(_rawid) );
272 }
HcalSubdetector getHcalSubdetector(int _geomId)
int getGeomId(HcalSubdetector _det, int _ieta, int _iphi, int _depth)
std::string HcalAssistant::getSubdetectorString ( HcalSubdetector  _det)

Definition at line 151 of file HcalAssistant.cc.

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

Referenced by EMap::EMap().

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

Definition at line 127 of file HcalAssistant.cc.

References abs, and AlCaHLTBitMon_QueryRunRegistry::string.

127  {
128  int _det = abs(_geomId) % 10;
129  std::string s_det = "";
130  if (_det==1) s_det = "HB";
131  else if (_det==2) s_det = "HE";
132  else if (_det==3) s_det = "HO";
133  else if (_det==4) s_det = "HF";
134  else if (_det==5) s_det = "HT";
135  else if (_det==6) s_det = "ZDC";
136  else if (_det==0) s_det = "Empty";
137  else s_det = "Other";
138  return s_det;
139 }
#define abs(x)
Definition: mlp_lapack.h:159
std::string HcalAssistant::getUserName ( void  )

Definition at line 76 of file HcalAssistant.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 173 of file HcalAssistant.cc.

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

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

Definition at line 163 of file HcalAssistant.cc.

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

Referenced by EMap::EMap().

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

Friends And Related Function Documentation

friend class HcalChannelQualityXml
friend

Definition at line 40 of file HcalAssistant.h.

Member Data Documentation

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

Definition at line 66 of file HcalAssistant.h.

bool HcalAssistant::listIsRead
private

Definition at line 68 of file HcalAssistant.h.

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

Definition at line 65 of file HcalAssistant.h.

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

Definition at line 67 of file HcalAssistant.h.