ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/grimes/L1Menu/src/MenuRatePlots.cpp
Revision: 1.1
Committed: Tue May 28 23:14:02 2013 UTC (11 years, 11 months ago) by grimes
Branch: MAIN
Log Message:
Numerous changes

File Contents

# User Rev Content
1 grimes 1.1 #include "l1menu/MenuRatePlots.h"
2    
3     #include <sstream>
4     #include <iostream>
5     #include "l1menu/ITrigger.h"
6     #include "l1menu/TriggerMenu.h"
7     #include "l1menu/TriggerRatePlot.h"
8     #include "l1menu/tools.h"
9     #include <TH1F.h>
10    
11     l1menu::MenuRatePlots::MenuRatePlots( const l1menu::TriggerMenu& triggerMenu, TDirectory* pDirectory )
12     {
13    
14     // Loop over each of the triggers in the menu, book a histogram for it and then create
15     // a l1menu::TriggerRate plot for it.
16     for( size_t triggerNumber=0; triggerNumber<triggerMenu.numberOfTriggers(); ++triggerNumber )
17     {
18     std::unique_ptr<l1menu::ITrigger> pTrigger=triggerMenu.getTriggerCopy(triggerNumber);
19     // Figure out the parameter names of all the possible thresholds.
20     const std::vector<std::string> thresholdNames= l1menu::getThresholdNames(*pTrigger);
21    
22     // When a threshold is tested, I want all the other thresholds to be zero. I'll run through
23     // and zero all of them now.
24     for( std::vector<std::string>::const_iterator iName=thresholdNames.begin(); iName!=thresholdNames.end(); ++iName )
25     {
26     pTrigger->parameter(*iName)=0;
27     }
28    
29    
30     // I want a plot for each of the thresholds, so I'll loop over the threshold names
31     for( std::vector<std::string>::const_iterator iThresholdName=thresholdNames.begin(); iThresholdName!=thresholdNames.end(); ++iThresholdName )
32     {
33     std::cout << "** Adding plot for " << *iThresholdName << " in trigger " << pTrigger->name() << std::endl;
34    
35     unsigned int numberOfBins=100;
36     float lowerEdge=0;
37     float upperEdge=100;
38     try
39     {
40     const l1menu::TriggerTable& triggerTable=l1menu::TriggerTable::instance();
41     numberOfBins=triggerTable.getSuggestedNumberOfBins( pTrigger->name(), *iThresholdName );
42     lowerEdge=triggerTable.getSuggestedLowerEdge( pTrigger->name(), *iThresholdName );
43     upperEdge=triggerTable.getSuggestedUpperEdge( pTrigger->name(), *iThresholdName );
44     }
45     catch( std::exception& error) { /* Do nothing. If no binning suggestions have been set for this trigger use the defaults I set above. */ }
46    
47     std::unique_ptr<TH1> pHistogram( new TH1F( (pTrigger->name()+"_v_"+(*iThresholdName)).c_str(), "This title gets changed by TriggerRatePlot anyway", numberOfBins, lowerEdge, upperEdge ) );
48     pHistogram->SetDirectory( pDirectory );
49     triggerPlots_.push_back( std::move(l1menu::TriggerRatePlot(*pTrigger,std::move(pHistogram),*iThresholdName)) );
50     }
51    
52     } // end of loop over the triggers in the menu
53     }
54    
55     void l1menu::MenuRatePlots::addEvent( const l1menu::IEvent& event )
56     {
57     // Loop over each of the TriggerRatePlots and add the event to each of them.
58     for( std::vector<l1menu::TriggerRatePlot>::iterator iRatePlot=triggerPlots_.begin(); iRatePlot!=triggerPlots_.end(); ++iRatePlot )
59     {
60     iRatePlot->addEvent( event );
61     }
62     }
63    
64     void l1menu::MenuRatePlots::setDirectory( TDirectory* pDirectory )
65     {
66     // Loop over each of the TriggerRatePlots and individually set the directory.
67     for( std::vector<l1menu::TriggerRatePlot>::iterator iRatePlot=triggerPlots_.begin(); iRatePlot!=triggerPlots_.end(); ++iRatePlot )
68     {
69     iRatePlot->getPlot()->SetDirectory( pDirectory );
70     }
71     }
72    
73     void l1menu::MenuRatePlots::relinquishOwnershipOfPlots()
74     {
75     // Loop over each of the TriggerRatePlots and individually release them.
76     for( std::vector<l1menu::TriggerRatePlot>::iterator iRatePlot=triggerPlots_.begin(); iRatePlot!=triggerPlots_.end(); ++iRatePlot )
77     {
78     iRatePlot->relinquishOwnershipOfPlot();
79     }
80     }