ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerMet.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: FillerMet.cc,v 1.9 2009/02/26 17:04:03 bendavid Exp $
2    
3     #include "MitProd/TreeFiller/interface/FillerMet.h"
4     #include "FWCore/MessageLogger/interface/MessageLogger.h"
5     #include "DataFormats/Common/interface/Handle.h"
6     #include "DataFormats/METReco/interface/CaloMET.h"
7     #include "MitAna/DataTree/interface/Names.h"
8    
9     using namespace std;
10     using namespace edm;
11     using namespace mithep;
12    
13     //--------------------------------------------------------------------------------------------------
14     FillerMet::FillerMet(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     mets_(new mithep::MetArr)
19     {
20     // Constructor.
21     }
22    
23     //--------------------------------------------------------------------------------------------------
24     FillerMet::~FillerMet()
25     {
26     // Destructor.
27    
28     delete mets_;
29     }
30    
31     //--------------------------------------------------------------------------------------------------
32     void FillerMet::BookDataBlock(TreeWriter &tws)
33     {
34     // Add mets branch to tree.
35    
36     tws.AddBranch(mitName_.c_str(),&mets_);
37     }
38    
39     //--------------------------------------------------------------------------------------------------
40     void FillerMet::FillDataBlock(const edm::Event &event,
41     const edm::EventSetup &setup)
42     {
43     // Fill missing energy from edm collection into our collection.
44    
45     mets_->Delete();
46    
47     Handle<reco::METCollection> hMetProduct;
48     GetProduct(edmName_, hMetProduct, event);
49    
50     const reco::METCollection inMets = *(hMetProduct.product());
51    
52     // loop through all mets
53     for (reco::METCollection::const_iterator inMet = inMets.begin();
54     inMet != inMets.end(); ++inMet) {
55    
56     mithep::Met *met = mets_->Allocate();
57     new (met) mithep::Met(inMet->px(), inMet->py());
58    
59     // Fill Met base class data
60     met->SetSumEt(inMet->sumEt());
61     met->SetElongitudinal(inMet->e_longitudinal());
62     for(unsigned i=0; i<inMet->mEtCorr().size(); i++) {
63     met->PushCorrectionX(inMet->mEtCorr()[i].mex);
64     met->PushCorrectionY(inMet->mEtCorr()[i].mey);
65     met->PushCorrectionSumEt(inMet->mEtCorr()[i].sumet);
66     }
67    
68     }
69    
70     mets_->Trim();
71     }