CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/CondFormats/HcalObjects/src/HcalMappingEntry.cc

Go to the documentation of this file.
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 //class HBHEHFLogicalMapEntry 
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   // string data members
00038   myslbin_  = in_s_slb;
00039   myslbin2_ = in_s_slb2;
00040   myslnam_  = in_s_slnam;
00041   myrctnam_ = in_s_rctnam;
00042 
00043   // create the hcal electronics id
00044   HcalElectronicsId heid( in_fi_ch, in_htr_fi, in_spig, in_fed - 700 );
00045   heid.setHTR( in_cr, in_htr, mytopbot );
00046   // create the hcal detector id
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   // store the different ids
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 = 20;
00075     mydcc    = 2;
00076   } 
00077   else {
00078     mydcc_sl = 10;
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 // class HOHXLogicalMapEntry 
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   // string data members
00117   myletter_ = in_s_let;
00118 
00119   // create the hcal electronics id
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     //create the hcal det id in the case of regular HO channel
00125     HcalDetId hdid( HcalOuter, in_sid*in_et, in_ph, in_dep );
00126     hcalDetID_ = hdid.rawId();
00127   }
00128   else {
00129     //create the calib det id in the case of HO cross talk channels
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   // store the different ids
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 = 20;
00154     mydcc    = 2;
00155   } 
00156   else {
00157     mydcc_sl = 10;
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 // class CalibLogicalMapEntry 
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   // string data members
00215   mycalibsubdet_ = in_s_subdet;
00216 
00217   //create the hcal electronics id
00218   HcalElectronicsId heid( in_fi_ch, in_htr_fi, in_spig, in_fed - 700 );
00219   heid.setHTR( in_cr, in_htr, mytopbot );
00220 
00221   //create the hcal det id for a calibration unit channel
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   //CM RM in HF is 4 rather than 5
00232   if (in_s_det=="HF")
00233     in_rm  = 4;
00234   else
00235     in_rm  = 5;
00236 
00237   in_pix = 0;
00238   in_qie = 1;
00239   in_adc = in_fi_ch + ( 3 * ( in_rm_fi - 1 ) );
00240 
00241   HcalFrontEndId hrbx( in_s_rbx, in_rm, in_pix, in_rm_fi, in_fi_ch, in_qie, in_adc );
00242 
00243   //store the different ids
00244   hcalEID_        = heid.rawId();
00245   hcalCalibDetID_ = hcalibdid.rawId();
00246   hcalFrontEndID_ = hrbx.rawId();
00247 }
00248 
00249 char* CALIBLogicalMapEntry::printLMapLine() {
00250 
00251   static char myline[512];
00252 
00253   HcalElectronicsId hcaleid(hcalEID_);
00254   HcalCalibDetId    hcalcalibid(hcalCalibDetID_);
00255   HcalGenericDetId  hcalgenid(hcalCalibDetID_);
00256   HcalFrontEndId    rbxid(hcalFrontEndID_);
00257 
00258   int mydcc_sl = 0;
00259   int mydcc    = 0;
00260   if ((hcaleid.dccid()%2)==1) {
00261     mydcc_sl = 20;
00262     mydcc    = 2;
00263   } 
00264   else {
00265     mydcc_sl = 10;
00266     mydcc    = 1;
00267   } 
00268 
00269   string myfpga = "";
00270   string mydet  = "";
00271   HcalSubdetector mysubdet = hcalcalibid.hcalSubdet();
00272   (mysubdet==HcalBarrel) ? mydet = "HB" : 
00273               ((mysubdet==HcalEndcap)  ? mydet = "HE" :
00274               ((mysubdet==HcalOuter)   ? mydet = "HO" : 
00275               ((mysubdet==HcalForward) ? mydet = "HF" : 
00276               mydet = "invalid")));
00277   (hcaleid.htrTopBottom()==0) ? myfpga = "bot" : myfpga = "top";
00278 
00279   sprintf(myline,"%1d %6d %6d %6d %6d %6s %7s",0,myside_,hcalcalibid.ieta(),hcalcalibid.iphi(),mydphi_,mydet.c_str(),rbxid.rbx().c_str());
00280   sprintf(myline+strlen(myline),"%8d %6d %6d %6d %6d %4d %5s",mywedge_,rbxid.rm(),rbxid.rmFiber(),hcaleid.fiberChanId(),hcaleid.readoutVMECrateId(),hcaleid.htrSlot(),myfpga.c_str());
00281   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());
00282 
00283   return myline;
00284 }
00285 
00286 
00287 // class ZDCLogicalMapEntry 
00288 
00289 ZDCLogicalMapEntry::ZDCLogicalMapEntry(
00290           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,
00291           std::string in_s_det, int in_sid, int in_dep, 
00292           int in_x, int in_y, int in_dx, int in_det_ch, int in_cab, int in_rm, int in_qie, 
00293           int in_adc, int in_rm_fi
00294   )
00295 {
00296   int mytopbot;
00297   (in_s_fpga=="bot") ? mytopbot = 0 : mytopbot = 1;
00298 
00299   myx_      = in_x;
00300   myy_      = in_y;
00301   mydx_     = in_dx;
00302   mycable_  = in_cab;
00303   myrm_     = in_rm;
00304   myqie_    = in_qie;
00305   myadc_    = in_adc;
00306   myrm_fi_  = in_rm_fi;
00307 
00308   // create the hcal electronics id
00309   HcalElectronicsId heid( in_fi_ch, in_htr_fi, in_spigot, in_fed - 700 );
00310   heid.setHTR( in_cr, in_htr, mytopbot );
00311 
00312   //create the hcal det id
00313   bool myzdccheck;
00314   HcalZDCDetId::Section myzdcsec;
00315   if (in_s_det=="ZDC_EM") myzdcsec = HcalZDCDetId::EM;
00316   else if (in_s_det=="ZDC_HAD") myzdcsec = HcalZDCDetId::HAD;
00317   else if (in_s_det=="ZDC_LUM") myzdcsec = HcalZDCDetId::LUM;
00318   else myzdcsec = HcalZDCDetId::Unknown;
00319  
00320   (in_sid > 0) ? myzdccheck = true : myzdccheck = false;
00321   HcalZDCDetId hzdcdid( myzdcsec, myzdccheck, in_det_ch );
00322 
00323   // store the different ids
00324   hcalEID_      = heid.rawId();
00325   hcalZDCDetID_ = hzdcdid.rawId();
00326 
00327 }
00328   
00329 char* ZDCLogicalMapEntry::printLMapLine() {
00330 
00331   static char myline[512];
00332 
00333   HcalElectronicsId hcaleid(hcalEID_);
00334   HcalZDCDetId hcalzdcid(hcalZDCDetID_);
00335   HcalGenericDetId hcalgenid(hcalZDCDetID_);
00336 
00337   int mydcc_sl = -1;
00338   int mydcc    = -1;
00339   if ((hcaleid.dccid()%2)==1) {
00340     mydcc_sl = 20;
00341     mydcc    = 2;
00342   } 
00343   else {
00344     mydcc_sl = 10;
00345     mydcc    = 1;
00346   } 
00347 
00348   string myfpga ="";
00349   string mydet ="ZDC_";
00350   HcalZDCDetId::Section myzdcsec = hcalzdcid.section();
00351 
00352   if (myzdcsec==0) mydet += "Unknown";
00353   else if (myzdcsec==1) mydet += "EM";
00354   else if (myzdcsec==2) mydet += "HAD";
00355   else mydet += "LUM";
00356 
00357   (hcaleid.htrTopBottom()==0) ? myfpga = "bot" : myfpga = "top";
00358 
00359   sprintf(myline,"%1d %5d %2d %2d %3d %6d %7s %7d",0,hcalzdcid.zside(),myx_,myy_,mydx_,hcalzdcid.depth(),mydet.c_str(),hcalzdcid.channel());
00360   sprintf(myline+strlen(myline),"%7d %3d %4d %4d %6d %6d %6d",mycable_,myrm_,myqie_,myadc_,myrm_fi_,hcaleid.fiberChanId(),hcaleid.readoutVMECrateId());
00361   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);
00362 
00363   return myline;
00364 }
00365 
00366 
00367 // class HTLogicalMapEntry 
00368 
00369 HTLogicalMapEntry::HTLogicalMapEntry(
00370              int in_et, int in_ph,
00371              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,
00372              int in_spig, int in_slb, std::string in_s_slb, std::string in_s_slb2, int in_ndat,
00373              std::string in_s_slnam, int in_rctcra, int in_rctcar, int in_rctcon, std::string in_s_rctnam, int in_fed
00374   )
00375 {
00376   myside_   = in_sid;
00377   mydphi_   = in_dph;
00378   mydepth_  = in_dep;
00379   mywedge_  = in_wed;
00380   myrctcra_ = in_rctcra;
00381   myrctcar_ = in_rctcar;
00382   myrctcon_ = in_rctcon;
00383   
00384   // string data members
00385   mydet_    = in_s_chDet;
00386   myslbin_  = in_s_slb;
00387   myslbin2_ = in_s_slb2;
00388   myslnam_  = in_s_slnam;
00389   myrctnam_ = in_s_rctnam;
00390 
00391   // necessary since LMap code makes top = 0, bottom = 1, but det ids have top = 1, bottom = 0
00392   int top = 1;
00393   in_tb == 1 ? top = 0 : top = 1;
00394   //create an hcal electronics id for the trigger tower, idea copied from CalibCalorimetry/HcalAlgos/src/HcalDBASCIIIO.cc
00395   HcalElectronicsId hteid( in_ndat, in_slb, in_spig, in_fed - 700, in_cr, in_htr, top );
00396   //HcalElectronicsId hteid( slbCh, slb, spigot, dcc, crate, slot, top );
00397 
00398   //create the hcal trigger tower det id
00399   HcalTrigTowerDetId htrigdid( in_et, in_ph );
00400 
00401   // store the different ids
00402   hcalTrigEID_   = hteid.rawId();
00403   hcalTrigDetID_ = htrigdid.rawId();
00404 
00405 }
00406 
00407 char* HTLogicalMapEntry::printLMapLine() {
00408   static char myline[512];
00409   HcalElectronicsId hcaltrigeid(hcalTrigEID_);
00410   HcalTrigTowerDetId hcaltrigid(hcalTrigDetID_);
00411   HcalGenericDetId hcalgenid(hcalTrigDetID_);
00412 
00413   int mydcc_sl = 0;
00414   int mydcc    = 0;
00415   if ((hcaltrigeid.dccid()%2)==1) {
00416     mydcc_sl = 20;
00417     mydcc    = 2;
00418   } 
00419   else {
00420     mydcc_sl = 10;
00421     mydcc    = 1;
00422   } 
00423 
00424   string myfpga ="";
00425   ( hcaltrigeid.htrTopBottom()==0 ) ? myfpga = "bot" : myfpga = "top";
00426 
00427   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());
00428   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());
00429   sprintf(myline+strlen(myline),"%13s %7d %7d %7d %17s %6d\n",myslnam_.c_str(),myrctcra_,myrctcar_,myrctcon_,myrctnam_.c_str(),hcaltrigeid.dccid()+700);
00430 
00431   return myline;
00432 }
00433