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

Constructor & Destructor Documentation

HcalAssistant::HcalAssistant ( )

Definition at line 33 of file HcalAssistant.cc.

References protons_cff::time.

34 {
35  addQuotes();
36  srand(time(nullptr));
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 305 of file HcalAssistant.cc.

References mps_fire::result.

305  {
306  int result;
307  sscanf(inbuf,"%d",&result);
308  return result;
309 }
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 292 of file HcalAssistant.cc.

292  {
293  return getHcalDepth( getGeomId(_rawid) );
294 }
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 224 of file HcalAssistant.cc.

224  {
225  if (listIsRead){
226  std::map<int,int>::const_iterator _geomId = rawid_to_geom.find(_rawid);
227  if (_geomId!=rawid_to_geom.end()){
228  return _geomId->second;
229  }
230  else return -1;
231  }
232  else return -1;
233 }
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 280 of file HcalAssistant.cc.

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

Definition at line 286 of file HcalAssistant.cc.

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

Definition at line 187 of file HcalAssistant.cc.

References MessageLogger_cfi::cerr, ConnectionManager::connect(), ConnectionManager::disconnect(), MillePedeFileConverter_cfg::e, ConnectionManager::getStatement(), AlCaHLTBitMon_QueryRunRegistry::string, toolbox::toString(), and toString().

187  {
188  int _n_channels = 0;
189  static ConnectionManager conn;
190  conn.connect();
191  std::string query = "select ";
192  query += " channel_map_id,subdet,ieta,iphi,depth ";
193  query += "from ";
194  query += " cms_hcl_hcal_cond.hcal_channels ";
195  query += "where ";
196  query += " subdet='HB' or subdet='HE' or subdet='HF' or subdet='HO' ";
197  try {
198  oracle::occi::Statement* stmt = conn.getStatement(query);
199  oracle::occi::ResultSet *rs = stmt->executeQuery();
200  geom_to_rawid.clear();
201  rawid_to_geom.clear();
202  while (rs->next()) {
203  _n_channels++;
204  int _rawid = rs->getInt(1);
205  int _geomId = getGeomId( getSubdetector(rs->getString(2)),
206  rs->getInt(3),
207  rs->getInt(4),
208  rs->getInt(5)
209  );
210  geom_to_rawid.insert(std::pair<int, int>(_geomId, _rawid));
211  rawid_to_geom.insert(std::pair<int, int>(_rawid, _geomId));
212  }
213  listIsRead = true;
214  }
215  catch (SQLException& e) {
216  std::cerr << ::toolbox::toString("Oracle exception : %s",e.getMessage().c_str()) << std::endl;
217  XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::toolbox::toString("Oracle exception : %s",e.getMessage().c_str()));
218  }
219  conn.disconnect();
220  return _n_channels;
221 }
oracle::occi::Statement * getStatement(const std::string &query)
Definition: query.py:1
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
std::string toString(const std::pair< T, T > &aT)
Definition: CaloEllipse.h:72
HcalSubdetector getSubdetector(std::string _det)
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 298 of file HcalAssistant.cc.

298  {
299  return getRawId( getGeomId(_det, _ieta, _iphi, _depth) );
300 }
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 237 of file HcalAssistant.cc.

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

Definition at line 249 of file HcalAssistant.cc.

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

249  {
250  std::string s_det = getSubdetectorString(_geomId);
251  if ( s_det.find("HB") != std::string::npos ||
252  s_det.find("HE") != std::string::npos ||
253  s_det.find("HF") != std::string::npos ||
254  s_det.find("HO") != std::string::npos ||
255  s_det.find("HT") != std::string::npos )
256  {
257  HcalDetId _id( getSubdetector(s_det),
258  getHcalIeta(_geomId),
259  getHcalIphi(_geomId),
260  getHcalDepth(_geomId)
261  );
262  return _id.rawId();
263  }
264  else if ( s_det.find("ZDC") != std::string::npos )
265  {
266  // FIXME: implement for ZDC channels
267  return -1;
268  }
269  else{
270  return -1;
271  }
272 }
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 275 of file HcalAssistant.cc.

275  {
276  return getHcalSubdetector( getGeomId(_rawid) );
277 }
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 177 of file HcalAssistant.cc.

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

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

Definition at line 166 of file HcalAssistant.cc.

References HcalZDCDetId::EM, HcalZDCDetId::HAD, HcalZDCDetId::LUM, HcalZDCDetId::RPD, 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 if ( _section==HcalZDCDetId::RPD) zdcSection = "ZDC RPD";
172  else zdcSection = "UNKNOWN";
173  return zdcSection;
174 }

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.