1 |
loizides |
1.4 |
// $Id: FillerMet.cc,v 1.3 2009/06/15 15:00:26 loizides 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 |
loizides |
1.3 |
#include "DataFormats/METReco/interface/METCollection.h"
|
8 |
bendavid |
1.1 |
#include "MitAna/DataTree/interface/Names.h"
|
9 |
loizides |
1.3 |
#include "MitAna/DataTree/interface/MetCol.h"
|
10 |
|
|
#include "MitProd/ObjectService/interface/ObjectService.h"
|
11 |
bendavid |
1.1 |
|
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 |
loizides |
1.4 |
void FillerMet::BookDataBlock(TreeWriter &tws, const edm::EventSetup &es)
|
36 |
bendavid |
1.1 |
{
|
37 |
|
|
// Add mets branch to tree.
|
38 |
|
|
|
39 |
loizides |
1.2 |
tws.AddBranch(mitName_,&mets_);
|
40 |
|
|
OS()->add<mithep::MetArr>(mets_,mitName_);
|
41 |
bendavid |
1.1 |
}
|
42 |
|
|
|
43 |
|
|
//--------------------------------------------------------------------------------------------------
|
44 |
|
|
void FillerMet::FillDataBlock(const edm::Event &event,
|
45 |
loizides |
1.2 |
const edm::EventSetup &setup)
|
46 |
bendavid |
1.1 |
{
|
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 |
loizides |
1.2 |
// fill met base class data
|
64 |
bendavid |
1.1 |
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 |
|
|
}
|