Wrapper class of type BasicAnalyzer to "convert" it into a full a basic FWLiteAnalyzer. More...
#include <PhysicsTools/UtilAlgos/interface/FWLiteAnalyzerWrapper.h>
Wrapper class of type BasicAnalyzer to "convert" it into a full a basic FWLiteAnalyzer.
This template class is a wrapper round classes of type BasicAnalyzer as defined in in the BasicAnalyzer.h file of this package. From this class the wrapper expects the following member functions:
+ a contructor with a const edm::ParameterSet& and a TFileDirectory& as input. + a beginJob function + a endJob function + a analyze function with an const edm::EventBase& as input
these functions are called within the wrapper. The wrapper translates the common class into a basic FWLiteAnalyzer, which provides basic functionality of reading configuration files and event looping. An example of an application given in the PatExamples package is shown below:
include "PhysicsTools/PatExamples/interface/BasicMuonAnalyzer.h" include "PhysicsTools/UtilAlgos/interface/FWLiteAnalyzerWrapper.h"
typedef fwlite::AnalyzerWrapper<BasicMuonAnalyzer> WrappedFWLiteAnalyzer;
int main(int argc, char* argv[]) { load framework libraries gSystem->Load( "libFWCoreFWLite" ); AutoLibraryLoader::enable();
only allow one argument for this simple example which should be the the python cfg file if ( argc < 2 ) { std::cout << "Usage : " << argv[0] << " [parameters.py]" << std::endl; return 0; }
get the python configuration PythonProcessDesc builder(argv[1]); WrappedFWLiteAnalyzer ana(*(builder.processDesc()->getProcessPSet()), std::string("MuonAnalyzer"), std::string("analyzeBasicPat")); ana.beginJob(); ana.analyze(); ana.endJob(); return 0; }
The configuration file for this FWLiteAnalyzer is expected to have the following structure:
import FWCore.ParameterSet.Config as cms
process = cms.Process("FWLitePlots")
process.fwliteInput = cms.PSet( fileNames = cms.untracked.vstring('file:patTuple.root'), ## mandatory maxEvents = cms.int32(-1), ## optional outputEvery = cms.uint32(10), ## optional )
process.fwliteOutput = cms.PSet( fileName = cms.untracked.string('outputHistos.root') ## mandatory )
process.muonAnalyzer = cms.PSet( muons = cms.InputTag('cleanPatMuons') ## input for the simple example above )
where the parameters maxEvents and reportAfter are optional. If omitted all events in the file(s) will be looped and no progress report will be given. More input files can be given as a vector of strings. Potential histograms per default will be written directely into the file without any furhter directory structure. If the class is instantiated with an additional directory string a new directory with the corresponding name will be created and the histograms will be added to this directory. With these wrapper classes we have the use case in mind that you keep classes, which easily can be used both within the full framework and within FWLite.
NOTE: in the current implementation this wrapper class only supports basic event looping. For anytasks of more complexity we recommend you to start from a FWLiteAnalyzer class from the very beginning and just to stay within FWLite.