CMS 3D CMS Logo

Public Member Functions | Private Attributes

CSCTFConfigProducer Class Reference

#include <CSCTFConfigProducer.h>

Inheritance diagram for CSCTFConfigProducer:
edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

List of all members.

Public Member Functions

 CSCTFConfigProducer (const edm::ParameterSet &pset)
std::auto_ptr< L1MuCSCPtLutproduceL1MuCSCPtLutRcd (const L1MuCSCPtLutRcd &iRecord)
std::auto_ptr< L1MuCSCTFAlignmentproduceL1MuCSCTFAlignmentRcd (const L1MuCSCTFAlignmentRcd &iRecord)
std::auto_ptr
< L1MuCSCTFConfiguration
produceL1MuCSCTFConfigurationRcd (const L1MuCSCTFConfigurationRcd &iRecord)
void readLUT (std::string path, unsigned short *lut, unsigned long length)
 ~CSCTFConfigProducer (void)

Private Attributes

std::vector< double > alignment
std::string ptLUT_path
std::string registers [12]

Detailed Description

Definition at line 19 of file CSCTFConfigProducer.h.


Constructor & Destructor Documentation

CSCTFConfigProducer::CSCTFConfigProducer ( const edm::ParameterSet pset)

Definition at line 9 of file CSCTFConfigProducer.cc.

References alignment, edm::ParameterSet::getParameter(), geometryCSVtoXML::line, mergeVDriftHistosByStation::name, produceL1MuCSCPtLutRcd(), produceL1MuCSCTFAlignmentRcd(), produceL1MuCSCTFConfigurationRcd(), ptLUT_path, registers, and edm::ESProducer::setWhatProduced().

                                                                    {
  const char *name[12] = {"registersSP1", "registersSP2", "registersSP3", "registersSP4",
                          "registersSP5", "registersSP6", "registersSP7", "registersSP8",
                          "registersSP9", "registersSP10","registersSP11","registersSP12"};
        
  for(int sp=0; sp<12; sp++){
    std::vector<std::string> regs = pset.getParameter<std::vector<std::string> >(name[sp]);
    for(std::vector<std::string>::const_iterator line=regs.begin(); line!=regs.end(); line++)
      registers[sp] += *line + "\n";
  }
        
  alignment  = pset.getParameter< std::vector<double> >("alignment");
  ptLUT_path = pset.getParameter< std::string >        ("ptLUT_path");
  setWhatProduced(this, &CSCTFConfigProducer::produceL1MuCSCTFConfigurationRcd);
  setWhatProduced(this, &CSCTFConfigProducer::produceL1MuCSCTFAlignmentRcd);
  setWhatProduced(this, &CSCTFConfigProducer::produceL1MuCSCPtLutRcd);

}
CSCTFConfigProducer::~CSCTFConfigProducer ( void  ) [inline]

Definition at line 32 of file CSCTFConfigProducer.h.

{}

Member Function Documentation

std::auto_ptr< L1MuCSCPtLut > CSCTFConfigProducer::produceL1MuCSCPtLutRcd ( const L1MuCSCPtLutRcd iRecord)

Definition at line 46 of file CSCTFConfigProducer.cc.

References Exception, ptLUT_path, and readLUT().

Referenced by CSCTFConfigProducer().

                                                                                                   {
  edm::LogInfo( "L1-O2O: CSCTFConfigProducer" ) << "Producing "
                                                << " L1MuCSCPtLut from PSET";
  


  std::auto_ptr<L1MuCSCPtLut> pt_lut = std::auto_ptr<L1MuCSCPtLut>( new L1MuCSCPtLut() );

  if( ptLUT_path.length() ){
    readLUT(ptLUT_path, (unsigned short *)pt_lut->pt_lut, 1<<21); //CSCBitWidths::kPtAddressWidth
  } else {
    throw cms::Exception("Undefined pT LUT")<<"CSCTFConfigProducer is unable to generate LUTs on the fly.\n"
      "Specify full LUT file names or just avoid using CSCTFConfigProducer by uncommenting PTLUT "
      "parameter sets in L1Trigger/CSCTrackFinder configuration."<<std::endl;
  }
  return pt_lut;
}
std::auto_ptr< L1MuCSCTFAlignment > CSCTFConfigProducer::produceL1MuCSCTFAlignmentRcd ( const L1MuCSCTFAlignmentRcd iRecord)

