Public Member Functions | |
SumHistoCalibration (const edm::ParameterSet &) | |
~SumHistoCalibration () | |
Private Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
virtual void | beginJob () |
virtual void | endJob () |
TrackProbabilityCalibration * | fromXml (edm::FileInPath xmlCalibration) |
Private Attributes | |
edm::ParameterSet | config |
TrackProbabilityCalibration * | m_calibration [2] |
bool | m_sum2D |
bool | m_sum3D |
std::vector< std::string > | m_xmlilelist2d |
std::vector< std::string > | m_xmlilelist3d |
unsigned int | maxLoop |
unsigned int | minLoop |
Definition at line 81 of file SumHistoCalibration.cc.
SumHistoCalibration::SumHistoCalibration | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 107 of file SumHistoCalibration.cc.
References edm::ParameterSet::getParameter(), m_sum2D, m_sum3D, m_xmlilelist2d, and m_xmlilelist3d.
:config(iConfig) { m_xmlilelist2d = iConfig.getParameter<std::vector<std::string> >("xmlfiles2d"); m_xmlilelist3d = iConfig.getParameter<std::vector<std::string> >("xmlfiles3d"); m_sum2D = iConfig.getParameter<bool>("sum2D"); m_sum3D = iConfig.getParameter<bool>("sum3D"); }
SumHistoCalibration::~SumHistoCalibration | ( | ) |
Definition at line 116 of file SumHistoCalibration.cc.
{ }
void SumHistoCalibration::analyze | ( | const edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Implements edm::EDAnalyzer.
Definition at line 122 of file SumHistoCalibration.cc.
References dt_dqm_sourceclient_common_cff::reco.
{ using namespace edm; using namespace reco; using namespace std; }
void SumHistoCalibration::beginJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 141 of file SumHistoCalibration.cc.
References TrackProbabilityCalibration::Entry::category, TrackProbabilityCalibration::data, alignCSCRings::e, fromXml(), TrackProbabilityCalibration::Entry::histogram, i, j, m_calibration, m_sum2D, m_sum3D, m_xmlilelist2d, m_xmlilelist3d, maxLoop, and minLoop.
{ if(m_sum2D && m_sum3D){minLoop = 0; maxLoop =1;} if(m_sum2D && !m_sum3D){minLoop = 0; maxLoop =0;} if(!m_sum2D && m_sum3D){minLoop = 1; maxLoop =1;} using namespace edm; m_calibration[0] = new TrackProbabilityCalibration(); m_calibration[1] = new TrackProbabilityCalibration(); const TrackProbabilityCalibration * ca[2]; edm::FileInPath fip(m_xmlilelist3d[0]); edm::FileInPath fip2(m_xmlilelist2d[0]); ca[0] = fromXml(fip); ca[1] = fromXml(fip2); for(unsigned int i=minLoop;i <=maxLoop ;i++) for(unsigned int j=0;j<ca[i]->data.size() ; j++) { TrackProbabilityCalibration::Entry e; e.category=ca[i]->data[j].category; e.histogram=ca[i]->data[j].histogram; m_calibration[i]->data.push_back(e); } delete ca[0]; delete ca[1]; }
void SumHistoCalibration::endJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 217 of file SumHistoCalibration.cc.
References config, TrackProbabilityCalibration::data, fromXml(), edm::ParameterSet::getParameter(), edm::Service< T >::isAvailable(), j, gen::k, m_calibration, m_sum2D, m_sum3D, m_xmlilelist2d, m_xmlilelist3d, summaryLumi::ofile, dt_dqm_sourceclient_common_cff::reco, and findQualityFiles::size.
{ using namespace edm; using namespace reco; using namespace std; if(m_sum3D){ for(unsigned int itFile =1; itFile< m_xmlilelist3d.size(); itFile++){ edm::FileInPath fip(m_xmlilelist3d[itFile]); const TrackProbabilityCalibration *ca = fromXml(fip); for(unsigned int j=0;j<ca->data.size() ; j++) { for(int k = 0; k< m_calibration[0]->data[j].histogram.numberOfBins(); k++){ m_calibration[0]->data[j].histogram.setBinContent(k, ca->data[j].histogram.binContent(k) + m_calibration[0]->data[j].histogram.binContent(k)); } } delete ca; } } if(m_sum2D){ for(unsigned int itFile =1; itFile< m_xmlilelist2d.size(); itFile++){ edm::FileInPath fip(m_xmlilelist2d[itFile]); TrackProbabilityCalibration * ca = fromXml(fip); for(unsigned int j=0;j<ca->data.size() ; j++) { for(int k = 0; k< m_calibration[1]->data[j].histogram.numberOfBins(); k++){ m_calibration[1]->data[j].histogram.setBinContent(k,ca->data[j].histogram.binContent(k) + m_calibration[1]->data[j].histogram.binContent(k)); } } delete ca; } } if(config.getParameter<bool>("writeToDB")) { edm::Service<cond::service::PoolDBOutputService> mydbservice; if( !mydbservice.isAvailable() ) return; //mydbservice->createNewIOV<TrackProbabilityCalibration>(m_calibration[0], mydbservice->endOfTime(),"BTagTrackProbability3DRcd"); //mydbservice->createNewIOV<TrackProbabilityCalibration>(m_calibration[1], mydbservice->endOfTime(),"BTagTrackProbability2DRcd"); mydbservice->createNewIOV<TrackProbabilityCalibration>(m_calibration[0], mydbservice->beginOfTime(), mydbservice->endOfTime(),"BTagTrackProbability3DRcd"); mydbservice->createNewIOV<TrackProbabilityCalibration>(m_calibration[1], mydbservice->beginOfTime(), mydbservice->endOfTime(),"BTagTrackProbability2DRcd"); } if(config.getParameter<bool>("writeToRootXML")) { std::ofstream of2("2d.xml"); TBufferXML b2(TBuffer::kWrite); of2 << b2.ConvertToXML(static_cast<void*>(m_calibration[1]), TClass::GetClass("TrackProbabilityCalibration"), kTRUE, kFALSE); of2.close(); std::ofstream of3("3d.xml"); TBufferXML b3(TBuffer::kWrite); of3 << b3.ConvertToXML(static_cast<void*>(m_calibration[0]), TClass::GetClass("TrackProbabilityCalibration"), kTRUE, kFALSE); of3.close(); } if(config.getParameter<bool>("writeToBinary")) { std::ofstream ofile("2d.dat"); MyTBuffer buffer(TBuffer::kWrite); buffer.StreamObject(const_cast<void*>(static_cast<const void*>(m_calibration[1])), TClass::GetClass("TrackProbabilityCalibration")); Int_t size = buffer.Length(); ofile.write(buffer.Buffer(),size); ofile.close(); std::ofstream ofile3("3d.dat"); MyTBuffer buffer3(TBuffer::kWrite); buffer3.StreamObject(const_cast<void*>(static_cast<const void*>(m_calibration[0])), TClass::GetClass("TrackProbabilityCalibration")); Int_t size3 = buffer3.Length(); ofile3.write(buffer3.Buffer(),size3); ofile3.close(); } }
TrackProbabilityCalibration * SumHistoCalibration::fromXml | ( | edm::FileInPath | xmlCalibration | ) | [private] |
Definition at line 182 of file SumHistoCalibration.cc.
References Exception, edm::FileInPath::fullPath(), and xmlFile().
Referenced by beginJob(), and endJob().
{ std::ifstream xmlFile(xmlCalibration.fullPath().c_str()); if (!xmlFile.good()) throw cms::Exception("BTauFakeMVAJetTagConditions") << "File \"" << xmlCalibration.fullPath() << "\" could not be opened for reading." << std::endl; std::ostringstream ss; ss << xmlFile.rdbuf(); xmlFile.close(); TClass *classType = 0; void *ptr = TBufferXML(TBuffer::kRead).ConvertFromXMLAny( ss.str().c_str(), &classType, kTRUE, kFALSE); if (!ptr) throw cms::Exception("SumHistoCalibration") << "Unknown error parsing XML serialization" << std::endl; if (std::strcmp(classType->GetName(), "TrackProbabilityCalibration")) { classType->Destructor(ptr); throw cms::Exception("SumHistoCalibration") << "Serialized object has wrong C++ type." << std::endl; } return static_cast<TrackProbabilityCalibration*>(ptr); }
edm::ParameterSet SumHistoCalibration::config [private] |
Definition at line 91 of file SumHistoCalibration.cc.
Referenced by endJob().
Definition at line 101 of file SumHistoCalibration.cc.
Referenced by beginJob(), and endJob().
bool SumHistoCalibration::m_sum2D [private] |
Definition at line 98 of file SumHistoCalibration.cc.
Referenced by beginJob(), endJob(), and SumHistoCalibration().
bool SumHistoCalibration::m_sum3D [private] |
Definition at line 99 of file SumHistoCalibration.cc.
Referenced by beginJob(), endJob(), and SumHistoCalibration().
std::vector<std::string> SumHistoCalibration::m_xmlilelist2d [private] |
Definition at line 96 of file SumHistoCalibration.cc.
Referenced by beginJob(), endJob(), and SumHistoCalibration().
std::vector<std::string> SumHistoCalibration::m_xmlilelist3d [private] |
Definition at line 97 of file SumHistoCalibration.cc.
Referenced by beginJob(), endJob(), and SumHistoCalibration().
unsigned int SumHistoCalibration::maxLoop [private] |
Definition at line 100 of file SumHistoCalibration.cc.
Referenced by beginJob().
unsigned int SumHistoCalibration::minLoop [private] |
Definition at line 100 of file SumHistoCalibration.cc.
Referenced by beginJob().