Go to the documentation of this file.00001 #include <TFile.h>
00002 #include <TSystem.h>
00003
00004 #include "DataFormats/FWLite/interface/Event.h"
00005 #include "DataFormats/FWLite/interface/Handle.h"
00006 #include "FWCore/FWLite/interface/AutoLibraryLoader.h"
00007
00008 #include "DataFormats/FWLite/interface/Run.h"
00009 #include "DataFormats/FWLite/interface/LuminosityBlock.h"
00010 #include "DataFormats/Luminosity/interface/LumiSummary.h"
00011 #include "PhysicsTools/FWLite/interface/CommandLineParser.h"
00012
00013
00014 int main(int argc, char ** argv){
00015
00016 gSystem->Load( "libFWCoreFWLite" );
00017 AutoLibraryLoader::enable();
00018
00019
00020 optutl::CommandLineParser parser ("Analyze FWLite Histograms");
00021
00022
00023 parser.parseArguments (argc, argv);
00024 std::vector<std::string> inputFiles_ = parser.stringVector("inputFiles");
00025
00026 for(unsigned int iFile=0; iFile<inputFiles_.size(); ++iFile){
00027
00028 TFile* inFile = TFile::Open(inputFiles_[iFile].c_str());
00029 if( inFile ){
00030 fwlite::Event ev(inFile);
00031 fwlite::Handle<LumiSummary> summary;
00032
00033 std::cout << "----------- Accessing by event ----------------" << std::endl;
00034
00035
00036
00037 for(ev.toBegin(); !ev.atEnd(); ++ev){
00038
00039 std::cout << " Luminosity ID " << ev.getLuminosityBlock().id() << std::endl;
00040
00041 std::cout <<" Run ID " << ev.getRun().id()<< std::endl;
00042
00043 std::cout << "Run via lumi " << ev.getLuminosityBlock().getRun().id() << std::endl;
00044
00045
00046 summary.getByLabel(ev.getLuminosityBlock(),"lumiProducer");
00047 }
00048
00049 std::cout << "----------- Accessing by lumi block ----------------" << std::endl;
00050
00051 double lumi_tot = 0.0;
00052
00053 fwlite::LuminosityBlock ls(inFile);
00054 for(ls.toBegin(); !ls.atEnd(); ++ls){
00055 summary.getByLabel(ls,"lumiProducer");
00056 std::cout << ls.id() << " Inst. Luminosity = " << summary->avgInsRecLumi() << std::endl;
00057
00058 std::cout << "Run from lumi " << ls.getRun().id() << std::endl;
00059
00060 lumi_tot += summary->avgInsRecLumi();
00061 }
00062
00063 std::cout << "----------------------------------------------------" << std::endl;
00064 std::cout << "Total luminosity from lumi sections = " << lumi_tot << std::endl;
00065 std::cout << "----------------------------------------------------" << std::endl;
00066
00067 std::cout << "----------- Accessing by run ----------------" << std::endl;
00068
00069
00070 fwlite::Run r(inFile);
00071 for(r.toBegin(); !r.atEnd(); ++r) {
00072 std::cout << "Run " << r.id() << std::endl;
00073 }
00074
00075 inFile->Close();
00076 }
00077 }
00078 return 0;
00079 }