ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerMet.cc
Revision: 1.3
Committed: Mon Jun 15 15:00:26 2009 UTC (15 years, 10 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_011, Mit_010a, Mit_010, Mit_009c, Mit_009b
Changes since 1.2: +4 -1 lines
Log Message:
Added proper fwd defs plus split up complilation of MitAna/DataTree LinkDefs.

File Contents

# Content
1 // $Id: FillerMet.cc,v 1.2 2009/03/15 11:20:41 loizides 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 "DataFormats/METReco/interface/METCollection.h"
8 #include "MitAna/DataTree/interface/Names.h"
9 #include "MitAna/DataTree/interface/MetCol.h"
10 #include "MitProd/ObjectService/interface/ObjectService.h"
11
12 using namespace std;
13 using namespace edm;
14 using namespace mithep;
15
16 //--------------------------------------------------------------------------------------------------
17 FillerMet::FillerMet(const ParameterSet &cfg, const char *name, bool active) :
18 BaseFiller(cfg,name,active),
19 edmName_(Conf().getUntrackedParameter<string>("edmName","met")),
20 mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkCaloMetBrn)),
21 mets_(new mithep::MetArr)
22 {
23 // Constructor.
24 }
25
26 //--------------------------------------------------------------------------------------------------
27 FillerMet::~FillerMet()
28 {
29 // Destructor.
30
31 delete mets_;
32 }
33
34 //--------------------------------------------------------------------------------------------------
35 void FillerMet::BookDataBlock(TreeWriter &tws)
36 {
37 // Add mets branch to tree.
38
39 tws.AddBranch(mitName_,&mets_);
40 OS()->add<mithep::MetArr>(mets_,mitName_);
41 }
42
43 //--------------------------------------------------------------------------------------------------
44 void FillerMet::FillDataBlock(const edm::Event &event,
45 const edm::EventSetup &setup)
46 {
47 // Fill missing energy from edm collection into our collection.
48
49 mets_->Delete();
50
51 Handle<reco::METCollection> hMetProduct;
52 GetProduct(edmName_, hMetProduct, event);
53
54 const reco::METCollection inMets = *(hMetProduct.product());
55
56 // loop through all mets
57 for (reco::METCollection::const_iterator inMet = inMets.begin();
58 inMet != inMets.end(); ++inMet) {
59
60 mithep::Met *met = mets_->Allocate();
61 new (met) mithep::Met(inMet->px(), inMet->py());
62
63 // fill met base class data
64 met->SetSumEt(inMet->sumEt());
65 met->SetElongitudinal(inMet->e_longitudinal());
66 for(unsigned i=0; i<inMet->mEtCorr().size(); i++) {
67 met->PushCorrectionX(inMet->mEtCorr()[i].mex);
68 met->PushCorrectionY(inMet->mEtCorr()[i].mey);
69 met->PushCorrectionSumEt(inMet->mEtCorr()[i].sumet);
70 }
71
72 }
73 mets_->Trim();
74 }