00001 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
00002 #include "DataFormats/HcalDetId/interface/HcalOtherDetId.h"
00003 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
00004
00005 #include "CondFormats/HcalObjects/interface/HcalMappingEntry.h"
00006
00007 #include <iostream>
00008 #include <fstream>
00009 #include <sstream>
00010 #include <stdio.h>
00011 #include <string>
00012 #include <cstring>
00013
00014 using namespace std;
00015
00016
00017
00018
00019 HBHEHFLogicalMapEntry::HBHEHFLogicalMapEntry(
00020 int in_fi_ch, int in_htr_fi, int in_spig, int in_fed, int in_cr, int in_htr, std::string in_s_fpga,
00021 std::string in_s_det, int in_sid, int in_et, int in_ph, int in_dep,
00022 int in_dph, int in_wed, int in_rm, int in_rm_fi, int in_pix, int in_qie, int in_adc,
00023 int in_slb, int in_rctcra, int in_rctcar, int in_rctcon,
00024 std::string in_s_rbx, std::string in_s_slb, std::string in_s_slb2, std::string in_s_slnam, std::string in_s_rctnam
00025 )
00026 {
00027 int mytopbot;
00028 (in_s_fpga=="bot") ? mytopbot = 0 : mytopbot = 1;
00029
00030 mydphi_ = in_dph;
00031 mywedge_ = in_wed;
00032 myslb_ = in_slb;
00033 myrctcra_ = in_rctcra;
00034 myrctcar_ = in_rctcar;
00035 myrctcon_ = in_rctcon;
00036
00037
00038 myslbin_ = in_s_slb;
00039 myslbin2_ = in_s_slb2;
00040 myslnam_ = in_s_slnam;
00041 myrctnam_ = in_s_rctnam;
00042
00043
00044 HcalElectronicsId heid( in_fi_ch, in_htr_fi, in_spig, in_fed - 700 );
00045 heid.setHTR( in_cr, in_htr, mytopbot );
00046
00047 HcalSubdetector mysubdet = HcalEmpty;
00048 if (in_s_det=="HB") mysubdet = HcalBarrel;
00049 else if (in_s_det=="HE") mysubdet = HcalEndcap;
00050 else if (in_s_det=="HF") mysubdet = HcalForward;
00051
00052 HcalDetId hdid( mysubdet, in_sid*in_et, in_ph, in_dep );
00053
00054 HcalFrontEndId hrbx( in_s_rbx, in_rm, in_pix, in_rm_fi, in_fi_ch, in_qie, in_adc );
00055
00056
00057 hcalEID_ = heid.rawId();
00058 hcalDetID_ = hdid.rawId();
00059 hcalFrontEndID_ = hrbx.rawId();
00060 }
00061
00062 char* HBHEHFLogicalMapEntry::printLMapLine() {
00063
00064 static char myline[512];
00065
00066 HcalElectronicsId hcaleid(hcalEID_);
00067 HcalDetId hcaldid(hcalDetID_);
00068 HcalGenericDetId hcalgenid(hcalDetID_);
00069 HcalFrontEndId rbxid(hcalFrontEndID_);
00070
00071 int mydcc_sl = 0;
00072 int mydcc = 0;
00073 if ((hcaleid.dccid()%2)==1) {
00074 mydcc_sl = 19;
00075 mydcc = 2;
00076 }
00077 else {
00078 mydcc_sl = 9;
00079 mydcc = 1;
00080 }
00081
00082 string myfpga = "";
00083 string mydet = "";
00084 HcalSubdetector mysubdet = hcaldid.subdet();
00085 (mysubdet==1) ? mydet = "HB" :
00086 ((mysubdet==2) ? mydet = "HE" :
00087 ((mysubdet==3) ? mydet = "HO" :
00088 ((mysubdet==4) ? mydet = "HF" :
00089 mydet = "invalid")));
00090
00091 ( hcaleid.htrTopBottom()==0 ) ? myfpga = "bot" : myfpga = "top";
00092
00093 sprintf(myline,"%1d %6d %6d %6d %6d %6d %6s %7s %6d %6d %6d",0,hcaldid.zside(),hcaldid.ietaAbs(),hcaldid.iphi(),mydphi_,hcaldid.depth(),mydet.c_str(),rbxid.rbx().c_str(),mywedge_,rbxid.rm(),rbxid.pixel());
00094 sprintf(myline+strlen(myline),"%6d %6d %6d %6d %6d %6d %6s",rbxid.qieCard(),rbxid.adc(),rbxid.rmFiber(),hcaleid.fiberChanId(),hcaleid.readoutVMECrateId(),hcaleid.htrSlot(),myfpga.c_str());
00095 sprintf(myline+strlen(myline),"%8d %7d %6d %6d %6d %6s",hcaleid.fiberIndex(),mydcc_sl,hcaleid.spigot(),mydcc,myslb_,myslbin_.c_str());
00096 sprintf(myline+strlen(myline),"%8s %15s %6d %6d %6d %20s %6d\n",myslbin2_.c_str(),myslnam_.c_str(),myrctcra_,myrctcar_,myrctcon_,myrctnam_.c_str(),hcaleid.dccid()+700);
00097
00098 return myline;
00099 }
00100
00101
00102
00103
00104 HOHXLogicalMapEntry::HOHXLogicalMapEntry(
00105 int in_fi_ch, int in_htr_fi, int in_spig, int in_fed, int in_cr, int in_htr, std::string in_s_fpga,
00106 std::string in_s_det, int in_sid, int in_et, int in_ph, int in_dep,
00107 int in_dph, int in_sec, int in_rm, int in_rm_fi, int in_pix, int in_qie, int in_adc,
00108 std::string in_s_rbx, std::string in_s_let
00109 )
00110 {
00111 int mytopbot;
00112 (in_s_fpga=="bot") ? mytopbot = 0 : mytopbot = 1;
00113
00114 mydphi_ = in_dph;
00115 mysector_ = in_sec;
00116
00117 myletter_ = in_s_let;
00118
00119
00120 HcalElectronicsId heid( in_fi_ch, in_htr_fi, in_spig, in_fed - 700 );
00121 heid.setHTR( in_cr, in_htr, mytopbot );
00122
00123 if (in_s_det=="HO") {
00124
00125 HcalDetId hdid( HcalOuter, in_sid*in_et, in_ph, in_dep );
00126 hcalDetID_ = hdid.rawId();
00127 }
00128 else {
00129
00130 HcalCalibDetId hdid( in_sid*in_et, in_ph );
00131 hcalDetID_ = hdid.rawId();
00132 }
00133
00134 HcalFrontEndId hrbx( in_s_rbx, in_rm, in_pix, in_rm_fi, in_fi_ch, in_qie, in_adc );
00135
00136
00137 hcalEID_ = heid.rawId();
00138 hcalFrontEndID_ = hrbx.rawId();
00139
00140 }
00141
00142 char* HOHXLogicalMapEntry::printLMapLine() {
00143
00144 static char myline[512];
00145
00146 HcalElectronicsId hcaleid(hcalEID_);
00147 HcalGenericDetId hcalgenid(hcalDetID_);
00148 HcalFrontEndId rbxid(hcalFrontEndID_);
00149
00150 int mydcc_sl = 0;
00151 int mydcc = 0;
00152 if ((hcaleid.dccid()%2)==1) {
00153 mydcc_sl = 19;
00154 mydcc = 2;
00155 }
00156 else {
00157 mydcc_sl = 9;
00158 mydcc = 1;
00159 }
00160
00161 string myfpga = "";
00162 string mydet = "";
00163 int mydepth = 0;
00164 int myside = -2;
00165 int myeta = 0;
00166 int myphi = -1;
00167 if ( hcalgenid.isHcalCalibDetId() ) {
00168 HcalCalibDetId hcalcompid(hcalDetID_);
00169 mydet = "HOX";
00170 mydepth = 4;
00171 myside = hcalcompid.zside();
00172 myeta = hcalcompid.ieta()*myside;
00173 myphi = hcalcompid.iphi();
00174 }
00175 else if ( hcalgenid.isHcalDetId() ) {
00176 HcalDetId hcalcompid(hcalDetID_);
00177 HcalSubdetector mysubdet = hcalcompid.subdet();
00178 (mysubdet==HcalBarrel) ? mydet = "HB" :
00179 ((mysubdet==HcalEndcap) ? mydet = "HE" :
00180 ((mysubdet==HcalOuter) ? mydet = "HO" :
00181 ((mysubdet==HcalForward) ? mydet = "HF" :
00182 mydet = "invalid")));
00183 mydepth = hcalcompid.depth();
00184 myside = hcalcompid.zside();
00185 myeta = hcalcompid.ietaAbs();
00186 myphi = hcalcompid.iphi();
00187 }
00188
00189 ( hcaleid.htrTopBottom()==0 ) ? myfpga = "bot" : myfpga = "top";
00190
00191 sprintf(myline,"%1d %6d %6d %6d %6d %6d %6s %7s %6d %6d %6d",0,myside,myeta,myphi,mydphi_,mydepth,mydet.c_str(),rbxid.rbx().c_str(),mysector_,rbxid.rm(),rbxid.pixel());
00192 sprintf(myline+strlen(myline),"%6d %6d %6d %6d %8s %6d %6d %6s",rbxid.qieCard(),rbxid.adc(),rbxid.rmFiber(),hcaleid.fiberChanId(),myletter_.c_str(),hcaleid.readoutVMECrateId(),hcaleid.htrSlot(),myfpga.c_str());
00193 sprintf(myline+strlen(myline),"%8d %7d %6d %6d %6d\n",hcaleid.fiberIndex(),mydcc_sl,hcaleid.spigot(),mydcc,hcaleid.dccid()+700);
00194
00195 return myline;
00196 }
00197
00198
00199
00200
00201 CALIBLogicalMapEntry::CALIBLogicalMapEntry(
00202 int in_fi_ch, int in_htr_fi, int in_spig, int in_fed, int in_cr, int in_htr, std::string in_s_fpga,
00203 std::string in_s_det, int in_et, int in_ph, int in_ch_ty,
00204 int in_sid, int in_dph, std::string in_s_rbx, int in_wed, int in_rm_fi,
00205 std::string in_s_subdet
00206 )
00207 {
00208 int mytopbot;
00209 (in_s_fpga=="bot") ? mytopbot = 0 : mytopbot = 1;
00210
00211 myside_ = in_sid;
00212 mydphi_ = in_dph;
00213 mywedge_ = in_wed;
00214
00215 mycalibsubdet_ = in_s_subdet;
00216
00217
00218 HcalElectronicsId heid( in_fi_ch, in_htr_fi, in_spig, in_fed - 700 );
00219 heid.setHTR( in_cr, in_htr, mytopbot );
00220
00221
00222 HcalSubdetector mysubdet = HcalEmpty;
00223 if (in_s_det=="HB") mysubdet = HcalBarrel;
00224 else if (in_s_det=="HE") mysubdet = HcalEndcap;
00225 else if (in_s_det=="HO") mysubdet = HcalOuter;
00226 else if (in_s_det=="HF") mysubdet = HcalForward;
00227
00228 HcalCalibDetId hcalibdid( mysubdet, in_et, in_ph, in_ch_ty );
00229
00230 int in_rm, in_pix, in_qie, in_adc;
00231 in_rm = 5;
00232 in_pix = 0;
00233 in_qie = 1;
00234 in_adc = in_fi_ch + ( 3 * ( in_rm_fi - 1 ) );
00235
00236 HcalFrontEndId hrbx( in_s_rbx, in_rm, in_pix, in_rm_fi, in_fi_ch, in_qie, in_adc );
00237
00238
00239 hcalEID_ = heid.rawId();
00240 hcalCalibDetID_ = hcalibdid.rawId();
00241 hcalFrontEndID_ = hrbx.rawId();
00242 }
00243
00244 char* CALIBLogicalMapEntry::printLMapLine() {
00245
00246 static char myline[512];
00247
00248 HcalElectronicsId hcaleid(hcalEID_);
00249 HcalCalibDetId hcalcalibid(hcalCalibDetID_);
00250 HcalGenericDetId hcalgenid(hcalCalibDetID_);
00251 HcalFrontEndId rbxid(hcalFrontEndID_);
00252
00253 int mydcc_sl = 0;
00254 int mydcc = 0;
00255 if ((hcaleid.dccid()%2)==1) {
00256 mydcc_sl = 19;
00257 mydcc = 2;
00258 }
00259 else {
00260 mydcc_sl = 9;
00261 mydcc = 1;
00262 }
00263
00264 string myfpga = "";
00265 string mydet = "";
00266 HcalSubdetector mysubdet = hcalcalibid.hcalSubdet();
00267 (mysubdet==HcalBarrel) ? mydet = "HB" :
00268 ((mysubdet==HcalEndcap) ? mydet = "HE" :
00269 ((mysubdet==HcalOuter) ? mydet = "HO" :
00270 ((mysubdet==HcalForward) ? mydet = "HF" :
00271 mydet = "invalid")));
00272 (hcaleid.htrTopBottom()==0) ? myfpga = "bot" : myfpga = "top";
00273
00274 sprintf(myline,"%1d %6d %6d %6d %6d %6s %7s",0,myside_,hcalcalibid.ieta(),hcalcalibid.iphi(),mydphi_,mydet.c_str(),rbxid.rbx().c_str());
00275 sprintf(myline+strlen(myline),"%8d %6d %6d %6d %4d %5s",mywedge_,rbxid.rmFiber(),hcaleid.fiberChanId(),hcaleid.readoutVMECrateId(),hcaleid.htrSlot(),myfpga.c_str());
00276 sprintf(myline+strlen(myline),"%8d %7d %6d %4d %6d %8d %9s\n",hcaleid.fiberIndex(),mydcc_sl,hcaleid.spigot(),mydcc,hcaleid.dccid()+700, hcalcalibid.cboxChannel(), mycalibsubdet_.c_str());
00277
00278 return myline;
00279 }
00280
00281
00282
00283
00284 ZDCLogicalMapEntry::ZDCLogicalMapEntry(
00285 int in_fi_ch, int in_htr_fi, int in_spigot, int in_fed, int in_cr, int in_htr, std::string in_s_fpga,
00286 std::string in_s_det, int in_sid, int in_dep,
00287 int in_x, int in_y, int in_dx, int in_det_ch, int in_cab, int in_rm, int in_qie,
00288 int in_adc, int in_rm_fi
00289 )
00290 {
00291 int mytopbot;
00292 (in_s_fpga=="bot") ? mytopbot = 0 : mytopbot = 1;
00293
00294 myx_ = in_x;
00295 myy_ = in_y;
00296 mydx_ = in_dx;
00297 mycable_ = in_cab;
00298 myrm_ = in_rm;
00299 myqie_ = in_qie;
00300 myadc_ = in_adc;
00301 myrm_fi_ = in_rm_fi;
00302
00303
00304 HcalElectronicsId heid( in_fi_ch, in_htr_fi, in_spigot, in_fed - 700 );
00305 heid.setHTR( in_cr, in_htr, mytopbot );
00306
00307
00308 bool myzdccheck;
00309 HcalZDCDetId::Section myzdcsec;
00310 if (in_s_det=="ZDC_EM") myzdcsec = HcalZDCDetId::EM;
00311 else if (in_s_det=="ZDC_HAD") myzdcsec = HcalZDCDetId::HAD;
00312 else if (in_s_det=="ZDC_LUM") myzdcsec = HcalZDCDetId::LUM;
00313 else myzdcsec = HcalZDCDetId::Unknown;
00314
00315 (in_sid > 0) ? myzdccheck = true : myzdccheck = false;
00316 HcalZDCDetId hzdcdid( myzdcsec, myzdccheck, in_det_ch );
00317
00318
00319 hcalEID_ = heid.rawId();
00320 hcalZDCDetID_ = hzdcdid.rawId();
00321
00322 }
00323
00324 char* ZDCLogicalMapEntry::printLMapLine() {
00325
00326 static char myline[512];
00327
00328 HcalElectronicsId hcaleid(hcalEID_);
00329 HcalZDCDetId hcalzdcid(hcalZDCDetID_);
00330 HcalGenericDetId hcalgenid(hcalZDCDetID_);
00331
00332 int mydcc_sl = -1;
00333 int mydcc = -1;
00334 if ((hcaleid.dccid()%2)==1) {
00335 mydcc_sl = 19;
00336 mydcc = 2;
00337 }
00338 else {
00339 mydcc_sl = 9;
00340 mydcc = 1;
00341 }
00342
00343 string myfpga ="";
00344 string mydet ="ZDC_";
00345 HcalZDCDetId::Section myzdcsec = hcalzdcid.section();
00346
00347 if (myzdcsec==0) mydet += "Unknown";
00348 else if (myzdcsec==1) mydet += "EM";
00349 else if (myzdcsec==2) mydet += "HAD";
00350 else mydet += "LUM";
00351
00352 (hcaleid.htrTopBottom()==0) ? myfpga = "bot" : myfpga = "top";
00353
00354 sprintf(myline,"%1d %5d %2d %2d %3d %6d %7s %7d",0,hcalzdcid.zside(),myx_,myy_,mydx_,hcalzdcid.depth(),mydet.c_str(),hcalzdcid.channel());
00355 sprintf(myline+strlen(myline),"%7d %3d %4d %4d %6d %6d %6d",mycable_,myrm_,myqie_,myadc_,myrm_fi_,hcaleid.fiberChanId(),hcaleid.readoutVMECrateId());
00356 sprintf(myline+strlen(myline),"%5d %5s %7d %7d %6d %4d %6d\n",hcaleid.htrSlot(),myfpga.c_str(),hcaleid.fiberIndex(),mydcc_sl,hcaleid.spigot(),mydcc,hcaleid.dccid()+700);
00357
00358 return myline;
00359 }
00360
00361
00362
00363
00364 HTLogicalMapEntry::HTLogicalMapEntry(
00365 int in_et, int in_ph,
00366 int in_sid, int in_dph, int in_dep, std::string in_s_chDet, int in_wed, int in_cr, int in_htr, int in_tb,
00367 int in_spig, int in_slb, std::string in_s_slb, std::string in_s_slb2, int in_ndat,
00368 std::string in_s_slnam, int in_rctcra, int in_rctcar, int in_rctcon, std::string in_s_rctnam, int in_fed
00369 )
00370 {
00371 myside_ = in_sid;
00372 mydphi_ = in_dph;
00373 mydepth_ = in_dep;
00374 mywedge_ = in_wed;
00375 myrctcra_ = in_rctcra;
00376 myrctcar_ = in_rctcar;
00377 myrctcon_ = in_rctcon;
00378
00379
00380 mydet_ = in_s_chDet;
00381 myslbin_ = in_s_slb;
00382 myslbin2_ = in_s_slb2;
00383 myslnam_ = in_s_slnam;
00384 myrctnam_ = in_s_rctnam;
00385
00386
00387 int top = 1;
00388 in_tb == 1 ? top = 0 : top = 1;
00389
00390 HcalElectronicsId hteid( in_ndat, in_slb, in_spig, in_fed - 700, in_cr, in_htr, top );
00391
00392
00393
00394 HcalTrigTowerDetId htrigdid( in_et, in_ph );
00395
00396
00397 hcalTrigEID_ = hteid.rawId();
00398 hcalTrigDetID_ = htrigdid.rawId();
00399
00400 }
00401
00402 char* HTLogicalMapEntry::printLMapLine() {
00403 static char myline[512];
00404 HcalElectronicsId hcaltrigeid(hcalTrigEID_);
00405 HcalTrigTowerDetId hcaltrigid(hcalTrigDetID_);
00406 HcalGenericDetId hcalgenid(hcalTrigDetID_);
00407
00408 int mydcc_sl = 0;
00409 int mydcc = 0;
00410 if ((hcaltrigeid.dccid()%2)==1) {
00411 mydcc_sl = 19;
00412 mydcc = 2;
00413 }
00414 else {
00415 mydcc_sl = 9;
00416 mydcc = 1;
00417 }
00418
00419 string myfpga ="";
00420 ( hcaltrigeid.htrTopBottom()==0 ) ? myfpga = "bot" : myfpga = "top";
00421
00422 sprintf(myline,"%1d %5d %4d %4d %5d %6d %4s %7d %6d ",0,myside_,hcaltrigid.ieta(),hcaltrigid.iphi(),mydphi_,mydepth_,mydet_.c_str(),mywedge_,hcaltrigeid.readoutVMECrateId());
00423 sprintf(myline+strlen(myline),"%4d %5s %7d %6d %4d %4d %6s %7s %5d ",hcaltrigeid.htrSlot(),myfpga.c_str(),mydcc_sl,hcaltrigeid.spigot(),mydcc,hcaltrigeid.slbSiteNumber(),myslbin_.c_str(),myslbin2_.c_str(),hcaltrigeid.slbChannelIndex());
00424 sprintf(myline+strlen(myline),"%13s %7d %7d %7d %17s %6d\n",myslnam_.c_str(),myrctcra_,myrctcar_,myrctcon_,myrctnam_.c_str(),hcaltrigeid.dccid()+700);
00425
00426 return myline;
00427 }