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 |
< |
|
7 |
< |
#include "MitProd/TreeFiller/interface/FillerGlobalMuons.h" |
8 |
< |
#include "MitProd/TreeFiller/interface/FillMitTree.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/FillerTracks.h" |
11 |
> |
#include "MitProd/TreeFiller/interface/FillerGsfTracks.h" |
12 |
> |
#include "MitProd/TreeFiller/interface/FillerBasicClusters.h" |
13 |
> |
#include "MitProd/TreeFiller/interface/FillerSuperClusters.h" |
14 |
> |
#include "MitProd/TreeFiller/interface/FillerCaloTowers.h" |
15 |
> |
#include "MitProd/TreeFiller/interface/FillerMuons.h" |
16 |
> |
#include "MitProd/TreeFiller/interface/FillerElectrons.h" |
17 |
> |
#include "MitProd/TreeFiller/interface/FillerGenJets.h" |
18 |
> |
#include "MitProd/TreeFiller/interface/FillerCaloJets.h" |
19 |
> |
#include "MitProd/TreeFiller/interface/FillerCaloMet.h" |
20 |
> |
#include "MitProd/TreeFiller/interface/FillerConversions.h" |
21 |
> |
#include "MitProd/TreeFiller/interface/FillerConversionElectrons.h" |
22 |
> |
#include "MitProd/TreeFiller/interface/FillerPhotons.h" |
23 |
> |
#include "MitProd/TreeFiller/interface/FillerMCParticles.h" |
24 |
> |
#include "MitProd/TreeFiller/interface/FillerDecayParts.h" |
25 |
> |
#include "MitProd/TreeFiller/interface/FillerStableParts.h" |
26 |
> |
#include "MitProd/TreeFiller/interface/FillerPATMuons.h" |
27 |
> |
#include "MitProd/TreeFiller/interface/FillerPATElectrons.h" |
28 |
|
|
29 |
|
using namespace std; |
30 |
|
using namespace edm; |
31 |
|
using namespace mithep; |
32 |
|
|
33 |
< |
//------------------------------------------------------------------------------------------------- |
33 |
> |
mithep::ObjectService *mithep::FillMitTree::os_ = 0; |
34 |
> |
|
35 |
> |
//-------------------------------------------------------------------------------------------------- |
36 |
|
FillMitTree::FillMitTree(const edm::ParameterSet &cfg) : |
37 |
< |
fillerGlobalMuons_(0) |
37 |
> |
defactive_(cfg.getUntrackedParameter<bool>("defactive",1)) |
38 |
|
{ |
39 |
< |
// initialize fillers |
40 |
< |
fillerGlobalMuons_ = new FillerGlobalMuons(cfg); |
41 |
< |
if (fillerGlobalMuons_->Active()) |
42 |
< |
fillers_.push_back(fillerGlobalMuons_); |
39 |
> |
// Constructor. |
40 |
> |
|
41 |
> |
if (!configure(cfg)) { |
42 |
> |
throw edm::Exception(edm::errors::Configuration, "FillMitTree::FillMitTree()\n") |
43 |
> |
<< "Could not configure fillers." << "\n"; |
44 |
> |
} |
45 |
|
} |
46 |
|
|
47 |
< |
//------------------------------------------------------------------------------------------------- |
47 |
> |
//-------------------------------------------------------------------------------------------------- |
48 |
|
FillMitTree::~FillMitTree() |
49 |
|
{ |
50 |
< |
// We own the fillers so we have to delete them |
29 |
< |
delete fillerGlobalMuons_; |
50 |
> |
// Destructor: nothing to be done here. |
51 |
|
} |
52 |
|
|
53 |
< |
//------------------------------------------------------------------------------------------------- |
54 |
< |
void FillMitTree::beginJob(edm::EventSetup const &event) |
53 |
> |
//-------------------------------------------------------------------------------------------------- |
54 |
> |
bool FillMitTree::addActiveFiller(BaseFiller *bf) |
55 |
|
{ |
56 |
< |
Service<TreeService> ts; |
36 |
< |
TreeWriter *tws = ts->get(); |
37 |
< |
if (! tws) { |
38 |
< |
throw edm::Exception(edm::errors::Configuration, "FillMitTree::beginJob()\n") |
39 |
< |
<< "Could not get pointer to Tree with name " << tws->GetName() << "\n"; |
40 |
< |
return; |
41 |
< |
} |
56 |
> |
// Check if filler is active and add it to list of fillers. Otherwise delete it. |
57 |
|
|
58 |
< |
// Loop over the various components and book the branches |
59 |
< |
for (std::vector<BaseFiller*>::iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) { |
60 |
< |
(*iF)->BookDataBlock(tws); |
58 |
> |
if (bf->Active()) { |
59 |
> |
fillers_.push_back(bf); |
60 |
> |
return 1; |
61 |
|
} |
62 |
< |
return; |
62 |
> |
|
63 |
> |
delete bf; |
64 |
> |
bf = 0; |
65 |
> |
return 0; |
66 |
|
} |
67 |
|
|
68 |
< |
//------------------------------------------------------------------------------------------------- |
68 |
> |
//-------------------------------------------------------------------------------------------------- |
69 |
|
void FillMitTree::analyze(const edm::Event &event, |
70 |
|
const edm::EventSetup &setup) |
71 |
|
{ |
72 |
+ |
// Access and copy event content. |
73 |
+ |
|
74 |
|
// First step: Loop over the data fillers of the various components |
75 |
|
for (std::vector<BaseFiller*>::const_iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) { |
76 |
|
(*iF)->FillDataBlock(event,setup); |
82 |
|
} |
83 |
|
} |
84 |
|
|
85 |
< |
//------------------------------------------------------------------------------------------------- |
85 |
> |
//-------------------------------------------------------------------------------------------------- |
86 |
> |
void FillMitTree::beginJob(const edm::EventSetup &event) |
87 |
> |
{ |
88 |
> |
// Access the tree and book branches. |
89 |
> |
|
90 |
> |
Service<TreeService> ts; |
91 |
> |
TreeWriter *tws = ts->get(); |
92 |
> |
if (! tws) { |
93 |
> |
throw edm::Exception(edm::errors::Configuration, "FillMitTree::beginJob()\n") |
94 |
> |
<< "Could not get pointer to tree. " |
95 |
> |
<< "Do you have the TreeServie define in your config?" << "\n"; |
96 |
> |
return; |
97 |
> |
} |
98 |
> |
|
99 |
> |
if (os_==0) { |
100 |
> |
Service<ObjectService> os; |
101 |
> |
if (!os.isAvailable()) { |
102 |
> |
throw edm::Exception(edm::errors::Configuration, "FillMitTree::beginJob()\n") |
103 |
> |
<< "Could not get object service. " |
104 |
> |
<< "Do you have the ObjectService defined in your config?" << "\n"; |
105 |
> |
return; |
106 |
> |
} |
107 |
> |
os_ = &(*os); |
108 |
> |
} |
109 |
> |
|
110 |
> |
// Loop over the various components and book the branches |
111 |
> |
for (std::vector<BaseFiller*>::iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) { |
112 |
> |
edm::LogInfo("FillMitTree::beginJob") << "Booking for " << (*iF)->Name() << endl; |
113 |
> |
(*iF)->BookDataBlock(*tws); |
114 |
> |
} |
115 |
> |
} |
116 |
> |
|
117 |
> |
//-------------------------------------------------------------------------------------------------- |
118 |
> |
bool FillMitTree::configure(const edm::ParameterSet &cfg) |
119 |
> |
{ |
120 |
> |
// Configure our fillers. |
121 |
> |
|
122 |
> |
FillerMetaInfos *fillerMetaInfos = new FillerMetaInfos(cfg,defactive_); |
123 |
> |
addActiveFiller(fillerMetaInfos); |
124 |
> |
|
125 |
> |
FillerMCParticles *fillerMCParticles = new FillerMCParticles(cfg,"MCParticles",defactive_); |
126 |
> |
addActiveFiller(fillerMCParticles); |
127 |
> |
|
128 |
> |
FillerCaloTowers *fillerCaloTowers = |
129 |
> |
new FillerCaloTowers(cfg, "CaloTowers", defactive_); |
130 |
> |
addActiveFiller(fillerCaloTowers); |
131 |
> |
|
132 |
> |
FillerGenJets *fillerIC5GenJets = new FillerGenJets(cfg,"IC5GenJets",defactive_); |
133 |
> |
addActiveFiller(fillerIC5GenJets); |
134 |
> |
|
135 |
> |
FillerGenJets *fillerSC5GenJets = new FillerGenJets(cfg,"SC5GenJets",defactive_); |
136 |
> |
addActiveFiller(fillerSC5GenJets); |
137 |
> |
|
138 |
> |
FillerGenJets *fillerSC7GenJets = new FillerGenJets(cfg,"SC7GenJets",defactive_); |
139 |
> |
addActiveFiller(fillerSC7GenJets); |
140 |
> |
|
141 |
> |
FillerGenJets *fillerKT4GenJets = new FillerGenJets(cfg,"KT4GenJets",defactive_); |
142 |
> |
addActiveFiller(fillerKT4GenJets); |
143 |
> |
|
144 |
> |
FillerGenJets *fillerKT6GenJets = new FillerGenJets(cfg,"KT6GenJets",defactive_); |
145 |
> |
addActiveFiller(fillerKT6GenJets); |
146 |
> |
|
147 |
> |
FillerCaloJets *fillerCaloJets = new FillerCaloJets(cfg,"CaloJets",defactive_); |
148 |
> |
addActiveFiller(fillerCaloJets); |
149 |
> |
|
150 |
> |
FillerCaloJets *fillerItrCone5Jets = new FillerCaloJets(cfg,"ItrCone5Jets",defactive_); |
151 |
> |
addActiveFiller(fillerItrCone5Jets); |
152 |
> |
|
153 |
> |
FillerCaloJets *fillerSisCone5Jets = new FillerCaloJets(cfg,"SisCone5Jets",defactive_); |
154 |
> |
addActiveFiller(fillerSisCone5Jets); |
155 |
> |
|
156 |
> |
FillerCaloJets *fillerSisCone7Jets = new FillerCaloJets(cfg,"SisCone7Jets",defactive_); |
157 |
> |
addActiveFiller(fillerSisCone7Jets); |
158 |
> |
|
159 |
> |
FillerCaloJets *fillerKt4Jets = new FillerCaloJets(cfg,"Kt4Jets",defactive_); |
160 |
> |
addActiveFiller(fillerKt4Jets); |
161 |
> |
|
162 |
> |
FillerCaloJets *fillerKt6Jets = new FillerCaloJets(cfg,"Kt6Jets",defactive_); |
163 |
> |
addActiveFiller(fillerKt6Jets); |
164 |
> |
|
165 |
> |
FillerCaloMet *fillerCaloMet = new FillerCaloMet(cfg,"CaloMet",defactive_); |
166 |
> |
addActiveFiller(fillerCaloMet); |
167 |
> |
|
168 |
> |
FillerCaloMet *fillerItrCone5Met = new FillerCaloMet(cfg,"ItrCone5Met",defactive_); |
169 |
> |
addActiveFiller(fillerItrCone5Met); |
170 |
> |
|
171 |
> |
FillerCaloMet *fillerSisCone5Met = new FillerCaloMet(cfg,"SisCone5Met",defactive_); |
172 |
> |
addActiveFiller(fillerSisCone5Met); |
173 |
> |
|
174 |
> |
FillerCaloMet *fillerSisCone7Met = new FillerCaloMet(cfg,"SisCone7Met",defactive_); |
175 |
> |
addActiveFiller(fillerSisCone7Met); |
176 |
> |
|
177 |
> |
FillerCaloMet *fillerKt4Met = new FillerCaloMet(cfg,"Kt4Met",defactive_); |
178 |
> |
addActiveFiller(fillerKt4Met); |
179 |
> |
|
180 |
> |
FillerCaloMet *fillerKt6Met = new FillerCaloMet(cfg,"Kt6Met",defactive_); |
181 |
> |
addActiveFiller(fillerKt6Met); |
182 |
> |
|
183 |
> |
FillerTracks *fillerGeneralTracks = new FillerTracks(cfg,"GeneralTracks",defactive_); |
184 |
> |
addActiveFiller(fillerGeneralTracks); |
185 |
> |
|
186 |
> |
FillerTracks *fillerStandaloneMuonTracks = |
187 |
> |
new FillerTracks(cfg,"StandaloneMuonTracks",defactive_); |
188 |
> |
addActiveFiller(fillerStandaloneMuonTracks); |
189 |
> |
|
190 |
> |
FillerTracks *fillerStandaloneMuonTracksVtx = |
191 |
> |
new FillerTracks(cfg,"StandaloneMuonTracksWVtxConstraint",defactive_); |
192 |
> |
addActiveFiller(fillerStandaloneMuonTracksVtx); |
193 |
> |
|
194 |
> |
FillerTracks *fillerGlobalMuonTracks = new FillerTracks(cfg,"GlobalMuonTracks",defactive_); |
195 |
> |
addActiveFiller(fillerGlobalMuonTracks); |
196 |
> |
|
197 |
> |
FillerTracks *fillerConversionInOutTracks = |
198 |
> |
new FillerTracks(cfg,"ConversionInOutTracks",defactive_); |
199 |
> |
addActiveFiller(fillerConversionInOutTracks); |
200 |
> |
|
201 |
> |
FillerTracks *fillerConversionOutInTracks = |
202 |
> |
new FillerTracks(cfg,"ConversionOutInTracks",defactive_); |
203 |
> |
addActiveFiller(fillerConversionOutInTracks); |
204 |
> |
|
205 |
> |
FillerGsfTracks *fillerGsfTracks = new FillerGsfTracks(cfg,"GsfTracks",defactive_); |
206 |
> |
addActiveFiller(fillerGsfTracks); |
207 |
> |
|
208 |
> |
FillerBasicClusters *fillerBarrelBasicClusters = |
209 |
> |
new FillerBasicClusters(cfg, "BarrelBasicClusters", defactive_); |
210 |
> |
addActiveFiller(fillerBarrelBasicClusters); |
211 |
> |
|
212 |
> |
FillerSuperClusters *fillerBarrelSuperClusters = |
213 |
> |
new FillerSuperClusters(cfg,"BarrelSuperClusters", defactive_); |
214 |
> |
addActiveFiller(fillerBarrelSuperClusters); |
215 |
> |
|
216 |
> |
FillerBasicClusters *fillerEndcapBasicClusters = |
217 |
> |
new FillerBasicClusters(cfg,"EndcapBasicClusters", defactive_); |
218 |
> |
addActiveFiller(fillerEndcapBasicClusters); |
219 |
> |
|
220 |
> |
FillerSuperClusters *fillerEndcapSuperClusters = |
221 |
> |
new FillerSuperClusters(cfg,"EndcapSuperClusters", defactive_); |
222 |
> |
addActiveFiller(fillerEndcapSuperClusters); |
223 |
> |
|
224 |
> |
FillerMuons *fillerMuons = new FillerMuons(cfg,defactive_); |
225 |
> |
addActiveFiller(fillerMuons); |
226 |
> |
|
227 |
> |
FillerElectrons *fillerElectrons = new FillerElectrons(cfg,defactive_); |
228 |
> |
addActiveFiller(fillerElectrons); |
229 |
> |
|
230 |
> |
FillerConversionElectrons *fillerConversionElectrons = |
231 |
> |
new FillerConversionElectrons(cfg,defactive_); |
232 |
> |
addActiveFiller(fillerConversionElectrons); |
233 |
> |
|
234 |
> |
FillerConversions *fillerConversions = new FillerConversions(cfg,defactive_); |
235 |
> |
addActiveFiller(fillerConversions); |
236 |
> |
|
237 |
> |
FillerPhotons *fillerPhotons = new FillerPhotons(cfg,defactive_); |
238 |
> |
addActiveFiller(fillerPhotons); |
239 |
> |
|
240 |
> |
FillerStableParts *fillerStableParts = new FillerStableParts(cfg,"StableParts",defactive_); |
241 |
> |
addActiveFiller(fillerStableParts); |
242 |
> |
|
243 |
> |
FillerDecayParts *fillerDecayParts = new FillerDecayParts(cfg,"DecayParts",defactive_); |
244 |
> |
addActiveFiller(fillerDecayParts); |
245 |
> |
|
246 |
> |
return 1; |
247 |
> |
} |
248 |
> |
|
249 |
> |
//-------------------------------------------------------------------------------------------------- |
250 |
|
void FillMitTree::endJob() |
251 |
|
{ |
252 |
+ |
// Delete fillers. |
253 |
+ |
|
254 |
+ |
for (std::vector<BaseFiller*>::iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) { |
255 |
+ |
delete *iF; |
256 |
+ |
} |
257 |
+ |
|
258 |
|
edm::LogInfo("FillMitTree::endJob") << "Ending Job" << endl; |
259 |
|
} |