1 |
loizides |
1.18 |
// $Id: FillerMuons.cc,v 1.17 2009/03/03 18:10:19 bendavid 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 |
bendavid |
1.15 |
#include "DataFormats/Common/interface/RefToPtr.h"
|
9 |
loizides |
1.1 |
#include "MitAna/DataTree/interface/Muon.h"
|
10 |
|
|
#include "MitAna/DataTree/interface/Track.h"
|
11 |
|
|
#include "MitAna/DataTree/interface/Names.h"
|
12 |
|
|
|
13 |
|
|
using namespace std;
|
14 |
|
|
using namespace edm;
|
15 |
|
|
using namespace mithep;
|
16 |
|
|
|
17 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
18 |
loizides |
1.18 |
FillerMuons::FillerMuons(const edm::ParameterSet &cfg, const char *name, bool active) :
|
19 |
|
|
BaseFiller(cfg,name,active),
|
20 |
loizides |
1.1 |
edmName_(Conf().getUntrackedParameter<string>("edmName","muons")),
|
21 |
|
|
mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkMuonBrn)),
|
22 |
loizides |
1.9 |
globalTrackMapName_(Conf().getUntrackedParameter<string>("globalTrackMapName","")),
|
23 |
|
|
staTrackMapName_(Conf().getUntrackedParameter<string>("staTrackMapName","")),
|
24 |
|
|
staVtxTrackMapName_(Conf().getUntrackedParameter<string>("staVtxTrackMapName","")),
|
25 |
|
|
trackerTrackMapName_(Conf().getUntrackedParameter<string>("trackerTrackMapName","")),
|
26 |
|
|
globalTrackMap_(0),
|
27 |
|
|
standaloneTrackMap_(0),
|
28 |
|
|
standaloneVtxTrackMap_(0),
|
29 |
|
|
trackerTrackMap_(0),
|
30 |
pharris |
1.12 |
muons_(new mithep::MuonArr(16))
|
31 |
loizides |
1.1 |
{
|
32 |
|
|
// Constructor.
|
33 |
|
|
}
|
34 |
|
|
|
35 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
36 |
pharris |
1.12 |
FillerMuons::~FillerMuons() {
|
37 |
loizides |
1.5 |
delete muons_;
|
38 |
loizides |
1.1 |
}
|
39 |
|
|
|
40 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
41 |
pharris |
1.13 |
void FillerMuons::BookDataBlock(TreeWriter &tws) {
|
42 |
loizides |
1.9 |
// Add muons branch to tree and get pointers to maps.
|
43 |
loizides |
1.1 |
|
44 |
|
|
tws.AddBranch(mitName_.c_str(),&muons_);
|
45 |
loizides |
1.9 |
|
46 |
|
|
if (!globalTrackMapName_.empty())
|
47 |
|
|
globalTrackMap_ = OS()->get<TrackMap>(globalTrackMapName_.c_str());
|
48 |
|
|
if (!staTrackMapName_.empty())
|
49 |
|
|
standaloneTrackMap_ = OS()->get<TrackMap>(staTrackMapName_.c_str());
|
50 |
|
|
if (!staVtxTrackMapName_.empty())
|
51 |
|
|
standaloneVtxTrackMap_ = OS()->get<TrackMap>(staVtxTrackMapName_.c_str());
|
52 |
|
|
if (!trackerTrackMapName_.empty())
|
53 |
|
|
trackerTrackMap_ = OS()->get<TrackMap>(trackerTrackMapName_.c_str());
|
54 |
loizides |
1.1 |
}
|
55 |
|
|
|
56 |
loizides |
1.9 |
|
57 |
|
|
|
58 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
59 |
loizides |
1.1 |
void FillerMuons::FillDataBlock(const edm::Event &event,
|
60 |
loizides |
1.4 |
const edm::EventSetup &setup)
|
61 |
loizides |
1.1 |
{
|
62 |
|
|
// Fill muon information.
|
63 |
|
|
|
64 |
bendavid |
1.16 |
muons_->Delete();
|
65 |
loizides |
1.1 |
|
66 |
loizides |
1.6 |
Handle<reco::MuonCollection> hMuonProduct;
|
67 |
sixie |
1.10 |
GetProduct(edmName_, hMuonProduct, event);
|
68 |
loizides |
1.6 |
const reco::MuonCollection inMuons = *(hMuonProduct.product());
|
69 |
loizides |
1.1 |
|
70 |
sixie |
1.10 |
for (reco::MuonCollection::const_iterator iM = inMuons.begin(); iM != inMuons.end(); ++iM) {
|
71 |
|
|
mithep::Muon* outMuon = muons_->AddNew();
|
72 |
|
|
outMuon->SetIsoR03SumPt(iM->isolationR03().sumPt);
|
73 |
|
|
outMuon->SetIsoR03EmEt(iM->isolationR03().emEt);
|
74 |
|
|
outMuon->SetIsoR03HadEt(iM->isolationR03().hadEt);
|
75 |
|
|
outMuon->SetIsoR03HoEt(iM->isolationR03().hoEt);
|
76 |
|
|
outMuon->SetIsoR03NTracks(iM->isolationR03().nTracks);
|
77 |
|
|
outMuon->SetIsoR03NJets(iM->isolationR03().nJets);
|
78 |
|
|
outMuon->SetIsoR05SumPt(iM->isolationR05().sumPt);
|
79 |
|
|
outMuon->SetIsoR05EmEt(iM->isolationR05().emEt);
|
80 |
|
|
outMuon->SetIsoR05HadEt(iM->isolationR05().hadEt);
|
81 |
|
|
outMuon->SetIsoR05HoEt(iM->isolationR05().hoEt);
|
82 |
|
|
outMuon->SetIsoR05NTracks(iM->isolationR05().nTracks);
|
83 |
|
|
outMuon->SetIsoR05NJets(iM->isolationR05().nJets);
|
84 |
|
|
outMuon->SetEmEnergy(iM->calEnergy().em);
|
85 |
|
|
outMuon->SetHadEnergy(iM->calEnergy().had);
|
86 |
|
|
outMuon->SetHoEnergy(iM->calEnergy().ho);
|
87 |
|
|
outMuon->SetEmS9Energy(iM->calEnergy().emS9);
|
88 |
|
|
outMuon->SetHadS9Energy(iM->calEnergy().hadS9);
|
89 |
|
|
outMuon->SetHoS9Energy(iM->calEnergy().hoS9);
|
90 |
bendavid |
1.17 |
outMuon->SetIsGlobalMuon(iM->isGlobalMuon());
|
91 |
|
|
outMuon->SetIsTrackerMuon(iM->isTrackerMuon());
|
92 |
|
|
outMuon->SetIsStandaloneMuon(iM->isStandAloneMuon());
|
93 |
|
|
outMuon->SetIsCaloMuon(iM->isCaloMuon());
|
94 |
pharris |
1.11 |
|
95 |
loizides |
1.1 |
if (globalTrackMap_ && iM->combinedMuon().isNonnull())
|
96 |
bendavid |
1.15 |
outMuon->SetGlobalTrk(globalTrackMap_->GetMit(refToPtr(iM->combinedMuon())));
|
97 |
loizides |
1.1 |
if (standaloneTrackMap_ && standaloneVtxTrackMap_ && iM->standAloneMuon().isNonnull()) {
|
98 |
|
|
Int_t refProductId = iM->standAloneMuon().id().id();
|
99 |
|
|
if ( refProductId == standaloneVtxTrackMap_->GetEdmProductId())
|
100 |
bendavid |
1.15 |
outMuon->SetStandaloneTrk(standaloneVtxTrackMap_->GetMit(refToPtr(iM->standAloneMuon())));
|
101 |
loizides |
1.1 |
else if ( refProductId == standaloneTrackMap_->GetEdmProductId())
|
102 |
bendavid |
1.15 |
outMuon->SetStandaloneTrk(standaloneTrackMap_->GetMit(refToPtr(iM->standAloneMuon())));
|
103 |
loizides |
1.1 |
else throw edm::Exception(edm::errors::Configuration, "FillerMuons:FillDataBlock()\n")
|
104 |
loizides |
1.14 |
<< "Error! Track reference in unmapped collection " << edmName_ << endl;
|
105 |
loizides |
1.1 |
}
|
106 |
|
|
if (trackerTrackMap_ && iM->track().isNonnull())
|
107 |
bendavid |
1.15 |
outMuon->SetTrackerTrk(trackerTrackMap_->GetMit(refToPtr(iM->track())));
|
108 |
loizides |
1.14 |
|
109 |
|
|
outMuon->SetNChambers (iM->numberOfChambers());
|
110 |
pharris |
1.11 |
outMuon->SetStationMask(iM->stationMask(reco::Muon::SegmentAndTrackArbitration));
|
111 |
loizides |
1.14 |
for(int i0 = 0; i0 < 4; i0++) {
|
112 |
pharris |
1.11 |
//DTs
|
113 |
|
|
outMuon->SetDX(i0, iM->dX(i0+1,1));
|
114 |
|
|
outMuon->SetDY(i0, iM->dY(i0+1,1));
|
115 |
|
|
outMuon->SetPullX(i0, iM->pullX(i0+1,1));
|
116 |
|
|
outMuon->SetPullY(i0, iM->pullY(i0+1,1));
|
117 |
|
|
outMuon->SetTrackDist(i0, iM->trackDist(i0+1,1));
|
118 |
|
|
outMuon->SetTrackDistErr(i0, iM->trackDistErr(i0+1,1));
|
119 |
loizides |
1.14 |
outMuon->SetNSegments(i0, iM->numberOfSegments(i0+1,1));
|
120 |
pharris |
1.11 |
//CSCs
|
121 |
|
|
outMuon->SetDX(4+i0, iM->dX (i0+1,2));
|
122 |
|
|
outMuon->SetDY(4+i0, iM->dY (i0+1,2));
|
123 |
|
|
outMuon->SetPullX(4+i0, iM->pullX (i0+1,2));
|
124 |
|
|
outMuon->SetPullY(4+i0, iM->pullY (i0+1,2));
|
125 |
|
|
outMuon->SetTrackDist(4+i0, iM->trackDist(i0+1,2));
|
126 |
|
|
outMuon->SetTrackDistErr(4+i0,iM->trackDistErr(i0+1,2));
|
127 |
|
|
outMuon->SetNSegments(4+i0, iM->numberOfSegments(i0+1,2));
|
128 |
|
|
}
|
129 |
|
|
}
|
130 |
loizides |
1.1 |
muons_->Trim();
|
131 |
|
|
}
|