Revision: | 1.5 |
Committed: | Thu Mar 18 20:21:00 2010 UTC (15 years, 1 month ago) by bendavid |
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, Mit_025b, Mit_025a, Mit_025, Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, Mit_020d, TMit_020d, Mit_020c, Mit_021, Mit_021pre2, Mit_021pre1, Mit_020b, Mit_020a, Mit_020, Mit_020pre1, Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d, Mit_014c, Mit_014b, Mit_014a, Mit_014, Mit_014pre3, Mit_014pre2, Mit_014pre1, Mit_013d, Mit_013c, Mit_013b, Mit_013a, Mit_013, HEAD |
Branch point for: | Mit_025c_branch |
Changes since 1.4: | +2 -2 lines |
Log Message: | Fix beginrun,beginjob mess |
# | Content |
---|---|
1 | // $Id: FillerMet.cc,v 1.4 2009/09/25 08:42:51 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 | } |