1 |
bendavid |
1.1 |
// $Id: FillerGenMet.cc,v 1.12 2009/06/15 15:00:25 loizides Exp $
|
2 |
|
|
|
3 |
|
|
#include "MitProd/TreeFiller/interface/FillerGenMet.h"
|
4 |
|
|
#include "DataFormats/METReco/interface/GenMET.h"
|
5 |
|
|
#include "DataFormats/METReco/interface/GenMETCollection.h"
|
6 |
|
|
#include "MitAna/DataTree/interface/GenMetCol.h"
|
7 |
|
|
#include "MitAna/DataTree/interface/Names.h"
|
8 |
|
|
#include "MitProd/ObjectService/interface/ObjectService.h"
|
9 |
|
|
|
10 |
|
|
using namespace std;
|
11 |
|
|
using namespace edm;
|
12 |
|
|
using namespace mithep;
|
13 |
|
|
|
14 |
|
|
//--------------------------------------------------------------------------------------------------
|
15 |
|
|
FillerGenMet::FillerGenMet(const ParameterSet &cfg, const char *name, bool active) :
|
16 |
|
|
BaseFiller(cfg,name,active),
|
17 |
|
|
edmName_(Conf().getUntrackedParameter<string>("edmName","genMetTrue")),
|
18 |
|
|
mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkGenMetBrn)),
|
19 |
|
|
genMets_(new mithep::GenMetArr)
|
20 |
|
|
{
|
21 |
|
|
// Constructor.
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
//--------------------------------------------------------------------------------------------------
|
25 |
|
|
FillerGenMet::~FillerGenMet()
|
26 |
|
|
{
|
27 |
|
|
// Destructor.
|
28 |
|
|
|
29 |
|
|
delete genMets_;
|
30 |
|
|
}
|
31 |
|
|
|
32 |
|
|
//--------------------------------------------------------------------------------------------------
|
33 |
|
|
void FillerGenMet::BookDataBlock(TreeWriter &tws)
|
34 |
|
|
{
|
35 |
|
|
// Add mets branch to tree.
|
36 |
|
|
|
37 |
|
|
tws.AddBranch(mitName_,&genMets_);
|
38 |
|
|
OS()->add<mithep::GenMetArr>(genMets_,mitName_);
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
//--------------------------------------------------------------------------------------------------
|
42 |
|
|
void FillerGenMet::FillDataBlock(const edm::Event &event,
|
43 |
|
|
const edm::EventSetup &setup)
|
44 |
|
|
{
|
45 |
|
|
// Fill missing energy from edm collection into our collection.
|
46 |
|
|
|
47 |
|
|
genMets_->Delete();
|
48 |
|
|
|
49 |
|
|
Handle<reco::GenMETCollection> hGenMetProduct;
|
50 |
|
|
GetProduct(edmName_, hGenMetProduct, event);
|
51 |
|
|
|
52 |
|
|
const reco::GenMETCollection inGenMets = *(hGenMetProduct.product());
|
53 |
|
|
|
54 |
|
|
// loop through all mets
|
55 |
|
|
for (reco::GenMETCollection::const_iterator inGenMet = inGenMets.begin();
|
56 |
|
|
inGenMet != inGenMets.end(); ++inGenMet) {
|
57 |
|
|
|
58 |
|
|
mithep::GenMet *genMet = genMets_->Allocate();
|
59 |
|
|
new (genMet) mithep::GenMet(inGenMet->px(), inGenMet->py());
|
60 |
|
|
|
61 |
|
|
// fill Met base class data
|
62 |
|
|
genMet->SetSumEt(inGenMet->sumEt());
|
63 |
|
|
genMet->SetElongitudinal(inGenMet->e_longitudinal());
|
64 |
|
|
for(unsigned i=0; i<inGenMet->mEtCorr().size(); i++) {
|
65 |
|
|
genMet->PushCorrectionX(inGenMet->mEtCorr()[i].mex);
|
66 |
|
|
genMet->PushCorrectionY(inGenMet->mEtCorr()[i].mey);
|
67 |
|
|
genMet->PushCorrectionSumEt(inGenMet->mEtCorr()[i].sumet);
|
68 |
|
|
}
|
69 |
|
|
// fill GenMet class data
|
70 |
|
|
genMet->SetEmEnergy(inGenMet->emEnergy());
|
71 |
|
|
genMet->SetHadEnergy(inGenMet->hadEnergy());
|
72 |
|
|
genMet->SetInvisibleEnergy(inGenMet->invisibleEnergy());
|
73 |
|
|
genMet->SetAuxiliaryEnergy(inGenMet->auxiliaryEnergy());
|
74 |
|
|
}
|
75 |
|
|
genMets_->Trim();
|
76 |
|
|
}
|