CMS 3D CMS Logo

Public Member Functions | Private Types | Private Attributes

L1CaloHcalScaleConfigOnlineProd Class Reference

Inheritance diagram for L1CaloHcalScaleConfigOnlineProd:
L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale > edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

List of all members.

Public Member Functions

 L1CaloHcalScaleConfigOnlineProd (const edm::ParameterSet &iConfig)
virtual boost::shared_ptr
< L1CaloHcalScale
newObject (const std::string &objectKey)
 ~L1CaloHcalScaleConfigOnlineProd ()

Private Types

typedef std::vector< double > RCTdecompression

Private Attributes

CaloTPGTranscoderULUTcaloTPG
L1CaloHcalScalehcalScale
std::vector< RCTdecompressionhcaluncomp
HcalTrigTowerGeometrytheTrigTowerGeometry
HcalTrigTowerDetIdttDetId

Detailed Description

Definition at line 39 of file L1CaloHcalScaleConfigOnlineProd.cc.


Member Typedef Documentation

typedef std::vector<double> L1CaloHcalScaleConfigOnlineProd::RCTdecompression [private]

Definition at line 54 of file L1CaloHcalScaleConfigOnlineProd.cc.


Constructor & Destructor Documentation

L1CaloHcalScaleConfigOnlineProd::L1CaloHcalScaleConfigOnlineProd ( const edm::ParameterSet iConfig)

Definition at line 76 of file L1CaloHcalScaleConfigOnlineProd.cc.

References caloTPG, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), hcalScale, HcalTopologyMode::LHC, alignBH_cfg::mode, geometryXMLtoCSV::parser, AlCaHLTBitMon_QueryRunRegistry::string, and theTrigTowerGeometry.

  : L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale >( iConfig )
{
  hcalScale = new L1CaloHcalScale(0);
  caloTPG = new CaloTPGTranscoderULUT();
  
  HcalTopologyMode::Mode mode = HcalTopologyMode::LHC;
  int maxDepthHB = 2;
  int maxDepthHE = 3;
  if( iConfig.exists( "hcalTopologyConstants" ))
  {
    const edm::ParameterSet hcalTopoConsts = iConfig.getParameter<edm::ParameterSet>( "hcalTopologyConstants" );
    StringToEnumParser<HcalTopologyMode::Mode> parser;
    mode = (HcalTopologyMode::Mode) parser.parseString(hcalTopoConsts.getParameter<std::string>("mode"));
    maxDepthHB = hcalTopoConsts.getParameter<int>("maxDepthHB");
    maxDepthHE = hcalTopoConsts.getParameter<int>("maxDepthHE");
  }
  
  theTrigTowerGeometry = new HcalTrigTowerGeometry( new HcalTopology( mode, maxDepthHB, maxDepthHE ));
}
L1CaloHcalScaleConfigOnlineProd::~L1CaloHcalScaleConfigOnlineProd ( )

Definition at line 99 of file L1CaloHcalScaleConfigOnlineProd.cc.

References caloTPG.

{
  // do anything here that needs to be done at desctruction time
  // (e.g. close files, deallocate resources etc.)

  if(caloTPG != 0)
    delete caloTPG;
}

Member Function Documentation

boost::shared_ptr< L1CaloHcalScale > L1CaloHcalScaleConfigOnlineProd::newObject ( const std::string &  objectKey) [virtual]

Implements L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale >.

Definition at line 109 of file L1CaloHcalScaleConfigOnlineProd.cc.

References abs, l1t::OMDSReader::QueryResults::attributeLists(), l1t::OMDSReader::basicQuery(), l1t::OMDSReader::basicQueryView(), caloTPG, gather_cfg::cout, l1t::DataManager::dbSession(), end, l1t::OMDSReader::QueryResults::fillVariableFromRow(), HcalTrigTowerGeometry::firstHFTower(), CaloTPGTranscoderULUT::getOutputLUTId(), hcalScale, hcaluncomp, CaloTPGTranscoderULUT::HTvalid(), i, createXMLFile::iphi, gen::k, funct::log(), L1ConfigOnlineProdBase< L1CaloHcalScaleRcd, L1CaloHcalScale >::m_omdsReader, min, L1CaloHcalScale::nBinEta, L1CaloHcalScale::nBinRank, l1t::OMDSReader::QueryResults::numberRows(), summarizeEdmComparisonLogfiles::objectName, pos, funct::pow(), L1CaloHcalScale::print(), o2o::query, l1t::OMDSReader::QueryResults::queryFailed(), cond::DbSession::schema(), python::IdGenerator::schema, L1CaloHcalScale::setBin(), l1t::OMDSReader::singleAttribute(), mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, theTrigTowerGeometry, dtDQMClient_cfg::threshold, and HcalTrigTowerGeometry::towerEtaBounds().

