ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/grimes/L1Menu/src/MenuRatePlots.cpp
(Generate patch)

Comparing UserCode/grimes/L1Menu/src/MenuRatePlots.cpp (file contents):
Revision 1.2 by grimes, Fri May 31 01:29:10 2013 UTC vs.
Revision 1.10 by grimes, Sat Jun 29 16:14:45 2013 UTC

# Line 4 | Line 4
4   #include "l1menu/ITrigger.h"
5   #include "l1menu/TriggerMenu.h"
6   #include "l1menu/TriggerRatePlot.h"
7 < #include "l1menu/tools.h"
7 > #include "l1menu/tools/tools.h"
8   #include "l1menu/ReducedMenuSample.h"
9 < #include "l1menu/IReducedEvent.h"
9 > #include "l1menu/ReducedEvent.h"
10   #include <TH1F.h>
11  
12   l1menu::MenuRatePlots::MenuRatePlots( const l1menu::TriggerMenu& triggerMenu, TDirectory* pDirectory )
13   {
14 +        // Before making any histograms make sure errors are done properly
15 +        TH1::SetDefaultSumw2();
16 +
17 +        // This is always useful
18 +        const l1menu::TriggerTable& triggerTable=l1menu::TriggerTable::instance();
19  
20          // Loop over each of the triggers in the menu, book a histogram for it and then create
21          // a l1menu::TriggerRate plot for it.
# Line 18 | Line 23 | l1menu::MenuRatePlots::MenuRatePlots( co
23          {
24                  std::unique_ptr<l1menu::ITrigger> pTrigger=triggerMenu.getTriggerCopy(triggerNumber);
25                  // Figure out the parameter names of all the possible thresholds.
26 <                const std::vector<std::string> thresholdNames= l1menu::getThresholdNames(*pTrigger);
26 >                const std::vector<std::string> thresholdNames=l1menu::tools::getThresholdNames(*pTrigger);
27 >
28 >                //
29 >                // If there is more than one threshold add a plot where all of the thresholds are scaled together.
30 >                //
31 >                if( thresholdNames.size()>1 )
32 >                {
33 >                        const std::string& mainThreshold=thresholdNames.front();
34 >                        unsigned int numberOfBins=100;
35 >                        float lowerEdge=0;
36 >                        float upperEdge=100;
37 >                        try
38 >                        {
39 >                                numberOfBins=triggerTable.getSuggestedNumberOfBins( pTrigger->name(), mainThreshold );
40 >                                lowerEdge=triggerTable.getSuggestedLowerEdge( pTrigger->name(), mainThreshold );
41 >                                upperEdge=triggerTable.getSuggestedUpperEdge( pTrigger->name(), mainThreshold );
42 >                        }
43 >                        catch( std::exception& error) { /* Do nothing. If no binning suggestions have been set for this trigger use the defaults I set above. */ }
44 >
45 >                        std::unique_ptr<TH1> pHistogram( new TH1F( (pTrigger->name()+"_v_allThresholdsScaled").c_str(), "This title gets changed by TriggerRatePlot anyway", numberOfBins, lowerEdge, upperEdge ) );
46 >                        pHistogram->SetDirectory( pDirectory );
47 >                        // Passing thresholdNames tells the TriggerRatePlot to scale all parameters named in that
48 >                        // vector along with mainThreshold.
49 >                        triggerPlots_.push_back( std::move(l1menu::TriggerRatePlot(*pTrigger,std::move(pHistogram),mainThreshold,thresholdNames)) );
50 >
51 >                }
52  
53                  // When a threshold is tested, I want all the other thresholds to be zero. I'll run through
54                  // and zero all of them now.
# Line 36 | Line 66 | l1menu::MenuRatePlots::MenuRatePlots( co
66                          float upperEdge=100;
67                          try
68                          {
39                                const l1menu::TriggerTable& triggerTable=l1menu::TriggerTable::instance();
69                                  numberOfBins=triggerTable.getSuggestedNumberOfBins( pTrigger->name(), *iThresholdName );
70                                  lowerEdge=triggerTable.getSuggestedLowerEdge( pTrigger->name(), *iThresholdName );
71                                  upperEdge=triggerTable.getSuggestedUpperEdge( pTrigger->name(), *iThresholdName );
# Line 51 | Line 80 | l1menu::MenuRatePlots::MenuRatePlots( co
80          } // end of loop over the triggers in the menu
81   }
82  
83 < void l1menu::MenuRatePlots::addEvent( const l1menu::IEvent& event )
83 > void l1menu::MenuRatePlots::addEvent( const l1menu::L1TriggerDPGEvent& event )
84   {
85          // Loop over each of the TriggerRatePlots and add the event to each of them.
86          for( auto& ratePlot : triggerPlots_ )
# Line 69 | Line 98 | void l1menu::MenuRatePlots::initiateForR
98          }
99   }
100  
101 < void l1menu::MenuRatePlots::addEvent( const l1menu::IReducedEvent& event )
101 > void l1menu::MenuRatePlots::addEvent( const l1menu::ReducedEvent& event )
102   {
103          // Loop over each of the TriggerRatePlots and add the event to each of them.
104          for( auto& ratePlot : triggerPlots_ )
# Line 78 | Line 107 | void l1menu::MenuRatePlots::addEvent( co
107          }
108   }
109  
110 + void l1menu::MenuRatePlots::addSample( const l1menu::ISample& sample )
111 + {
112 +        // Loop over each of the TriggerRatePlots and add the sample to each of them.
113 +        for( auto& ratePlot : triggerPlots_ )
114 +        {
115 +                ratePlot.addSample( sample );
116 +        }
117 + }
118 +
119   void l1menu::MenuRatePlots::setDirectory( TDirectory* pDirectory )
120   {
121          // Loop over each of the TriggerRatePlots and individually set the directory.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines