ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/grimes/L1Menu/interface/l1menu/TriggerRatePlot.h
Revision: 1.5
Committed: Sat Jun 29 16:14:45 2013 UTC (11 years, 10 months ago) by grimes
Content type: text/plain
Branch: MAIN
Changes since 1.4: +15 -9 lines
Log Message:
Added an option to the TriggerRatePlot to scale all thresholds at once for the plot

File Contents

# User Rev Content
1 grimes 1.1 #ifndef l1menu_TriggerRatePlot_h
2     #define l1menu_TriggerRatePlot_h
3    
4     #include <memory>
5     #include <string>
6 grimes 1.5 #include <vector>
7 grimes 1.1
8     //
9     // Forward declarations
10     //
11     class TH1;
12     namespace l1menu
13     {
14     class ITrigger;
15 grimes 1.4 class L1TriggerDPGEvent;
16 grimes 1.2 class ReducedMenuSample;
17 grimes 1.4 class ReducedEvent;
18     class ISample;
19 grimes 1.1 }
20    
21    
22     namespace l1menu
23     {
24     /** @brief Class that plots trigger rates versus threshold.
25     *
26     * @author Mark Grimes (mark.grimes@bristol.ac.uk)
27     * @date 24/May/2013
28     */
29     class TriggerRatePlot
30     {
31     public:
32     /** @brief Constructor that sets the trigger to plot for, the histogram to plot into, and the trigger parameter to vary.
33     *
34     * Note that the title of the histogram is modified to record the state of the trigger (all other parameters).
35     *
36 grimes 1.5 * @param[in] trigger The trigger that the plot will be created for. The trigger should be set exactly as you want
37     * the plots made for it, e.g. with the correct eta cuts already set. The other thresholds are
38     * not modified so you should set these to zero beforehand if that's what you want. The trigger
39     * is copied so these cannot be changed afterwards.
40     * @param[in] pHistogram The root histogram to fill with the rates. This should be set up with the required binning
41     * beforehand. The title is changed to record the trigger name, version, parameter plotted against
42     * and other parameter values.
43     * @param[in] versusParameter The trigger parameter to plot along the x-axis. Defaults to "threshold1".
44     * @param[in] scaledParameters A list of parameters that should be scaled along with the versusParameter. The ratio between each
45     * parameter and the versusParameter at the time of construction is kept as the versusParameter is
46     * changed. A check is made to ensure the versusParameter is taken out of the list if it is present.
47 grimes 1.1 */
48 grimes 1.5 TriggerRatePlot( const l1menu::ITrigger& trigger, std::unique_ptr<TH1> pHistogram, const std::string& versusParameter="threshold1", const std::vector<std::string> scaledParameters=std::vector<std::string>() );
49 grimes 1.2 TriggerRatePlot( l1menu::TriggerRatePlot& otherTriggerRatePlot ) = delete;
50     TriggerRatePlot& operator=( l1menu::TriggerRatePlot& otherTriggerRatePlot ) = delete;
51 grimes 1.1
52     /** @brief Explicit rvalue constructor to allow moving of TriggerRatePlot objects. */
53     TriggerRatePlot( l1menu::TriggerRatePlot&& otherTriggerRatePlot ) noexcept;
54     /** @brief Explicit rvalue assignment operator to allow moving of TriggerRatePlot objects. */
55     TriggerRatePlot& operator=( l1menu::TriggerRatePlot&& otherTriggerRatePlot ) noexcept;
56    
57     virtual ~TriggerRatePlot();
58 grimes 1.4 void addEvent( const l1menu::L1TriggerDPGEvent& event );
59 grimes 1.2
60     void initiateForReducedSample( const l1menu::ReducedMenuSample& sample );
61 grimes 1.4 void addEvent( const l1menu::ReducedEvent& event );
62    
63     void addSample( const l1menu::ISample& sample );
64 grimes 1.1
65 grimes 1.3 /** @brief Returns the trigger being used to create the plot. */
66     const l1menu::ITrigger& getTrigger() const;
67    
68 grimes 1.1 /** @brief Returns the internal pointer to the root histogram. Ownership is retained by TriggerRatePlot. */
69     TH1* getPlot();
70    
71     /** @brief Tells TriggerRatePlot to relinquish ownership of the internal root histogram. A pointer to the
72     * histogram is also returned.
73     *
74     * Note that the pointer is still held so that further operations on this object are still valid,
75     * just that the TH1 won't be deleted when the instance goes out of scope. */
76     TH1* relinquishOwnershipOfPlot();
77     protected:
78     std::unique_ptr<l1menu::ITrigger> pTrigger_;
79     std::unique_ptr<TH1> pHistogram_;
80     /// The parameter to plot against, usually "threshold1";
81     std::string versusParameter_;
82 grimes 1.2 /// Pointer to the versusParameter_ reference in pTrigger_ to avoid expensive string comparison look ups
83     float* pParameter_;
84 grimes 1.5 /// A vector of pointers of any other parameters that should be scaled, and what the scaling should be.
85     std::vector< std::pair<float*,float> > otherParameterScalings_;
86 grimes 1.1 /// Flag to say whether the histogram should be deleted when this instance goes out of scope.
87     bool histogramOwnedByMe_;
88     };
89     }
90     #endif