CMS 3D CMS Logo

Classes | Functions

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/src/CaloOnlineTools/HcalOnlineDb/interface/DBlmapReader.h File Reference

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include "OnlineDB/Oracle/interface/Oracle.h"
#include "CaloOnlineTools/HcalOnlineDb/interface/HCALConfigDB.h"
#include "CalibCalorimetry/HcalTPGAlgos/interface/XMLProcessor.h"
#include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabase.hh"
#include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabaseImplOracle.hh"
#include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabaseImplXMLFile.hh"
#include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationItemNotFoundException.hh"
#include "DataFormats/HcalDetId/interface/HcalDetId.h"

Go to the source code of this file.

Classes

class  DBlmapReader
struct  VectorLMAP

Functions

void printEMAProw (int channel, FILE *emap, VectorLMAP *lmap)
void printHBHEHF (int channel, FILE *HBEFmap, VectorLMAP *lmap)
void printHO (int channel, FILE *HOmap, VectorLMAP *lmap)
VectorLMAPSortByGeometry (VectorLMAP *lmapHBEFO)
VectorLMAPSortByHardware (VectorLMAP *lmapHBEFO)
bool SortComp (int x, int y)

Function Documentation

void printEMAProw ( int  channel,
FILE *  emap,
VectorLMAP lmap 
)

Definition at line 207 of file DBlmapReader.cc.

References benchmark_cfg::cerr, VectorLMAP::crateC, VectorLMAP::depthC, VectorLMAP::detC, VectorLMAP::etaC, VectorLMAP::fedidC, VectorLMAP::fi_chC, VectorLMAP::fpgaC, HcalBarrel, HcalEndcap, HcalForward, HcalOuter, VectorLMAP::htr_fiC, VectorLMAP::htrC, j, VectorLMAP::phiC, VectorLMAP::sideC, and VectorLMAP::spigoC.

Referenced by DBlmapReader::PrintEMAPfromLMAP().

                                                              {
  j = lmap -> orderC[channel];

  HcalSubdetector _subdet;
  if      ( lmap->detC[j] == "HB" ) _subdet = HcalBarrel;
  else if ( lmap->detC[j] == "HE" ) _subdet = HcalEndcap;
  else if ( lmap->detC[j] == "HO" ) _subdet = HcalOuter;
  else if ( lmap->detC[j] == "HF" ) _subdet = HcalForward;
  else{
    _subdet = HcalBarrel;
    std::cerr<<"Bad Subdet"<<std::endl;
  }
  HcalDetId _hcaldetid( _subdet, (lmap->sideC[j])*(lmap->etaC[j]), lmap->phiC[j], lmap->depthC[j] );
  int hcalID = _hcaldetid . rawId(); 

  char tb = lmap->fpgaC[j][0];
  fprintf(emap,"%10d %3d %3d %2c %4d %5d",hcalID, lmap->crateC[j], lmap->htrC[j], tb, (lmap->fedidC[j] - 700), lmap->spigoC[j]);
  fprintf(emap,"%5d %8d %8s %5d %4d %6d\n", lmap->htr_fiC[j], lmap->fi_chC[j], lmap->detC[j].c_str(), (lmap->etaC[j]*lmap->sideC[j]), lmap->phiC[j], lmap->depthC[j]);

  return;
}
void printHBHEHF ( int  channel,
FILE *  HBEFmap,
VectorLMAP lmap 
)

Definition at line 160 of file DBlmapReader.cc.

References VectorLMAP::adcC, VectorLMAP::crateC, VectorLMAP::dcc_slC, VectorLMAP::dccC, VectorLMAP::detC, VectorLMAP::dphiC, VectorLMAP::etaC, VectorLMAP::fedidC, VectorLMAP::fi_chC, VectorLMAP::fpgaC, VectorLMAP::htr_fiC, VectorLMAP::htrC, j, VectorLMAP::phiC, VectorLMAP::pixelC, VectorLMAP::qieC, VectorLMAP::rbxC, VectorLMAP::rctcarC, VectorLMAP::rctconC, VectorLMAP::rctcraC, VectorLMAP::rctnamC, VectorLMAP::rm_fiC, VectorLMAP::rmC, VectorLMAP::sideC, VectorLMAP::slbC, VectorLMAP::slbin2C, VectorLMAP::slbinC, VectorLMAP::slnamC, VectorLMAP::spigoC, and VectorLMAP::wedgeC.

