17 #include <sys/types.h>
21 #include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabaseException.hh"
22 #include "xgi/Utils.h"
23 #include "toolbox/string.h"
28 using namespace oracle::occi;
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?");
70 int _quotes_array_size = quotes.size();
71 int _num =
rand()%_quotes_array_size;
77 struct passwd * _pwd = getpwuid(geteuid());
78 std::string _name(_pwd->pw_name);
98 int _ieta = _geomId/10000;
104 int _iphi =
abs( _geomId % 10000 )/100;
116 int _det =
abs(_geomId) % 10;
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";
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;
164 std::string zdcSection;
168 else zdcSection =
"UNKNOWN";
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;
186 std::string
query =
"select ";
187 query +=
" channel_map_id,subdet,ieta,iphi,depth ";
189 query +=
" cms_hcl_hcal_cond.hcal_channels ";
191 query +=
" subdet='HB' or subdet='HE' or subdet='HF' or subdet='HO' ";
193 oracle::occi::Statement* stmt = conn.
getStatement(query);
195 geom_to_rawid.clear();
196 rawid_to_geom.clear();
199 int _rawid = rs->getInt(1);
200 int _geomId = getGeomId( getSubdetector(rs->getString(2)),
205 geom_to_rawid.insert(std::pair<int, int>(_geomId, _rawid));
206 rawid_to_geom.insert(std::pair<int, int>(_rawid, _geomId));
212 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::
toolbox::toString(
"Oracle exception : %s",e.getMessage().c_str()));
221 std::map<int,int>::const_iterator _geomId = rawid_to_geom.find(_rawid);
222 if (_geomId!=rawid_to_geom.end()){
223 return _geomId->second;
234 std::map<int,int>::const_iterator _rawid = geom_to_rawid.find(_geomId);
235 if (_rawid!=geom_to_rawid.end()){
236 return _rawid->second;
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 )
253 getHcalIeta(_geomId),
254 getHcalIphi(_geomId),
255 getHcalDepth(_geomId)
259 else if ( s_det.find(
"ZDC") != std::string::npos )
271 return getHcalSubdetector( getGeomId(_rawid) );
276 return getHcalIeta( getGeomId(_rawid) );
282 return getHcalIphi( getGeomId(_rawid) );
288 return getHcalDepth( getGeomId(_rawid) );
294 return getRawId( getGeomId(_det, _ieta, _iphi, _depth) );
302 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)
HcalZDCDetId::Section getZDCSection(std::string _section)
std::string toString(const std::pair< T, T > &aT)
HcalSubdetector getSubdetector(std::string _det)
oracle::occi::ResultSet ResultSet
int getListOfChannelsFromDb()
int getHcalIphi(int _geomId)
std::string getUserName(void)