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/TreeFiller/interface/AssociationMaps.h" |
8 |
> |
#include "MitProd/TreeFiller/interface/FillerMetaInfos.h" |
9 |
> |
#include "MitProd/TreeFiller/interface/FillerSimParticles.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/FillerConvElectrons.h" |
15 |
> |
//#include "MitProd/TreeFiller/interface/FillerPhotons.h" |
16 |
> |
#include "MitProd/TreeFiller/interface/FillerGenParts.h" |
17 |
|
|
18 |
|
using namespace std; |
19 |
|
using namespace edm; |
21 |
|
|
22 |
|
//------------------------------------------------------------------------------------------------- |
23 |
|
FillMitTree::FillMitTree(const edm::ParameterSet &cfg) : |
24 |
< |
fillerGlobalMuons_(0) |
24 |
> |
defactive_(cfg.getUntrackedParameter<bool>("defactive",1)) |
25 |
|
{ |
26 |
< |
// initialize fillers |
27 |
< |
fillerGlobalMuons_ = new FillerGlobalMuons(cfg); |
28 |
< |
if (fillerGlobalMuons_->Active()) |
29 |
< |
fillers_.push_back(fillerGlobalMuons_); |
26 |
> |
// Constructor. |
27 |
> |
|
28 |
> |
if (!configure(cfg)) { |
29 |
> |
throw edm::Exception(edm::errors::Configuration, "FillMitTree::FillMitTree()\n") |
30 |
> |
<< "Could not configure fillers." << "\n"; |
31 |
> |
} |
32 |
|
} |
33 |
|
|
34 |
|
//------------------------------------------------------------------------------------------------- |
35 |
|
FillMitTree::~FillMitTree() |
36 |
|
{ |
37 |
< |
// We own the fillers so we have to delete them |
38 |
< |
delete fillerGlobalMuons_; |
37 |
> |
// Destructor: nothing to be done here. |
38 |
> |
} |
39 |
> |
|
40 |
> |
//------------------------------------------------------------------------------------------------- |
41 |
> |
void FillMitTree::analyze(const edm::Event &event, |
42 |
> |
const edm::EventSetup &setup) |
43 |
> |
{ |
44 |
> |
// Access and copy event content. |
45 |
> |
|
46 |
> |
// First step: Loop over the data fillers of the various components |
47 |
> |
for (std::vector<BaseFiller*>::const_iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) { |
48 |
> |
(*iF)->FillDataBlock(event,setup); |
49 |
> |
} |
50 |
> |
|
51 |
> |
// Second step: Loop over the link resolution of the various components |
52 |
> |
for (std::vector<BaseFiller*>::const_iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) { |
53 |
> |
(*iF)->ResolveLinks(event,setup); |
54 |
> |
} |
55 |
|
} |
56 |
|
|
57 |
|
//------------------------------------------------------------------------------------------------- |
58 |
< |
void FillMitTree::beginJob(edm::EventSetup const &event) |
58 |
> |
void FillMitTree::beginJob(const edm::EventSetup &event) |
59 |
|
{ |
60 |
+ |
// Access the tree and book branches. |
61 |
+ |
|
62 |
|
Service<TreeService> ts; |
63 |
|
TreeWriter *tws = ts->get(); |
64 |
|
if (! tws) { |
65 |
|
throw edm::Exception(edm::errors::Configuration, "FillMitTree::beginJob()\n") |
66 |
< |
<< "Could not get pointer to Tree with name " << tws->GetName() << "\n"; |
66 |
> |
<< "Could not get pointer to tree." << "\n"; |
67 |
|
return; |
68 |
|
} |
69 |
< |
|
69 |
> |
|
70 |
|
// Loop over the various components and book the branches |
71 |
|
for (std::vector<BaseFiller*>::iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) { |
72 |
< |
(*iF)->BookDataBlock(tws); |
72 |
> |
(*iF)->BookDataBlock(*tws); |
73 |
|
} |
47 |
– |
return; |
74 |
|
} |
75 |
|
|
76 |
|
//------------------------------------------------------------------------------------------------- |
77 |
< |
void FillMitTree::analyze(const edm::Event &event, |
52 |
< |
const edm::EventSetup &setup) |
77 |
> |
bool FillMitTree::configure(const edm::ParameterSet &cfg) |
78 |
|
{ |
79 |
< |
// First step: Loop over the data fillers of the various components |
80 |
< |
for (std::vector<BaseFiller*>::const_iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) { |
81 |
< |
(*iF)->FillDataBlock(event,setup); |
79 |
> |
// Configure our fillers. |
80 |
> |
|
81 |
> |
FillerMetaInfos *fillerMetaInfos = new FillerMetaInfos(cfg); |
82 |
> |
if (fillerMetaInfos->Active()) |
83 |
> |
fillers_.push_back(fillerMetaInfos); |
84 |
> |
else |
85 |
> |
delete fillerMetaInfos; |
86 |
> |
|
87 |
> |
FillerGenParts *fillerGenParts = new FillerGenParts(cfg,defactive_); |
88 |
> |
if (fillerGenParts->Active()) |
89 |
> |
fillers_.push_back(fillerGenParts); |
90 |
> |
else |
91 |
> |
delete fillerGenParts; |
92 |
> |
|
93 |
> |
FillerSimParticles *fillerSimParticles = new FillerSimParticles(cfg,defactive_); |
94 |
> |
const SimParticleMap* simParticleMap=0; |
95 |
> |
if (fillerSimParticles->Active()) { |
96 |
> |
fillers_.push_back(fillerSimParticles); |
97 |
> |
simParticleMap = fillerSimParticles->GetSimParticleMap(); |
98 |
|
} |
99 |
+ |
else |
100 |
+ |
delete fillerSimParticles; |
101 |
+ |
|
102 |
+ |
FillerTracks *fillerGeneralTracks = new FillerTracks(cfg,"GeneralTracks",defactive_,simParticleMap); |
103 |
+ |
const TrackMap* generalTrackMap=0; |
104 |
+ |
if (fillerGeneralTracks->Active()) { |
105 |
+ |
fillers_.push_back(fillerGeneralTracks); |
106 |
+ |
generalTrackMap = fillerGeneralTracks->GetTrackMap(); |
107 |
+ |
} |
108 |
+ |
else |
109 |
+ |
delete fillerGeneralTracks; |
110 |
+ |
|
111 |
+ |
FillerTracks *fillerStandaloneMuonTracks = new FillerTracks(cfg,"StandaloneMuonTracks",defactive_); |
112 |
+ |
const TrackMap* standaloneMuonTrackMap=0; |
113 |
+ |
if (fillerStandaloneMuonTracks->Active()) { |
114 |
+ |
fillers_.push_back(fillerStandaloneMuonTracks); |
115 |
+ |
standaloneMuonTrackMap = fillerStandaloneMuonTracks->GetTrackMap(); |
116 |
+ |
} |
117 |
+ |
else |
118 |
+ |
delete fillerStandaloneMuonTracks; |
119 |
|
|
120 |
< |
// Second step: Loop over the link resolution of the various components |
121 |
< |
for (std::vector<BaseFiller*>::const_iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) { |
122 |
< |
(*iF)->ResolveLinks(event,setup); |
120 |
> |
FillerTracks *fillerStandaloneMuonTracksVtx = |
121 |
> |
new FillerTracks(cfg,"StandaloneMuonTracksWVtxConstraint",defactive_); |
122 |
> |
const TrackMap* standaloneMuonTrackVtxMap=0; |
123 |
> |
if (fillerStandaloneMuonTracksVtx->Active()) { |
124 |
> |
fillers_.push_back(fillerStandaloneMuonTracksVtx); |
125 |
> |
standaloneMuonTrackVtxMap = fillerStandaloneMuonTracksVtx->GetTrackMap(); |
126 |
|
} |
127 |
+ |
else |
128 |
+ |
delete fillerStandaloneMuonTracksVtx; |
129 |
+ |
|
130 |
+ |
FillerTracks *fillerGlobalMuonTracks = new FillerTracks(cfg,"GlobalMuonTracks",defactive_); |
131 |
+ |
const TrackMap* globalMuonTrackMap=0; |
132 |
+ |
if (fillerGlobalMuonTracks->Active()) { |
133 |
+ |
fillers_.push_back(fillerGlobalMuonTracks); |
134 |
+ |
globalMuonTrackMap = fillerGlobalMuonTracks->GetTrackMap(); |
135 |
+ |
} |
136 |
+ |
else |
137 |
+ |
delete fillerGlobalMuonTracks; |
138 |
+ |
|
139 |
+ |
FillerTracks *fillerConversionInOutTracks = |
140 |
+ |
new FillerTracks(cfg,"ConversionInOutTracks",defactive_,simParticleMap); |
141 |
+ |
const TrackMap* conversionInOutTrackMap=0; |
142 |
+ |
const TrackCol* conversionInOutTracks=0; |
143 |
+ |
if (fillerConversionInOutTracks->Active()) { |
144 |
+ |
fillers_.push_back(fillerConversionInOutTracks); |
145 |
+ |
conversionInOutTrackMap = fillerConversionInOutTracks->GetTrackMap(); |
146 |
+ |
conversionInOutTracks = fillerConversionInOutTracks->GetTrackCol(); |
147 |
+ |
} |
148 |
+ |
else |
149 |
+ |
delete fillerConversionInOutTracks; |
150 |
+ |
|
151 |
+ |
FillerTracks *fillerConversionOutInTracks = |
152 |
+ |
new FillerTracks(cfg,"ConversionOutInTracks",defactive_,simParticleMap); |
153 |
+ |
const TrackMap* conversionOutInTrackMap=0; |
154 |
+ |
const TrackCol* conversionOutInTracks=0; |
155 |
+ |
if (fillerConversionOutInTracks->Active()) { |
156 |
+ |
fillers_.push_back(fillerConversionOutInTracks); |
157 |
+ |
conversionOutInTrackMap = fillerConversionOutInTracks->GetTrackMap(); |
158 |
+ |
conversionOutInTracks = fillerConversionOutInTracks->GetTrackCol(); |
159 |
+ |
} |
160 |
+ |
else |
161 |
+ |
delete fillerConversionOutInTracks; |
162 |
+ |
|
163 |
+ |
FillerGsfTracks *fillerGsfTracks = new FillerGsfTracks(cfg,"GsfTracks",defactive_,simParticleMap); |
164 |
+ |
const GsfTrackMap* gsfTrackMap=0; |
165 |
+ |
if (fillerGsfTracks->Active()) { |
166 |
+ |
fillers_.push_back(fillerGsfTracks); |
167 |
+ |
gsfTrackMap = (GsfTrackMap*)fillerGsfTracks->GetTrackMap(); |
168 |
+ |
} |
169 |
+ |
else |
170 |
+ |
delete fillerGsfTracks; |
171 |
+ |
|
172 |
+ |
FillerMuons *fillerMuons = |
173 |
+ |
new FillerMuons(cfg,defactive_,globalMuonTrackMap,standaloneMuonTrackMap, |
174 |
+ |
standaloneMuonTrackVtxMap,generalTrackMap); |
175 |
+ |
if (fillerMuons->Active()) |
176 |
+ |
fillers_.push_back(fillerMuons); |
177 |
+ |
else |
178 |
+ |
delete fillerMuons; |
179 |
+ |
|
180 |
+ |
FillerElectrons *fillerElectrons = new FillerElectrons(cfg,defactive_,gsfTrackMap,generalTrackMap); |
181 |
+ |
if (fillerElectrons->Active()) |
182 |
+ |
fillers_.push_back(fillerElectrons); |
183 |
+ |
else |
184 |
+ |
delete fillerElectrons; |
185 |
+ |
|
186 |
+ |
#if 0 |
187 |
+ |
FillerConversionElectrons *fillerConversionElectrons = |
188 |
+ |
new FillerConversionElectrons(cfg,defactive_,conversionInOutTracks,conversionOutInTracks, |
189 |
+ |
conversionInOutTrackMap,conversionOutInTrackMap); |
190 |
+ |
|
191 |
+ |
const ConversionElectronMap* convElectronMap=0; |
192 |
+ |
if (fillerConversionElectrons->Active()) { |
193 |
+ |
fillers_.push_back(fillerConversionElectrons); |
194 |
+ |
convElectronMap = fillerConversionElectrons->GetConversionElectronMap(); |
195 |
+ |
} |
196 |
+ |
else |
197 |
+ |
delete fillerConversionElectrons; |
198 |
+ |
|
199 |
+ |
FillerPhotons *fillerPhotons = new FillerPhotons(cfg,defactive_,convElectronMap); |
200 |
+ |
if (fillerPhotons->Active()) |
201 |
+ |
fillers_.push_back(fillerPhotons); |
202 |
+ |
else |
203 |
+ |
delete fillerPhotons; |
204 |
+ |
#endif |
205 |
+ |
|
206 |
+ |
return 1; |
207 |
|
} |
208 |
|
|
209 |
|
//------------------------------------------------------------------------------------------------- |
210 |
|
void FillMitTree::endJob() |
211 |
|
{ |
212 |
+ |
// Delete fillers. |
213 |
+ |
|
214 |
+ |
for (std::vector<BaseFiller*>::iterator iF = fillers_.begin(); iF != fillers_.end(); ++iF) { |
215 |
+ |
delete *iF; |
216 |
+ |
} |
217 |
+ |
|
218 |
|
edm::LogInfo("FillMitTree::endJob") << "Ending Job" << endl; |
219 |
|
} |