ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/grimes/VHbbAnalysisCode/src/MuonInfoCollectionPlotSet.cpp
Revision: 1.2
Committed: Fri Apr 27 13:52:14 2012 UTC (13 years ago) by grimes
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +4 -4 lines
Log Message:
Added code to analyse muon isolation.

File Contents

# User Rev Content
1 grimes 1.1 #include "TrkUpgradeAnalysis/VHbb/interface/MuonInfoCollectionPlotSet.h"
2    
3     #include <stdexcept>
4    
5     #include <TDirectory.h>
6     #include <TH1F.h>
7    
8    
9 grimes 1.2 trkupgradeanalysis::MuonInfoCollectionPlotSet::MuonInfoCollectionPlotSet( bool createIsolationTree )
10     : histogramHaveBeenBooked_(false), muonInfoPlotSet_(createIsolationTree)
11 grimes 1.1 {
12     // No operation besides the initialiser list.
13     }
14    
15     void trkupgradeanalysis::MuonInfoCollectionPlotSet::book( TDirectory* pDirectory )
16     {
17     if( histogramHaveBeenBooked_ ) throw std::runtime_error( "trkupgradeanalysis::MuonInfoCollectionPlotSet::book() - histograms have already been booked" );
18    
19     //
20     // Note that the root file which TDirectory is part of takes ownership of all
21     // of these objects, so I don't need to (and shouldn't) delete them when I'm
22     // finished.
23     //
24    
25     pNumberOfMuons_=new TH1F( "numberOfMuons", "Number of muons in each collection", 21, -0.5, 20.5 );
26     pNumberOfMuons_->SetDirectory( pDirectory );
27    
28     muonInfoPlotSet_.book( pDirectory );
29    
30     histogramHaveBeenBooked_=true;
31     }
32    
33 grimes 1.2 void trkupgradeanalysis::MuonInfoCollectionPlotSet::fill( const std::vector<VHbbEvent::MuonInfo>& muonCollection, const VHbbEventAuxInfo* pAuxInfo )
34 grimes 1.1 {
35     if( !histogramHaveBeenBooked_ ) throw std::runtime_error( "trkupgradeanalysis::MuonInfoCollectionPlotSet::book() - histograms have not been booked" );
36    
37     pNumberOfMuons_->Fill( muonCollection.size() );
38    
39     for( std::vector<VHbbEvent::MuonInfo>::const_iterator iMuon=muonCollection.begin(); iMuon!=muonCollection.end(); ++iMuon )
40     {
41 grimes 1.2 muonInfoPlotSet_.fill( *iMuon, pAuxInfo );
42 grimes 1.1 }
43    
44     }
45