ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerPFMet.cc
Revision: 1.8
Committed: Mon Nov 28 12:58:33 2011 UTC (13 years, 5 months ago) by pharris
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_032, Mit_031, Mit_025c_branch2, Mit_025c_branch1, Mit_030, Mit_029c, Mit_029b, Mit_030_pre1, Mit_029a, Mit_029, Mit_029_pre1, Mit_028a, Mit_025c_branch0, Mit_028, Mit_027a, Mit_027, Mit_026, Mit_025e, Mit_025d, Mit_025c, HEAD
Branch point for: Mit_025c_branch
Changes since 1.7: +1 -3 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 pharris 1.8 // $Id: FillerPFMet.cc,v 1.7 2011/10/03 16:15:50 ksung 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 ksung 1.7 edmName_(Conf().getUntrackedParameter<edm::InputTag>("edmName")),
18 bendavid 1.1 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 bendavid 1.5 void FillerPFMet::BookDataBlock(TreeWriter &tws)
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 ksung 1.7 reco::PFMETCollection inPFMets;
50    
51 bendavid 1.1 Handle<reco::PFMETCollection> hCaloMetProduct;
52 ksung 1.7 //GetProduct(edmName_, hCaloMetProduct, event);
53     event.getByLabel(edmName_,hCaloMetProduct);
54     if(hCaloMetProduct.isValid()) {
55     inPFMets = *(hCaloMetProduct.product());
56     } else {
57     Handle<reco::PFMET> hSingleMetProduct;
58     event.getByLabel(edmName_, hSingleMetProduct);
59     inPFMets.push_back(*hSingleMetProduct.product());
60     }
61 bendavid 1.1 // loop through all mets
62     for (reco::PFMETCollection::const_iterator inPFMet = inPFMets.begin();
63     inPFMet != inPFMets.end(); ++inPFMet) {
64    
65     mithep::PFMet *pfMet = pfMets_->Allocate();
66     new (pfMet) mithep::PFMet(inPFMet->px(), inPFMet->py());
67    
68 loizides 1.2 // fill Met base class data
69 bendavid 1.1 pfMet->SetSumEt(inPFMet->sumEt());
70     pfMet->SetElongitudinal(inPFMet->e_longitudinal());
71     for(unsigned i=0; i<inPFMet->mEtCorr().size(); i++) {
72     pfMet->PushCorrectionX(inPFMet->mEtCorr()[i].mex);
73     pfMet->PushCorrectionY(inPFMet->mEtCorr()[i].mey);
74     pfMet->PushCorrectionSumEt(inPFMet->mEtCorr()[i].sumet);
75     }
76 loizides 1.2 // fill PFMet class data
77 ksung 1.6 pfMet->SetPFMetSig(inPFMet->significance());
78 bendavid 1.1 pfMet->SetNeutralEMFraction(inPFMet->NeutralEMFraction());
79     pfMet->SetNeutralHadFraction(inPFMet->NeutralHadFraction());
80     pfMet->SetChargedEMFraction(inPFMet->ChargedEMFraction());
81     pfMet->SetChargedHadFraction(inPFMet->ChargedHadFraction());
82     pfMet->SetMuonFraction(inPFMet->MuonFraction());
83    
84     }
85     pfMets_->Trim();
86     }