Go to the documentation of this file.00001 #include <iostream>
00002 #include <sstream>
00003 #include <istream>
00004 #include <fstream>
00005 #include <iomanip>
00006 #include <stdlib.h>
00007 #include <string.h>
00008
00009 #include "HLTrigger/HLTanalyzers/interface/EventHeader.h"
00010
00011 EventHeader::EventHeader() :
00012 fRun( -1 ),
00013 fEvent( -1 ),
00014 fLumiBlock( -1 ),
00015 fBx( -1 ),
00016 fOrbit( -1 ),
00017 fAvgInstDelLumi( -999. ),
00018 _Debug( false )
00019 { }
00020
00021 EventHeader::~EventHeader() {
00022
00023 }
00024
00025
00026 void EventHeader::setup(TTree* HltTree) {
00027
00028 fRun = -1;
00029 fEvent = -1;
00030 fLumiBlock=-1;
00031 fBx = -1;
00032 fOrbit = -1;
00033 fAvgInstDelLumi = -999.;
00034
00035 HltTree->Branch("Run", &fRun, "Run/I");
00036 HltTree->Branch("Event", &fEvent, "Event/I");
00037 HltTree->Branch("LumiBlock", &fLumiBlock, "LumiBlock/I");
00038 HltTree->Branch("Bx", &fBx, "Bx/I");
00039 HltTree->Branch("Orbit", &fOrbit, "Orbit/I");
00040 HltTree->Branch("AvgInstDelLumi", &fAvgInstDelLumi, "AvgInstDelLumi/D");
00041 }
00042
00043
00044 void EventHeader::analyze(edm::Event const& iEvent, const edm::ESHandle<LumiCorrectionParam> & lumicorrdatahandle, TTree* HltTree) {
00045
00046 fRun = iEvent.id().run();
00047 fEvent = iEvent.id().event();
00048 fLumiBlock = iEvent.luminosityBlock();
00049 fBx = iEvent.bunchCrossing();
00050 fOrbit = iEvent.orbitNumber();
00051
00052
00053 bool lumiException = false;
00054 const edm::LuminosityBlock& iLumi = iEvent.getLuminosityBlock();
00055 edm::Handle<LumiSummary> lumiSummary;
00056 try{
00057 iLumi.getByLabel("lumiProducer", lumiSummary);
00058 lumiSummary->isValid();
00059 }
00060 catch(cms::Exception&){
00061 lumiException = true;
00062 }
00063 if(!lumiException)
00064 {
00065
00066 fAvgInstDelLumi = lumiSummary->avgInsDelLumi();
00067
00068
00069 float instlumi = fAvgInstDelLumi;
00070 float corrfac=1.;
00071 if(lumicorrdatahandle.isValid()){
00072 const LumiCorrectionParam* mydata=lumicorrdatahandle.product();
00073 corrfac=mydata->getCorrection(instlumi);
00074 fAvgInstDelLumi= corrfac * instlumi;
00075 }
00076 }
00077 else
00078 fAvgInstDelLumi = -999.;
00079
00080 if (_Debug) {
00081 std::cout << "EventHeader -- run = " << fRun << std::endl;
00082 std::cout << "EventHeader -- event = " << fEvent << std::endl;
00083 std::cout << "EventHeader -- lumisection = " << fLumiBlock << std::endl;
00084 std::cout << "EventHeader -- bunch crossing = " << fBx << std::endl;
00085 std::cout << "EventHeader -- orbit number = " << fOrbit << std::endl;
00086 }
00087
00088 }