CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

DTTPGParamsWriter Class Reference

#include <DTTPGParamsWriter.h>

Inheritance diagram for DTTPGParamsWriter:
edm::EDAnalyzer

List of all members.

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &eventSetup)
 Compute the ttrig by fiting the TB rising edge.
 DTTPGParamsWriter (const edm::ParameterSet &pset)
 Constructor.
void endJob ()
 Write ttrig in the DB.
virtual ~DTTPGParamsWriter ()
 Destructor.

Private Member Functions

void pharseLine (std::string &line, DTChamberId &chId, float &fine, int &coarse)

Private Attributes

bool debug_
std::string inputFileName_
DTTPGParametersphaseMap_

Detailed Description

Definition at line 25 of file DTTPGParamsWriter.h.


Constructor & Destructor Documentation

DTTPGParamsWriter::DTTPGParamsWriter ( const edm::ParameterSet pset)

Constructor.

Definition at line 30 of file DTTPGParamsWriter.cc.

References gather_cfg::cout, and edm::ParameterSet::getUntrackedParameter().

                                                             {

  debug_ = pset.getUntrackedParameter<bool>("debug", false);
  inputFileName_ = pset.getUntrackedParameter<string>("inputFile");
  // Create the object to be written to DB
  phaseMap_ = new DTTPGParameters();
  
  if(debug_)
    cout << "[DTTPGParamsWriter]Constructor called!" << endl;

}
DTTPGParamsWriter::~DTTPGParamsWriter ( ) [virtual]

Destructor.

Definition at line 45 of file DTTPGParamsWriter.cc.

References gather_cfg::cout.

                                     {

  if(debug_)
    cout << "[DTTPGParamsWriter]Destructor called!" << endl;

}

Member Function Documentation

void DTTPGParamsWriter::analyze ( const edm::Event event,
const edm::EventSetup eventSetup 
) [virtual]

Compute the ttrig by fiting the TB rising edge.

Implements edm::EDAnalyzer.

Definition at line 53 of file DTTPGParamsWriter.cc.

References gather_cfg::cout, geometryCSVtoXML::line, submitDQMOfflineCAF::nLines, and DTTimeUnits::ns.

                                                                                 {

  if(debug_)
    cout << "[DTTPGParamsWriter]Reading data from file." << endl;

  std::ifstream inputFile_(inputFileName_.c_str());  
  int nLines=0;
  std::string line;

  while(std::getline(inputFile_, line)) {
    DTChamberId chId;
    float fine;
    int coarse;
    pharseLine(line,chId,fine,coarse);
    phaseMap_->set(chId,coarse,fine,DTTimeUnits::ns);
    if (debug_) {
      float fineDB;
      int coarseDB;
      phaseMap_->get(chId,coarseDB,fineDB,DTTimeUnits::ns);
      std::cout << "[DTTPGParamsWriter] Read data for chamber " << chId 
                << ". File params -> fine: " << fine << " coarse: " << coarse 
                << ". DB params -> fine: " << fineDB << " coarse: " << coarseDB << std::endl;
    }
    nLines++;
  }
  if (debug_) {
    std::cout << "[DTTPGParamsWriter] # of entries written the the DB: " << nLines << std::endl;
  }
  if (nLines!=250) {
    std::cout << "[DTTPGParamsWriter] # of DB entries != 250. Check you input file!" << std::endl;
  }
  

  inputFile_.close();


}
void DTTPGParamsWriter::endJob ( void  ) [virtual]

Write ttrig in the DB.

Reimplemented from edm::EDAnalyzer.

Definition at line 106 of file DTTPGParamsWriter.cc.

References gather_cfg::cout, and DTCalibDBUtils::writeToDB().

                               {
  if(debug_) 
        cout << "[DTTPGParamsWriter] Writing ttrig object to DB!" << endl;

  string delayRecord = "DTTPGParametersRcd";
  DTCalibDBUtils::writeToDB(delayRecord, phaseMap_);

}  
void DTTPGParamsWriter::pharseLine ( std::string &  line,
DTChamberId chId,
float &  fine,
int &  coarse 
) [private]

Definition at line 91 of file DTTPGParamsWriter.cc.

References gather_cfg::cout, DTChamberId, asciidump::elements, and split.

                                                                                                {

  std::vector<std::string> elements;
  boost::algorithm::split(elements,line,boost::algorithm::is_any_of(string(" \t\n")));  // making string conversion explicit (needed to cope with -Warray-bounds in slc5_ia32_gcc434  
  if (elements.size() != 5) {
    std::cout << "[DTTPGParamsWriter] wrong number of entries in line : " << line << " pleas check your input file syntax!" << std::endl;
  } else {
    chId   = DTChamberId(atoi(elements[0].c_str()),atoi(elements[1].c_str()),atoi(elements[2].c_str()));
    fine   = atof(elements[3].c_str());
    coarse = atoi(elements[4].c_str());
  }

}

Member Data Documentation

bool DTTPGParamsWriter::debug_ [private]

Definition at line 45 of file DTTPGParamsWriter.h.

std::string DTTPGParamsWriter::inputFileName_ [private]

Definition at line 46 of file DTTPGParamsWriter.h.

Definition at line 47 of file DTTPGParamsWriter.h.