CMS 3D CMS Logo

Public Member Functions | Private Attributes

JetCorrectorDBWriter Class Reference

Inheritance diagram for JetCorrectorDBWriter:
edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginJob ()
virtual void endJob ()
 JetCorrectorDBWriter (const edm::ParameterSet &)
 ~JetCorrectorDBWriter ()

Private Attributes

std::string algo
std::string era
std::string inputTxtFile
std::string payloadTag

Detailed Description

Definition at line 17 of file JetCorrectorDBWriter.cc.


Constructor & Destructor Documentation

JetCorrectorDBWriter::JetCorrectorDBWriter ( const edm::ParameterSet pSet)

Definition at line 34 of file JetCorrectorDBWriter.cc.

References algo, era, edm::ParameterSet::getUntrackedParameter(), and payloadTag.

{
  era    = pSet.getUntrackedParameter<std::string>("era");
  algo   = pSet.getUntrackedParameter<std::string>("algo");
  //payloadTag = "JetCorrectorParametersCollection_"+era+"_"+algo;
  payloadTag = algo;
}
JetCorrectorDBWriter::~JetCorrectorDBWriter ( ) [inline]

Definition at line 24 of file JetCorrectorDBWriter.cc.

{}

Member Function Documentation

virtual void JetCorrectorDBWriter::analyze ( const edm::Event ,
const edm::EventSetup  
) [inline, virtual]

Implements edm::EDAnalyzer.

Definition at line 22 of file JetCorrectorDBWriter.cc.

{}
void JetCorrectorDBWriter::beginJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 43 of file JetCorrectorDBWriter.cc.

References algo, python::multivaluedict::append(), gather_cfg::cout, era, JetCorrectorParametersCollection::findLabel(), edm::FileInPath::fullPath(), JetCorrectorParametersCollection::getSections(), i, collect_tpl::input, inputTxtFile, edm::Service< T >::isAvailable(), JetCorrectorParametersCollection::N_LEVELS, getHLTPrescaleColumns::path, payloadTag, JetCorrectorParametersCollection::push_back(), and alignCSCRings::s.

{
  std::string path("CondFormats/JetMETObjects/data/");

  JetCorrectorParametersCollection *payload = new JetCorrectorParametersCollection();
  std::cout << "Starting to import payload " << payloadTag << " from text files." << std::endl;
  for ( int i = 0; i < JetCorrectorParametersCollection::N_LEVELS; ++i ) {
    
    std::string append("_");
    std::string ilev = JetCorrectorParametersCollection::findLabel( static_cast<JetCorrectorParametersCollection::Level_t>(i) );
    append += ilev;
    append += "_";
    append += algo;
    append += ".txt"; 
    inputTxtFile = path+era+append;
    std::ifstream input( ("../../../"+inputTxtFile).c_str() );
    if ( input.good() ) {
      edm::FileInPath fip(inputTxtFile);
      std::cout << "Opened file " << inputTxtFile << std::endl;
      // create the parameter object from file 
      std::vector<std::string> sections;
      JetCorrectorParametersCollection::getSections("../../../"+inputTxtFile, sections );
      if ( sections.size() == 0 ) {
        payload->push_back( i, JetCorrectorParameters(fip.fullPath(),"") );
      }
      else {
        for ( std::vector<std::string>::const_iterator isectbegin = sections.begin(), isectend = sections.end(), isect = isectbegin;
              isect != isectend; ++isect ) {
          payload->push_back( i, JetCorrectorParameters(fip.fullPath(),*isect), ilev + "_" + *isect );    
          std::cout << "Added " << ilev + "_" + *isect <<  " to record " << i << std::endl;
        }
      }
      std::cout << "Added record " << i << std::endl;
    } else {
      std::cout << "Did not find JEC file " << inputTxtFile << std::endl;
    }
    
  }
  
  std::cout << "Opening PoolDBOutputService" << std::endl;

  // now write it into the DB
  edm::Service<cond::service::PoolDBOutputService> s;
  if (s.isAvailable()) 
    {
      std::cout << "Setting up payload tag " << payloadTag << std::endl;
      if (s->isNewTagRequest(payloadTag)) 
        s->createNewIOV<JetCorrectorParametersCollection>(payload, s->beginOfTime(), s->endOfTime(), payloadTag);
      else 
        s->appendSinceTime<JetCorrectorParametersCollection>(payload, 111, payloadTag);
    }
  std::cout << "Wrote in CondDB payload label: " << payloadTag << std::endl;
}
virtual void JetCorrectorDBWriter::endJob ( void  ) [inline, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 23 of file JetCorrectorDBWriter.cc.

{}

Member Data Documentation

std::string JetCorrectorDBWriter::algo [private]

Definition at line 28 of file JetCorrectorDBWriter.cc.

Referenced by beginJob(), and JetCorrectorDBWriter().

std::string JetCorrectorDBWriter::era [private]

Definition at line 27 of file JetCorrectorDBWriter.cc.

Referenced by beginJob(), and JetCorrectorDBWriter().

std::string JetCorrectorDBWriter::inputTxtFile [private]

Definition at line 29 of file JetCorrectorDBWriter.cc.

Referenced by beginJob().

std::string JetCorrectorDBWriter::payloadTag [private]

Definition at line 30 of file JetCorrectorDBWriter.cc.

Referenced by beginJob(), and JetCorrectorDBWriter().