1 |
loizides |
1.3 |
// $Id: FillMitTree.cc,v 1.2 2008/06/18 19:17:21 loizides Exp $
|
2 |
paus |
1.1 |
|
3 |
loizides |
1.3 |
#include "MitProd/TreeFiller/interface/FillMitTree.h"
|
4 |
paus |
1.1 |
#include "FWCore/MessageLogger/interface/MessageLogger.h"
|
5 |
|
|
#include "FWCore/ServiceRegistry/interface/Service.h"
|
6 |
loizides |
1.3 |
#include "MitProd/TreeService/interface/TreeService.h"
|
7 |
|
|
#include "MitProd/TreeFiller/interface/FillerMetaInfos.h"
|
8 |
paus |
1.1 |
#include "MitProd/TreeFiller/interface/FillerGlobalMuons.h"
|
9 |
|
|
|
10 |
|
|
using namespace std;
|
11 |
|
|
using namespace edm;
|
12 |
|
|
using namespace mithep;
|
13 |
|
|
|
14 |
|
|
//-------------------------------------------------------------------------------------------------
|
15 |
loizides |
1.2 |
FillMitTree::FillMitTree(const edm::ParameterSet &cfg)
|
16 |
paus |
1.1 |
{
|
17 |
loizides |
1.2 |
// Constructor: initialize fillers
|
18 |
|
|
|
19 |
loizides |
1.3 |
if (!configure(cfg)) {
|
20 |
|
|
throw edm::Exception(edm::errors::Configuration, "FillMitTree::FillMitTree()\n")
|
21 |
|
|
<< "Could not configure fillers." << "\n";
|
22 |
|
|
}
|
23 |
paus |
1.1 |
}
|
24 |
|
|
|
25 |
|
|
//-------------------------------------------------------------------------------------------------
|
26 |
|
|
FillMitTree::~FillMitTree()
|
27 |
|
|
{
|
28 |
loizides |
1.2 |
// Destructor: nothing to be done here.
|
29 |
paus |
1.1 |
}
|
30 |
|
|
|
31 |
|
|
//-------------------------------------------------------------------------------------------------
|
32 |
loizides |
1.3 |
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(const edm::EventSetup &event)
|
50 |
paus |
1.1 |
{
|
51 |
loizides |
1.2 |
// Access the tree and book branches.
|
52 |
|
|
|
53 |
paus |
1.1 |
Service<TreeService> ts;
|
54 |
|
|
TreeWriter *tws = ts->get();
|
55 |
|
|
if (! tws) {
|
56 |
|
|
throw edm::Exception(edm::errors::Configuration, "FillMitTree::beginJob()\n")
|
57 |
loizides |
1.2 |
<< "Could not get pointer to tree." << "\n";
|
58 |
paus |
1.1 |
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);
|
64 |
|
|
}
|
65 |
|
|
return;
|
66 |
|
|
}
|
67 |
|
|
|
68 |
|
|
//-------------------------------------------------------------------------------------------------
|
69 |
loizides |
1.3 |
bool FillMitTree::configure(const edm::ParameterSet &cfg)
|
70 |
paus |
1.1 |
{
|
71 |
loizides |
1.3 |
// Configure our fillers.
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
FillerMetaInfos *fillerMetaInfos = new FillerMetaInfos(cfg);
|
75 |
|
|
if (fillerMetaInfos->Active())
|
76 |
|
|
fillers_.push_back(fillerMetaInfos);
|
77 |
|
|
else
|
78 |
|
|
delete fillerMetaInfos;
|
79 |
loizides |
1.2 |
|
80 |
loizides |
1.3 |
FillerGlobalMuons *fillerGlobalMuons = new FillerGlobalMuons(cfg);
|
81 |
|
|
if (fillerGlobalMuons->Active())
|
82 |
|
|
fillers_.push_back(fillerGlobalMuons);
|
83 |
|
|
else
|
84 |
|
|
delete fillerGlobalMuons;
|
85 |
paus |
1.1 |
|
86 |
loizides |
1.3 |
return 1;
|
87 |
paus |
1.1 |
}
|
88 |
|
|
|
89 |
|
|
//-------------------------------------------------------------------------------------------------
|
90 |
|
|
void FillMitTree::endJob()
|
91 |
|
|
{
|
92 |
loizides |
1.2 |
// Delete fillers.
|
93 |
|
|
|
94 |
|
|
for (std::vector<BaseFiller*>::iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) {
|
95 |
|
|
delete *iF;
|
96 |
|
|
}
|
97 |
|
|
|
98 |
paus |
1.1 |
edm::LogInfo("FillMitTree::endJob") << "Ending Job" << endl;
|
99 |
|
|
}
|