QwAnalysis
MQwHistograms.h
Go to the documentation of this file.
1 #ifndef __MQWHISTOGRAMS__
2 #define __MQWHISTOGRAMS__
3 
4 // System headers
5 #include <vector>
6 
7 // Root headers
8 #include "TH1.h"
9 
10 // Qweak headers
11 #include "QwLog.h"
12 
14 
15  /// Regular pointers for the histograms
16  typedef TH1* TH1_ptr;
17  // Shared pointers (boost::shared_ptr) are not advisable
18  // because ROOT keep ownership of all histograms. They
19  // are automatically deleted when ROOT closes the file.
20  // If we put them in a shared_ptr here, they would be
21  // deleted by the time the shared_ptr goes out of scope.
22 
23  protected:
24  /// Default constructor
26  /// Copy constructor
28  : fHistograms(source.fHistograms) { }
29  /// Virtual destructor
30  virtual ~MQwHistograms() { }
31 
32  /// Arithmetic assignment operator: Should only copy event-based data.
33  /// In this particular class, there is no event-based data.
34  virtual MQwHistograms& operator=(const MQwHistograms& value) {
35  return *this;
36  }
37 
38  inline void Fill_Pointer(TH1_ptr hist_ptr, Double_t value){
39  if (hist_ptr != NULL){
40  hist_ptr->Fill(value);
41  }
42  }
43 
44  protected:
45  /// Histograms associated with this data element
46  std::vector<TH1_ptr> fHistograms;
47 
48  protected:
49  /// Register a histogram
50  void AddHistogram(TH1* h) {
51  fHistograms.push_back(TH1_ptr(h));
52  }
53 
54  public:
55  /// Share histogram pointers between objects
56  void ShareHistograms(const MQwHistograms* source) {
57  if (source) fHistograms = source->fHistograms;
58  }
59 
60 
61 }; // class MQwHistograms
62 
63 #endif // __MQWHISTOGRAMS__
std::vector< TH1_ptr > fHistograms
Histograms associated with this data element.
Definition: MQwHistograms.h:46
void AddHistogram(TH1 *h)
Register a histogram.
Definition: MQwHistograms.h:50
virtual ~MQwHistograms()
Virtual destructor.
Definition: MQwHistograms.h:30
A logfile class, based on an identical class in the Hermes analyzer.
void Fill_Pointer(TH1_ptr hist_ptr, Double_t value)
Definition: MQwHistograms.h:38
MQwHistograms()
Default constructor.
Definition: MQwHistograms.h:25
TH1 * TH1_ptr
Regular pointers for the histograms.
Definition: MQwHistograms.h:16
virtual MQwHistograms & operator=(const MQwHistograms &value)
Definition: MQwHistograms.h:34
void ShareHistograms(const MQwHistograms *source)
Share histogram pointers between objects.
Definition: MQwHistograms.h:56
MQwHistograms(const MQwHistograms &source)
Copy constructor.
Definition: MQwHistograms.h:27