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.5 by loizides, Tue Jun 24 14:25:46 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 > #include "MitProd/TreeFiller/interface/FillerGenParts.h"
10  
11   using namespace std;
12   using namespace edm;
13   using namespace mithep;
14  
15   //-------------------------------------------------------------------------------------------------
16 < FillMitTree::FillMitTree(const edm::ParameterSet &cfg) :
17 <  fillerGlobalMuons_(0)
16 > FillMitTree::FillMitTree(const edm::ParameterSet &cfg)
17   {
18 <  // initialize fillers
19 <  fillerGlobalMuons_ = new FillerGlobalMuons(cfg);
20 <  if (fillerGlobalMuons_->Active())
21 <    fillers_.push_back(fillerGlobalMuons_);
18 >  // Constructor: initialize fillers
19 >
20 >  if (!configure(cfg)) {
21 >    throw edm::Exception(edm::errors::Configuration, "FillMitTree::FillMitTree()\n")
22 >      << "Could not configure fillers." << "\n";
23 >  }
24   }
25  
26   //-------------------------------------------------------------------------------------------------
27   FillMitTree::~FillMitTree()
28   {
29 <  // We own the fillers so we have to delete them
30 <  delete fillerGlobalMuons_;
29 >  // Destructor: nothing to be done here.
30 > }
31 >
32 > //-------------------------------------------------------------------------------------------------
33 > 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(edm::EventSetup const &event)
50 > void FillMitTree::beginJob(const edm::EventSetup &event)
51   {
52 +  // Access the tree and book branches.
53 +
54    Service<TreeService> ts;
55    TreeWriter *tws = ts->get();
56    if (! tws) {
57      throw edm::Exception(edm::errors::Configuration, "FillMitTree::beginJob()\n")
58 <      << "Could not get pointer to Tree with name " << tws->GetName() << "\n";
58 >      << "Could not get pointer to tree." << "\n";
59      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 <    (*iF)->BookDataBlock(tws);
64 >    (*iF)->BookDataBlock(*tws);
65    }
47  return;
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 >  FillerGenParts *fillerGenParts = new FillerGenParts(cfg);
87 >  if (fillerGenParts->Active())
88 >    fillers_.push_back(fillerGenParts);
89 >  else
90 >    delete fillerGenParts;
91 >
92 >  return 1;
93   }
94  
95   //-------------------------------------------------------------------------------------------------
96   void FillMitTree::endJob()
97   {
98 +  // Delete fillers.
99 +
100 +  for (std::vector<BaseFiller*>::iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) {
101 +    delete *iF;
102 +  }
103 +
104    edm::LogInfo("FillMitTree::endJob") << "Ending Job" << endl;
105   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines