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.5 by loizides, Tue Jun 24 14:25:46 2008 UTC vs.
Revision 1.17 by loizides, Thu Jul 31 12:34:04 2008 UTC

# Line 4 | Line 4
4   #include "FWCore/MessageLogger/interface/MessageLogger.h"
5   #include "FWCore/ServiceRegistry/interface/Service.h"
6   #include "MitProd/TreeService/interface/TreeService.h"
7 + #include "MitProd/ObjectService/interface/ObjectService.h"
8 + #include "MitProd/TreeFiller/interface/AssociationMaps.h"
9   #include "MitProd/TreeFiller/interface/FillerMetaInfos.h"
10 < #include "MitProd/TreeFiller/interface/FillerGlobalMuons.h"
11 < #include "MitProd/TreeFiller/interface/FillerGenParts.h"
10 > #include "MitProd/TreeFiller/interface/FillerTracks.h"
11 > #include "MitProd/TreeFiller/interface/FillerGsfTracks.h"
12 > #include "MitProd/TreeFiller/interface/FillerMuons.h"
13 > #include "MitProd/TreeFiller/interface/FillerElectrons.h"
14 > #include "MitProd/TreeFiller/interface/FillerElectrons.h"
15 > #include "MitProd/TreeFiller/interface/FillerCaloJets.h"
16 > #include "MitProd/TreeFiller/interface/FillerCaloMet.h"
17 > #include "MitProd/TreeFiller/interface/FillerConversions.h"
18 > #include "MitProd/TreeFiller/interface/FillerConversionElectrons.h"
19 > #include "MitProd/TreeFiller/interface/FillerPhotons.h"
20 > #include "MitProd/TreeFiller/interface/FillerMCParticles.h"
21 > #include "MitProd/TreeFiller/interface/FillerDecayParts.h"
22 > #include "MitProd/TreeFiller/interface/FillerStableParts.h"
23  
24   using namespace std;
25   using namespace edm;
26   using namespace mithep;
27  
28 < //-------------------------------------------------------------------------------------------------
29 < FillMitTree::FillMitTree(const edm::ParameterSet &cfg)
28 > mithep::ObjectService *mithep::FillMitTree::os_ = 0;
29 >
30 > //--------------------------------------------------------------------------------------------------
31 > FillMitTree::FillMitTree(const edm::ParameterSet &cfg) :
32 >  defactive_(cfg.getUntrackedParameter<bool>("defactive",1))
33   {
34 <  // Constructor: initialize fillers
34 >  // Constructor.
35  
36    if (!configure(cfg)) {
37      throw edm::Exception(edm::errors::Configuration, "FillMitTree::FillMitTree()\n")
# Line 23 | Line 39 | FillMitTree::FillMitTree(const edm::Para
39    }
40   }
41  
42 < //-------------------------------------------------------------------------------------------------
42 > //--------------------------------------------------------------------------------------------------
43   FillMitTree::~FillMitTree()
44   {
45    // Destructor: nothing to be done here.
46   }
47  
48 < //-------------------------------------------------------------------------------------------------
48 > //--------------------------------------------------------------------------------------------------
49 > bool FillMitTree::addActiveFiller(BaseFiller *bf)
50 > {
51 >  // Check if filler is active and add it to list of fillers. Otherwise delete it.
52 >
53 >  if (bf->Active()) {
54 >    fillers_.push_back(bf);
55 >    return 1;
56 >  }
57 >
58 >  delete bf;
59 >  bf = 0;
60 >  return 0;
61 > }
62 >
63 > //--------------------------------------------------------------------------------------------------
64   void FillMitTree::analyze(const edm::Event      &event,
65                            const edm::EventSetup &setup)
66   {
# Line 46 | Line 77 | void FillMitTree::analyze(const edm::Eve
77    }
78   }
79  
80 < //-------------------------------------------------------------------------------------------------
80 > //--------------------------------------------------------------------------------------------------
81   void FillMitTree::beginJob(const edm::EventSetup &event)
82   {
83    // Access the tree and book branches.
# Line 55 | Line 86 | void FillMitTree::beginJob(const edm::Ev
86    TreeWriter *tws = ts->get();
87    if (! tws) {
88      throw edm::Exception(edm::errors::Configuration, "FillMitTree::beginJob()\n")
89 <      << "Could not get pointer to tree." << "\n";
89 >      << "Could not get pointer to tree. "
90 >      << "Do you have the TreeServie define in your config?" << "\n";
91      return;
92    }
93  
94 +  if (os_==0) {
95 +    Service<ObjectService> os;
96 +    if (!os.isAvailable()) {
97 +      throw edm::Exception(edm::errors::Configuration, "FillMitTree::beginJob()\n")
98 +        << "Could not get object service. "
99 +        << "Do you have the ObjectService defined in your config?" << "\n";
100 +      return;
101 +    }
102 +    os_ = &(*os);
103 +  }
104 +
105    // Loop over the various components and book the branches
106    for (std::vector<BaseFiller*>::iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) {
107 +    edm::LogInfo("FillMitTree::beginJob") << "Booking for " << (*iF)->Name() << endl;
108      (*iF)->BookDataBlock(*tws);
109    }
110   }
111  
112 < //-------------------------------------------------------------------------------------------------
112 > //--------------------------------------------------------------------------------------------------
113   bool FillMitTree::configure(const edm::ParameterSet &cfg)
114   {
115    // Configure our fillers.
116  
117 +  FillerMetaInfos *fillerMetaInfos = new FillerMetaInfos(cfg,defactive_);
118 +  addActiveFiller(fillerMetaInfos);
119 +
120 +  FillerMCParticles *fillerMCParticles = new FillerMCParticles(cfg,"MCParticles",defactive_);
121 +  addActiveFiller(fillerMCParticles);
122 +
123 +  FillerCaloJets *fillerCaloJets = new FillerCaloJets(cfg,"CaloJets",defactive_);
124 +  addActiveFiller(fillerCaloJets);
125 +
126 +  FillerCaloMet *fillerCaloMet = new FillerCaloMet(cfg,"CaloMet",defactive_);
127 +  addActiveFiller(fillerCaloMet);
128 +
129 +  FillerTracks *fillerGeneralTracks = new FillerTracks(cfg,"GeneralTracks",defactive_);
130 +  addActiveFiller(fillerGeneralTracks);
131 +
132 +  FillerTracks *fillerStandaloneMuonTracks =
133 +    new FillerTracks(cfg,"StandaloneMuonTracks",defactive_);
134 +  addActiveFiller(fillerStandaloneMuonTracks);
135 +
136 +  FillerTracks *fillerStandaloneMuonTracksVtx =
137 +    new FillerTracks(cfg,"StandaloneMuonTracksWVtxConstraint",defactive_);
138 +  addActiveFiller(fillerStandaloneMuonTracksVtx);
139 +
140 +  FillerTracks *fillerGlobalMuonTracks = new FillerTracks(cfg,"GlobalMuonTracks",defactive_);
141 +  addActiveFiller(fillerGlobalMuonTracks);
142 +    
143 +  FillerTracks *fillerConversionInOutTracks =
144 +    new FillerTracks(cfg,"ConversionInOutTracks",defactive_);
145 +  addActiveFiller(fillerConversionInOutTracks);
146 +
147 +  FillerTracks *fillerConversionOutInTracks =
148 +    new FillerTracks(cfg,"ConversionOutInTracks",defactive_);
149 +  addActiveFiller(fillerConversionOutInTracks);
150 +
151 +  FillerGsfTracks *fillerGsfTracks = new FillerGsfTracks(cfg,"GsfTracks",defactive_);
152 +  addActiveFiller(fillerGsfTracks);
153 +
154 +  FillerMuons *fillerMuons = new FillerMuons(cfg,defactive_);
155 +  addActiveFiller(fillerMuons);
156 +
157 +  FillerElectrons *fillerElectrons = new FillerElectrons(cfg,defactive_);
158 +  addActiveFiller(fillerElectrons);
159 +
160 +  FillerConversionElectrons *fillerConversionElectrons =
161 +    new FillerConversionElectrons(cfg,defactive_);
162 +  addActiveFiller(fillerConversionElectrons);
163 +
164 +  FillerConversions *fillerConversions = new FillerConversions(cfg,defactive_);
165 +  addActiveFiller(fillerConversions);
166 +
167 +  FillerPhotons *fillerPhotons = new FillerPhotons(cfg,defactive_);
168 +  addActiveFiller(fillerPhotons);
169  
170 <  FillerMetaInfos *fillerMetaInfos = new FillerMetaInfos(cfg);
171 <  if (fillerMetaInfos->Active())
172 <    fillers_.push_back(fillerMetaInfos);
173 <  else
174 <    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;
170 >  FillerStableParts *fillerStableParts = new FillerStableParts(cfg,"StableParts",defactive_);
171 >  addActiveFiller(fillerStableParts);
172 >  
173 >  FillerDecayParts *fillerDecayParts = new FillerDecayParts(cfg,"DecayParts",defactive_);
174 >  addActiveFiller(fillerDecayParts);
175  
176    return 1;
177   }
178  
179 < //-------------------------------------------------------------------------------------------------
179 > //--------------------------------------------------------------------------------------------------
180   void FillMitTree::endJob()
181   {
182    // Delete fillers.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines