ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerMuons.cc
Revision: 1.9
Committed: Thu Jul 31 12:34:04 2008 UTC (16 years, 9 months ago) by loizides
Content type: text/plain
Branch: MAIN
Changes since 1.8: +23 -10 lines
Log Message:
Consistently introduced ObjectService. Updated comments. Updated .cfg files. Switched off default handling of Stable and DecayParts (for now). ZmmFullReco.cfg shows how to use standard filler with extensions.

File Contents

# User Rev Content
1 loizides 1.9 // $Id: FillerMuons.cc,v 1.8 2008/07/14 21:01:00 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.9 FillerMuons::FillerMuons(const edm::ParameterSet &cfg, bool active) :
18 loizides 1.7 BaseFiller(cfg,"Muons",active),
19 loizides 1.1 edmName_(Conf().getUntrackedParameter<string>("edmName","muons")),
20     mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkMuonBrn)),
21 loizides 1.9 globalTrackMapName_(Conf().getUntrackedParameter<string>("globalTrackMapName","")),
22     staTrackMapName_(Conf().getUntrackedParameter<string>("staTrackMapName","")),
23     staVtxTrackMapName_(Conf().getUntrackedParameter<string>("staVtxTrackMapName","")),
24     trackerTrackMapName_(Conf().getUntrackedParameter<string>("trackerTrackMapName","")),
25     globalTrackMap_(0),
26     standaloneTrackMap_(0),
27     standaloneVtxTrackMap_(0),
28     trackerTrackMap_(0),
29     muons_(new mithep::MuonArr(16))
30 loizides 1.1 {
31     // Constructor.
32     }
33    
34 loizides 1.4 //--------------------------------------------------------------------------------------------------
35 loizides 1.1 FillerMuons::~FillerMuons()
36     {
37     // Destructor.
38 loizides 1.5
39     delete muons_;
40 loizides 1.1 }
41    
42 loizides 1.4 //--------------------------------------------------------------------------------------------------
43 loizides 1.1 void FillerMuons::BookDataBlock(TreeWriter &tws)
44     {
45 loizides 1.9 // Add muons branch to tree and get pointers to maps.
46 loizides 1.1
47     tws.AddBranch(mitName_.c_str(),&muons_);
48 loizides 1.9
49     if (!globalTrackMapName_.empty())
50     globalTrackMap_ = OS()->get<TrackMap>(globalTrackMapName_.c_str());
51     if (!staTrackMapName_.empty())
52     standaloneTrackMap_ = OS()->get<TrackMap>(staTrackMapName_.c_str());
53     if (!staVtxTrackMapName_.empty())
54     standaloneVtxTrackMap_ = OS()->get<TrackMap>(staVtxTrackMapName_.c_str());
55     if (!trackerTrackMapName_.empty())
56     trackerTrackMap_ = OS()->get<TrackMap>(trackerTrackMapName_.c_str());
57 loizides 1.1 }
58    
59 loizides 1.9
60    
61 loizides 1.4 //--------------------------------------------------------------------------------------------------
62 loizides 1.1 void FillerMuons::FillDataBlock(const edm::Event &event,
63 loizides 1.4 const edm::EventSetup &setup)
64 loizides 1.1 {
65     // Fill muon information.
66    
67     muons_->Reset();
68    
69 loizides 1.6 Handle<reco::MuonCollection> hMuonProduct;
70     GetProduct(edmName_, hMuonProduct, event);
71 loizides 1.1
72 loizides 1.6 const reco::MuonCollection inMuons = *(hMuonProduct.product());
73 loizides 1.1
74     for (reco::MuonCollection::const_iterator iM = inMuons.begin(); iM != inMuons.end(); ++iM) {
75    
76     mithep::Muon* outMuon = muons_->AddNew();
77    
78     if (globalTrackMap_ && iM->combinedMuon().isNonnull())
79 loizides 1.8 outMuon->SetGlobalTrk(globalTrackMap_->GetMit(iM->combinedMuon()));
80 loizides 1.1
81     if (standaloneTrackMap_ && standaloneVtxTrackMap_ && iM->standAloneMuon().isNonnull()) {
82     Int_t refProductId = iM->standAloneMuon().id().id();
83     if ( refProductId == standaloneVtxTrackMap_->GetEdmProductId())
84 loizides 1.8 outMuon->SetStandaloneTrk(standaloneVtxTrackMap_->GetMit(iM->standAloneMuon()));
85 loizides 1.1 else if ( refProductId == standaloneTrackMap_->GetEdmProductId())
86 loizides 1.8 outMuon->SetStandaloneTrk(standaloneTrackMap_->GetMit(iM->standAloneMuon()));
87 loizides 1.1 else throw edm::Exception(edm::errors::Configuration, "FillerMuons:FillDataBlock()\n")
88     << "Error! Track reference in unmapped collection " << edmName_ << endl;
89     }
90     if (trackerTrackMap_ && iM->track().isNonnull())
91 loizides 1.8 outMuon->SetTrackerTrk(trackerTrackMap_->GetMit(iM->track()));
92 loizides 1.1 }
93    
94     muons_->Trim();
95     }