ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/TreeFiller/src/FillMitTree.cc
(Generate patch)

Comparing UserCode/MitProd/TreeFiller/src/FillMitTree.cc (file contents):
Revision 1.1 by paus, Wed Jun 18 13:23:22 2008 UTC vs.
Revision 1.3 by loizides, Thu Jun 19 16:53:43 2008 UTC

# Line 1 | Line 1
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  
# Line 48 | Line 66 | void FillMitTree::beginJob(edm::EventSet
66   }
67  
68   //-------------------------------------------------------------------------------------------------
69 < void FillMitTree::analyze(const edm::Event      &event,
52 <                          const edm::EventSetup &setup)
69 > bool FillMitTree::configure(const edm::ParameterSet &cfg)
70   {
71 <  // 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 <  }
71 >  // Configure our fillers.
72  
73 <  // Second step: Loop over the link resolution of the various components
74 <  for (std::vector<BaseFiller*>::const_iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) {
75 <    (*iF)->ResolveLinks(event,setup);
76 <  }
73 >
74 >  FillerMetaInfos *fillerMetaInfos = new FillerMetaInfos(cfg);
75 >  if (fillerMetaInfos->Active())
76 >    fillers_.push_back(fillerMetaInfos);
77 >  else
78 >    delete fillerMetaInfos;
79 >
80 >  FillerGlobalMuons *fillerGlobalMuons = new FillerGlobalMuons(cfg);
81 >  if (fillerGlobalMuons->Active())
82 >    fillers_.push_back(fillerGlobalMuons);
83 >  else
84 >    delete fillerGlobalMuons;
85 >
86 >  return 1;
87   }
88  
89   //-------------------------------------------------------------------------------------------------
90   void FillMitTree::endJob()
91   {
92 +  // Delete fillers.
93 +
94 +  for (std::vector<BaseFiller*>::iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) {
95 +    delete *iF;
96 +  }
97 +
98    edm::LogInfo("FillMitTree::endJob") << "Ending Job" << endl;
99   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines