1 |
|
// $Id$ |
2 |
|
|
3 |
+ |
#include "MitProd/TreeFiller/interface/FillMitTree.h" |
4 |
|
#include "FWCore/MessageLogger/interface/MessageLogger.h" |
4 |
– |
#include "FWCore/Framework/interface/ESHandle.h" |
5 |
– |
#include "DataFormats/Common/interface/Handle.h" |
5 |
|
#include "FWCore/ServiceRegistry/interface/Service.h" |
6 |
< |
|
6 |
> |
#include "MitProd/TreeService/interface/TreeService.h" |
7 |
> |
#include "MitProd/TreeFiller/interface/FillerMetaInfos.h" |
8 |
|
#include "MitProd/TreeFiller/interface/FillerGlobalMuons.h" |
9 |
– |
#include "MitProd/TreeFiller/interface/FillMitTree.h" |
9 |
|
|
10 |
|
using namespace std; |
11 |
|
using namespace edm; |
12 |
|
using namespace mithep; |
13 |
|
|
14 |
|
//------------------------------------------------------------------------------------------------- |
15 |
< |
FillMitTree::FillMitTree(const edm::ParameterSet &cfg) : |
17 |
< |
fillerGlobalMuons_(0) |
15 |
> |
FillMitTree::FillMitTree(const edm::ParameterSet &cfg) |
16 |
|
{ |
17 |
< |
// initialize fillers |
18 |
< |
fillerGlobalMuons_ = new FillerGlobalMuons(cfg); |
19 |
< |
if (fillerGlobalMuons_->Active()) |
20 |
< |
fillers_.push_back(fillerGlobalMuons_); |
17 |
> |
// Constructor: initialize fillers |
18 |
> |
|
19 |
> |
if (!configure(cfg)) { |
20 |
> |
throw edm::Exception(edm::errors::Configuration, "FillMitTree::FillMitTree()\n") |
21 |
> |
<< "Could not configure fillers." << "\n"; |
22 |
> |
} |
23 |
|
} |
24 |
|
|
25 |
|
//------------------------------------------------------------------------------------------------- |
26 |
|
FillMitTree::~FillMitTree() |
27 |
|
{ |
28 |
< |
// We own the fillers so we have to delete them |
29 |
< |
delete fillerGlobalMuons_; |
28 |
> |
// Destructor: nothing to be done here. |
29 |
> |
} |
30 |
> |
|
31 |
> |
//------------------------------------------------------------------------------------------------- |
32 |
> |
void FillMitTree::analyze(const edm::Event &event, |
33 |
> |
const edm::EventSetup &setup) |
34 |
> |
{ |
35 |
> |
// Access and copy event content. |
36 |
> |
|
37 |
> |
// First step: Loop over the data fillers of the various components |
38 |
> |
for (std::vector<BaseFiller*>::const_iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) { |
39 |
> |
(*iF)->FillDataBlock(event,setup); |
40 |
> |
} |
41 |
> |
|
42 |
> |
// Second step: Loop over the link resolution of the various components |
43 |
> |
for (std::vector<BaseFiller*>::const_iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) { |
44 |
> |
(*iF)->ResolveLinks(event,setup); |
45 |
> |
} |
46 |
|
} |
47 |
|
|
48 |
|
//------------------------------------------------------------------------------------------------- |
49 |
< |
void FillMitTree::beginJob(edm::EventSetup const &event) |
49 |
> |
void FillMitTree::beginJob(const edm::EventSetup &event) |
50 |
|
{ |
51 |
+ |
// Access the tree and book branches. |
52 |
+ |
|
53 |
|
Service<TreeService> ts; |
54 |
|
TreeWriter *tws = ts->get(); |
55 |
|
if (! tws) { |
56 |
|
throw edm::Exception(edm::errors::Configuration, "FillMitTree::beginJob()\n") |
57 |
< |
<< "Could not get pointer to Tree with name " << tws->GetName() << "\n"; |
57 |
> |
<< "Could not get pointer to tree." << "\n"; |
58 |
|
return; |
59 |
|
} |
60 |
|
|
61 |
|
// Loop over the various components and book the branches |
62 |
|
for (std::vector<BaseFiller*>::iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) { |
63 |
< |
(*iF)->BookDataBlock(tws); |
63 |
> |
(*iF)->BookDataBlock(*tws); |
64 |
|
} |
47 |
– |
return; |
65 |
|
} |
66 |
|
|
67 |
|
//------------------------------------------------------------------------------------------------- |
68 |
< |
void FillMitTree::analyze(const edm::Event &event, |
52 |
< |
const edm::EventSetup &setup) |
68 |
> |
bool FillMitTree::configure(const edm::ParameterSet &cfg) |
69 |
|
{ |
70 |
< |
// First step: Loop over the data fillers of the various components |
55 |
< |
for (std::vector<BaseFiller*>::const_iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) { |
56 |
< |
(*iF)->FillDataBlock(event,setup); |
57 |
< |
} |
70 |
> |
// Configure our fillers. |
71 |
|
|
72 |
< |
// Second step: Loop over the link resolution of the various components |
73 |
< |
for (std::vector<BaseFiller*>::const_iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) { |
74 |
< |
(*iF)->ResolveLinks(event,setup); |
75 |
< |
} |
72 |
> |
|
73 |
> |
FillerMetaInfos *fillerMetaInfos = new FillerMetaInfos(cfg); |
74 |
> |
if (fillerMetaInfos->Active()) |
75 |
> |
fillers_.push_back(fillerMetaInfos); |
76 |
> |
else |
77 |
> |
delete fillerMetaInfos; |
78 |
> |
|
79 |
> |
FillerGlobalMuons *fillerGlobalMuons = new FillerGlobalMuons(cfg); |
80 |
> |
if (fillerGlobalMuons->Active()) |
81 |
> |
fillers_.push_back(fillerGlobalMuons); |
82 |
> |
else |
83 |
> |
delete fillerGlobalMuons; |
84 |
> |
|
85 |
> |
return 1; |
86 |
|
} |
87 |
|
|
88 |
|
//------------------------------------------------------------------------------------------------- |
89 |
|
void FillMitTree::endJob() |
90 |
|
{ |
91 |
+ |
// Delete fillers. |
92 |
+ |
|
93 |
+ |
for (std::vector<BaseFiller*>::iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) { |
94 |
+ |
delete *iF; |
95 |
+ |
} |
96 |
+ |
|
97 |
|
edm::LogInfo("FillMitTree::endJob") << "Ending Job" << endl; |
98 |
|
} |