MQwHistograms.h

Go to the documentation of this file.
00001 #ifndef __MQWHISTOGRAMS__
00002 #define __MQWHISTOGRAMS__
00003 
00004 // System headers
00005 #include <vector>
00006 
00007 // Root headers
00008 #include "TH1.h"
00009 
00010 // Qweak headers
00011 #include "QwLog.h"
00012 
00013 class MQwHistograms {
00014 
00015     /// Regular pointers for the histograms
00016     typedef TH1* TH1_ptr;
00017     // Shared pointers (boost::shared_ptr) are not advisable
00018     // because ROOT keep ownership of all histograms.  They
00019     // are automatically deleted when ROOT closes the file.
00020     // If we put them in a shared_ptr here, they would be
00021     // deleted by the time the shared_ptr goes out of scope.
00022 
00023   protected:
00024     /// Default constructor
00025     MQwHistograms() { }
00026     /// Copy constructor
00027     MQwHistograms(const MQwHistograms& source)
00028     : fHistograms(source.fHistograms) { }
00029     /// Virtual destructor
00030     virtual ~MQwHistograms() { }
00031 
00032     /// Arithmetic assignment operator:  Should only copy event-based data.
00033     /// In this particular class, there is no event-based data.
00034     virtual MQwHistograms& operator=(const MQwHistograms& value) {
00035       return *this;
00036     }
00037 
00038     inline void Fill_Pointer(TH1_ptr hist_ptr, Double_t value){
00039       if (hist_ptr != NULL){
00040   hist_ptr->Fill(value);
00041       }
00042     }
00043 
00044   protected:
00045     /// Histograms associated with this data element
00046     std::vector<TH1_ptr> fHistograms;
00047 
00048   protected:
00049     /// Register a histogram
00050     void AddHistogram(TH1* h) {
00051       fHistograms.push_back(TH1_ptr(h));
00052     }
00053 
00054   public:
00055     /// Share histogram pointers between objects
00056     void ShareHistograms(const MQwHistograms* source) {
00057       if (source) fHistograms = source->fHistograms;
00058     }
00059 
00060 
00061 }; // class MQwHistograms
00062 
00063 #endif // __MQWHISTOGRAMS__

Generated on 19 Feb 2017 for QwAnalysis by  doxygen 1.6.1