6 using namespace oracle::occi;
21 const std::string _accessor =
"occi://CMS_HCL_PRTTYPE_HCAL_READER@anyhost/int2r?PASSWORD=HCAL_Reader_88,LHWM_VERSION=22";
24 oracle::occi::Connection * myConn = db -> getConnection();
30 sstemp<<
"'"<<LMversion<<
"'";
35 Statement* stmt = myConn -> createStatement();
38 query +=
" H.SIDE, H.ETA, H.PHI, ";
39 query +=
" H.DELTA_PHI, H.DEPTH, H.SUBDETECTOR, H.RBX, H.WEDGE, ";
40 query +=
" H.SECTOR, H.RM_SLOT, H.HPD_PIXEL, H.QIE_SLOT, H.ADC, ";
41 query +=
" H.RM_FIBER, H.FIBER_CHANNEL, H.LETTER_CODE, H.CRATE, H.HTR_SLOT, ";
42 query +=
" H.HTR_FPGA, H.HTR_FIBER, H.DCC_SL, H.SPIGOT, H.DCC_SLOT, ";
43 query +=
" H.SLB_SITE, H.SLB_CHANNEL, H.SLB_CHANNEL2, H.SLB_CABLE, H.RCT_CRATE, ";
44 query +=
" H.RCT_CARD, H.RCT_CONNECTOR, H.RCT_NAME, H.FED_ID ";
45 query +=
" FROM CMS_HCL_HCAL_CONDITION_OWNER.HCAL_HARDWARE_LOGICAL_MAPS_V3 H inner join ";
46 query +=
" CMS_HCL_CORE_CONDITION_OWNER.COND_DATA_SETS C ";
47 query +=
" on C.CONDITION_DATA_SET_ID=H.CONDITION_DATA_SET_ID ";
48 query +=
" inner join CMS_HCL_CORE_CONDITION_OWNER.KINDS_OF_CONDITIONS K ";
49 query +=
" on K.KIND_OF_CONDITION_ID=C.KIND_OF_CONDITION_ID ";
50 query +=
" where C.IS_RECORD_DELETED='F' and K.IS_RECORD_DELETED='F' ";
51 query +=
" and K.NAME='HCAL hardware logical channel maps v3' ";
52 query +=
" and C.VERSION=";
56 ResultSet *rs = stmt->executeQuery(query.c_str());
58 while (rs->next() && CHAcount < 10000) {
60 lmapHBEFO -> versionC . push_back( rs ->
getInt(1) );
61 lmapHBEFO -> sideC . push_back( rs ->
getInt(2) );
62 lmapHBEFO -> etaC . push_back( rs ->
getInt(3) );
63 lmapHBEFO -> phiC . push_back( rs ->
getInt(4) );
64 lmapHBEFO -> dphiC . push_back( rs ->
getInt(5) );
66 lmapHBEFO -> depthC . push_back( rs ->
getInt(6) );
67 lmapHBEFO -> detC . push_back( rs -> getString(7) );
68 lmapHBEFO -> rbxC . push_back( rs -> getString(8) );
69 lmapHBEFO -> wedgeC . push_back( rs ->
getInt(9) );
70 lmapHBEFO -> sectorC . push_back( rs ->
getInt(10) );
72 lmapHBEFO -> rmC . push_back( rs ->
getInt(11) );
73 lmapHBEFO -> pixelC . push_back( rs ->
getInt(12) );
74 lmapHBEFO -> qieC . push_back( rs ->
getInt(13) );
75 lmapHBEFO -> adcC . push_back( rs ->
getInt(14) );
76 lmapHBEFO -> rm_fiC . push_back( rs ->
getInt(15) );
78 lmapHBEFO -> fi_chC . push_back( rs ->
getInt(16) );
79 lmapHBEFO -> let_codeC . push_back( rs -> getString(17) );
80 lmapHBEFO -> crateC . push_back( rs ->
getInt(18) );
81 lmapHBEFO -> htrC . push_back( rs ->
getInt(19) );
82 lmapHBEFO -> fpgaC . push_back( rs -> getString(20) );
84 lmapHBEFO -> htr_fiC . push_back( rs ->
getInt(21) );
85 lmapHBEFO -> dcc_slC . push_back( rs ->
getInt(22) );
86 lmapHBEFO -> spigoC . push_back( rs ->
getInt(23) );
87 lmapHBEFO -> dccC . push_back( rs ->
getInt(24) );
88 lmapHBEFO -> slbC . push_back( rs ->
getInt(25) );
90 lmapHBEFO -> slbinC . push_back( rs -> getString(26) );
91 lmapHBEFO -> slbin2C . push_back( rs -> getString(27) );
92 lmapHBEFO -> slnamC . push_back( rs -> getString(28) );
93 lmapHBEFO -> rctcraC . push_back( rs ->
getInt(29) );
94 lmapHBEFO -> rctcarC . push_back( rs ->
getInt(30) );
96 lmapHBEFO -> rctconC . push_back( rs ->
getInt(31) );
97 lmapHBEFO -> rctnamC . push_back( rs -> getString(32) );
98 lmapHBEFO -> fedidC . push_back( rs ->
getInt(33) );
100 lmapHBEFO -> orderC . push_back( CHAcount );
105 myConn -> terminateStatement(stmt);
108 std::cout<<
"Couldn't get statement"<<std::endl;
117 int CHAcount = lmapHBEFO->
orderC.size();
120 for (
i = 0;
i < CHAcount;
i++){
121 if (lmapHBEFO -> orderC[
i] >= CHAcount){
126 if (lmapHBEFO -> detC[lmapHBEFO -> orderC[
i]] !=
"HO")
printHBHEHF(
i, HBEFmap, lmapHBEFO);
130 for (
i = 0;
i < CHAcount;
i++){
131 if (lmapHBEFO -> orderC[
i] >= CHAcount){
135 if (lmapHBEFO -> detC[lmapHBEFO -> orderC[
i]] ==
"HO")
printHO(
i, HOmap, lmapHBEFO);
144 int CHAcount = lmapHBEFO->
orderC.size();
147 for (
i = 0;
i < CHAcount;
i++){
148 if (lmapHBEFO ->detC[lmapHBEFO -> orderC[
i]] !=
"HO")
printEMAProw(
i, emap, lmapHBEFO);
152 for (
i = 0;
i < CHAcount;
i++){
153 if (lmapHBEFO -> detC[lmapHBEFO -> orderC[
i]] ==
"HO")
printEMAProw(
i, emap, lmapHBEFO);
162 if (channel % 21 == 0){
163 fprintf(HBEFmap,
"# side eta phi dphi depth det rbx wedge rm pixel qie adc");
164 fprintf(HBEFmap,
" rm_fi fi_ch crate htr fpga htr_fi dcc_sl spigo dcc slb slbin slbin2");
165 fprintf(HBEFmap,
" slnam rctcra rctcar rctcon rctnam fedid\n");
168 j = lmap -> orderC[channel];
170 fprintf(HBEFmap,
"%6d %6d %6d %6d %6d ", lmap->
sideC[
j], lmap->
etaC[
j], lmap->
phiC[
j], lmap->
dphiC[
j], lmap -> depthC[
j]);
171 fprintf(HBEFmap,
"%6s %7s %6d %6d %6d", lmap->
detC[j].c_str(), lmap->
rbxC[
j].c_str(), lmap->
wedgeC[
j], lmap->
rmC[
j], lmap->
pixelC[
j]);
174 fprintf(HBEFmap,
"%6d %6d %6d %6s", lmap->
spigoC[j], lmap->
dccC[j], lmap->
slbC[j], lmap->
slbinC[j].c_str());
181 if (channel % 21 == 3){
182 fprintf(HOmap,
"# side eta phi dphi depth det rbx sector rm pixel qie adc");
183 fprintf(HOmap,
" rm_fi fi_ch let_code crate htr fpga htr_fi dcc_sl spigo dcc slb slbin slbin2");
184 fprintf(HOmap,
" slnam rctcra rctcar rctcon rctnam fedid\n");
187 j = lmap -> orderC[channel];
189 fprintf(HOmap,
"%6d %6d %6d %6d %6d ", lmap->
sideC[
j], lmap->
etaC[
j], lmap->
phiC[
j], lmap->
dphiC[
j], lmap -> depthC[
j]);
191 fprintf(HOmap,
"%6d %6d %6d ", lmap->
qieC[j], lmap->
adcC[j], lmap->
rm_fiC[j]);
194 fprintf(HOmap,
"%6d %6d %6d\n", lmap->
spigoC[j], lmap->
dccC[j], lmap->
fedidC[j]);
208 j = lmap -> orderC[channel];
220 int hcalID = _hcaldetid . rawId();
222 char tb = lmap->
fpgaC[
j][0];
223 fprintf(emap,
"%10d %3d %3d %2c %4d %5d",hcalID, lmap->
crateC[
j], lmap->
htrC[
j], tb, (lmap->
fedidC[
j] - 700), lmap->
spigoC[
j]);
235 int CHAcount = lmapHBEFO->
orderC.size();
239 for (
i = 0;
i < CHAcount;
i++){
242 stable_sort(lmapHBEFO -> orderC.begin( ), lmapHBEFO -> orderC.end( ),
SortComp);
246 for (
i = 0;
i < CHAcount;
i++){
249 stable_sort(lmapHBEFO -> orderC.begin( ), lmapHBEFO -> orderC.end( ),
SortComp);
253 for (
i = 0;
i < CHAcount;
i++){
254 if (lmapHBEFO -> fpgaC[
i] ==
"top")
tempVector.push_back (0);
257 stable_sort(lmapHBEFO -> orderC.begin( ), lmapHBEFO -> orderC.end( ),
SortComp);
261 for (
i = 0;
i < CHAcount;
i++){
264 stable_sort(lmapHBEFO -> orderC.begin( ), lmapHBEFO -> orderC.end( ),
SortComp);
268 for (
i = 0;
i < CHAcount;
i++){
271 stable_sort(lmapHBEFO -> orderC.begin( ), lmapHBEFO -> orderC.end( ),
SortComp);
275 for (
i = 0;
i < CHAcount;
i++){
276 if (lmapHBEFO -> detC[
i] ==
"HB" || lmapHBEFO -> detC[
i] ==
"HE")
tempVector.push_back (0);
277 else if (lmapHBEFO -> detC[
i] ==
"HF")
tempVector.push_back (1);
280 stable_sort(lmapHBEFO -> orderC.begin( ), lmapHBEFO -> orderC.end( ),
SortComp);
288 int CHAcount = lmapHBEFO->
orderC.size();
292 for (
i = 0;
i < CHAcount;
i++){
295 stable_sort(lmapHBEFO -> orderC.begin( ), lmapHBEFO -> orderC.end( ),
SortComp);
299 for (
i = 0;
i < CHAcount;
i++){
302 stable_sort(lmapHBEFO -> orderC.begin( ), lmapHBEFO -> orderC.end( ),
SortComp);
306 for (
i = 0;
i < CHAcount;
i++){
309 stable_sort(lmapHBEFO -> orderC.begin( ), lmapHBEFO -> orderC.end( ),
SortComp);
313 for (
i = 0;
i < CHAcount;
i++){
314 if (lmapHBEFO -> detC[
i] ==
"HB" || lmapHBEFO -> detC[
i] ==
"HE")
tempVector.push_back (0);
315 else if (lmapHBEFO -> detC[
i] ==
"HF")
tempVector.push_back (1);
318 stable_sort(lmapHBEFO -> orderC.begin( ), lmapHBEFO -> orderC.end( ),
SortComp);
VectorLMAP * SortByGeometry(VectorLMAP *lmapHBEFO)
std::vector< int > sectorC
void PrintEMAPfromLMAP(FILE *emap, VectorLMAP *lmapHBEFO)
void printEMAProw(int channel, FILE *emap, VectorLMAP *lmap)
std::vector< int > spigoC
std::vector< int > wedgeC
int getInt(ResultSet *rset, int ipar)
void printHO(int channel, FILE *HOmap, VectorLMAP *lmap)
void printHBHEHF(int channel, FILE *HBEFmap, VectorLMAP *lmap)
oracle::occi::SQLException SQLException
std::vector< int > orderC
std::vector< int > fedidC
VectorLMAP * GetLMAP(int version)
std::vector< int > crateC
std::vector< int > pixelC
std::vector< int > htr_fiC
std::vector< std::string > rctnamC
bool SortComp(int x, int y)
void PrintLMAP(FILE *HBEFmap, FILE *HOmap, VectorLMAP *lmapHBEFO)
std::vector< std::string > slbinC
std::vector< std::string > let_codeC
std::vector< std::string > rbxC
std::vector< int > depthC
VectorLMAP * SortByHardware(VectorLMAP *lmapHBEFO)
std::vector< int > rm_fiC
Gather config data from online DB.
std::vector< std::string > fpgaC
std::vector< int > rctcraC
oracle::occi::ResultSet ResultSet
void lrTestFunction(void)
std::vector< int > rctcarC
std::vector< int > rctconC
std::vector< std::string > detC
std::vector< int > dcc_slC
std::vector< std::string > slnamC
std::vector< std::string > slbin2C
std::vector< int > fi_chC