4 |
|
#include "l1menu/ITrigger.h" |
5 |
|
#include "l1menu/TriggerMenu.h" |
6 |
|
#include "l1menu/TriggerRatePlot.h" |
7 |
< |
#include "l1menu/tools.h" |
8 |
< |
#include "l1menu/ReducedMenuSample.h" |
9 |
< |
#include "l1menu/IReducedEvent.h" |
7 |
> |
#include "l1menu/tools/tools.h" |
8 |
|
#include <TH1F.h> |
9 |
|
|
10 |
|
l1menu::MenuRatePlots::MenuRatePlots( const l1menu::TriggerMenu& triggerMenu, TDirectory* pDirectory ) |
11 |
|
{ |
12 |
+ |
// Before making any histograms make sure errors are done properly |
13 |
+ |
TH1::SetDefaultSumw2(); |
14 |
+ |
|
15 |
+ |
// This is always useful |
16 |
+ |
const l1menu::TriggerTable& triggerTable=l1menu::TriggerTable::instance(); |
17 |
|
|
18 |
|
// Loop over each of the triggers in the menu, book a histogram for it and then create |
19 |
|
// a l1menu::TriggerRate plot for it. |
21 |
|
{ |
22 |
|
std::unique_ptr<l1menu::ITrigger> pTrigger=triggerMenu.getTriggerCopy(triggerNumber); |
23 |
|
// Figure out the parameter names of all the possible thresholds. |
24 |
< |
const std::vector<std::string> thresholdNames= l1menu::getThresholdNames(*pTrigger); |
24 |
> |
const std::vector<std::string> thresholdNames=l1menu::tools::getThresholdNames(*pTrigger); |
25 |
> |
|
26 |
> |
// |
27 |
> |
// If there is more than one threshold add a plot where all of the thresholds are scaled together. |
28 |
> |
// |
29 |
> |
if( thresholdNames.size()>1 ) |
30 |
> |
{ |
31 |
> |
const std::string& mainThreshold=thresholdNames.front(); |
32 |
> |
unsigned int numberOfBins=100; |
33 |
> |
float lowerEdge=0; |
34 |
> |
float upperEdge=100; |
35 |
> |
try |
36 |
> |
{ |
37 |
> |
numberOfBins=triggerTable.getSuggestedNumberOfBins( pTrigger->name(), mainThreshold ); |
38 |
> |
lowerEdge=triggerTable.getSuggestedLowerEdge( pTrigger->name(), mainThreshold ); |
39 |
> |
upperEdge=triggerTable.getSuggestedUpperEdge( pTrigger->name(), mainThreshold ); |
40 |
> |
} |
41 |
> |
catch( std::exception& error) { /* Do nothing. If no binning suggestions have been set for this trigger use the defaults I set above. */ } |
42 |
> |
|
43 |
> |
std::unique_ptr<TH1> pHistogram( new TH1F( (pTrigger->name()+"_v_allThresholdsScaled").c_str(), "This title gets changed by TriggerRatePlot anyway", numberOfBins, lowerEdge, upperEdge ) ); |
44 |
> |
pHistogram->SetDirectory( pDirectory ); |
45 |
> |
// Passing thresholdNames tells the TriggerRatePlot to scale all parameters named in that |
46 |
> |
// vector along with mainThreshold. |
47 |
> |
triggerPlots_.push_back( std::move(l1menu::TriggerRatePlot(*pTrigger,std::move(pHistogram),mainThreshold,thresholdNames)) ); |
48 |
> |
|
49 |
> |
} |
50 |
|
|
51 |
|
// When a threshold is tested, I want all the other thresholds to be zero. I'll run through |
52 |
|
// and zero all of them now. |
64 |
|
float upperEdge=100; |
65 |
|
try |
66 |
|
{ |
39 |
– |
const l1menu::TriggerTable& triggerTable=l1menu::TriggerTable::instance(); |
67 |
|
numberOfBins=triggerTable.getSuggestedNumberOfBins( pTrigger->name(), *iThresholdName ); |
68 |
|
lowerEdge=triggerTable.getSuggestedLowerEdge( pTrigger->name(), *iThresholdName ); |
69 |
|
upperEdge=triggerTable.getSuggestedUpperEdge( pTrigger->name(), *iThresholdName ); |
43 |
– |
upperEdge*=5; // I'm getting incomplete ReducedSamples, I think because there is the odd overflow event. |
70 |
|
} |
71 |
|
catch( std::exception& error) { /* Do nothing. If no binning suggestions have been set for this trigger use the defaults I set above. */ } |
72 |
|
|
87 |
|
} |
88 |
|
} |
89 |
|
|
90 |
< |
void l1menu::MenuRatePlots::initiateForReducedSample( const l1menu::ReducedMenuSample& sample ) |
90 |
> |
void l1menu::MenuRatePlots::addSample( const l1menu::ISample& sample ) |
91 |
|
{ |
92 |
< |
// Loop over each of the TriggerRatePlots and delegate the call to them. |
92 |
> |
// Loop over each of the TriggerRatePlots and add the sample to each of them. |
93 |
|
for( auto& ratePlot : triggerPlots_ ) |
94 |
|
{ |
95 |
< |
ratePlot.initiateForReducedSample( sample ); |
70 |
< |
} |
71 |
< |
} |
72 |
< |
|
73 |
< |
void l1menu::MenuRatePlots::addEvent( const l1menu::IReducedEvent& event ) |
74 |
< |
{ |
75 |
< |
// Loop over each of the TriggerRatePlots and add the event to each of them. |
76 |
< |
for( auto& ratePlot : triggerPlots_ ) |
77 |
< |
{ |
78 |
< |
ratePlot.addEvent( event ); |
95 |
> |
ratePlot.addSample( sample ); |
96 |
|
} |
97 |
|
} |
98 |
|
|