ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerMuons.cc
Revision: 1.23
Committed: Fri Sep 25 08:42:51 2009 UTC (15 years, 7 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_013pre1, Mit_012i, Mit_012h, Mit_012g, Mit_012f, Mit_012e, Mit_012d, Mit_012c, Mit_012b, Mit_012a, Mit_012, Mit_011a
Changes since 1.22: +2 -2 lines
Log Message:
Extended interface of BookDataBlock to contain event setup.

File Contents

# Content
1 // $Id: FillerMuons.cc,v 1.22 2009/06/15 15:00:26 loizides Exp $
2
3 #include "MitProd/TreeFiller/interface/FillerMuons.h"
4 #include "DataFormats/MuonReco/interface/Muon.h"
5 #include "DataFormats/MuonReco/interface/MuonFwd.h"
6 #include "DataFormats/Common/interface/RefToPtr.h"
7 #include "MitAna/DataTree/interface/Names.h"
8 #include "MitAna/DataTree/interface/MuonCol.h"
9 #include "MitAna/DataTree/interface/Track.h"
10 #include "MitProd/ObjectService/interface/ObjectService.h"
11
12 using namespace std;
13 using namespace edm;
14 using namespace mithep;
15
16 //--------------------------------------------------------------------------------------------------
17 FillerMuons::FillerMuons(const edm::ParameterSet &cfg, const char *name, bool active) :
18 BaseFiller(cfg,name,active),
19 edmName_(Conf().getUntrackedParameter<string>("edmName","muons")),
20 mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkMuonBrn)),
21 globalTrackMapName_(Conf().getUntrackedParameter<string>("globalTrackMapName","")),
22 staTrackMapName_(Conf().getUntrackedParameter<string>("staTrackMapName","")),
23 staVtxTrackMapName_(Conf().getUntrackedParameter<string>("staVtxTrackMapName","")),
24 trackerTrackMapName_(Conf().getUntrackedParameter<string>("trackerTrackMapName","")),
25 muonMapName_(Conf().getUntrackedParameter<string>("muonMapName","")),
26 globalTrackMap_(0),
27 standaloneTrackMap_(0),
28 standaloneVtxTrackMap_(0),
29 trackerTrackMap_(0),
30 muonMap_(new mithep::MuonMap),
31 muons_(new mithep::MuonArr(16))
32 {
33 // Constructor.
34 }
35
36 //--------------------------------------------------------------------------------------------------
37 FillerMuons::~FillerMuons()
38 {
39 // Destructor.
40
41 delete muons_;
42 delete muonMap_;
43 }
44
45 //--------------------------------------------------------------------------------------------------
46 void FillerMuons::BookDataBlock(TreeWriter &tws, const edm::EventSetup &es)
47 {
48 // Add muons branch to tree and get pointers to maps.
49
50 tws.AddBranch(mitName_,&muons_);
51 OS()->add<mithep::MuonArr>(muons_,mitName_);
52
53 if (!globalTrackMapName_.empty()) {
54 globalTrackMap_ = OS()->get<TrackMap>(globalTrackMapName_);
55 if (globalTrackMap_)
56 AddBranchDep(mitName_,globalTrackMap_->GetBrName());
57 }
58 if (!staTrackMapName_.empty()) {
59 standaloneTrackMap_ = OS()->get<TrackMap>(staTrackMapName_);
60 if (standaloneTrackMap_)
61 AddBranchDep(mitName_,standaloneTrackMap_->GetBrName());
62 }
63 if (!staVtxTrackMapName_.empty()) {
64 standaloneVtxTrackMap_ = OS()->get<TrackMap>(staVtxTrackMapName_);
65 if (standaloneVtxTrackMap_)
66 AddBranchDep(mitName_,standaloneVtxTrackMap_->GetBrName());
67 }
68 if (!trackerTrackMapName_.empty()) {
69 trackerTrackMap_ = OS()->get<TrackMap>(trackerTrackMapName_);
70 if (trackerTrackMap_)
71 AddBranchDep(mitName_,trackerTrackMap_->GetBrName());
72 }
73 if (!muonMapName_.empty()) {
74 muonMap_->SetBrName(mitName_);
75 OS()->add<MuonMap>(muonMap_,muonMapName_);
76 }
77 }
78
79 //--------------------------------------------------------------------------------------------------
80 void FillerMuons::FillDataBlock(const edm::Event &event,
81 const edm::EventSetup &setup)
82 {
83 // Fill muon information.
84
85 muons_->Delete();
86 muonMap_->Reset();
87
88 Handle<reco::MuonCollection> hMuonProduct;
89 GetProduct(edmName_, hMuonProduct, event);
90 const reco::MuonCollection inMuons = *(hMuonProduct.product());
91
92 for (reco::MuonCollection::const_iterator iM = inMuons.begin(); iM != inMuons.end(); ++iM) {
93 mithep::Muon* outMuon = muons_->AddNew();
94 outMuon->SetIsoR03SumPt(iM->isolationR03().sumPt);
95 outMuon->SetIsoR03EmEt(iM->isolationR03().emEt);
96 outMuon->SetIsoR03HadEt(iM->isolationR03().hadEt);
97 outMuon->SetIsoR03HoEt(iM->isolationR03().hoEt);
98 outMuon->SetIsoR03NTracks(iM->isolationR03().nTracks);
99 outMuon->SetIsoR03NJets(iM->isolationR03().nJets);
100 outMuon->SetIsoR05SumPt(iM->isolationR05().sumPt);
101 outMuon->SetIsoR05EmEt(iM->isolationR05().emEt);
102 outMuon->SetIsoR05HadEt(iM->isolationR05().hadEt);
103 outMuon->SetIsoR05HoEt(iM->isolationR05().hoEt);
104 outMuon->SetIsoR05NTracks(iM->isolationR05().nTracks);
105 outMuon->SetIsoR05NJets(iM->isolationR05().nJets);
106 outMuon->SetEmEnergy(iM->calEnergy().em);
107 outMuon->SetHadEnergy(iM->calEnergy().had);
108 outMuon->SetHoEnergy(iM->calEnergy().ho);
109 outMuon->SetEmS9Energy(iM->calEnergy().emS9);
110 outMuon->SetHadS9Energy(iM->calEnergy().hadS9);
111 outMuon->SetHoS9Energy(iM->calEnergy().hoS9);
112 outMuon->SetIsGlobalMuon(iM->isGlobalMuon());
113 outMuon->SetIsTrackerMuon(iM->isTrackerMuon());
114 outMuon->SetIsStandaloneMuon(iM->isStandAloneMuon());
115 outMuon->SetIsCaloMuon(iM->isCaloMuon());
116
117 if (globalTrackMap_ && iM->combinedMuon().isNonnull())
118 outMuon->SetGlobalTrk(globalTrackMap_->GetMit(refToPtr(iM->combinedMuon())));
119 if (standaloneTrackMap_ && standaloneVtxTrackMap_ && iM->standAloneMuon().isNonnull()) {
120 Int_t refProductId = iM->standAloneMuon().id().id();
121 if ( refProductId == standaloneVtxTrackMap_->GetEdmProductId())
122 outMuon->SetStandaloneTrk(standaloneVtxTrackMap_->GetMit(refToPtr(iM->standAloneMuon())));
123 else if ( refProductId == standaloneTrackMap_->GetEdmProductId())
124 outMuon->SetStandaloneTrk(standaloneTrackMap_->GetMit(refToPtr(iM->standAloneMuon())));
125 else throw edm::Exception(edm::errors::Configuration, "FillerMuons:FillDataBlock()\n")
126 << "Error! Track reference in unmapped collection " << edmName_ << endl;
127 }
128 if (trackerTrackMap_ && iM->track().isNonnull())
129 outMuon->SetTrackerTrk(trackerTrackMap_->GetMit(refToPtr(iM->track())));
130
131 outMuon->SetNChambers (iM->numberOfChambers());
132 outMuon->SetStationMask(iM->stationMask(reco::Muon::SegmentAndTrackArbitration));
133 for(int i0 = 0; i0 < 4; i0++) {
134 // DTs
135 outMuon->SetDX(i0, iM->dX(i0+1,1));
136 outMuon->SetDY(i0, iM->dY(i0+1,1));
137 outMuon->SetPullX(i0, iM->pullX(i0+1,1));
138 outMuon->SetPullY(i0, iM->pullY(i0+1,1));
139 outMuon->SetTrackDist(i0, iM->trackDist(i0+1,1));
140 outMuon->SetTrackDistErr(i0, iM->trackDistErr(i0+1,1));
141 outMuon->SetNSegments(i0, iM->numberOfSegments(i0+1,1));
142 // CSCs
143 outMuon->SetDX(4+i0, iM->dX (i0+1,2));
144 outMuon->SetDY(4+i0, iM->dY (i0+1,2));
145 outMuon->SetPullX(4+i0, iM->pullX (i0+1,2));
146 outMuon->SetPullY(4+i0, iM->pullY (i0+1,2));
147 outMuon->SetTrackDist(4+i0, iM->trackDist(i0+1,2));
148 outMuon->SetTrackDistErr(4+i0,iM->trackDistErr(i0+1,2));
149 outMuon->SetNSegments(4+i0, iM->numberOfSegments(i0+1,2));
150 }
151
152 // add muon to map
153 edm::Ptr<reco::Muon> thePtr(hMuonProduct, iM - inMuons.begin());
154 muonMap_->Add(thePtr, outMuon);
155
156 if (verbose_>1) {
157 if (!outMuon->HasGlobalTrk() && !outMuon->HasStandaloneTrk()) {
158 printf("mithep::Muon, pt=%5f, eta=%5f, phi=%5f, mass=%5f\n",outMuon->Pt(),outMuon->Eta(),outMuon->Phi(), outMuon->Mass());
159 printf(" reco::Muon, pt=%5f, eta=%5f, phi=%5f, mass=%5f\n",iM->pt(),iM->eta(),iM->phi(),iM->mass());
160 }
161 }
162
163 }
164 muons_->Trim();
165 }