ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerPFMet.cc
Revision: 1.4
Committed: Fri Sep 25 08:42:51 2009 UTC (15 years, 7 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_013pre1, Mit_012i, Mit_012h, Mit_012g, Mit_012f, Mit_012e, Mit_012d, Mit_012c, Mit_012b, Mit_012a, Mit_012, Mit_011a
Changes since 1.3: +2 -2 lines
Log Message:
Extended interface of BookDataBlock to contain event setup.

File Contents

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