UserUtils
EDHistogramAnalyzer.hpp
1#include "CommonTools/UtilAlgos/interface/TFileService.h"
2#include "FWCore/Framework/interface/one/EDAnalyzer.h"
3#include "FWCore/ServiceRegistry/interface/Service.h"
4
5#include "UserUtils/EDMUtils/interface/PluginAlias.hpp"
6
7#include "TH1D.h"
8#include "TH2D.h"
9
10namespace usr
11{
12
14{
15public:
16 EDHistogramAnalyzer( const edm::ParameterSet& );
18
19protected:
20 edm::Service<TFileService> fs;
21 std::map<std::string, TH1D*> _histmap;
22 std::map<std::string, TH2D*> _hist2dmap;
23
24 template<typename ... Args>
25 inline TH1D&
26 BookHist1D( const std::string& name, Args ... args )
27 {
28 _histmap[name] = fs->make<TH1D>( name.c_str(), "", args ... );
29 return *( _histmap[name] );
30 }
31
32
33 template<typename ... Args>
34 inline TH2D&
35 BookHist2D( const std::string& name, Args ... args )
36 {
37 _hist2dmap[name] = fs->make<TH2D>( name.c_str(), "", args ... );
38 return *( _hist2dmap[name] );
39 }
40
41
42 inline bool
43 HasHist( const std::string& x )
44 {
45 return _histmap.count( x );
46 }
47
48
49 inline bool
50 HasHist2D( const std::string & x )
51 {
52 return _hist2dmap.count( x );
53 }
54
55
56 inline TH1D&
57 Hist( const std::string& x )
58 {
59 return *( _histmap[x] );
60 }
61
62
63 inline TH2D&
64 Hist2D( const std::string& x )
65 {
66 return *( _hist2dmap[x] );
67 }
68};
69
70}// namespace usr
Definition: EDHistogramAnalyzer.hpp:14
class for reducing the verbosity of the various edm plugin calls.
Definition: PluginAlias.hpp:37