00001 #ifndef HLTriggerOffline_BJet_VertexPlots_h
00002 #define HLTriggerOffline_BJet_VertexPlots_h
00003
00004
00005 #include <vector>
00006 #include <string>
00007
00008
00009 #include <TDirectory.h>
00010 #include <TH1F.h>
00011
00012
00013 #include "FWCore/ServiceRegistry/interface/Service.h"
00014 #include "PhysicsTools/UtilAlgos/interface/TFileService.h"
00015 #include "DataFormats/VertexReco/interface/Vertex.h"
00016
00017 struct VertexPlots {
00018 VertexPlots() :
00019 m_r(0),
00020 m_z(0)
00021 { }
00022
00023 void init(const std::string & name, const std::string & title, unsigned int bins, double zRange, double rRange)
00024 {
00025
00026 edm::Service<TFileService> fileservice;
00027
00028
00029 bool sumw2 = TH1::GetDefaultSumw2();
00030 TH1::SetDefaultSumw2(true);
00031
00032 m_r = fileservice->make<TH1F>((name + "_R").c_str(), (title + " R position").c_str(), bins, -rRange, rRange);
00033 m_z = fileservice->make<TH1F>((name + "_Z").c_str(), (title + " Z position").c_str(), bins, -zRange, zRange);
00034
00035
00036 TH1::SetDefaultSumw2(sumw2);
00037 }
00038
00039 void fill(const reco::Vertex & vertex)
00040 {
00041 m_r->Fill(vertex.position().rho());
00042 m_z->Fill(vertex.z());
00043 }
00044
00045 void save(TDirectory & file)
00046 {
00047 m_r->SetDirectory(&file);
00048 m_z->SetDirectory(&file);
00049 }
00050
00051 TH1 * m_r;
00052 TH1 * m_z;
00053 };
00054
00055 #endif // HLTriggerOffline_BJet_VertexPlots_h