1 |
yilmaz |
1.1 |
#ifndef RecoHIJets_JetProducers_plugins_FullConeProducer_h
|
2 |
|
|
#define RecoHIJets_JetProducers_plugins_FullConeProducer_h
|
3 |
|
|
|
4 |
|
|
#include "MyVirtualJetProducer.h"
|
5 |
|
|
|
6 |
|
|
class FullConeProducer : public MyVirtualJetProducer
|
7 |
|
|
{
|
8 |
|
|
|
9 |
|
|
public:
|
10 |
|
|
//
|
11 |
|
|
// construction/destruction
|
12 |
|
|
//
|
13 |
|
|
explicit FullConeProducer(const edm::ParameterSet& iConfig);
|
14 |
|
|
virtual ~FullConeProducer();
|
15 |
|
|
|
16 |
|
|
protected:
|
17 |
|
|
|
18 |
|
|
//
|
19 |
|
|
// member functions
|
20 |
|
|
//
|
21 |
|
|
|
22 |
|
|
virtual void runAlgorithm( edm::Event& iEvent, const edm::EventSetup& iSetup );
|
23 |
|
|
virtual void output( edm::Event & iEvent, edm::EventSetup const& iSetup );
|
24 |
|
|
template< typename T >
|
25 |
|
|
void writeBkgJets( edm::Event & iEvent, edm::EventSetup const& iSetup );
|
26 |
|
|
|
27 |
|
|
private:
|
28 |
|
|
|
29 |
|
|
// trackjet clustering parameters
|
30 |
|
|
bool useOnlyVertexTracks_;
|
31 |
|
|
bool useOnlyOnePV_;
|
32 |
|
|
float dzTrVtxMax_;
|
33 |
|
|
|
34 |
|
|
int nFill_;
|
35 |
|
|
float etaMax_;
|
36 |
|
|
bool avoidNegative_;
|
37 |
|
|
|
38 |
|
|
const CaloGeometry *geo;
|
39 |
|
|
};
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
#endif
|
43 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
44 |
|
|
//
|
45 |
|
|
// FullConeProducer
|
46 |
|
|
// ------------------
|
47 |
|
|
//
|
48 |
|
|
// 04/21/2009 Philipp Schieferdecker <philipp.schieferdecker@cern.ch>
|
49 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
50 |
|
|
|
51 |
|
|
//#include "FullConeProducer.h"
|
52 |
|
|
|
53 |
|
|
#include "RecoJets/JetProducers/interface/JetSpecific.h"
|
54 |
|
|
|
55 |
|
|
#include "FWCore/Framework/interface/Event.h"
|
56 |
|
|
#include "FWCore/Framework/interface/EventSetup.h"
|
57 |
|
|
#include "FWCore/Framework/interface/ESHandle.h"
|
58 |
frankma |
1.2 |
#include "FWCore/Utilities/interface/Exception.h"
|
59 |
yilmaz |
1.1 |
#include "FWCore/MessageLogger/interface/MessageLogger.h"
|
60 |
|
|
#include "FWCore/Framework/interface/MakerMacros.h"
|
61 |
|
|
#include "FWCore/ServiceRegistry/interface/Service.h"
|
62 |
|
|
|
63 |
|
|
#include "DataFormats/Common/interface/Handle.h"
|
64 |
|
|
#include "DataFormats/VertexReco/interface/Vertex.h"
|
65 |
|
|
#include "DataFormats/VertexReco/interface/VertexFwd.h"
|
66 |
|
|
#include "DataFormats/JetReco/interface/CaloJetCollection.h"
|
67 |
|
|
#include "DataFormats/JetReco/interface/GenJetCollection.h"
|
68 |
|
|
#include "DataFormats/JetReco/interface/PFJetCollection.h"
|
69 |
|
|
#include "DataFormats/JetReco/interface/BasicJetCollection.h"
|
70 |
|
|
#include "DataFormats/Candidate/interface/CandidateFwd.h"
|
71 |
|
|
#include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
|
72 |
|
|
#include "DataFormats/Candidate/interface/LeafCandidate.h"
|
73 |
|
|
#include "DataFormats/Math/interface/deltaR.h"
|
74 |
|
|
|
75 |
|
|
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
|
76 |
|
|
#include "Geometry/Records/interface/CaloGeometryRecord.h"
|
77 |
|
|
|
78 |
|
|
#include "fastjet/SISConePlugin.hh"
|
79 |
|
|
#include "fastjet/CMSIterativeConePlugin.hh"
|
80 |
|
|
#include "fastjet/ATLASConePlugin.hh"
|
81 |
|
|
#include "fastjet/CDFMidPointPlugin.hh"
|
82 |
|
|
|
83 |
|
|
#include <iostream>
|
84 |
|
|
#include <memory>
|
85 |
|
|
#include <algorithm>
|
86 |
|
|
#include <limits>
|
87 |
|
|
#include <cmath>
|
88 |
|
|
|
89 |
|
|
using namespace std;
|
90 |
|
|
using namespace edm;
|
91 |
|
|
|
92 |
|
|
static const double pi = 3.14159265358979;
|
93 |
|
|
|
94 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
95 |
|
|
// construction / destruction
|
96 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
97 |
|
|
|
98 |
|
|
//______________________________________________________________________________
|
99 |
|
|
FullConeProducer::FullConeProducer(const edm::ParameterSet& iConfig)
|
100 |
|
|
: MyVirtualJetProducer( iConfig ),
|
101 |
|
|
nFill_(5),
|
102 |
|
|
etaMax_(3),
|
103 |
|
|
geo(0)
|
104 |
|
|
{
|
105 |
|
|
avoidNegative_ = iConfig.getParameter<bool>("avoidNegative");
|
106 |
|
|
|
107 |
|
|
if ( iConfig.exists("UseOnlyVertexTracks") )
|
108 |
|
|
useOnlyVertexTracks_ = iConfig.getParameter<bool>("UseOnlyVertexTracks");
|
109 |
|
|
else
|
110 |
|
|
useOnlyVertexTracks_ = false;
|
111 |
|
|
|
112 |
|
|
if ( iConfig.exists("UseOnlyOnePV") )
|
113 |
|
|
useOnlyOnePV_ = iConfig.getParameter<bool>("UseOnlyOnePV");
|
114 |
|
|
else
|
115 |
|
|
useOnlyOnePV_ = false;
|
116 |
|
|
|
117 |
|
|
if ( iConfig.exists("DrTrVtxMax") )
|
118 |
|
|
dzTrVtxMax_ = iConfig.getParameter<double>("DzTrVtxMax");
|
119 |
|
|
else
|
120 |
|
|
dzTrVtxMax_ = false;
|
121 |
|
|
|
122 |
|
|
produces<std::vector<bool> >("directions");
|
123 |
|
|
|
124 |
|
|
}
|
125 |
|
|
|
126 |
|
|
|
127 |
|
|
//______________________________________________________________________________
|
128 |
|
|
FullConeProducer::~FullConeProducer()
|
129 |
|
|
{
|
130 |
|
|
}
|
131 |
|
|
|
132 |
|
|
void FullConeProducer::output(edm::Event & iEvent, edm::EventSetup const& iSetup)
|
133 |
|
|
{
|
134 |
|
|
// Write jets and constitutents. Will use fjJets_, inputs_
|
135 |
|
|
// and fjClusterSeq_
|
136 |
|
|
switch( jetTypeE ) {
|
137 |
|
|
case JetType::CaloJet :
|
138 |
|
|
writeBkgJets<reco::CaloJet>( iEvent, iSetup);
|
139 |
|
|
break;
|
140 |
|
|
case JetType::PFJet :
|
141 |
|
|
writeBkgJets<reco::PFJet>( iEvent, iSetup);
|
142 |
|
|
break;
|
143 |
|
|
case JetType::GenJet :
|
144 |
|
|
writeBkgJets<reco::GenJet>( iEvent, iSetup);
|
145 |
|
|
break;
|
146 |
|
|
case JetType::TrackJet :
|
147 |
|
|
writeBkgJets<reco::TrackJet>( iEvent, iSetup);
|
148 |
|
|
break;
|
149 |
|
|
case JetType::BasicJet :
|
150 |
|
|
writeBkgJets<reco::BasicJet>( iEvent, iSetup);
|
151 |
|
|
break;
|
152 |
|
|
default:
|
153 |
|
|
edm::LogError("InvalidInput") << " invalid jet type in MyVirtualJetProducer\n";
|
154 |
|
|
break;
|
155 |
|
|
};
|
156 |
|
|
|
157 |
|
|
}
|
158 |
|
|
|
159 |
|
|
template< typename T >
|
160 |
|
|
void FullConeProducer::writeBkgJets( edm::Event & iEvent, edm::EventSetup const& iSetup )
|
161 |
|
|
{
|
162 |
|
|
// produce output jet collection
|
163 |
|
|
|
164 |
|
|
using namespace reco;
|
165 |
|
|
|
166 |
|
|
if(!geo){
|
167 |
|
|
edm::ESHandle<CaloGeometry> pGeo;
|
168 |
|
|
iSetup.get<CaloGeometryRecord>().get(pGeo);
|
169 |
|
|
geo = pGeo.product();
|
170 |
|
|
}
|
171 |
|
|
|
172 |
|
|
std::vector<fastjet::PseudoJet> fjFakeJets_;
|
173 |
|
|
std::vector<std::vector<reco::CandidatePtr> > constituents_;
|
174 |
|
|
vector<double> et;
|
175 |
|
|
vector<double> pileUp;
|
176 |
|
|
std::auto_ptr<std::vector<bool> > directions(new std::vector<bool>());
|
177 |
|
|
|
178 |
|
|
nFill_ = fjJets_.size();
|
179 |
|
|
directions->reserve(nFill_);
|
180 |
|
|
et.reserve(nFill_);
|
181 |
|
|
pileUp.reserve(nFill_);
|
182 |
|
|
|
183 |
|
|
fjFakeJets_.reserve(nFill_);
|
184 |
|
|
constituents_.reserve(nFill_);
|
185 |
|
|
|
186 |
|
|
constituents_.reserve(nFill_);
|
187 |
|
|
for(int ijet = 0; ijet < nFill_; ++ijet){
|
188 |
|
|
vector<reco::CandidatePtr> vec;
|
189 |
|
|
constituents_.push_back(vec);
|
190 |
|
|
directions->push_back(true);
|
191 |
|
|
}
|
192 |
|
|
|
193 |
|
|
for(int ijet = 0; ijet < nFill_; ++ijet){
|
194 |
|
|
et[ijet] = 0;
|
195 |
|
|
pileUp[ijet] = 0;
|
196 |
|
|
}
|
197 |
|
|
|
198 |
|
|
for (vector<fastjet::PseudoJet>::const_iterator input_object = fjInputs_.begin (),
|
199 |
|
|
fjInputsEnd = fjInputs_.end();
|
200 |
|
|
input_object != fjInputsEnd; ++input_object) {
|
201 |
|
|
|
202 |
|
|
const reco::CandidatePtr & tower=inputs_[input_object->user_index()];
|
203 |
|
|
const CaloTower* ctc = dynamic_cast<const CaloTower*>(tower.get());
|
204 |
|
|
int ieta = ctc->id().ieta();
|
205 |
|
|
int iphi = ctc->id().iphi();
|
206 |
|
|
CaloTowerDetId id(ieta,iphi);
|
207 |
|
|
const GlobalPoint& hitpoint = geo->getPosition(id);
|
208 |
|
|
double towEta = hitpoint.eta();
|
209 |
|
|
double towPhi = hitpoint.phi();
|
210 |
|
|
|
211 |
|
|
for (unsigned int ijet = 0; ijet < fjJets_.size(); ++ijet){
|
212 |
|
|
fastjet::PseudoJet & jet = fjJets_[ijet];
|
213 |
|
|
if(reco::deltaR(towEta,towPhi,jet.eta(),jet.phi()) > rParam_) continue;
|
214 |
|
|
constituents_[ijet].push_back(tower);
|
215 |
|
|
|
216 |
|
|
double towet = tower->et();
|
217 |
|
|
double putow = subtractor_->getPileUpAtTower(tower);
|
218 |
|
|
double etadd = towet - putow;
|
219 |
|
|
if(avoidNegative_ && etadd < 0.) etadd = 0;
|
220 |
|
|
et[ijet] += etadd;
|
221 |
|
|
pileUp[ijet] += towet - etadd;
|
222 |
|
|
}
|
223 |
|
|
}
|
224 |
|
|
|
225 |
|
|
cout<<"Start filling jets"<<endl;
|
226 |
|
|
|
227 |
|
|
for(int ir = 0; ir < nFill_; ++ir){
|
228 |
|
|
if(et[ir] < 0){
|
229 |
|
|
cout<<"Flipping vector"<<endl;
|
230 |
|
|
(*directions)[ir] = false;
|
231 |
|
|
et[ir] = -et[ir];
|
232 |
|
|
}else{
|
233 |
|
|
cout<<"Keep vector same"<<endl;
|
234 |
|
|
(*directions)[ir] = true;
|
235 |
|
|
}
|
236 |
|
|
cout<<"Lorentz"<<endl;
|
237 |
|
|
|
238 |
|
|
math::PtEtaPhiMLorentzVector p(et[ir],fjJets_[ir].eta(),fjJets_[ir].phi(),0);
|
239 |
|
|
fastjet::PseudoJet jet(p.px(),p.py(),p.pz(),p.energy());
|
240 |
|
|
fjFakeJets_.push_back(jet);
|
241 |
|
|
}
|
242 |
|
|
|
243 |
|
|
std::auto_ptr<std::vector<T> > jets(new std::vector<T>() );
|
244 |
|
|
jets->reserve(fjFakeJets_.size());
|
245 |
|
|
|
246 |
|
|
for (unsigned int ijet=0;ijet<fjFakeJets_.size();++ijet) {
|
247 |
|
|
// allocate this jet
|
248 |
|
|
T jet;
|
249 |
|
|
// get the fastjet jet
|
250 |
|
|
const fastjet::PseudoJet& fjJet = fjFakeJets_[ijet];
|
251 |
|
|
|
252 |
|
|
// convert them to CandidatePtr vector
|
253 |
|
|
std::vector<CandidatePtr> constituents =
|
254 |
|
|
constituents_[ijet];
|
255 |
|
|
|
256 |
|
|
writeSpecific(jet,
|
257 |
|
|
Particle::LorentzVector(fjJet.px(),
|
258 |
|
|
fjJet.py(),
|
259 |
|
|
fjJet.pz(),
|
260 |
|
|
fjJet.E()),
|
261 |
|
|
vertex_,
|
262 |
|
|
constituents, iSetup);
|
263 |
|
|
|
264 |
|
|
// calcuate the jet area
|
265 |
|
|
double jetArea=0.0;
|
266 |
|
|
jet.setJetArea (jetArea);
|
267 |
|
|
if(doPUOffsetCorr_){
|
268 |
|
|
jet.setPileup(pileUp[ijet]);
|
269 |
|
|
}else{
|
270 |
|
|
jet.setPileup (0.0);
|
271 |
|
|
}
|
272 |
|
|
|
273 |
|
|
// add to the list
|
274 |
|
|
jets->push_back(jet);
|
275 |
|
|
}
|
276 |
|
|
|
277 |
|
|
// put the jets in the collection
|
278 |
|
|
iEvent.put(jets);
|
279 |
|
|
iEvent.put(directions,"directions");
|
280 |
|
|
}
|
281 |
|
|
|
282 |
|
|
void FullConeProducer::runAlgorithm( edm::Event & iEvent, edm::EventSetup const& iSetup){
|
283 |
|
|
if ( !doAreaFastjet_ && !doRhoFastjet_) {
|
284 |
|
|
fjClusterSeq_ = ClusterSequencePtr( new fastjet::ClusterSequence( fjInputs_, *fjJetDefinition_ ) );
|
285 |
|
|
} else {
|
286 |
|
|
fjClusterSeq_ = ClusterSequencePtr( new fastjet::ClusterSequenceArea( fjInputs_, *fjJetDefinition_ , *fjActiveArea_ ) );
|
287 |
|
|
}
|
288 |
|
|
fjJets_ = fastjet::sorted_by_pt(fjClusterSeq_->inclusive_jets(jetPtMin_));
|
289 |
|
|
|
290 |
|
|
}
|
291 |
|
|
|
292 |
|
|
|
293 |
|
|
|
294 |
|
|
|
295 |
|
|
|
296 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
297 |
|
|
// define as cmssw plugin
|
298 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
299 |
|
|
|
300 |
|
|
DEFINE_FWK_MODULE(FullConeProducer);
|
301 |
|
|
|