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