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.12 by grimes, Thu Jul 4 13:02:22 2013 UTC vs.
Revision 1.13 by grimes, Wed Jul 24 11:48:55 2013 UTC

# Line 6 | Line 6
6   #include "l1menu/TriggerRatePlot.h"
7   #include "l1menu/tools/tools.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 78 | Line 81 | l1menu::MenuRatePlots::MenuRatePlots( co
81          } // end of loop over the triggers in the menu
82   }
83  
84 + l1menu::MenuRatePlots::MenuRatePlots( const TDirectory* pPreExistingPlotDirectory )
85 + {
86 +        // Before making any histograms make sure errors are done properly
87 +        TH1::SetDefaultSumw2();
88 +
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 +                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::IEvent& event )
120   {
121          // Loop over each of the TriggerRatePlots and add the event to each of them.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines