ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerPFMet.cc
Revision: 1.1
Committed: Thu Mar 12 16:00:23 2009 UTC (16 years, 1 month ago) by bendavid
Content type: text/plain
Branch: MAIN
Log Message:
Updated Met fillers to reflect changes to Met classes, added FillerPFMet

File Contents

# User Rev Content
1 bendavid 1.1 // $Id: FillerPFMet.cc,v 1.9 2009/02/26 17:04:03 bendavid Exp $
2    
3     #include "MitProd/TreeFiller/interface/FillerPFMet.h"
4     #include "FWCore/MessageLogger/interface/MessageLogger.h"
5     #include "DataFormats/Common/interface/Handle.h"
6     #include "DataFormats/METReco/interface/PFMET.h"
7     #include "MitAna/DataTree/interface/Names.h"
8    
9     using namespace std;
10     using namespace edm;
11     using namespace mithep;
12    
13     //--------------------------------------------------------------------------------------------------
14     FillerPFMet::FillerPFMet(const ParameterSet &cfg, const char *name, bool active) :
15     BaseFiller(cfg,name,active),
16     edmName_(Conf().getUntrackedParameter<string>("edmName","met")),
17     mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkCaloMetBrn)),
18     pfMets_(new mithep::PFMetArr)
19     {
20     // Constructor.
21     }
22    
23     //--------------------------------------------------------------------------------------------------
24     FillerPFMet::~FillerPFMet()
25     {
26     // Destructor.
27    
28     delete pfMets_;
29     }
30    
31     //--------------------------------------------------------------------------------------------------
32     void FillerPFMet::BookDataBlock(TreeWriter &tws)
33     {
34     // Add mets branch to tree.
35    
36     tws.AddBranch(mitName_.c_str(),&pfMets_);
37     }
38    
39     //--------------------------------------------------------------------------------------------------
40     void FillerPFMet::FillDataBlock(const edm::Event &event,
41     const edm::EventSetup &setup)
42     {
43     // Fill missing energy from edm collection into our collection.
44    
45     pfMets_->Delete();
46    
47     Handle<reco::PFMETCollection> hCaloMetProduct;
48     GetProduct(edmName_, hCaloMetProduct, event);
49    
50     const reco::PFMETCollection inPFMets = *(hCaloMetProduct.product());
51    
52     // loop through all mets
53     for (reco::PFMETCollection::const_iterator inPFMet = inPFMets.begin();
54     inPFMet != inPFMets.end(); ++inPFMet) {
55    
56     mithep::PFMet *pfMet = pfMets_->Allocate();
57     new (pfMet) mithep::PFMet(inPFMet->px(), inPFMet->py());
58    
59     // Fill Met base class data
60     pfMet->SetSumEt(inPFMet->sumEt());
61     pfMet->SetElongitudinal(inPFMet->e_longitudinal());
62     for(unsigned i=0; i<inPFMet->mEtCorr().size(); i++) {
63     pfMet->PushCorrectionX(inPFMet->mEtCorr()[i].mex);
64     pfMet->PushCorrectionY(inPFMet->mEtCorr()[i].mey);
65     pfMet->PushCorrectionSumEt(inPFMet->mEtCorr()[i].sumet);
66     }
67    
68     // Fill PFMet class data
69     pfMet->SetNeutralEMFraction(inPFMet->NeutralEMFraction());
70     pfMet->SetNeutralHadFraction(inPFMet->NeutralHadFraction());
71     pfMet->SetChargedEMFraction(inPFMet->ChargedEMFraction());
72     pfMet->SetChargedHadFraction(inPFMet->ChargedHadFraction());
73     pfMet->SetMuonFraction(inPFMet->MuonFraction());
74    
75     }
76    
77     pfMets_->Trim();
78     }