ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerMet.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: +5 -5 lines
Log Message:
Introduced BranchTable plus general cleanup.

File Contents

# User Rev Content
1 loizides 1.2 // $Id: FillerMet.cc,v 1.1 2009/03/12 16:00:23 bendavid Exp $
2 bendavid 1.1
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 loizides 1.2 tws.AddBranch(mitName_,&mets_);
37     OS()->add<mithep::MetArr>(mets_,mitName_);
38 bendavid 1.1 }
39    
40     //--------------------------------------------------------------------------------------------------
41     void FillerMet::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     mets_->Delete();
47    
48     Handle<reco::METCollection> hMetProduct;
49     GetProduct(edmName_, hMetProduct, event);
50    
51     const reco::METCollection inMets = *(hMetProduct.product());
52    
53     // loop through all mets
54     for (reco::METCollection::const_iterator inMet = inMets.begin();
55     inMet != inMets.end(); ++inMet) {
56    
57     mithep::Met *met = mets_->Allocate();
58     new (met) mithep::Met(inMet->px(), inMet->py());
59    
60 loizides 1.2 // fill met base class data
61 bendavid 1.1 met->SetSumEt(inMet->sumEt());
62     met->SetElongitudinal(inMet->e_longitudinal());
63     for(unsigned i=0; i<inMet->mEtCorr().size(); i++) {
64     met->PushCorrectionX(inMet->mEtCorr()[i].mex);
65     met->PushCorrectionY(inMet->mEtCorr()[i].mey);
66     met->PushCorrectionSumEt(inMet->mEtCorr()[i].sumet);
67     }
68    
69     }
70     mets_->Trim();
71     }