Referenced by DBlmapReader::PrintLMAP().

                                                                {
  
  if (channel % 21 == 0){
    fprintf(HBEFmap,"# side    eta    phi   dphi  depth    det     rbx  wedge     rm  pixel   qie    adc");
    fprintf(HBEFmap,"  rm_fi  fi_ch  crate    htr   fpga  htr_fi  dcc_sl  spigo    dcc    slb  slbin  slbin2");
    fprintf(HBEFmap,"           slnam    rctcra rctcar rctcon               rctnam     fedid\n");
  }
  
  j = lmap -> orderC[channel];

  fprintf(HBEFmap,"%6d %6d %6d %6d %6d ", lmap->sideC[j],           lmap->etaC[j],            lmap->phiC[j],    lmap->dphiC[j],     lmap -> depthC[j]);
  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]);
  fprintf(HBEFmap,"%6d %6d %6d %6d %6d ", lmap->qieC[j],            lmap->adcC[j],            lmap->rm_fiC[j],  lmap->fi_chC[j],    lmap->crateC[j]);
  fprintf(HBEFmap,"%6d %6s%8d %7d ",      lmap->htrC[j],            lmap->fpgaC[j].c_str(),   lmap->htr_fiC[j], lmap->dcc_slC[j]);
  fprintf(HBEFmap,"%6d %6d %6d %6s",      lmap->spigoC[j],          lmap->dccC[j],            lmap->slbC[j],    lmap->slbinC[j].c_str());
  fprintf(HBEFmap,"%8s %15s    %6d %6d ", lmap->slbin2C[j].c_str(), lmap->slnamC[j].c_str(),  lmap->rctcraC[j], lmap->rctcarC[j]);
  fprintf(HBEFmap,"%6d %20s    %6d\n",    lmap->rctconC[j],         lmap->rctnamC[j].c_str(), lmap->fedidC[j]);
}
void printHO ( int  channel,
FILE *  HOmap,
VectorLMAP lmap 
)

Definition at line 179 of file DBlmapReader.cc.

References VectorLMAP::adcC, VectorLMAP::crateC, VectorLMAP::dcc_slC, VectorLMAP::dccC, VectorLMAP::detC, VectorLMAP::dphiC, VectorLMAP::etaC, VectorLMAP::fedidC, VectorLMAP::fi_chC, VectorLMAP::fpgaC, VectorLMAP::htr_fiC, VectorLMAP::htrC, j, VectorLMAP::let_codeC, VectorLMAP::phiC, VectorLMAP::pixelC, VectorLMAP::qieC, VectorLMAP::rbxC, VectorLMAP::rm_fiC, VectorLMAP::rmC, VectorLMAP::sectorC, VectorLMAP::sideC, and VectorLMAP::spigoC.

Referenced by DBlmapReader::PrintLMAP().

                                                          {
  //HO goes last, after 6912 entries; 6912 % 21 = 3
  if (channel % 21 == 3){    
    fprintf(HOmap,"# side    eta    phi   dphi  depth    det     rbx  sector    rm  pixel   qie    adc");
    fprintf(HOmap,"  rm_fi  fi_ch let_code  crate    htr   fpga  htr_fi  dcc_sl  spigo    dcc    slb  slbin  slbin2");
    fprintf(HOmap,"           slnam    rctcra rctcar rctcon               rctnam     fedid\n");
  }

  j = lmap -> orderC[channel];

  fprintf(HOmap,"%6d %6d %6d %6d %6d ", lmap->sideC[j],           lmap->etaC[j],              lmap->phiC[j],    lmap->dphiC[j],     lmap -> depthC[j]);
  fprintf(HOmap,"%6s %7s %6d %6d %6d",  lmap->detC[j].c_str(),    lmap->rbxC[j].c_str(),      lmap->sectorC[j], lmap->rmC[j],       lmap->pixelC[j]);
  fprintf(HOmap,"%6d %6d %6d ",         lmap->qieC[j],            lmap->adcC[j],              lmap->rm_fiC[j]);
  fprintf(HOmap,"%6d %8s %6d ",         lmap->fi_chC[j],          lmap->let_codeC[j].c_str(), lmap->crateC[j]);
  fprintf(HOmap,"%6d %6s%8d %7d ",      lmap->htrC[j],            lmap->fpgaC[j].c_str(),     lmap->htr_fiC[j], lmap->dcc_slC[j]);
  fprintf(HOmap,"%6d %6d %6d\n",        lmap->spigoC[j],          lmap->dccC[j],              lmap->fedidC[j]);


  // New Format (will update as soon as database update is complete

//   fprintf(HOmap,"# side    eta    phi   dphi  depth    det     rbx  sector    rm  pixel   qie    adc");
//   fprintf(HOmap,"  rm_fi  fi_ch let_code  crate    htr   fpga  htr_fi  dcc_sl  spigo    dcc  fedid    geo  block     lc\n");
//   fprintf(HOmap,"%6d %6d %6d %6d %6d %6s %7s %6d %6d %6d",iside,ieta,iphi,idphi,idepth,det.c_str(),rbx.c_str(),isector,irm,ipixel);
//   fprintf(HOmap,"%6d %6d %6d %6d %8s %6d %6d %6s",iqie,iadc,irm_fi,ifi_ch,letter.c_str(),icrate,ihtr,fpga.c_str());
//   fprintf(HOmap,"%8d %7d %6d %6d %6d %6d %6d %6d\n",ihtr_fi,idcc_sl,ispigot,idcc,ifed,geo,block,lc);
  
}
VectorLMAP* SortByGeometry ( VectorLMAP lmapHBEFO)

