16 #include <sys/types.h>
20 #include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabaseException.hh"
25 #include <toolbox/string.h>
31 using namespace oracle::occi;
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?");
73 int _quotes_array_size = quotes.size();
74 int _num =
rand()%_quotes_array_size;
80 struct passwd * _pwd = getpwuid(geteuid());
101 int _ieta = _geomId/10000;
107 int _iphi =
abs( _geomId % 10000 )/100;
113 int _depth =
abs( _geomId % 100 ) / 10;
119 int _det =
abs(_geomId) % 10;
131 int _det =
abs(_geomId) % 10;
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";
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;
172 else zdcSection =
"UNKNOWN";
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;
192 query +=
" channel_map_id,subdet,ieta,iphi,depth ";
194 query +=
" cms_hcl_hcal_cond.hcal_channels ";
196 query +=
" subdet='HB' or subdet='HE' or subdet='HF' or subdet='HO' ";
198 oracle::occi::Statement* stmt = conn.
getStatement(query);
200 geom_to_rawid.clear();
201 rawid_to_geom.clear();
204 int _rawid = rs->getInt(1);
205 int _geomId = getGeomId( getSubdetector(rs->getString(2)),
210 geom_to_rawid.insert(std::pair<int, int>(_geomId, _rawid));
211 rawid_to_geom.insert(std::pair<int, int>(_rawid, _geomId));
217 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::
toolbox::toString(
"Oracle exception : %s",e.getMessage().c_str()));
226 std::map<int,int>::const_iterator _geomId = rawid_to_geom.find(_rawid);
227 if (_geomId!=rawid_to_geom.end()){
228 return _geomId->second;
239 std::map<int,int>::const_iterator _rawid = geom_to_rawid.find(_geomId);
240 if (_rawid!=geom_to_rawid.end()){
241 return _rawid->second;
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 )
258 getHcalIeta(_geomId),
259 getHcalIphi(_geomId),
260 getHcalDepth(_geomId)
264 else if ( s_det.find(
"ZDC") != std::string::npos )
276 return getHcalSubdetector( getGeomId(_rawid) );
281 return getHcalIeta( getGeomId(_rawid) );
287 return getHcalIphi( getGeomId(_rawid) );
293 return getHcalDepth( getGeomId(_rawid) );
299 return getRawId( getGeomId(_det, _ieta, _iphi, _depth) );
307 sscanf(inbuf,
"%d",&result);
std::string getSubdetectorString(HcalSubdetector _det)
HcalSubdetector getHcalSubdetector(int _geomId)
int getHcalDepth(int _geomId)
std::string getRandomQuote(void)
std::string getZDCSectionString(HcalZDCDetId::Section _section)
oracle::occi::Statement * getStatement(const std::string &query)
int getRawIdFromCmssw(int _geomId)
oracle::occi::SQLException SQLException
int getRawId(HcalSubdetector _det, int _ieta, int _iphi, int _depth)
uint32_t rawId() const
get the raw id
int getGeomId(HcalSubdetector _det, int _ieta, int _iphi, int _depth)
int getHcalIeta(int _geomId)
Abs< T >::type abs(const T &t)
HcalZDCDetId::Section getZDCSection(std::string _section)
HcalSubdetector getSubdetector(std::string _det)
oracle::occi::ResultSet ResultSet
int getListOfChannelsFromDb()
int getHcalIphi(int _geomId)
std::string getUserName(void)