ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillMitTree.cc
Revision: 1.4
Committed: Fri Jun 20 17:52:57 2008 UTC (16 years, 10 months ago) by loizides
Content type: text/plain
Branch: MAIN
Changes since 1.3: +2 -3 lines
Log Message:
First proof-of-principle implementation of MetaInfo.

File Contents

# User Rev Content
1 loizides 1.4 // $Id: FillMitTree.cc,v 1.3 2008/06/19 16:53:43 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 loizides 1.4 (*iF)->BookDataBlock(*tws);
64 paus 1.1 }
65     }
66    
67     //-------------------------------------------------------------------------------------------------
68 loizides 1.3 bool FillMitTree::configure(const edm::ParameterSet &cfg)
69 paus 1.1 {
70 loizides 1.3 // Configure our fillers.
71    
72    
73     FillerMetaInfos *fillerMetaInfos = new FillerMetaInfos(cfg);
74     if (fillerMetaInfos->Active())
75     fillers_.push_back(fillerMetaInfos);
76     else
77     delete fillerMetaInfos;
78 loizides 1.2
79 loizides 1.3 FillerGlobalMuons *fillerGlobalMuons = new FillerGlobalMuons(cfg);
80     if (fillerGlobalMuons->Active())
81     fillers_.push_back(fillerGlobalMuons);
82     else
83     delete fillerGlobalMuons;
84 paus 1.1
85 loizides 1.3 return 1;
86 paus 1.1 }
87    
88     //-------------------------------------------------------------------------------------------------
89     void FillMitTree::endJob()
90     {
91 loizides 1.2 // Delete fillers.
92    
93     for (std::vector<BaseFiller*>::iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) {
94     delete *iF;
95     }
96    
97 paus 1.1 edm::LogInfo("FillMitTree::endJob") << "Ending Job" << endl;
98     }