ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerMuons.cc
Revision: 1.6
Committed: Tue Jul 8 12:38:20 2008 UTC (16 years, 9 months ago) by loizides
Content type: text/plain
Branch: MAIN
Changes since 1.5: +4 -11 lines
Log Message:
Updated Fillers to use GetProduct function in BaseFiller. This function will determine whether a product is valid and otherwise exit.

File Contents

# User Rev Content
1 loizides 1.6 // $Id: FillerMuons.cc,v 1.5 2008/07/07 16:14:01 loizides Exp $
2 loizides 1.1
3     #include "MitProd/TreeFiller/interface/FillerMuons.h"
4     #include "FWCore/MessageLogger/interface/MessageLogger.h"
5     #include "DataFormats/Common/interface/Handle.h"
6     #include "DataFormats/MuonReco/interface/Muon.h"
7     #include "DataFormats/MuonReco/interface/MuonFwd.h"
8     #include "MitAna/DataTree/interface/Muon.h"
9     #include "MitAna/DataTree/interface/Track.h"
10     #include "MitAna/DataTree/interface/Names.h"
11    
12     using namespace std;
13     using namespace edm;
14     using namespace mithep;
15    
16 loizides 1.4 //--------------------------------------------------------------------------------------------------
17 loizides 1.2 FillerMuons::FillerMuons(const edm::ParameterSet &cfg, bool active,
18     const TrackMap *globalMap, const TrackMap *stdMap,
19     const TrackMap *stdVtxMap, const TrackMap* trackerMap) :
20     BaseFiller(cfg, "Muons", active),
21 loizides 1.1 edmName_(Conf().getUntrackedParameter<string>("edmName","muons")),
22     mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkMuonBrn)),
23     muons_(new mithep::MuonArr),
24     globalTrackMap_(globalMap),
25     standaloneTrackMap_(stdMap),
26     standaloneVtxTrackMap_(stdVtxMap),
27     trackerTrackMap_(trackerMap)
28     {
29     // Constructor.
30     }
31    
32 loizides 1.4 //--------------------------------------------------------------------------------------------------
33 loizides 1.1 FillerMuons::~FillerMuons()
34     {
35     // Destructor.
36 loizides 1.5
37     delete muons_;
38 loizides 1.1 }
39    
40 loizides 1.4 //--------------------------------------------------------------------------------------------------
41 loizides 1.1 void FillerMuons::BookDataBlock(TreeWriter &tws)
42     {
43     // Add muons branch to tree.
44    
45     tws.AddBranch(mitName_.c_str(),&muons_);
46     }
47    
48 loizides 1.4 //--------------------------------------------------------------------------------------------------
49 loizides 1.1 void FillerMuons::FillDataBlock(const edm::Event &event,
50 loizides 1.4 const edm::EventSetup &setup)
51 loizides 1.1 {
52     // Fill muon information.
53    
54     muons_->Reset();
55    
56 loizides 1.6 Handle<reco::MuonCollection> hMuonProduct;
57     GetProduct(edmName_, hMuonProduct, event);
58 loizides 1.1
59 loizides 1.6 const reco::MuonCollection inMuons = *(hMuonProduct.product());
60 loizides 1.1
61     for (reco::MuonCollection::const_iterator iM = inMuons.begin(); iM != inMuons.end(); ++iM) {
62    
63     mithep::Muon* outMuon = muons_->AddNew();
64    
65     if (globalTrackMap_ && iM->combinedMuon().isNonnull())
66     outMuon->SetGlobalTrack(globalTrackMap_->GetMit(iM->combinedMuon()));
67    
68     if (standaloneTrackMap_ && standaloneVtxTrackMap_ && iM->standAloneMuon().isNonnull()) {
69     Int_t refProductId = iM->standAloneMuon().id().id();
70     if ( refProductId == standaloneVtxTrackMap_->GetEdmProductId())
71     outMuon->SetStandaloneTrack(standaloneVtxTrackMap_->GetMit(iM->standAloneMuon()));
72     else if ( refProductId == standaloneTrackMap_->GetEdmProductId())
73     outMuon->SetStandaloneTrack(standaloneTrackMap_->GetMit(iM->standAloneMuon()));
74     else throw edm::Exception(edm::errors::Configuration, "FillerMuons:FillDataBlock()\n")
75     << "Error! Track reference in unmapped collection " << edmName_ << endl;
76     }
77     if (trackerTrackMap_ && iM->track().isNonnull())
78     outMuon->SetTrackerTrack(trackerTrackMap_->GetMit(iM->track()));
79     }
80    
81     muons_->Trim();
82     }