ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Morgan/src/METAnalyzer.cc
Revision: 1.4
Committed: Wed Dec 17 16:23:49 2008 UTC (16 years, 4 months ago) by lethuill
Content type: text/plain
Branch: MAIN
Changes since 1.3: +2 -2 lines
Log Message:
Add reference (TRef) to mcParticle

File Contents

# User Rev Content
1 lethuill 1.2 #include "../interface/METAnalyzer.h"
2 lethuill 1.1
3     using namespace std;
4     using namespace reco;
5     using namespace edm;
6    
7 lethuill 1.3 METAnalyzer::METAnalyzer(const edm::ParameterSet& producersNames):verbosity_(0), useMC_(false)
8 lethuill 1.1 {
9 lethuill 1.2 dataType_ = producersNames.getUntrackedParameter<string>("dataType","unknown");
10 lethuill 1.1 metProducer_ = producersNames.getParameter<edm::InputTag>("metProducer");
11     }
12    
13 lethuill 1.3 METAnalyzer::METAnalyzer(const edm::ParameterSet& producersNames, const edm::ParameterSet& myConfig, int verbosity):verbosity_(verbosity)
14 lethuill 1.1 {
15 lethuill 1.2 dataType_ = producersNames.getUntrackedParameter<string>("dataType","unknown");
16 lethuill 1.1 metProducer_ = producersNames.getParameter<edm::InputTag>("metProducer");
17 lethuill 1.3 useMC_ = myConfig.getUntrackedParameter<bool>("doMETMC");
18 lethuill 1.1 }
19    
20     METAnalyzer::~METAnalyzer()
21     {
22     }
23    
24 lethuill 1.2 void METAnalyzer::Process(const edm::Event& iEvent, TClonesArray* rootMET)
25 lethuill 1.1 {
26    
27 lethuill 1.2 unsigned int nMETs=0;
28 lethuill 1.1
29 lethuill 1.2 edm::Handle < std::vector <reco::CaloMET> > recoMETs;
30     if( dataType_=="RECO" || dataType_=="AOD" )
31 lethuill 1.1 {
32 lethuill 1.2 iEvent.getByLabel(metProducer_, recoMETs);
33     nMETs = recoMETs->size();
34     }
35    
36     edm::Handle < std::vector <pat::MET> > patMETs;
37     if( dataType_=="PAT" || dataType_=="PATAOD" )
38     {
39     iEvent.getByLabel(metProducer_, patMETs);
40     nMETs = patMETs->size();
41     }
42    
43     if(verbosity_>1) std::cout << " Number of MET objects = " << nMETs << " Label: " << metProducer_.label() << " Instance: " << metProducer_.instance() << std::endl;
44    
45     for (unsigned int j=0; j<nMETs; j++)
46     {
47     const reco::Candidate* met = 0;
48     if( dataType_=="RECO" || dataType_=="AOD" ) met = (const reco::Candidate*) ( & ((*recoMETs)[j]) );
49     if( dataType_=="PAT" || dataType_=="PATAOD" ) met = (const reco::Candidate*) ( & ((*patMETs)[j]) );
50    
51 lethuill 1.1 TRootMET localMET(
52 lethuill 1.2 met->px()
53     ,met->py()
54     ,met->pz()
55     ,met->energy()
56     ,met->vx()
57     ,met->vy()
58     ,met->vz()
59 lethuill 1.1 );
60    
61    
62 lethuill 1.2 if( dataType_=="RECO" || dataType_=="AOD" || dataType_=="PATAOD")
63     {
64     // Some specific methods to reco::MET
65     /*
66     const reco::CaloMET *recoMET = dynamic_cast<const reco::CaloMET*>(&*met);
67     localMET.setCaloMETFraction(
68     recoMET->maxEtInEmTowers()
69     ,recoMET->maxEtInHadTowers()
70     ,recoMET->hadEtInHO()
71     ,recoMET->hadEtInHB()
72     ,recoMET->hadEtInHF()
73     ,recoMET->hadEtInHE()
74     ,recoMET->emEtInEB()
75     ,recoMET->emEtInEE()
76     ,recoMET->emEtInHF()
77     ,recoMET->etFractionHadronic()
78     ,recoMET->emEtFraction()
79     ,recoMET->metSignificance()
80     ,recoMET->CaloMETInpHF()
81     ,recoMET->CaloMETInmHF()
82     ,recoMET->CaloSETInpHF()
83     ,recoMET->CaloSETInmHF()
84     ,recoMET->CaloMETPhiInpHF()
85     ,recoMET->CaloMETPhiInmHF()
86     );
87     */
88    
89     }
90    
91     if( dataType_=="PATAOD" )
92     {
93     // Some specific methods to pat::MET
94     const pat::MET *patMET = dynamic_cast<const pat::MET*>(&*met);
95    
96     localMET.setCaloMETFraction(
97     patMET->maxEtInEmTowers()
98     ,patMET->maxEtInHadTowers()
99     ,patMET->hadEtInHO()
100     ,patMET->hadEtInHB()
101     ,patMET->hadEtInHF()
102     ,patMET->hadEtInHE()
103     ,patMET->emEtInEB()
104     ,patMET->emEtInEE()
105     ,patMET->emEtInHF()
106     ,patMET->etFractionHadronic()
107     ,patMET->emEtFraction()
108     ,patMET->metSignificance()
109     ,patMET->CaloMETInpHF()
110     ,patMET->CaloMETInmHF()
111     ,patMET->CaloSETInpHF()
112     ,patMET->CaloSETInmHF()
113     ,patMET->CaloMETPhiInpHF()
114     ,patMET->CaloMETPhiInmHF()
115     );
116    
117     //pat::MET::UncorectionType ix;
118     //ix = pat::MET::uncorrALL;
119     localMET.setCorExALL(patMET->corEx(pat::MET::uncorrALL));
120     localMET.setCorExJES(patMET->corEx(pat::MET::uncorrJES));
121     localMET.setCorExMUON(patMET->corEx(pat::MET::uncorrMUON));
122    
123     localMET.setCorEyALL(patMET->corEy(pat::MET::uncorrALL));
124     localMET.setCorEyJES(patMET->corEy(pat::MET::uncorrJES));
125     localMET.setCorEyMUON(patMET->corEy(pat::MET::uncorrMUON));
126    
127     localMET.setCorSumEtALL(patMET->corSumEt(pat::MET::uncorrALL));
128     localMET.setCorSumEtJES(patMET->corSumEt(pat::MET::uncorrJES));
129     localMET.setCorSumEtMUON(patMET->corSumEt(pat::MET::uncorrMUON));
130    
131     localMET.setUncorrectedPhiALL(patMET->uncorrectedPhi(pat::MET::uncorrALL));
132     localMET.setUncorrectedPhiJES(patMET->uncorrectedPhi(pat::MET::uncorrJES));
133     localMET.setUncorrectedPhiMUON(patMET->uncorrectedPhi(pat::MET::uncorrMUON));
134    
135     localMET.setUncorrectedPtALL(patMET->uncorrectedPt(pat::MET::uncorrALL));
136     localMET.setUncorrectedPtJES(patMET->uncorrectedPt(pat::MET::uncorrJES));
137     localMET.setUncorrectedPtMUON(patMET->uncorrectedPt(pat::MET::uncorrMUON));
138    
139 lethuill 1.3 if(useMC_)
140     {
141     // MC truth associator index
142     if ((patMET->genParticleRef()).isNonnull()) {
143 lethuill 1.4 localMET.setGenParticleIndex((patMET->genParticleRef()).index());
144 lethuill 1.3 } else {
145 lethuill 1.4 localMET.setGenParticleIndex(-1);
146 lethuill 1.3 }
147    
148     if ( patMET->genMET() != NULL ) {
149     localMET.setMomentumMCMet(patMET->genMET()->px(),patMET->genMET()->py(),patMET->genMET()->pz(),patMET->genMET()->energy());
150     localMET.setVertexMCMet(TVector3(patMET->genMET()->vx(),patMET->genMET()->vy(),patMET->genMET()->vz()));
151     localMET.setPdgIdMCMet(patMET->genMET()->pdgId());
152     }
153     }
154 lethuill 1.2 }
155    
156     new( (*rootMET)[j] ) TRootMET(localMET);
157     if(verbosity_>2) cout << " ["<< setw(3) << j << "] " << localMET << endl;
158 lethuill 1.1 }
159    
160     }