{
     using namespace edm::es;
 
     std:: cout << "object Key " << objectKey <<std::endl <<std::flush;

     if(objectKey == "NULL" || objectKey == "")  // return default blank ecal scale      
       return boost::shared_ptr< L1CaloHcalScale >( hcalScale );
     if(objectKey == "IDENTITY"){  // return identity ecal scale  
       
       delete hcalScale;
       
       hcalScale = new L1CaloHcalScale(1);
       
       return boost::shared_ptr< L1CaloHcalScale >( hcalScale);
     }
  
     std::vector<unsigned int> analyticalLUT(1024, 0);
     std::vector<unsigned int> identityLUT(1024, 0);
     
     // Compute compression LUT
     for (unsigned int i=0; i < 1024; i++) {
       analyticalLUT[i] = (unsigned int)(sqrt(14.94*log(1.+i/14.94)*i) + 0.5);
       identityLUT[i] = std::min(i,0xffu);
     }
     
     hcaluncomp.clear();
     for (int i = 0; i < 4176; i++){
       RCTdecompression decompressionTable(256,0);
       hcaluncomp.push_back(decompressionTable);
    }
     


     std::vector < std::string > mainStrings;
     mainStrings.push_back("HCAL_LUT_METADATA");
     mainStrings.push_back("HCAL_LUT_CHAN_DATA");

     // ~~~~~~~~~ Cut values ~~~~~~~~~

 
     std::vector< std::string > metaStrings ;
     metaStrings.push_back("RCTLSB");  
     metaStrings.push_back("NOMINAL_GAIN");  
   
 
    l1t::OMDSReader::QueryResults paramResults =
       m_omdsReader.basicQueryView( metaStrings,
                                "CMS_HCL_HCAL_COND",
                                "V_HCAL_LUT_METADATA_V1",
                                "V_HCAL_LUT_METADATA_V1.TAG_NAME",
                                m_omdsReader.basicQuery(
                                                        "HCAL_LUT_METADATA",
                                                        "CMS_RCT",
                                                        "HCAL_SCALE_KEY",
                                                        "HCAL_SCALE_KEY.HCAL_TAG",
                                                        m_omdsReader.singleAttribute(objectKey)));
    

    
    
    if( paramResults.queryFailed()
        || (paramResults.numberRows()!=1) ) // check query successful
       {
         edm::LogError( "L1-O2O" ) << "Problem with L1CaloHcalScale key.  Unable to find lutparam dat table" ;
         return boost::shared_ptr< L1CaloHcalScale >() ;
       }
        
    double hcalLSB, nominal_gain;
    paramResults.fillVariable("RCTLSB",hcalLSB);    
    paramResults.fillVariable("NOMINAL_GAIN",nominal_gain);
 
    float    rctlsb = hcalLSB;



    l1t::OMDSReader::QueryResults chanKey =m_omdsReader.basicQuery(
                                                                  "HCAL_LUT_CHAN_DATA",
                                                                  "CMS_RCT",
                                                                  "HCAL_SCALE_KEY",
                                                                  "HCAL_SCALE_KEY.HCAL_TAG",
                                                                  m_omdsReader.singleAttribute(objectKey));
      
    //coral::AttributeList myresult;
    //    myresult.extend(
    
 
    std::string schemaName("CMS_HCL_HCAL_COND");
    coral::ISchema& schema = m_omdsReader.dbSession()->schema( schemaName ) ;
    coral::IQuery* query = schema.newQuery(); ;

     
    std::vector< std::string > channelStrings;
    channelStrings.push_back("IPHI");
    channelStrings.push_back("IETA");
    channelStrings.push_back("LUT_GRANULARITY");
    channelStrings.push_back("OUTPUT_LUT_THRESHOLD");
    channelStrings.push_back("OBJECTNAME");

                 
   
     std::vector< std::string >::const_iterator it = channelStrings.begin() ;
     std::vector< std::string >::const_iterator end = channelStrings.end() ;
     for( ; it != end ; ++it )
       {
         query->addToOutputList( *it ) ;
       }

    std::string ob = "OBJECTNAME";
    coral::AttributeList myresult; 
    myresult.extend("IPHI", typeid(int)); 
    myresult.extend("IETA", typeid(int)); 
    myresult.extend("LUT_GRANULARITY", typeid(int)); 
    myresult.extend("OUTPUT_LUT_THRESHOLD", typeid(int)); 
    myresult.extend( ob,typeid(std::string));//, typeid(std::string)); 

    query->defineOutput( myresult ); 

    query->addToTableList( "V_HCAL_LUT_CHAN_DATA_V1");

    query->setCondition(
                        "V_HCAL_LUT_CHAN_DATA_V1.TAG_NAME = :" + chanKey.columnNames().front(),
                        chanKey.attributeLists().front());

    coral::ICursor& cursor = query->execute();

 // when the query goes out of scope.
    std::vector<coral::AttributeList> atts;
    while (cursor.next()) {
        atts.push_back(cursor.currentRow());
    };

    delete query;

    l1t::OMDSReader::QueryResults chanResults(channelStrings,atts); 
    if( chanResults.queryFailed()
        || (chanResults.numberRows()==0) ) // check query successful
       {
         edm::LogError( "L1-O2O" ) << "Problem with L1CaloHcalScale key.  Unable to find lutparam dat table nrows" << chanResults.numberRows() ;
         return boost::shared_ptr< L1CaloHcalScale >() ;
       }



    chanResults.attributeLists();
     for(int i = 0; i < chanResults.numberRows() ; ++i){
       std::string objectName;
       chanResults.fillVariableFromRow("OBJECTNAME",i, objectName);
       //       int
       if(objectName == "HcalTrigTowerDetId") { //trig tower
         int ieta, iphi, lutGranularity, threshold;
         
         
         chanResults.fillVariableFromRow("LUT_GRANULARITY",i,lutGranularity);
         chanResults.fillVariableFromRow("IPHI",i,iphi);
         chanResults.fillVariableFromRow("IETA",i,ieta);
         chanResults.fillVariableFromRow("OUTPUT_LUT_THRESHOLD",i,threshold);
         

         unsigned int outputLut[1024];

         uint32_t lutId = caloTPG->getOutputLUTId(ieta,iphi);

         double eta_low = 0., eta_high = 0.;
         theTrigTowerGeometry->towerEtaBounds(ieta,eta_low,eta_high); 
         double cosh_ieta = fabs(cosh((eta_low + eta_high)/2.));


         if (!caloTPG->HTvalid(ieta, iphi)) continue;
         double factor = 0.;
         if (abs(ieta) >= theTrigTowerGeometry->firstHFTower())
           factor = rctlsb;
         else 
           factor = nominal_gain / cosh_ieta * lutGranularity;
         for (int k = 0; k < threshold; ++k)
           outputLut[k] = 0;
         
         for (unsigned int k = threshold; k < 1024; ++k)
           outputLut[k] = (abs(ieta) < theTrigTowerGeometry->firstHFTower()) ? analyticalLUT[k] : identityLUT[k];
         

           // tpg - compressed value
           unsigned int tpg = outputLut[0];
          
           int low = 0;

          for (unsigned int k = 0; k < 1024; ++k){
             if (outputLut[k] != tpg){
                unsigned int mid = (low + k)/2;
                hcaluncomp[lutId][tpg] = (tpg == 0 ? low : factor * mid);
                low = k;
                tpg = outputLut[k];
             }
          }
          hcaluncomp[lutId][tpg] = factor * low;
       }
     }
     


     for( unsigned short ieta = 1 ; ieta <= L1CaloHcalScale::nBinEta; ++ieta ){
       for(int pos = 0; pos <=1; pos++){
         for( unsigned short irank = 0 ; irank < L1CaloHcalScale::nBinRank; ++irank ){
     
           
           
           int zside = (int)  pow(-1,pos);
           int nphi = 0;
           double etvalue = 0.;
           

           for(int iphi = 1; iphi<=72; iphi++){
             if(!caloTPG->HTvalid(ieta, iphi))
               continue;
             uint32_t lutId = caloTPG->getOutputLUTId(ieta,iphi);
             nphi++;
             etvalue += (double) hcaluncomp[lutId][irank];

           } // phi
           if (nphi > 0) etvalue /= nphi;
           
           hcalScale->setBin(irank, ieta, zside, etvalue);

         } // rank
       } // zside
     }// eta

     std::cout << std::setprecision(10);
     hcalScale->print(std::cout);
// ------------ method called to produce the data  ------------
     return boost::shared_ptr< L1CaloHcalScale >( hcalScale );

}

Member Data Documentation

Definition at line 55 of file L1CaloHcalScaleConfigOnlineProd.cc.

Referenced by newObject().

Definition at line 60 of file L1CaloHcalScaleConfigOnlineProd.cc.