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.10 by grimes, Sat Jun 29 16:14:45 2013 UTC vs.
Revision 1.13 by grimes, Wed Jul 24 11:48:55 2013 UTC

# Line 5 | Line 5
5   #include "l1menu/TriggerMenu.h"
6   #include "l1menu/TriggerRatePlot.h"
7   #include "l1menu/tools/tools.h"
8 #include "l1menu/ReducedMenuSample.h"
9 #include "l1menu/ReducedEvent.h"
8   #include <TH1F.h>
9 + #include <TDirectory.h>
10 + #include <TKey.h>
11 + #include <iostream>
12  
13   l1menu::MenuRatePlots::MenuRatePlots( const l1menu::TriggerMenu& triggerMenu, TDirectory* pDirectory )
14   {
# Line 80 | Line 81 | l1menu::MenuRatePlots::MenuRatePlots( co
81          } // end of loop over the triggers in the menu
82   }
83  
84 < void l1menu::MenuRatePlots::addEvent( const l1menu::L1TriggerDPGEvent& event )
84 > l1menu::MenuRatePlots::MenuRatePlots( const TDirectory* pPreExistingPlotDirectory )
85   {
86 <        // Loop over each of the TriggerRatePlots and add the event to each of them.
87 <        for( auto& ratePlot : triggerPlots_ )
87 <        {
88 <                ratePlot.addEvent( event );
89 <        }
90 < }
86 >        // Before making any histograms make sure errors are done properly
87 >        TH1::SetDefaultSumw2();
88  
89 < void l1menu::MenuRatePlots::initiateForReducedSample( const l1menu::ReducedMenuSample& sample )
90 < {
91 <        // Loop over each of the TriggerRatePlots and delegate the call to them.
92 <        for( auto& ratePlot : triggerPlots_ )
89 >        // Loop over all of the histograms in the directory.
90 >        TList* pListOfKeys=pPreExistingPlotDirectory->GetListOfKeys();
91 >        std::string oldKeyName;
92 >
93 >        for( int index=0; index<pListOfKeys->GetEntries(); ++index )
94          {
95 <                ratePlot.initiateForReducedSample( sample );
96 <        }
95 >                TKey* pKey=dynamic_cast<TKey*>( pListOfKeys->At(index) );
96 >                // Only use the highest cycle number for each key
97 >                if( oldKeyName==pKey->GetName() ) continue;
98 >                oldKeyName=pKey->GetName();
99 >
100 >                TH1* pHistogram=dynamic_cast<TH1*>( pKey->ReadObj() );
101 >
102 >                if( pHistogram!=NULL )
103 >                {
104 >                        try
105 >                        {
106 >                                l1menu::TriggerRatePlot ratePlotFromHistogram( pHistogram );
107 >                                triggerPlots_.push_back( std::move(ratePlotFromHistogram) );
108 >                        }
109 >                        catch( std::exception& error )
110 >                        {
111 >                                std::cerr << "Couldn't create TriggerRatePlot for " << pHistogram->GetName() << " because: " << error.what() << std::endl;
112 >                        }
113 >
114 >                } // end of "if( dynamic_cast to TH1* successful )"
115 >
116 >        } // end of loop over the keys in the file
117   }
118  
119 < void l1menu::MenuRatePlots::addEvent( const l1menu::ReducedEvent& event )
119 > void l1menu::MenuRatePlots::addEvent( const l1menu::IEvent& event )
120   {
121          // Loop over each of the TriggerRatePlots and add the event to each of them.
122          for( auto& ratePlot : triggerPlots_ )

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines