1 |
bendavid |
1.8 |
// $Id: FillerPATMuons.cc,v 1.7 2009/09/25 08:42:51 loizides Exp $
|
2 |
sixie |
1.1 |
|
3 |
|
|
#include "MitProd/TreeFiller/interface/FillerPATMuons.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.3 |
#include "DataFormats/Common/interface/RefToPtr.h"
|
9 |
sixie |
1.1 |
#include "DataFormats/PatCandidates/interface/Muon.h"
|
10 |
|
|
#include "DataFormats/PatCandidates/interface/Jet.h"
|
11 |
|
|
#include "DataFormats/PatCandidates/interface/Electron.h"
|
12 |
|
|
#include "DataFormats/PatCandidates/interface/Tau.h"
|
13 |
|
|
#include "DataFormats/PatCandidates/interface/Photon.h"
|
14 |
|
|
#include "DataFormats/PatCandidates/interface/MET.h"
|
15 |
|
|
#include "DataFormats/Common/interface/View.h"
|
16 |
loizides |
1.6 |
#include "MitAna/DataTree/interface/MuonCol.h"
|
17 |
|
|
#include "MitAna/DataTree/interface/Track.h"
|
18 |
|
|
#include "MitAna/DataTree/interface/Names.h"
|
19 |
|
|
#include "MitProd/ObjectService/interface/ObjectService.h"
|
20 |
sixie |
1.1 |
|
21 |
|
|
using namespace std;
|
22 |
|
|
using namespace edm;
|
23 |
|
|
using namespace mithep;
|
24 |
|
|
|
25 |
|
|
//--------------------------------------------------------------------------------------------------
|
26 |
loizides |
1.5 |
FillerPATMuons::FillerPATMuons(const edm::ParameterSet &cfg, const char *name, bool active) :
|
27 |
sixie |
1.1 |
BaseFiller(cfg,"PATMuons",active),
|
28 |
|
|
edmName_(Conf().getUntrackedParameter<string>("edmName","selectedLayer1Muons")),
|
29 |
|
|
mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkMuonBrn)),
|
30 |
|
|
globalTrackMapName_(Conf().getUntrackedParameter<string>("globalTrackMapName","")),
|
31 |
|
|
staTrackMapName_(Conf().getUntrackedParameter<string>("staTrackMapName","")),
|
32 |
|
|
staVtxTrackMapName_(Conf().getUntrackedParameter<string>("staVtxTrackMapName","")),
|
33 |
|
|
trackerTrackMapName_(Conf().getUntrackedParameter<string>("trackerTrackMapName","")),
|
34 |
|
|
globalTrackMap_(0),
|
35 |
|
|
standaloneTrackMap_(0),
|
36 |
|
|
standaloneVtxTrackMap_(0),
|
37 |
|
|
trackerTrackMap_(0),
|
38 |
|
|
muons_(new mithep::MuonArr(16))
|
39 |
|
|
{
|
40 |
|
|
// Constructor.
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
//--------------------------------------------------------------------------------------------------
|
44 |
|
|
FillerPATMuons::~FillerPATMuons()
|
45 |
|
|
{
|
46 |
|
|
// Destructor.
|
47 |
|
|
|
48 |
|
|
delete muons_;
|
49 |
|
|
}
|
50 |
|
|
|
51 |
|
|
//--------------------------------------------------------------------------------------------------
|
52 |
bendavid |
1.8 |
void FillerPATMuons::BookDataBlock(TreeWriter &tws)
|
53 |
sixie |
1.1 |
{
|
54 |
|
|
// Add muons branch to tree and get pointers to maps.
|
55 |
|
|
|
56 |
loizides |
1.5 |
tws.AddBranch(mitName_,&muons_);
|
57 |
|
|
OS()->add<mithep::MuonArr>(muons_,mitName_);
|
58 |
sixie |
1.1 |
|
59 |
loizides |
1.5 |
if (!globalTrackMapName_.empty()) {
|
60 |
|
|
globalTrackMap_ = OS()->get<TrackMap>(globalTrackMapName_);
|
61 |
|
|
if (globalTrackMap_)
|
62 |
|
|
AddBranchDep(mitName_,globalTrackMap_->GetBrName());
|
63 |
|
|
}
|
64 |
|
|
if (!staTrackMapName_.empty()) {
|
65 |
|
|
standaloneTrackMap_ = OS()->get<TrackMap>(staTrackMapName_);
|
66 |
|
|
if (standaloneTrackMap_)
|
67 |
|
|
AddBranchDep(mitName_,standaloneTrackMap_->GetBrName());
|
68 |
|
|
}
|
69 |
|
|
if (!staVtxTrackMapName_.empty()) {
|
70 |
|
|
standaloneVtxTrackMap_ = OS()->get<TrackMap>(staVtxTrackMapName_);
|
71 |
|
|
if (standaloneVtxTrackMap_)
|
72 |
|
|
AddBranchDep(mitName_,standaloneVtxTrackMap_->GetBrName());
|
73 |
|
|
}
|
74 |
|
|
if (!trackerTrackMapName_.empty()) {
|
75 |
|
|
trackerTrackMap_ = OS()->get<TrackMap>(trackerTrackMapName_);
|
76 |
|
|
if (trackerTrackMap_)
|
77 |
|
|
AddBranchDep(mitName_,trackerTrackMap_->GetBrName());
|
78 |
|
|
}
|
79 |
sixie |
1.1 |
}
|
80 |
|
|
|
81 |
|
|
//--------------------------------------------------------------------------------------------------
|
82 |
|
|
void FillerPATMuons::FillDataBlock(const edm::Event &event,
|
83 |
|
|
const edm::EventSetup &setup)
|
84 |
|
|
{
|
85 |
|
|
// Fill muon information.
|
86 |
|
|
|
87 |
bendavid |
1.4 |
muons_->Delete();
|
88 |
sixie |
1.1 |
|
89 |
|
|
edm::Handle<edm::View<pat::Muon> > muonHandle;
|
90 |
|
|
event.getByLabel(edm::InputTag(edmName_),muonHandle);
|
91 |
|
|
edm::View<pat::Muon> muons = *muonHandle;
|
92 |
|
|
|
93 |
loizides |
1.5 |
for(edm::View<pat::Muon>::const_iterator iM = muons.begin(); iM!=muons.end(); ++iM){
|
94 |
|
|
|
95 |
|
|
if(iM->pt()>0) {
|
96 |
|
|
mithep::Muon* outMuon = muons_->AddNew();
|
97 |
sixie |
1.1 |
|
98 |
loizides |
1.5 |
if (globalTrackMap_ && iM->combinedMuon().isNonnull())
|
99 |
|
|
outMuon->SetGlobalTrk(globalTrackMap_->GetMit(refToPtr(iM->combinedMuon())));
|
100 |
sixie |
1.1 |
|
101 |
loizides |
1.5 |
if (standaloneTrackMap_ && standaloneVtxTrackMap_ && iM->standAloneMuon().isNonnull()) {
|
102 |
|
|
Int_t refProductId = iM->standAloneMuon().id().id();
|
103 |
|
|
if ( refProductId == standaloneVtxTrackMap_->GetEdmProductId())
|
104 |
|
|
outMuon->SetStandaloneTrk(standaloneVtxTrackMap_->GetMit(refToPtr(iM->standAloneMuon())));
|
105 |
|
|
else if ( refProductId == standaloneTrackMap_->GetEdmProductId())
|
106 |
|
|
outMuon->SetStandaloneTrk(standaloneTrackMap_->GetMit(refToPtr(iM->standAloneMuon())));
|
107 |
|
|
else throw edm::Exception(edm::errors::Configuration, "FillerPATMuons:FillDataBlock()\n")
|
108 |
|
|
<< "Error! Track reference in unmapped collection " << edmName_ << endl;
|
109 |
|
|
}
|
110 |
sixie |
1.1 |
|
111 |
loizides |
1.5 |
if (trackerTrackMap_ && iM->track().isNonnull())
|
112 |
|
|
outMuon->SetTrackerTrk(trackerTrackMap_->GetMit(refToPtr(iM->track())));
|
113 |
sixie |
1.1 |
|
114 |
loizides |
1.5 |
outMuon->SetIsoR03SumPt(iM->isolationR03().sumPt);
|
115 |
|
|
outMuon->SetIsoR03EmEt(iM->isolationR03().emEt);
|
116 |
|
|
outMuon->SetIsoR03HadEt(iM->isolationR03().hadEt);
|
117 |
|
|
outMuon->SetIsoR03HoEt(iM->isolationR03().hoEt);
|
118 |
|
|
outMuon->SetIsoR03NTracks(iM->isolationR03().nTracks);
|
119 |
|
|
outMuon->SetIsoR03NJets(iM->isolationR03().nJets);
|
120 |
|
|
outMuon->SetIsoR05SumPt(iM->isolationR05().sumPt);
|
121 |
|
|
outMuon->SetIsoR05EmEt(iM->isolationR05().emEt);
|
122 |
|
|
outMuon->SetIsoR05HadEt(iM->isolationR05().hadEt);
|
123 |
|
|
outMuon->SetIsoR05HoEt(iM->isolationR05().hoEt);
|
124 |
|
|
outMuon->SetIsoR05NTracks(iM->isolationR05().nTracks);
|
125 |
|
|
outMuon->SetIsoR05NJets(iM->isolationR05().nJets);
|
126 |
|
|
outMuon->SetEmEnergy(iM->calEnergy().em);
|
127 |
|
|
outMuon->SetHadEnergy(iM->calEnergy().had);
|
128 |
|
|
outMuon->SetHoEnergy(iM->calEnergy().ho);
|
129 |
|
|
outMuon->SetEmS9Energy(iM->calEnergy().emS9);
|
130 |
|
|
outMuon->SetHadS9Energy(iM->calEnergy().hadS9);
|
131 |
|
|
outMuon->SetHoS9Energy(iM->calEnergy().hoS9);
|
132 |
|
|
}
|
133 |
|
|
}
|
134 |
|
|
muons_->Trim();
|
135 |
sixie |
1.1 |
}
|