ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerPFMet.cc
Revision: 1.2
Committed: Sun Mar 15 11:20:41 2009 UTC (16 years, 1 month ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_009a, Mit_009, Mit_008, Mit_008pre2
Changes since 1.1: +6 -6 lines
Log Message:
Introduced BranchTable plus general cleanup.

File Contents

# User Rev Content
1 loizides 1.2 // $Id: FillerPFMet.cc,v 1.1 2009/03/12 16:00:23 bendavid Exp $
2 bendavid 1.1
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 loizides 1.2 tws.AddBranch(mitName_,&pfMets_);
37     OS()->add<mithep::PFMetArr>(pfMets_,mitName_);
38 bendavid 1.1 }
39    
40     //--------------------------------------------------------------------------------------------------
41     void FillerPFMet::FillDataBlock(const edm::Event &event,
42 loizides 1.2 const edm::EventSetup &setup)
43 bendavid 1.1 {
44     // Fill missing energy from edm collection into our collection.
45    
46     pfMets_->Delete();
47    
48     Handle<reco::PFMETCollection> hCaloMetProduct;
49     GetProduct(edmName_, hCaloMetProduct, event);
50    
51     const reco::PFMETCollection inPFMets = *(hCaloMetProduct.product());
52    
53     // loop through all mets
54     for (reco::PFMETCollection::const_iterator inPFMet = inPFMets.begin();
55     inPFMet != inPFMets.end(); ++inPFMet) {
56    
57     mithep::PFMet *pfMet = pfMets_->Allocate();
58     new (pfMet) mithep::PFMet(inPFMet->px(), inPFMet->py());
59    
60 loizides 1.2 // fill Met base class data
61 bendavid 1.1 pfMet->SetSumEt(inPFMet->sumEt());
62     pfMet->SetElongitudinal(inPFMet->e_longitudinal());
63     for(unsigned i=0; i<inPFMet->mEtCorr().size(); i++) {
64     pfMet->PushCorrectionX(inPFMet->mEtCorr()[i].mex);
65     pfMet->PushCorrectionY(inPFMet->mEtCorr()[i].mey);
66     pfMet->PushCorrectionSumEt(inPFMet->mEtCorr()[i].sumet);
67     }
68    
69 loizides 1.2 // fill PFMet class data
70 bendavid 1.1 pfMet->SetNeutralEMFraction(inPFMet->NeutralEMFraction());
71     pfMet->SetNeutralHadFraction(inPFMet->NeutralHadFraction());
72     pfMet->SetChargedEMFraction(inPFMet->ChargedEMFraction());
73     pfMet->SetChargedHadFraction(inPFMet->ChargedHadFraction());
74     pfMet->SetMuonFraction(inPFMet->MuonFraction());
75    
76     }
77     pfMets_->Trim();
78     }