Definition at line 37 of file CSCTFConfigProducer.cc.

References alignment.

Referenced by CSCTFConfigProducer().

                                                                                                                     {
  edm::LogInfo( "L1-O2O: CSCTFConfigProducer" ) << "Producing "
                                                << " L1MuCSCTFAlignment from PSET";
  

  std::auto_ptr<L1MuCSCTFAlignment> al = std::auto_ptr<L1MuCSCTFAlignment>( new L1MuCSCTFAlignment(alignment) );
  return al;
}
std::auto_ptr< L1MuCSCTFConfiguration > CSCTFConfigProducer::produceL1MuCSCTFConfigurationRcd ( const L1MuCSCTFConfigurationRcd iRecord)

Definition at line 28 of file CSCTFConfigProducer.cc.

References HDQMDatabaseProducer::config, and registers.

Referenced by CSCTFConfigProducer().

                                                                                                                                 {

  edm::LogInfo( "L1-O2O: CSCTFConfigProducer" ) << "Producing "
                                                << " L1MuCSCTFConfiguration from PSET";
                                                
  std::auto_ptr<L1MuCSCTFConfiguration> config = std::auto_ptr<L1MuCSCTFConfiguration>( new L1MuCSCTFConfiguration(registers) );
  return config;
}
void CSCTFConfigProducer::readLUT ( std::string  path,
unsigned short *  lut,
unsigned long  length 
)

Definition at line 64 of file CSCTFConfigProducer.cc.

References Exception, mergeVDriftHistosByStation::file, and LogDebug.

Referenced by produceL1MuCSCPtLutRcd().

                                                                                          {
  // Reading
  if( path.find(".bin") != std::string::npos ) { // Binary format
    std::ifstream file(path.c_str(), std::ios::binary);
    file.read((char*)lut,length*sizeof(unsigned short));
    if( file.fail() )
      throw cms::Exception("Reading error")<<"CSCTFConfigProducer cannot read "<<length<<" words from "<<path<<" (errno="<<errno<<")"<<std::endl;
    if( (unsigned int)file.gcount() != length*sizeof(unsigned short) )
      throw cms::Exception("Incorrect LUT size")<<"CSCTFConfigProducer read "<<(file.gcount()/sizeof(unsigned short))<<" words from "<<path<<" instead of "<<length<<" (errno="<<errno<<")"<<std::endl;
    file.close();
  } else {
    std::ifstream file(path.c_str());
    if( file.fail() )
      throw cms::Exception("Cannot open file")<<"CSCTFConfigProducer cannot open "<<path<<" (errno="<<errno<<")"<<std::endl;
    unsigned int address=0;
    for(address=0; !file.eof() && address<length; address++)
      file >> lut[address]; // Warning: this may throw non-cms like exception
    if( address!=length ) throw cms::Exception("Incorrect LUT size")<<"CSCTFConfigProducer read "<<address<<" words from "<<path<<" instead of "<<length<<std::endl;
    file.close();
  }
  LogDebug("CSCTFConfigProducer::readLUT")<<" read from "<<path<<" "<<length<<" words"<<std::endl;
}

Member Data Documentation

std::vector<double> CSCTFConfigProducer::alignment [private]

Definition at line 22 of file CSCTFConfigProducer.h.

Referenced by CSCTFConfigProducer(), and produceL1MuCSCTFAlignmentRcd().

std::string CSCTFConfigProducer::ptLUT_path [private]

Definition at line 23 of file CSCTFConfigProducer.h.

Referenced by CSCTFConfigProducer(), and produceL1MuCSCPtLutRcd().

std::string CSCTFConfigProducer::registers[12] [private]

Definition at line 21 of file CSCTFConfigProducer.h.

Referenced by CSCTFConfigProducer(), and produceL1MuCSCTFConfigurationRcd().