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