ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillMitTree.cc
Revision: 1.5
Committed: Tue Jun 24 14:25:46 2008 UTC (16 years, 10 months ago) by loizides
Content type: text/plain
Branch: MAIN
Changes since 1.4: +8 -1 lines
Log Message:
Cleanup

File Contents

# User Rev Content
1 loizides 1.5 // $Id: FillMitTree.cc,v 1.4 2008/06/20 17:52:57 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 loizides 1.5 #include "MitProd/TreeFiller/interface/FillerGenParts.h"
10 paus 1.1
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 loizides 1.3 if (!configure(cfg)) {
21     throw edm::Exception(edm::errors::Configuration, "FillMitTree::FillMitTree()\n")
22     << "Could not configure fillers." << "\n";
23     }
24 paus 1.1 }
25    
26     //-------------------------------------------------------------------------------------------------
27     FillMitTree::~FillMitTree()
28     {
29 loizides 1.2 // Destructor: nothing to be done here.
30 paus 1.1 }
31    
32     //-------------------------------------------------------------------------------------------------
33 loizides 1.3 void FillMitTree::analyze(const edm::Event &event,
34     const edm::EventSetup &setup)
35     {
36     // Access and copy event content.
37    
38     // First step: Loop over the data fillers of the various components
39     for (std::vector<BaseFiller*>::const_iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) {
40     (*iF)->FillDataBlock(event,setup);
41     }
42    
43     // Second step: Loop over the link resolution of the various components
44     for (std::vector<BaseFiller*>::const_iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) {
45     (*iF)->ResolveLinks(event,setup);
46     }
47     }
48    
49     //-------------------------------------------------------------------------------------------------
50     void FillMitTree::beginJob(const edm::EventSetup &event)
51 paus 1.1 {
52 loizides 1.2 // Access the tree and book branches.
53    
54 paus 1.1 Service<TreeService> ts;
55     TreeWriter *tws = ts->get();
56     if (! tws) {
57     throw edm::Exception(edm::errors::Configuration, "FillMitTree::beginJob()\n")
58 loizides 1.2 << "Could not get pointer to tree." << "\n";
59 paus 1.1 return;
60     }
61    
62     // Loop over the various components and book the branches
63     for (std::vector<BaseFiller*>::iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) {
64 loizides 1.4 (*iF)->BookDataBlock(*tws);
65 paus 1.1 }
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.5 FillerGenParts *fillerGenParts = new FillerGenParts(cfg);
87     if (fillerGenParts->Active())
88     fillers_.push_back(fillerGenParts);
89     else
90     delete fillerGenParts;
91    
92 loizides 1.3 return 1;
93 paus 1.1 }
94    
95     //-------------------------------------------------------------------------------------------------
96     void FillMitTree::endJob()
97     {
98 loizides 1.2 // Delete fillers.
99    
100     for (std::vector<BaseFiller*>::iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) {
101     delete *iF;
102     }
103    
104 paus 1.1 edm::LogInfo("FillMitTree::endJob") << "Ending Job" << endl;
105     }