Definition at line 286 of file DBlmapReader.cc.

References i, VectorLMAP::orderC, SortComp(), and tempVector.

Referenced by DBlmapReader::PrintEMAPfromLMAP(), and DBlmapReader::PrintLMAP().

                                                 {

  int CHAcount = lmapHBEFO->orderC.size();
  tempVector.clear();
  
  //Sort by eta
  for (i = 0; i < CHAcount; i++){
    tempVector.push_back (lmapHBEFO -> etaC[i]);
  }
  stable_sort(lmapHBEFO -> orderC.begin( ), lmapHBEFO -> orderC.end( ), SortComp);
  tempVector.clear();

  //Sort by phi
  for (i = 0; i < CHAcount; i++){
    tempVector.push_back (lmapHBEFO -> phiC[i]);
  }
  stable_sort(lmapHBEFO -> orderC.begin( ), lmapHBEFO -> orderC.end( ), SortComp);
  tempVector.clear();

  //Sort by side
  for (i = 0; i < CHAcount; i++){
    tempVector.push_back (lmapHBEFO -> sideC[i]);
  }
  stable_sort(lmapHBEFO -> orderC.begin( ), lmapHBEFO -> orderC.end( ), SortComp);
  tempVector.clear();
  
  //Sort by subdetector
  for (i = 0; i < CHAcount; i++){
    if      (lmapHBEFO -> detC[i] == "HB" || lmapHBEFO -> detC[i] == "HE") tempVector.push_back (0);
    else if (lmapHBEFO -> detC[i] == "HF")                                 tempVector.push_back (1);
    else                                                                   tempVector.push_back (2);
  }
  stable_sort(lmapHBEFO -> orderC.begin( ), lmapHBEFO -> orderC.end( ), SortComp);
  tempVector.clear();

  return lmapHBEFO;
}
VectorLMAP* SortByHardware ( VectorLMAP lmapHBEFO)

Definition at line 233 of file DBlmapReader.cc.

References i, VectorLMAP::orderC, SortComp(), and tempVector.

Referenced by DBlmapReader::PrintEMAPfromLMAP(), and DBlmapReader::PrintLMAP().

                                                 {

  int CHAcount = lmapHBEFO->orderC.size();
  tempVector.clear();

  //Sort by fiber channel
  for (i = 0; i < CHAcount; i++){
    tempVector.push_back (lmapHBEFO -> fi_chC[i]);
  }
  stable_sort(lmapHBEFO -> orderC.begin( ), lmapHBEFO -> orderC.end( ), SortComp);
  tempVector.clear();

  //Sort by HTR fiber
  for (i = 0; i < CHAcount; i++){
    tempVector.push_back (lmapHBEFO -> htr_fiC[i]);
  }
  stable_sort(lmapHBEFO -> orderC.begin( ), lmapHBEFO -> orderC.end( ), SortComp);
  tempVector.clear();

  //Sort by FPGA
  for (i = 0; i < CHAcount; i++){
    if (lmapHBEFO -> fpgaC[i] == "top") tempVector.push_back (0);
    else                                tempVector.push_back (1);
  }
  stable_sort(lmapHBEFO -> orderC.begin( ), lmapHBEFO -> orderC.end( ), SortComp);
  tempVector.clear();

  //Sort by HTR
  for (i = 0; i < CHAcount; i++){
    tempVector.push_back (lmapHBEFO -> htrC[i]);
  }
  stable_sort(lmapHBEFO -> orderC.begin( ), lmapHBEFO -> orderC.end( ), SortComp);
  tempVector.clear();

  //Sort by crate
  for (i = 0; i < CHAcount; i++){
    tempVector.push_back (lmapHBEFO -> crateC[i]);
  }
  stable_sort(lmapHBEFO -> orderC.begin( ), lmapHBEFO -> orderC.end( ), SortComp);
  tempVector.clear();

  //Sort by subdetector
  for (i = 0; i < CHAcount; i++){
    if      (lmapHBEFO -> detC[i] == "HB" || lmapHBEFO -> detC[i] == "HE") tempVector.push_back (0);
    else if (lmapHBEFO -> detC[i] == "HF")                                 tempVector.push_back (1);
    else                                                                   tempVector.push_back (2);
  }
  stable_sort(lmapHBEFO -> orderC.begin( ), lmapHBEFO -> orderC.end( ), SortComp);
  tempVector.clear();

  return lmapHBEFO;
}
bool SortComp ( int  x,
int  y 
)

Definition at line 229 of file DBlmapReader.cc.

References tempVector, x, and detailsBasic3DVector::y.

Referenced by SortByGeometry(), and SortByHardware().

                           {
  return tempVector[x] < tempVector[y];
}