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;
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;
171 else zdcSection =
"UNKNOWN";
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;
190 query +=
" channel_map_id,subdet,ieta,iphi,depth ";
192 query +=
" cms_hcl_hcal_cond.hcal_channels ";
194 query +=
" subdet='HB' or subdet='HE' or subdet='HF' or subdet='HO' ";
196 oracle::occi::Statement* stmt = conn.
getStatement(query);
198 geom_to_rawid.clear();
199 rawid_to_geom.clear();
202 int _rawid = rs->getInt(1);
203 int _geomId = getGeomId( getSubdetector(rs->getString(2)),
208 geom_to_rawid.insert(std::pair<int, int>(_geomId, _rawid));
209 rawid_to_geom.insert(std::pair<int, int>(_rawid, _geomId));
215 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::
toolbox::toString(
"Oracle exception : %s",e.getMessage().c_str()));
224 std::map<int,int>::const_iterator _geomId = rawid_to_geom.find(_rawid);
225 if (_geomId!=rawid_to_geom.end()){
226 return _geomId->second;
237 std::map<int,int>::const_iterator _rawid = geom_to_rawid.find(_geomId);
238 if (_rawid!=geom_to_rawid.end()){
239 return _rawid->second;
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 )
256 getHcalIeta(_geomId),
257 getHcalIphi(_geomId),
258 getHcalDepth(_geomId)
262 else if ( s_det.find(
"ZDC") != std::string::npos )
274 return getHcalSubdetector( getGeomId(_rawid) );
279 return getHcalIeta( getGeomId(_rawid) );
285 return getHcalIphi( getGeomId(_rawid) );
291 return getHcalDepth( getGeomId(_rawid) );
297 return getRawId( getGeomId(_det, _ieta, _iphi, _depth) );
305 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)