ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerPATMuons.cc
Revision: 1.8
Committed: Thu Mar 18 20:21:00 2010 UTC (15 years, 1 month ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_032, Mit_031, Mit_025c_branch2, Mit_025c_branch1, Mit_030, Mit_029c, Mit_029b, Mit_030_pre1, Mit_029a, Mit_029, Mit_029_pre1, Mit_028a, Mit_025c_branch0, Mit_028, Mit_027a, Mit_027, Mit_026, Mit_025e, Mit_025d, Mit_025c, Mit_025b, Mit_025a, Mit_025, Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, Mit_020d, TMit_020d, Mit_020c, Mit_021, Mit_021pre2, Mit_021pre1, Mit_020b, Mit_020a, Mit_020, Mit_020pre1, Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d, Mit_014c, Mit_014b, Mit_014a, Mit_014, Mit_014pre3, Mit_014pre2, Mit_014pre1, Mit_013d, Mit_013c, Mit_013b, Mit_013a, Mit_013, HEAD
Branch point for: Mit_025c_branch
Changes since 1.7: +2 -2 lines
Error occurred while calculating annotation data.
Log Message:
Fix beginrun,beginjob mess

File Contents

# Content
1 // $Id: FillerPATMuons.cc,v 1.7 2009/09/25 08:42:51 loizides Exp $
2
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 #include "DataFormats/Common/interface/RefToPtr.h"
9 #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 #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
21 using namespace std;
22 using namespace edm;
23 using namespace mithep;
24
25 //--------------------------------------------------------------------------------------------------
26 FillerPATMuons::FillerPATMuons(const edm::ParameterSet &cfg, const char *name, bool active) :
27 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 void FillerPATMuons::BookDataBlock(TreeWriter &tws)
53 {
54 // Add muons branch to tree and get pointers to maps.
55
56 tws.AddBranch(mitName_,&muons_);
57 OS()->add<mithep::MuonArr>(muons_,mitName_);
58
59 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 }
80
81 //--------------------------------------------------------------------------------------------------
82 void FillerPATMuons::FillDataBlock(const edm::Event &event,
83 const edm::EventSetup &setup)
84 {
85 // Fill muon information.
86
87 muons_->Delete();
88
89 edm::Handle<edm::View<pat::Muon> > muonHandle;
90 event.getByLabel(edm::InputTag(edmName_),muonHandle);
91 edm::View<pat::Muon> muons = *muonHandle;
92
93 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
98 if (globalTrackMap_ && iM->combinedMuon().isNonnull())
99 outMuon->SetGlobalTrk(globalTrackMap_->GetMit(refToPtr(iM->combinedMuon())));
100
101 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
111 if (trackerTrackMap_ && iM->track().isNonnull())
112 outMuon->SetTrackerTrk(trackerTrackMap_->GetMit(refToPtr(iM->track())));
113
114 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 }