1 |
yilmaz |
1.1 |
#ifndef RecoJets_JetProducers_plugins_JetAlgorithmAnalyzer_h
|
2 |
|
|
#define RecoJets_JetProducers_plugins_JetAlgorithmAnalyzer_h
|
3 |
|
|
|
4 |
yilmaz |
1.3 |
//#include "RecoJets/JetProducers/plugins/VirtualJetProducer.h"
|
5 |
|
|
#include "MyVirtualJetProducer.h"
|
6 |
yilmaz |
1.1 |
|
7 |
|
|
#include "FWCore/ServiceRegistry/interface/Service.h"
|
8 |
|
|
#include "CommonTools/UtilAlgos/interface/TFileService.h"
|
9 |
yilmaz |
1.3 |
#include "DataFormats/HeavyIonEvent/interface/Centrality.h"
|
10 |
yilmaz |
1.13 |
#include "DataFormats/HeavyIonEvent/interface/EvtPlane.h"
|
11 |
yilmaz |
1.1 |
#include "TNtuple.h"
|
12 |
yilmaz |
1.2 |
#include "TH2D.h"
|
13 |
|
|
#include <vector>
|
14 |
yilmaz |
1.13 |
#include <iostream>
|
15 |
|
|
using namespace std;
|
16 |
yilmaz |
1.2 |
|
17 |
|
|
static const int nSteps = 8;
|
18 |
|
|
static const double PI = 3.141592653589;
|
19 |
yilmaz |
1.1 |
|
20 |
yilmaz |
1.3 |
class JetAlgorithmAnalyzer : public MyVirtualJetProducer
|
21 |
yilmaz |
1.1 |
{
|
22 |
|
|
|
23 |
|
|
public:
|
24 |
|
|
//
|
25 |
|
|
// construction/destruction
|
26 |
|
|
//
|
27 |
|
|
explicit JetAlgorithmAnalyzer(const edm::ParameterSet& iConfig);
|
28 |
|
|
virtual ~JetAlgorithmAnalyzer();
|
29 |
|
|
|
30 |
|
|
protected:
|
31 |
|
|
|
32 |
|
|
//
|
33 |
|
|
// member functions
|
34 |
|
|
//
|
35 |
|
|
|
36 |
|
|
virtual void produce( edm::Event& iEvent, const edm::EventSetup& iSetup );
|
37 |
|
|
virtual void runAlgorithm( edm::Event& iEvent, const edm::EventSetup& iSetup );
|
38 |
|
|
virtual void output( edm::Event & iEvent, edm::EventSetup const& iSetup );
|
39 |
|
|
template< typename T >
|
40 |
|
|
void writeBkgJets( edm::Event & iEvent, edm::EventSetup const& iSetup );
|
41 |
|
|
|
42 |
yilmaz |
1.2 |
void fillNtuple(int output, const std::vector<fastjet::PseudoJet>& jets, int step);
|
43 |
yilmaz |
1.1 |
void fillTowerNtuple(const std::vector<fastjet::PseudoJet>& jets, int step);
|
44 |
|
|
void fillJetNtuple(const std::vector<fastjet::PseudoJet>& jets, int step);
|
45 |
|
|
void fillBkgNtuple(const PileUpSubtractor* subtractor, int step);
|
46 |
|
|
|
47 |
|
|
private:
|
48 |
|
|
|
49 |
|
|
// trackjet clustering parameters
|
50 |
|
|
bool useOnlyVertexTracks_;
|
51 |
|
|
bool useOnlyOnePV_;
|
52 |
yilmaz |
1.11 |
float dzTrVtxMax_;
|
53 |
|
|
|
54 |
yilmaz |
1.18 |
int evtPlaneIndex_;
|
55 |
yilmaz |
1.11 |
double phi0_;
|
56 |
|
|
int nFill_;
|
57 |
yilmaz |
1.1 |
float etaMax_;
|
58 |
|
|
int iev_;
|
59 |
yilmaz |
1.11 |
bool avoidNegative_;
|
60 |
|
|
|
61 |
yilmaz |
1.1 |
bool doAnalysis_;
|
62 |
|
|
|
63 |
yilmaz |
1.2 |
bool doMC_;
|
64 |
yilmaz |
1.13 |
bool doRecoEvtPlane_;
|
65 |
yilmaz |
1.12 |
bool doRandomCones_;
|
66 |
|
|
bool doFullCone_;
|
67 |
|
|
|
68 |
yilmaz |
1.14 |
bool sumRecHits_;
|
69 |
|
|
|
70 |
yilmaz |
1.12 |
double hf_;
|
71 |
|
|
double sumET_;
|
72 |
|
|
int bin_;
|
73 |
|
|
|
74 |
yilmaz |
1.3 |
int centBin_;
|
75 |
yilmaz |
1.11 |
edm::InputTag centTag_;
|
76 |
yilmaz |
1.13 |
edm::InputTag epTag_;
|
77 |
yilmaz |
1.3 |
const CentralityBins* cbins_;
|
78 |
|
|
|
79 |
yilmaz |
1.6 |
TNtuple* ntTowers;
|
80 |
|
|
TNtuple* ntJetTowers;
|
81 |
|
|
|
82 |
yilmaz |
1.2 |
TNtuple* ntTowersFromEvtPlane;
|
83 |
|
|
|
84 |
yilmaz |
1.1 |
TNtuple* ntJets;
|
85 |
|
|
TNtuple* ntPU;
|
86 |
|
|
TNtuple* ntRandom;
|
87 |
|
|
|
88 |
yilmaz |
1.2 |
std::vector<TH2D*> hTowers;
|
89 |
yilmaz |
1.6 |
std::vector<TH2D*> hJetTowers;
|
90 |
|
|
|
91 |
yilmaz |
1.2 |
std::vector<TH2D*> hTowersFromEvtPlane;
|
92 |
|
|
|
93 |
|
|
std::vector<TH2D*> hJets;
|
94 |
yilmaz |
1.3 |
std::vector<TH1D*> hPU;
|
95 |
|
|
std::vector<TH1D*> hMean;
|
96 |
|
|
std::vector<TH1D*> hSigma;
|
97 |
|
|
|
98 |
yilmaz |
1.2 |
std::vector<TH2D*> hRandom;
|
99 |
|
|
|
100 |
yilmaz |
1.3 |
|
101 |
yilmaz |
1.11 |
TH2D* hPTieta;
|
102 |
|
|
TH1D* hMeanieta;
|
103 |
|
|
TH1D* hRMSieta;
|
104 |
|
|
TH1D* hPUieta;
|
105 |
yilmaz |
1.3 |
|
106 |
yilmaz |
1.1 |
const CaloGeometry *geo;
|
107 |
|
|
edm::Service<TFileService> f;
|
108 |
|
|
};
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
#endif
|
112 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
113 |
|
|
//
|
114 |
|
|
// JetAlgorithmAnalyzer
|
115 |
|
|
// ------------------
|
116 |
|
|
//
|
117 |
|
|
// 04/21/2009 Philipp Schieferdecker <philipp.schieferdecker@cern.ch>
|
118 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
119 |
|
|
|
120 |
|
|
//#include "RecoJets/JetProducers/plugins/JetAlgorithmAnalyzer.h"
|
121 |
|
|
//#include "JetAlgorithmAnalyzer.h"
|
122 |
|
|
|
123 |
|
|
#include "RecoJets/JetProducers/interface/JetSpecific.h"
|
124 |
|
|
|
125 |
|
|
#include "FWCore/Framework/interface/Event.h"
|
126 |
|
|
#include "FWCore/Framework/interface/EventSetup.h"
|
127 |
|
|
#include "FWCore/Framework/interface/ESHandle.h"
|
128 |
|
|
#include "FWCore/Utilities/interface/CodedException.h"
|
129 |
|
|
#include "FWCore/MessageLogger/interface/MessageLogger.h"
|
130 |
|
|
#include "FWCore/Framework/interface/MakerMacros.h"
|
131 |
|
|
#include "FWCore/Utilities/interface/RandomNumberGenerator.h"
|
132 |
|
|
#include "FWCore/ServiceRegistry/interface/Service.h"
|
133 |
|
|
|
134 |
|
|
#include "DataFormats/Common/interface/Handle.h"
|
135 |
|
|
#include "DataFormats/VertexReco/interface/Vertex.h"
|
136 |
|
|
#include "DataFormats/VertexReco/interface/VertexFwd.h"
|
137 |
|
|
#include "DataFormats/JetReco/interface/CaloJetCollection.h"
|
138 |
|
|
#include "DataFormats/JetReco/interface/GenJetCollection.h"
|
139 |
|
|
#include "DataFormats/JetReco/interface/PFJetCollection.h"
|
140 |
|
|
#include "DataFormats/JetReco/interface/BasicJetCollection.h"
|
141 |
|
|
#include "DataFormats/Candidate/interface/CandidateFwd.h"
|
142 |
|
|
#include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
|
143 |
|
|
#include "DataFormats/Candidate/interface/LeafCandidate.h"
|
144 |
|
|
#include "DataFormats/Math/interface/deltaR.h"
|
145 |
|
|
|
146 |
yilmaz |
1.2 |
#include "SimDataFormats/HiGenData/interface/GenHIEvent.h"
|
147 |
|
|
|
148 |
yilmaz |
1.1 |
#include "DataFormats/CaloTowers/interface/CaloTower.h"
|
149 |
|
|
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
|
150 |
|
|
#include "Geometry/Records/interface/CaloGeometryRecord.h"
|
151 |
|
|
|
152 |
|
|
#include "fastjet/SISConePlugin.hh"
|
153 |
|
|
#include "fastjet/CMSIterativeConePlugin.hh"
|
154 |
|
|
#include "fastjet/ATLASConePlugin.hh"
|
155 |
|
|
#include "fastjet/CDFMidPointPlugin.hh"
|
156 |
|
|
|
157 |
|
|
#include "CLHEP/Random/RandomEngine.h"
|
158 |
|
|
|
159 |
|
|
#include <iostream>
|
160 |
|
|
#include <memory>
|
161 |
|
|
#include <algorithm>
|
162 |
|
|
#include <limits>
|
163 |
|
|
#include <cmath>
|
164 |
|
|
|
165 |
|
|
using namespace std;
|
166 |
|
|
using namespace edm;
|
167 |
|
|
|
168 |
|
|
static const double pi = 3.14159265358979;
|
169 |
|
|
|
170 |
|
|
CLHEP::HepRandomEngine* randomEngine;
|
171 |
|
|
|
172 |
|
|
|
173 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
174 |
|
|
// construction / destruction
|
175 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
176 |
|
|
|
177 |
|
|
//______________________________________________________________________________
|
178 |
|
|
JetAlgorithmAnalyzer::JetAlgorithmAnalyzer(const edm::ParameterSet& iConfig)
|
179 |
yilmaz |
1.3 |
: MyVirtualJetProducer( iConfig ),
|
180 |
yilmaz |
1.2 |
phi0_(0),
|
181 |
yilmaz |
1.1 |
nFill_(5),
|
182 |
|
|
etaMax_(3),
|
183 |
|
|
iev_(0),
|
184 |
yilmaz |
1.3 |
geo(0),
|
185 |
|
|
cbins_(0)
|
186 |
yilmaz |
1.1 |
{
|
187 |
yilmaz |
1.19 |
|
188 |
|
|
puSubtractorName_ = iConfig.getParameter<string> ("subtractorName");
|
189 |
|
|
subtractor_ = boost::shared_ptr<PileUpSubtractor>(PileUpSubtractorFactory::get()->create( puSubtractorName_, iConfig));
|
190 |
|
|
|
191 |
yilmaz |
1.1 |
edm::Service<RandomNumberGenerator> rng;
|
192 |
|
|
randomEngine = &(rng->getEngine());
|
193 |
|
|
|
194 |
|
|
doAnalysis_ = iConfig.getUntrackedParameter<bool>("doAnalysis",true);
|
195 |
yilmaz |
1.12 |
doRandomCones_ = iConfig.getUntrackedParameter<bool>("doRandomCones",true);
|
196 |
|
|
doFullCone_ = iConfig.getUntrackedParameter<bool>("doFullCone",true);
|
197 |
|
|
|
198 |
yilmaz |
1.2 |
doMC_ = iConfig.getUntrackedParameter<bool>("doMC",true);
|
199 |
yilmaz |
1.13 |
doRecoEvtPlane_ = iConfig.getUntrackedParameter<bool>("doRecoEvtPlane",true);
|
200 |
yilmaz |
1.18 |
evtPlaneIndex_ = iConfig.getUntrackedParameter<int>("evtPlaneIndex",31);
|
201 |
yilmaz |
1.13 |
|
202 |
yilmaz |
1.14 |
sumRecHits_ = iConfig.getParameter<bool>("sumRecHits");
|
203 |
|
|
|
204 |
yilmaz |
1.11 |
centTag_ = iConfig.getParameter<InputTag>("centralityTag");
|
205 |
yilmaz |
1.13 |
epTag_ = iConfig.getParameter<InputTag>("evtPlaneTag");
|
206 |
yilmaz |
1.3 |
|
207 |
|
|
if(doAnalysis_) centBin_ = iConfig.getUntrackedParameter<int>("centrality",0);
|
208 |
|
|
|
209 |
yilmaz |
1.1 |
avoidNegative_ = iConfig.getParameter<bool>("avoidNegative");
|
210 |
|
|
|
211 |
|
|
if ( iConfig.exists("UseOnlyVertexTracks") )
|
212 |
|
|
useOnlyVertexTracks_ = iConfig.getParameter<bool>("UseOnlyVertexTracks");
|
213 |
|
|
else
|
214 |
|
|
useOnlyVertexTracks_ = false;
|
215 |
|
|
|
216 |
|
|
if ( iConfig.exists("UseOnlyOnePV") )
|
217 |
|
|
useOnlyOnePV_ = iConfig.getParameter<bool>("UseOnlyOnePV");
|
218 |
|
|
else
|
219 |
|
|
useOnlyOnePV_ = false;
|
220 |
|
|
|
221 |
|
|
if ( iConfig.exists("DrTrVtxMax") )
|
222 |
|
|
dzTrVtxMax_ = iConfig.getParameter<double>("DzTrVtxMax");
|
223 |
|
|
else
|
224 |
|
|
dzTrVtxMax_ = false;
|
225 |
|
|
|
226 |
yilmaz |
1.3 |
produces<reco::CaloJetCollection>("randomCones");
|
227 |
yilmaz |
1.1 |
produces<std::vector<bool> >("directions");
|
228 |
|
|
|
229 |
|
|
if(doAnalysis_){
|
230 |
|
|
ntTowers = f->make<TNtuple>("ntTowers","Algorithm Analysis Towers","eta:phi:et:step:event");
|
231 |
yilmaz |
1.3 |
ntTowersFromEvtPlane = f->make<TNtuple>("ntTowersFromEvtPlane","Algorithm Analysis Towers","eta:phi:et:step:event");
|
232 |
yilmaz |
1.6 |
ntJetTowers = f->make<TNtuple>("ntTowers","Algorithm Analysis Towers","eta:phi:et:step:event");
|
233 |
yilmaz |
1.3 |
|
234 |
yilmaz |
1.1 |
ntJets = f->make<TNtuple>("ntJets","Algorithm Analysis Jets","eta:phi:et:step:event");
|
235 |
|
|
ntPU = f->make<TNtuple>("ntPU","Algorithm Analysis Background","eta:mean:sigma:step:event");
|
236 |
yilmaz |
1.17 |
ntRandom = f->make<TNtuple>("ntRandom","Algorithm Analysis Background","eta:phi:phiRel:et:had:em:pu:mean:rms:bin:hf:sumET:event");
|
237 |
yilmaz |
1.2 |
|
238 |
yilmaz |
1.5 |
ntuple = f->make<TNtuple>("nt","debug","ieta:eta:iphi:phi:pt:em:had");
|
239 |
|
|
|
240 |
yilmaz |
1.11 |
hPTieta = f->make<TH2D>("hPTieta","hPTieta",23,-11.5,11.5,200,0,10);
|
241 |
|
|
hRMSieta = f->make<TH1D>("hRMSieta","hPTieta",23,-11.5,11.5);
|
242 |
|
|
hMeanieta = f->make<TH1D>("hMeanieta","hPTieta",23,-11.5,11.5);
|
243 |
|
|
hPUieta = f->make<TH1D>("hPUieta","hPTieta",23,-11.5,11.5);
|
244 |
|
|
|
245 |
yilmaz |
1.2 |
for(int i = 0; i < nSteps; ++i){
|
246 |
yilmaz |
1.3 |
hTowers.push_back(f->make<TH2D>(Form("hTowers_step%d",i),"",200,-5.5,5.5,200,-0.02,6.3));
|
247 |
|
|
hJets.push_back(f->make<TH2D>(Form("hJets_step%d",i),"",200,-5.5,5.5,200,-0.02,6.3));
|
248 |
|
|
hTowersFromEvtPlane.push_back(f->make<TH2D>(Form("hTowersFromEvtPlane_step%d",i),"",200,-5.5,5.5,200,-0.02,6.3));
|
249 |
|
|
|
250 |
yilmaz |
1.6 |
hJetTowers.push_back(f->make<TH2D>(Form("hJetTowers_step%d",i),"",200,-5.5,5.5,200,-0.02,6.3));
|
251 |
|
|
|
252 |
yilmaz |
1.3 |
hPU.push_back(f->make<TH1D>(Form("hPU_step%d",i),"",200,-5.5,5.5));
|
253 |
|
|
hMean.push_back(f->make<TH1D>(Form("hMean_step%d",i),"",200,-5.5,5.5));
|
254 |
|
|
hSigma.push_back(f->make<TH1D>(Form("hSigma_step%d",i),"",200,-5.5,5.5));
|
255 |
|
|
|
256 |
yilmaz |
1.2 |
}
|
257 |
|
|
|
258 |
yilmaz |
1.1 |
}
|
259 |
|
|
|
260 |
|
|
}
|
261 |
|
|
|
262 |
|
|
|
263 |
|
|
//______________________________________________________________________________
|
264 |
|
|
JetAlgorithmAnalyzer::~JetAlgorithmAnalyzer()
|
265 |
|
|
{
|
266 |
|
|
}
|
267 |
|
|
|
268 |
yilmaz |
1.2 |
void JetAlgorithmAnalyzer::fillNtuple(int output, const std::vector<fastjet::PseudoJet>& jets, int step){
|
269 |
yilmaz |
1.1 |
if(!doAnalysis_) return;
|
270 |
|
|
|
271 |
|
|
TNtuple* nt;
|
272 |
yilmaz |
1.2 |
TH2D* h;
|
273 |
|
|
|
274 |
|
|
if(output == 1){
|
275 |
|
|
nt = ntJets;
|
276 |
|
|
h = hJets[step];
|
277 |
|
|
}
|
278 |
|
|
if(output == 0){
|
279 |
|
|
nt = ntTowers;
|
280 |
|
|
h = hTowers[step];
|
281 |
|
|
}
|
282 |
|
|
if(output == 2){
|
283 |
|
|
nt = ntTowersFromEvtPlane;
|
284 |
|
|
h = hTowersFromEvtPlane[step];
|
285 |
|
|
}
|
286 |
yilmaz |
1.6 |
if(output == 3){
|
287 |
|
|
nt = ntJetTowers;
|
288 |
|
|
h = hJetTowers[step];
|
289 |
|
|
}
|
290 |
yilmaz |
1.1 |
|
291 |
yilmaz |
1.4 |
double totet = 0;
|
292 |
|
|
int ntow = 0;
|
293 |
yilmaz |
1.5 |
int nj = jets.size();
|
294 |
|
|
|
295 |
|
|
cout<<"step : "<<step<<endl;
|
296 |
|
|
cout<<"Size of input : "<<nj<<endl;
|
297 |
|
|
|
298 |
yilmaz |
1.1 |
for(unsigned int i = 0; i < jets.size(); ++i){
|
299 |
yilmaz |
1.4 |
const fastjet::PseudoJet& jet = jets[i];
|
300 |
|
|
|
301 |
|
|
double pt = jet.perp();
|
302 |
yilmaz |
1.11 |
int ieta = -99;
|
303 |
yilmaz |
1.4 |
if(output != 1){
|
304 |
|
|
reco::CandidatePtr const & itow = inputs_[ jet.user_index() ];
|
305 |
|
|
pt = itow->et();
|
306 |
yilmaz |
1.11 |
ieta = subtractor_->ieta(itow);
|
307 |
|
|
}
|
308 |
|
|
|
309 |
|
|
if(output == 0 && step == 6){
|
310 |
|
|
hPTieta->Fill(ieta,pt);
|
311 |
yilmaz |
1.4 |
}
|
312 |
|
|
|
313 |
|
|
double phi = jet.phi();
|
314 |
|
|
if(output == 2){
|
315 |
|
|
phi = phi - phi0_;
|
316 |
|
|
if(phi < 0) phi += 2*PI;
|
317 |
|
|
if(phi > 2*PI) phi -= 2*PI;
|
318 |
|
|
}
|
319 |
|
|
|
320 |
yilmaz |
1.11 |
double eta = jet.eta();
|
321 |
yilmaz |
1.4 |
if(eta > 0 && eta < 0.08){
|
322 |
|
|
// if(fabs(eta) < 1.){
|
323 |
|
|
totet += pt;
|
324 |
|
|
ntow++;
|
325 |
|
|
}
|
326 |
|
|
|
327 |
|
|
nt->Fill(jet.eta(),phi,pt,step,iev_);
|
328 |
|
|
h->Fill(jet.eta(),phi,pt);
|
329 |
|
|
}
|
330 |
|
|
|
331 |
|
|
cout<<"-----------------------------"<<endl;
|
332 |
|
|
cout<<"STEP = "<<step<<endl;
|
333 |
|
|
cout<<"Total ET = "<<totet<<endl;
|
334 |
|
|
cout<<"Towers counted = "<<ntow<<endl;
|
335 |
|
|
cout<<"Average tower ET = "<<totet/ntow<<endl;
|
336 |
|
|
cout<<"-----------------------------"<<endl;
|
337 |
|
|
|
338 |
yilmaz |
1.1 |
}
|
339 |
|
|
|
340 |
|
|
|
341 |
|
|
void JetAlgorithmAnalyzer::fillTowerNtuple(const std::vector<fastjet::PseudoJet>& jets, int step){
|
342 |
|
|
fillNtuple(0,jets,step);
|
343 |
yilmaz |
1.2 |
fillNtuple(2,jets,step);
|
344 |
yilmaz |
1.1 |
}
|
345 |
|
|
|
346 |
|
|
void JetAlgorithmAnalyzer::fillJetNtuple(const std::vector<fastjet::PseudoJet>& jets, int step){
|
347 |
|
|
fillNtuple(1,jets,step);
|
348 |
yilmaz |
1.6 |
|
349 |
|
|
for(unsigned int i = 0; i < jets.size(); ++i){
|
350 |
|
|
const fastjet::PseudoJet& jet = jets[i];
|
351 |
|
|
std::vector<fastjet::PseudoJet> fjConstituents = sorted_by_pt(fjClusterSeq_->constituents(jet));
|
352 |
yilmaz |
1.8 |
|
353 |
|
|
|
354 |
|
|
|
355 |
yilmaz |
1.6 |
|
356 |
|
|
fillNtuple(3,fjConstituents,step);
|
357 |
|
|
}
|
358 |
yilmaz |
1.1 |
}
|
359 |
|
|
|
360 |
|
|
void JetAlgorithmAnalyzer::fillBkgNtuple(const PileUpSubtractor* subtractor, int step){
|
361 |
|
|
if(!doAnalysis_) return;
|
362 |
|
|
CaloTowerCollection col;
|
363 |
yilmaz |
1.3 |
for(int ieta = -29; ieta < 30; ++ieta){
|
364 |
|
|
if(ieta == 0) continue;
|
365 |
|
|
CaloTowerDetId id(ieta,1);
|
366 |
|
|
const GlobalPoint& hitpoint = geo->getPosition(id);
|
367 |
nart |
1.21 |
// cout<<"iETA "<<ieta<<endl;
|
368 |
yilmaz |
1.3 |
double eta = hitpoint.eta();
|
369 |
nart |
1.21 |
// cout<<"eta "<<eta<<endl;
|
370 |
yilmaz |
1.3 |
math::PtEtaPhiMLorentzVector p4(1,eta,1.,1.);
|
371 |
|
|
GlobalPoint pos(1,1,1);
|
372 |
|
|
CaloTower c(id,1.,1.,1.,1,1, p4, pos,pos);
|
373 |
|
|
col.push_back(c);
|
374 |
|
|
reco::CandidatePtr ptr(&col,col.size() - 1);
|
375 |
|
|
double mean = subtractor->getMeanAtTower(ptr);
|
376 |
|
|
double sigma = subtractor->getSigmaAtTower(ptr);
|
377 |
|
|
double pu = subtractor->getPileUpAtTower(ptr);
|
378 |
|
|
ntPU->Fill(eta,mean,sigma,step,iev_);
|
379 |
|
|
hPU[step]->Fill(eta,pu);
|
380 |
|
|
hMean[step]->Fill(eta,mean);
|
381 |
|
|
hSigma[step]->Fill(eta,sigma);
|
382 |
yilmaz |
1.11 |
|
383 |
|
|
if(step == 7){
|
384 |
|
|
hPUieta->Fill(ieta,pu);
|
385 |
|
|
hMeanieta->Fill(ieta,mean);
|
386 |
|
|
hRMSieta->Fill(ieta,sigma);
|
387 |
|
|
}
|
388 |
yilmaz |
1.1 |
}
|
389 |
|
|
}
|
390 |
|
|
|
391 |
|
|
void JetAlgorithmAnalyzer::produce(edm::Event& iEvent,const edm::EventSetup& iSetup)
|
392 |
|
|
{
|
393 |
yilmaz |
1.4 |
|
394 |
yilmaz |
1.6 |
// if(doAnalysis_) subtractor_->setDebug(1);
|
395 |
|
|
// else subtractor_->setDebug(0);
|
396 |
yilmaz |
1.13 |
phi0_ = 0;
|
397 |
yilmaz |
1.4 |
|
398 |
yilmaz |
1.1 |
if(!geo){
|
399 |
|
|
edm::ESHandle<CaloGeometry> pGeo;
|
400 |
|
|
iSetup.get<CaloGeometryRecord>().get(pGeo);
|
401 |
|
|
geo = pGeo.product();
|
402 |
|
|
}
|
403 |
|
|
|
404 |
yilmaz |
1.13 |
edm::Handle<reco::Centrality> cent;
|
405 |
|
|
iEvent.getByLabel(centTag_,cent);
|
406 |
|
|
if(!cbins_) cbins_ = getCentralityBinsFromDB(iSetup);
|
407 |
|
|
|
408 |
|
|
hf_ = cent->EtHFhitSum();
|
409 |
|
|
sumET_ = cent->EtMidRapiditySum();
|
410 |
|
|
bin_ = cbins_->getBin(hf_);
|
411 |
|
|
|
412 |
|
|
if(centBin_ >= 0 && bin_ != centBin_) return;
|
413 |
|
|
|
414 |
yilmaz |
1.1 |
LogDebug("VirtualJetProducer") << "Entered produce\n";
|
415 |
|
|
//determine signal vertex
|
416 |
|
|
vertex_=reco::Jet::Point(0,0,0);
|
417 |
|
|
if (makeCaloJet(jetTypeE)&&doPVCorrection_) {
|
418 |
|
|
LogDebug("VirtualJetProducer") << "Adding PV info\n";
|
419 |
|
|
edm::Handle<reco::VertexCollection> pvCollection;
|
420 |
|
|
iEvent.getByLabel(srcPVs_,pvCollection);
|
421 |
|
|
if (pvCollection->size()>0) vertex_=pvCollection->begin()->position();
|
422 |
|
|
}
|
423 |
|
|
|
424 |
|
|
// For Pileup subtraction using offset correction:
|
425 |
|
|
// set up geometry map
|
426 |
|
|
if ( doPUOffsetCorr_ ) {
|
427 |
yilmaz |
1.13 |
cout<<"setting up ... "<<endl;
|
428 |
yilmaz |
1.1 |
subtractor_->setupGeometryMap(iEvent, iSetup);
|
429 |
|
|
}
|
430 |
|
|
|
431 |
|
|
// clear data
|
432 |
|
|
LogDebug("VirtualJetProducer") << "Clear data\n";
|
433 |
|
|
fjInputs_.clear();
|
434 |
|
|
fjJets_.clear();
|
435 |
|
|
inputs_.clear();
|
436 |
yilmaz |
1.2 |
|
437 |
|
|
if(doAnalysis_ && doMC_){
|
438 |
|
|
Handle<GenHIEvent> hi;
|
439 |
|
|
iEvent.getByLabel("heavyIon",hi);
|
440 |
|
|
phi0_ = hi->evtPlane();
|
441 |
yilmaz |
1.3 |
|
442 |
|
|
double b = hi->b();
|
443 |
|
|
cout<<"===================================="<<endl;
|
444 |
|
|
cout<<"IMPACT PARAMETER OF THE EVENT : "<<b<<endl;
|
445 |
|
|
cout<<"===================================="<<endl;
|
446 |
yilmaz |
1.13 |
}
|
447 |
yilmaz |
1.3 |
|
448 |
yilmaz |
1.13 |
if(doRecoEvtPlane_){
|
449 |
|
|
Handle<reco::EvtPlaneCollection> planes;
|
450 |
|
|
iEvent.getByLabel(epTag_,planes);
|
451 |
yilmaz |
1.18 |
phi0_ = (*planes)[evtPlaneIndex_].angle();
|
452 |
yilmaz |
1.13 |
}
|
453 |
yilmaz |
1.3 |
|
454 |
yilmaz |
1.2 |
|
455 |
yilmaz |
1.1 |
// get inputs and convert them to the fastjet format (fastjet::PeudoJet)
|
456 |
|
|
edm::Handle<reco::CandidateView> inputsHandle;
|
457 |
|
|
iEvent.getByLabel(src_,inputsHandle);
|
458 |
|
|
for (size_t i = 0; i < inputsHandle->size(); ++i) {
|
459 |
|
|
inputs_.push_back(inputsHandle->ptrAt(i));
|
460 |
|
|
}
|
461 |
|
|
LogDebug("VirtualJetProducer") << "Got inputs\n";
|
462 |
|
|
|
463 |
|
|
// Convert candidates to fastjet::PseudoJets.
|
464 |
|
|
// Also correct to Primary Vertex. Will modify fjInputs_
|
465 |
|
|
// and use inputs_
|
466 |
|
|
fjInputs_.reserve(inputs_.size());
|
467 |
|
|
inputTowers();
|
468 |
|
|
LogDebug("VirtualJetProducer") << "Inputted towers\n";
|
469 |
|
|
|
470 |
|
|
fillTowerNtuple(fjInputs_,0);
|
471 |
|
|
fillBkgNtuple(subtractor_.get(),0);
|
472 |
|
|
|
473 |
|
|
// For Pileup subtraction using offset correction:
|
474 |
|
|
// Subtract pedestal.
|
475 |
yilmaz |
1.8 |
|
476 |
yilmaz |
1.1 |
if ( doPUOffsetCorr_ ) {
|
477 |
yilmaz |
1.8 |
subtractor_->reset(inputs_,fjInputs_,fjJets_);
|
478 |
yilmaz |
1.1 |
subtractor_->calculatePedestal(fjInputs_);
|
479 |
|
|
|
480 |
|
|
fillTowerNtuple(fjInputs_,1);
|
481 |
|
|
fillBkgNtuple(subtractor_.get(),1);
|
482 |
yilmaz |
1.8 |
subtractor_->subtractPedestal(fjInputs_);
|
483 |
yilmaz |
1.1 |
|
484 |
|
|
fillTowerNtuple(fjInputs_,2);
|
485 |
|
|
fillBkgNtuple(subtractor_.get(),2);
|
486 |
|
|
|
487 |
|
|
LogDebug("VirtualJetProducer") << "Subtracted pedestal\n";
|
488 |
|
|
}
|
489 |
|
|
|
490 |
|
|
// Run algorithm. Will modify fjJets_ and allocate fjClusterSeq_.
|
491 |
|
|
// This will use fjInputs_
|
492 |
|
|
runAlgorithm( iEvent, iSetup );
|
493 |
|
|
|
494 |
|
|
fillTowerNtuple(fjInputs_,3);
|
495 |
|
|
fillBkgNtuple(subtractor_.get(),3);
|
496 |
|
|
fillJetNtuple(fjJets_,3);
|
497 |
|
|
|
498 |
|
|
if ( doPUOffsetCorr_ ) {
|
499 |
|
|
subtractor_->setAlgorithm(fjClusterSeq_);
|
500 |
|
|
}
|
501 |
|
|
|
502 |
|
|
LogDebug("VirtualJetProducer") << "Ran algorithm\n";
|
503 |
|
|
|
504 |
|
|
// For Pileup subtraction using offset correction:
|
505 |
|
|
// Now we find jets and need to recalculate their energy,
|
506 |
|
|
// mark towers participated in jet,
|
507 |
|
|
// remove occupied towers from the list and recalculate mean and sigma
|
508 |
|
|
// put the initial towers collection to the jet,
|
509 |
|
|
// and subtract from initial towers in jet recalculated mean and sigma of towers
|
510 |
|
|
if ( doPUOffsetCorr_ ) {
|
511 |
|
|
vector<fastjet::PseudoJet> orphanInput;
|
512 |
|
|
subtractor_->calculateOrphanInput(orphanInput);
|
513 |
|
|
fillTowerNtuple(orphanInput,4);
|
514 |
|
|
fillBkgNtuple(subtractor_.get(),4);
|
515 |
|
|
fillJetNtuple(fjJets_,4);
|
516 |
|
|
|
517 |
yilmaz |
1.4 |
//only the id's of the orphan input are used, not their energy
|
518 |
yilmaz |
1.1 |
subtractor_->calculatePedestal(orphanInput);
|
519 |
|
|
fillTowerNtuple(orphanInput,5);
|
520 |
|
|
fillBkgNtuple(subtractor_.get(),5);
|
521 |
|
|
fillJetNtuple(fjJets_,5);
|
522 |
|
|
|
523 |
|
|
subtractor_->offsetCorrectJets();
|
524 |
|
|
fillTowerNtuple(orphanInput,6);
|
525 |
|
|
fillBkgNtuple(subtractor_.get(),6);
|
526 |
|
|
fillJetNtuple(fjJets_,6);
|
527 |
|
|
|
528 |
|
|
}
|
529 |
|
|
|
530 |
|
|
// Write the output jets.
|
531 |
|
|
// This will (by default) call the member function template
|
532 |
|
|
// "writeJets", but can be overridden.
|
533 |
|
|
// this will use inputs_
|
534 |
|
|
output( iEvent, iSetup );
|
535 |
|
|
fillBkgNtuple(subtractor_.get(),7);
|
536 |
|
|
fillJetNtuple(fjJets_,7);
|
537 |
|
|
|
538 |
|
|
LogDebug("VirtualJetProducer") << "Wrote jets\n";
|
539 |
|
|
|
540 |
|
|
++iev_;
|
541 |
yilmaz |
1.2 |
|
542 |
|
|
doAnalysis_ = false;
|
543 |
yilmaz |
1.1 |
return;
|
544 |
|
|
}
|
545 |
|
|
|
546 |
|
|
void JetAlgorithmAnalyzer::output(edm::Event & iEvent, edm::EventSetup const& iSetup)
|
547 |
|
|
{
|
548 |
|
|
// Write jets and constitutents. Will use fjJets_, inputs_
|
549 |
|
|
// and fjClusterSeq_
|
550 |
yilmaz |
1.13 |
|
551 |
nart |
1.21 |
// cout<<"output running "<<endl;
|
552 |
yilmaz |
1.13 |
|
553 |
yilmaz |
1.1 |
switch( jetTypeE ) {
|
554 |
|
|
case JetType::CaloJet :
|
555 |
yilmaz |
1.10 |
writeJets<reco::CaloJet>( iEvent, iSetup);
|
556 |
|
|
writeBkgJets<reco::CaloJet>( iEvent, iSetup);
|
557 |
yilmaz |
1.1 |
break;
|
558 |
|
|
case JetType::PFJet :
|
559 |
yilmaz |
1.3 |
writeJets<reco::PFJet>( iEvent, iSetup);
|
560 |
yilmaz |
1.1 |
writeBkgJets<reco::PFJet>( iEvent, iSetup);
|
561 |
|
|
break;
|
562 |
|
|
case JetType::GenJet :
|
563 |
yilmaz |
1.3 |
writeJets<reco::GenJet>( iEvent, iSetup);
|
564 |
yilmaz |
1.1 |
writeBkgJets<reco::GenJet>( iEvent, iSetup);
|
565 |
|
|
break;
|
566 |
|
|
case JetType::TrackJet :
|
567 |
yilmaz |
1.3 |
writeJets<reco::TrackJet>( iEvent, iSetup);
|
568 |
yilmaz |
1.1 |
writeBkgJets<reco::TrackJet>( iEvent, iSetup);
|
569 |
|
|
break;
|
570 |
|
|
case JetType::BasicJet :
|
571 |
yilmaz |
1.3 |
writeJets<reco::BasicJet>( iEvent, iSetup);
|
572 |
yilmaz |
1.1 |
writeBkgJets<reco::BasicJet>( iEvent, iSetup);
|
573 |
|
|
break;
|
574 |
|
|
default:
|
575 |
|
|
edm::LogError("InvalidInput") << " invalid jet type in VirtualJetProducer\n";
|
576 |
|
|
break;
|
577 |
|
|
};
|
578 |
|
|
|
579 |
|
|
}
|
580 |
|
|
|
581 |
|
|
template< typename T >
|
582 |
|
|
void JetAlgorithmAnalyzer::writeBkgJets( edm::Event & iEvent, edm::EventSetup const& iSetup )
|
583 |
|
|
{
|
584 |
|
|
// produce output jet collection
|
585 |
|
|
|
586 |
|
|
using namespace reco;
|
587 |
|
|
|
588 |
|
|
std::vector<fastjet::PseudoJet> fjFakeJets_;
|
589 |
|
|
std::vector<std::vector<reco::CandidatePtr> > constituents_;
|
590 |
|
|
vector<double> phiRandom;
|
591 |
|
|
vector<double> etaRandom;
|
592 |
|
|
vector<double> et;
|
593 |
yilmaz |
1.15 |
vector<double> had;
|
594 |
|
|
vector<double> em;
|
595 |
yilmaz |
1.1 |
vector<double> pileUp;
|
596 |
yilmaz |
1.12 |
vector<double> mean;
|
597 |
|
|
vector<double> rms;
|
598 |
|
|
|
599 |
yilmaz |
1.1 |
std::auto_ptr<std::vector<bool> > directions(new std::vector<bool>());
|
600 |
|
|
directions->reserve(nFill_);
|
601 |
|
|
|
602 |
|
|
phiRandom.reserve(nFill_);
|
603 |
|
|
etaRandom.reserve(nFill_);
|
604 |
|
|
et.reserve(nFill_);
|
605 |
|
|
pileUp.reserve(nFill_);
|
606 |
yilmaz |
1.12 |
rms.reserve(nFill_);
|
607 |
|
|
mean.reserve(nFill_);
|
608 |
yilmaz |
1.16 |
em.reserve(nFill_);
|
609 |
yilmaz |
1.15 |
had.reserve(nFill_);
|
610 |
yilmaz |
1.1 |
|
611 |
|
|
fjFakeJets_.reserve(nFill_);
|
612 |
|
|
constituents_.reserve(nFill_);
|
613 |
|
|
|
614 |
|
|
constituents_.reserve(nFill_);
|
615 |
|
|
for(int ijet = 0; ijet < nFill_; ++ijet){
|
616 |
|
|
vector<reco::CandidatePtr> vec;
|
617 |
|
|
constituents_.push_back(vec);
|
618 |
|
|
directions->push_back(true);
|
619 |
|
|
}
|
620 |
|
|
|
621 |
|
|
for(int ijet = 0; ijet < nFill_; ++ijet){
|
622 |
|
|
phiRandom[ijet] = 2*pi*randomEngine->flat() - pi;
|
623 |
|
|
etaRandom[ijet] = 2*etaMax_*randomEngine->flat() - etaMax_;
|
624 |
|
|
et[ijet] = 0;
|
625 |
yilmaz |
1.15 |
had[ijet] = 0;
|
626 |
|
|
em[ijet] = 0;
|
627 |
yilmaz |
1.1 |
pileUp[ijet] = 0;
|
628 |
nart |
1.21 |
mean[ijet]=0;
|
629 |
|
|
rms[ijet]=0;
|
630 |
yilmaz |
1.1 |
}
|
631 |
|
|
|
632 |
nart |
1.20 |
|
633 |
|
|
for(unsigned int iy = 0; iy < inputs_.size(); ++iy){
|
634 |
|
|
|
635 |
|
|
/*
|
636 |
yilmaz |
1.1 |
for (vector<fastjet::PseudoJet>::const_iterator input_object = fjInputs_.begin (),
|
637 |
|
|
fjInputsEnd = fjInputs_.end();
|
638 |
|
|
input_object != fjInputsEnd; ++input_object) {
|
639 |
nart |
1.20 |
*/
|
640 |
|
|
|
641 |
|
|
const reco::CandidatePtr & tower=inputs_[iy];
|
642 |
|
|
const CaloTower* ctc = dynamic_cast<const CaloTower*>(tower.get());
|
643 |
yilmaz |
1.1 |
|
644 |
yilmaz |
1.9 |
int ieta = ctc->id().ieta();
|
645 |
|
|
int iphi = ctc->id().iphi();
|
646 |
|
|
CaloTowerDetId id(ieta,iphi);
|
647 |
|
|
const GlobalPoint& hitpoint = geo->getPosition(id);
|
648 |
|
|
double towEta = hitpoint.eta();
|
649 |
|
|
double towPhi = hitpoint.phi();
|
650 |
|
|
|
651 |
yilmaz |
1.1 |
for(int ir = 0; ir < nFill_; ++ir){
|
652 |
yilmaz |
1.9 |
if(reco::deltaR(towEta,towPhi,etaRandom[ir],phiRandom[ir]) > rParam_) continue;
|
653 |
yilmaz |
1.1 |
|
654 |
|
|
constituents_[ir].push_back(tower);
|
655 |
|
|
|
656 |
yilmaz |
1.14 |
if(sumRecHits_){
|
657 |
|
|
const GlobalPoint& pos=geo->getPosition(ctc->id());
|
658 |
|
|
double energy = ctc->emEnergy() + ctc->hadEnergy();
|
659 |
yilmaz |
1.15 |
double ang = sin(pos.theta());
|
660 |
nart |
1.21 |
// towet = energy*ang;
|
661 |
yilmaz |
1.15 |
em[ir] += ctc->emEnergy()*ang;
|
662 |
|
|
had[ir] += ctc->hadEnergy()*ang;
|
663 |
yilmaz |
1.14 |
}
|
664 |
|
|
|
665 |
nart |
1.21 |
double towet = tower->et();
|
666 |
yilmaz |
1.1 |
double putow = subtractor_->getPileUpAtTower(tower);
|
667 |
|
|
double etadd = towet - putow;
|
668 |
|
|
if(avoidNegative_ && etadd < 0.) etadd = 0;
|
669 |
|
|
et[ir] += etadd;
|
670 |
|
|
pileUp[ir] += towet - etadd;
|
671 |
yilmaz |
1.12 |
mean[ir] += subtractor_->getMeanAtTower(tower);
|
672 |
|
|
rms[ir] += subtractor_->getSigmaAtTower(tower);
|
673 |
|
|
|
674 |
yilmaz |
1.1 |
}
|
675 |
|
|
}
|
676 |
|
|
cout<<"Start filling jets"<<endl;
|
677 |
|
|
|
678 |
|
|
for(int ir = 0; ir < nFill_; ++ir){
|
679 |
yilmaz |
1.13 |
double phiRel = reco::deltaPhi(phiRandom[ir],phi0_);
|
680 |
yilmaz |
1.15 |
ntRandom->Fill(etaRandom[ir],phiRandom[ir],phiRel,et[ir],had[ir],em[ir],pileUp[ir],mean[ir],rms[ir],bin_,hf_,sumET_,iev_);
|
681 |
yilmaz |
1.1 |
if(et[ir] < 0){
|
682 |
yilmaz |
1.3 |
// cout<<"Flipping vector"<<endl;
|
683 |
yilmaz |
1.1 |
(*directions)[ir] = false;
|
684 |
|
|
et[ir] = -et[ir];
|
685 |
|
|
}else{
|
686 |
yilmaz |
1.3 |
// cout<<"Keep vector same"<<endl;
|
687 |
yilmaz |
1.1 |
(*directions)[ir] = true;
|
688 |
|
|
}
|
689 |
nart |
1.21 |
// cout<<"Lorentz"<<endl;
|
690 |
yilmaz |
1.1 |
|
691 |
|
|
math::PtEtaPhiMLorentzVector p(et[ir],etaRandom[ir],phiRandom[ir],0);
|
692 |
|
|
fastjet::PseudoJet jet(p.px(),p.py(),p.pz(),p.energy());
|
693 |
|
|
fjFakeJets_.push_back(jet);
|
694 |
|
|
}
|
695 |
|
|
|
696 |
|
|
std::auto_ptr<std::vector<T> > jets(new std::vector<T>() );
|
697 |
|
|
jets->reserve(fjFakeJets_.size());
|
698 |
|
|
|
699 |
|
|
for (unsigned int ijet=0;ijet<fjFakeJets_.size();++ijet) {
|
700 |
|
|
// allocate this jet
|
701 |
|
|
T jet;
|
702 |
|
|
// get the fastjet jet
|
703 |
|
|
const fastjet::PseudoJet& fjJet = fjFakeJets_[ijet];
|
704 |
|
|
|
705 |
|
|
// convert them to CandidatePtr vector
|
706 |
|
|
std::vector<CandidatePtr> constituents =
|
707 |
|
|
constituents_[ijet];
|
708 |
|
|
|
709 |
|
|
writeSpecific(jet,
|
710 |
|
|
Particle::LorentzVector(fjJet.px(),
|
711 |
|
|
fjJet.py(),
|
712 |
|
|
fjJet.pz(),
|
713 |
|
|
fjJet.E()),
|
714 |
|
|
vertex_,
|
715 |
|
|
constituents, iSetup);
|
716 |
|
|
|
717 |
|
|
// calcuate the jet area
|
718 |
|
|
double jetArea=0.0;
|
719 |
|
|
jet.setJetArea (jetArea);
|
720 |
|
|
if(doPUOffsetCorr_){
|
721 |
|
|
jet.setPileup(pileUp[ijet]);
|
722 |
|
|
}else{
|
723 |
|
|
jet.setPileup (0.0);
|
724 |
|
|
}
|
725 |
|
|
|
726 |
|
|
// add to the list
|
727 |
|
|
jets->push_back(jet);
|
728 |
|
|
}
|
729 |
|
|
|
730 |
|
|
// put the jets in the collection
|
731 |
yilmaz |
1.3 |
iEvent.put(jets,"randomCones");
|
732 |
yilmaz |
1.1 |
iEvent.put(directions,"directions");
|
733 |
|
|
}
|
734 |
|
|
|
735 |
yilmaz |
1.8 |
//void JetAlgorithmAnalyzer::runAlgorithm( edm::Event & iEvent, edm::EventSetup const& iSetup, std::vector<fastjet::PseudoJet>& input )
|
736 |
yilmaz |
1.1 |
void JetAlgorithmAnalyzer::runAlgorithm( edm::Event & iEvent, edm::EventSetup const& iSetup)
|
737 |
|
|
{
|
738 |
yilmaz |
1.8 |
if ( !doAreaFastjet_ && !doRhoFastjet_) {
|
739 |
|
|
fjClusterSeq_ = ClusterSequencePtr( new fastjet::ClusterSequence( fjInputs_, *fjJetDefinition_ ) );
|
740 |
|
|
} else {
|
741 |
|
|
fjClusterSeq_ = ClusterSequencePtr( new fastjet::ClusterSequenceArea( fjInputs_, *fjJetDefinition_ , *fjActiveArea_ ) );
|
742 |
|
|
}
|
743 |
|
|
fjJets_ = fastjet::sorted_by_pt(fjClusterSeq_->inclusive_jets(jetPtMin_));
|
744 |
yilmaz |
1.1 |
|
745 |
|
|
}
|
746 |
|
|
|
747 |
|
|
|
748 |
|
|
|
749 |
|
|
|
750 |
|
|
|
751 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
752 |
|
|
// define as cmssw plugin
|
753 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
754 |
|
|
|
755 |
|
|
DEFINE_FWK_MODULE(JetAlgorithmAnalyzer);
|
756 |
|
|
|