CMS 3D CMS Logo

VertexPlots.h

Go to the documentation of this file.
00001 #ifndef HLTriggerOffline_BJet_VertexPlots_h
00002 #define HLTriggerOffline_BJet_VertexPlots_h
00003 
00004 // STL
00005 #include <vector>
00006 #include <string>
00007 
00008 // ROOT
00009 #include <TDirectory.h>
00010 #include <TH1F.h>
00011 
00012 // CMSSW
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     // access the shared ROOT file via TFileService
00026     edm::Service<TFileService> fileservice;
00027     
00028     // enable sum-of-squares for all plots
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     // reset sum-of-squares status
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

Generated on Tue Jun 9 17:38:00 2009 for CMSSW by  doxygen 1.5.4