CMS 3D CMS Logo

Public Member Functions | Private Attributes

PhysicsPerformanceDBWriterFromFile_WPandPayload Class Reference

Inheritance diagram for PhysicsPerformanceDBWriterFromFile_WPandPayload:
edm::EDAnalyzer edm::EDConsumerBase

List of all members.

Public Member Functions

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

Private Attributes

std::string inputTxtFile
std::string rec1
std::string rec2

Detailed Description

Definition at line 17 of file PhysicsPerformanceDBWriterFromFile_WPandPayload.cc.


Constructor & Destructor Documentation

PhysicsPerformanceDBWriterFromFile_WPandPayload::PhysicsPerformanceDBWriterFromFile_WPandPayload ( const edm::ParameterSet p)
PhysicsPerformanceDBWriterFromFile_WPandPayload::~PhysicsPerformanceDBWriterFromFile_WPandPayload ( ) [inline]

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 22 of file PhysicsPerformanceDBWriterFromFile_WPandPayload.cc.

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

JUST A STUPID PATCH

Reimplemented from edm::EDAnalyzer.

Definition at line 39 of file PhysicsPerformanceDBWriterFromFile_WPandPayload.cc.

References newFWLiteAna::bin, comment, gather_cfg::cout, GOODCOLL_filter_cfg::cut, recoMuon::in, inputTxtFile, edm::Service< T >::isAvailable(), rec1, rec2, alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, and tmp.

{
  //
  // read object from file
  //

  //
  // File Format is
  // - tagger name
  // - cut
  // - concrete class name
  // - how many results and how many binning
  // - their values
  // - vector<float>
  //

  std::ifstream in;
  std::cout << "Opening "<< inputTxtFile<<std::endl;
  in.open(inputTxtFile.c_str());
  std::string tagger;
  float cut;
 
  std::string concreteType;
  std::string comment;
  std::vector<float> pl;
  int stride;

  in >> tagger;
  std::cout << "WP Tagger is "<<tagger<<std::endl;
  
  in >> cut;
  std::cout << "WP Cut is "<<cut<<std::endl;

  in >> concreteType;
  std::cout << "concrete Type is "<<concreteType<<std::endl;

  //  return ;

  // read # of results

  int nres, nbin;
  in >> nres;
  in >> nbin;
  std::cout <<" Results: " << nres<<" Binning variables: "<<nbin<<std::endl;

  stride = nres+nbin*2;
  
  int number=0;
  
  std::vector<PerformanceResult::ResultType> res;
  std::vector<BinningVariables::BinningVariablesType> bin;

  while (number<nres && !in.eof()) {
    int tmp;
    in>> tmp;
    res.push_back((PerformanceResult::ResultType)(tmp));
    number++;
  }
  if (number != nres){
    std::cout <<" Table not well formed"<<std::endl;
  }
  number=0;
  while (number<nbin && !in.eof()) {
    int tmp;
    in>> tmp;
    bin.push_back((BinningVariables::BinningVariablesType)(tmp));
    number++;
  }
  if (number != nbin){
    std::cout <<" Table not well formed"<<std::endl;
  }

  number=0;
  while (!in.eof()){
    float temp;
    in >> temp;
    std::cout <<" Intersing "<<temp<< " in position "<<number<<std::endl;
    number++;
    pl.push_back(temp);
  }

  //
  // CHECKS
  //
  if (stride != nbin*2+nres){
    std::cout <<" Table not well formed"<<std::endl;
  }
  if ((number % stride) != 0){
    std::cout <<" Table not well formed"<<std::endl;
  }

  std::cout <<" CLOSING "<<std::endl;
  in.close();


  /*  for (int k=0;k<(number/stride); k++){
    for (int j=0; j<stride; j++){
      std::cout << "Pos["<<k<<","<<j<<"] = "<<pl[k*stride+j]<<std::endl;
    }
  }
  */

  //
  // now create pl etc etc
  //

  PerformanceWorkingPoint * wp = new PerformanceWorkingPoint(cut, tagger);

  PerformancePayloadFromTable * btagpl = 0;

  if (concreteType == "PerformancePayloadFromTable"){
    btagpl = new PerformancePayloadFromTable(res, bin, stride, pl);
  }else{
    std::cout <<" Non existing request: " <<concreteType<<std::endl;
  }
  
  std::cout <<" Created the "<<concreteType <<" object"<<std::endl;
  
  edm::Service<cond::service::PoolDBOutputService> s;
  if (s.isAvailable())
    {
      if (s->isNewTagRequest(rec1))
        {
          s->createNewIOV<PerformancePayload>(btagpl,
                                                  s->beginOfTime(),
                                                  s->endOfTime(),
                                                  rec1);
        }
      else
        {
          
          s->appendSinceTime<PerformancePayload>(btagpl,
                                                     // JUST A STUPID PATCH
                                                     111,
                                                     rec1);
        }
    }

  // write also the WP
  
  if (s.isAvailable())
    {
      if (s->isNewTagRequest(rec2))
        {
          s->createNewIOV<PerformanceWorkingPoint>(wp,
                                            s->beginOfTime(),
                                            s->endOfTime(),
                                            rec2);
        }
      else
        {
          
          s->appendSinceTime<PerformanceWorkingPoint>(wp,
                                               111,
                                               rec2);
        }
    }
  
  
  
}
virtual void PhysicsPerformanceDBWriterFromFile_WPandPayload::endJob ( void  ) [inline, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 23 of file PhysicsPerformanceDBWriterFromFile_WPandPayload.cc.

{}

Member Data Documentation

Definition at line 27 of file PhysicsPerformanceDBWriterFromFile_WPandPayload.cc.

Referenced by beginJob().

Definition at line 28 of file PhysicsPerformanceDBWriterFromFile_WPandPayload.cc.

Referenced by beginJob().

Definition at line 28 of file PhysicsPerformanceDBWriterFromFile_WPandPayload.cc.

Referenced by beginJob().