ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillerEmbedWeight.cc
Revision: 1.3
Committed: Fri Dec 28 17:27:21 2012 UTC (12 years, 4 months ago) by pharris
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_030_pre1, Mit_029a
Changes since 1.2: +15 -6 lines
Log Message:
Added Embedded and PFAOD functionality

File Contents

# Content
1 // $Id: FillerEmbedWeight.cc,v 1.2 2011/11/28 13:03:07 pharris Exp $
2
3 #include "MitProd/TreeFiller/interface/FillerEmbedWeight.h"
4 #include "MitAna/DataTree/interface/Names.h"
5 #include "MitAna/DataTree/interface/EmbedWeightCol.h"
6 #include "MitProd/ObjectService/interface/ObjectService.h"
7 #include "SimDataFormats/GeneratorProducts/interface/GenFilterInfo.h"
8
9 using namespace std;
10 using namespace edm;
11 using namespace mithep;
12
13 //--------------------------------------------------------------------------------------------------
14 FillerEmbedWeight::FillerEmbedWeight(const ParameterSet &cfg, const char *name, bool active) :
15 BaseFiller(cfg,name,active),
16 edmName_(Conf().getUntrackedParameter<string>("edmName","generator_weight")),
17 genInfo_(Conf().getUntrackedParameter<bool> ("useGenInfo","True")),
18 mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkEmbedWeightBrn)),
19 embedWeight_(new mithep::EmbedWeightArr)
20 {
21 // Constructor.
22 }
23
24 //--------------------------------------------------------------------------------------------------
25 FillerEmbedWeight::~FillerEmbedWeight()
26 {
27 // Destructor.
28
29 delete embedWeight_;
30 }
31
32 //--------------------------------------------------------------------------------------------------
33 void FillerEmbedWeight::BookDataBlock(TreeWriter &tws)
34 {
35 // Add mets branch to tree.
36
37 tws.AddBranch(mitName_,&embedWeight_);
38 OS()->add<mithep::EmbedWeightArr>(embedWeight_,mitName_);
39 }
40
41 //--------------------------------------------------------------------------------------------------
42 void FillerEmbedWeight::FillDataBlock(const edm::Event &event,
43 const edm::EventSetup &setup)
44 {
45 // Fill missing energy from edm collection into our collection.
46 embedWeight_->Delete();
47
48 double inEmbedWeightValue = 0;
49 if(!genInfo_) {
50 Handle<double> hEmbedWeight;
51 event.getByLabel(edm::InputTag(edmName_,"weight","EmbeddedRECO"),hEmbedWeight);
52 inEmbedWeightValue = *(hEmbedWeight.product());
53 } else {
54 edm::Handle<GenFilterInfo> hGenFilterInfo;
55 event.getByLabel(edm::InputTag(edmName_, "minVisPtFilter", "EmbeddedRECO"), hGenFilterInfo);
56 inEmbedWeightValue = hGenFilterInfo->filterEfficiency();
57 }
58 const double inEmbedWeight = inEmbedWeightValue;
59 mithep::EmbedWeight *embedWeight = embedWeight_->Allocate();
60 new (embedWeight) mithep::EmbedWeight(inEmbedWeight);
61 //embedWeight->SetWeight(inEmbedWeight);
62 embedWeight_->Trim();
63 }