CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

FFTJetCorrectorDBReader Class Reference

#include <JetMETCorrections/FFTJetModules/plugins/FFTJetCorrectorDBReader.cc>

Inheritance diagram for FFTJetCorrectorDBReader:
edm::EDAnalyzer edm::EDConsumerBase

List of all members.

Public Member Functions

 FFTJetCorrectorDBReader (const edm::ParameterSet &)
virtual ~FFTJetCorrectorDBReader ()

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 FFTJetCorrectorDBReader (const FFTJetCorrectorDBReader &)
 FFTJetCorrectorDBReader ()
FFTJetCorrectorDBReaderoperator= (const FFTJetCorrectorDBReader &)

Private Attributes

bool isArchiveCompressed
std::string outputFile
bool printAsString
bool readArchive
std::string record

Detailed Description

Description: writes a blob from a file into a database

Implementation: [Notes on implementation]

Definition at line 46 of file FFTJetCorrectorDBReader.cc.


Constructor & Destructor Documentation

FFTJetCorrectorDBReader::FFTJetCorrectorDBReader ( const edm::ParameterSet ps) [explicit]
virtual FFTJetCorrectorDBReader::~FFTJetCorrectorDBReader ( ) [inline, virtual]

Definition at line 50 of file FFTJetCorrectorDBReader.cc.

{}
FFTJetCorrectorDBReader::FFTJetCorrectorDBReader ( ) [private]
FFTJetCorrectorDBReader::FFTJetCorrectorDBReader ( const FFTJetCorrectorDBReader ) [private]

Member Function Documentation

void FFTJetCorrectorDBReader::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 75 of file FFTJetCorrectorDBReader.cc.

References prof2calltree::count, gather_cfg::cout, alignCSCRings::e, instance, isArchiveCompressed, outputFile, printAsString, readArchive, and record.

{
    edm::ESHandle<FFTJetCorrectorParameters> JetCorParams;
    StaticFFTJetCorrectorParametersLoader::instance().load(
        iSetup, record, JetCorParams);

    if (printAsString || readArchive)
        std::cout << "++++ FFTJetCorrectorDBReader: info for record \""
                  << record << '"' << std::endl;

    if (printAsString)
        std::cout << "++++ String rep: \"" 
                  << JetCorParams->str() << '"' << std::endl;
    else if (readArchive)
    {
        CPP11_auto_ptr<gs::StringArchive> par;

        {
            std::istringstream is(JetCorParams->str());
            if (isArchiveCompressed)
                par = gs::read_compressed_item<gs::StringArchive>(is);
            else
                par = gs::read_item<gs::StringArchive>(is);
        }

        const unsigned long long idSmall = par->smallestId();
        if (!idSmall)
            std::cout << "++++ No valid records in the archive" << std::endl;
        else
        {
            std::cout << "++++ Archive metadata begins" << std::endl;
            const unsigned long long idLarge = par->largestId();
            unsigned long long count = 0;
            for (unsigned long long id = idSmall; id <= idLarge; ++id)
                if (par->itemExists(id))
                {
                    CPP11_shared_ptr<const gs::CatalogEntry> e = 
                        par->catalogEntry(id);
                    std::cout << '\n';
                    e->humanReadable(std::cout);
                    ++count;
                }
            std::cout << "\n++++ Archive metadata ends, "
                      << count << " items total" << std::endl;
        }
    }

    if (!outputFile.empty())
    {
        std::ofstream of(outputFile.c_str(), std::ios_base::binary);
        if (!of.is_open())
            throw cms::Exception("InvalidArgument")
                << "Failed to open file \"" << outputFile << '"' << std::endl;
        if (!JetCorParams->empty())
        {
            of.write(JetCorParams->getBuffer(), JetCorParams->length());
            if (of.fail())
                throw cms::Exception("SystemError")
                    << "Output stream failure while writing file \""
                    << outputFile << '"' << std::endl;
        }
    }
}
FFTJetCorrectorDBReader& FFTJetCorrectorDBReader::operator= ( const FFTJetCorrectorDBReader ) [private]

Member Data Documentation

Definition at line 63 of file FFTJetCorrectorDBReader.cc.

Referenced by analyze().

std::string FFTJetCorrectorDBReader::outputFile [private]

Definition at line 60 of file FFTJetCorrectorDBReader.cc.

Referenced by analyze().

Definition at line 61 of file FFTJetCorrectorDBReader.cc.

Referenced by analyze().

Definition at line 62 of file FFTJetCorrectorDBReader.cc.

Referenced by analyze().

std::string FFTJetCorrectorDBReader::record [private]

Definition at line 59 of file FFTJetCorrectorDBReader.cc.

Referenced by analyze().