1 |
yilmaz |
1.1 |
#ifndef RecoJets_JetProducers_plugins_MyVirtualJetProducer_h
|
2 |
|
|
#define RecoJets_JetProducers_plugins_MyVirtualJetProducer_h
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
#include "FWCore/Framework/interface/EDProducer.h"
|
6 |
|
|
#include "FWCore/ParameterSet/interface/ParameterSet.h"
|
7 |
|
|
#include "DataFormats/Candidate/interface/Candidate.h"
|
8 |
|
|
#include "DataFormats/Candidate/interface/CandidateFwd.h"
|
9 |
|
|
#include "DataFormats/JetReco/interface/Jet.h"
|
10 |
|
|
#include "DataFormats/JetReco/interface/CaloJet.h"
|
11 |
|
|
#include "DataFormats/JetReco/interface/PFJet.h"
|
12 |
|
|
#include "DataFormats/JetReco/interface/BasicJet.h"
|
13 |
|
|
#include "DataFormats/JetReco/interface/GenJet.h"
|
14 |
|
|
|
15 |
|
|
#include "RecoJets/JetProducers/interface/PileUpSubtractor.h"
|
16 |
|
|
|
17 |
|
|
#include "fastjet/JetDefinition.hh"
|
18 |
|
|
#include "fastjet/ClusterSequence.hh"
|
19 |
|
|
#include "fastjet/ClusterSequenceArea.hh"
|
20 |
|
|
#include "fastjet/PseudoJet.hh"
|
21 |
|
|
#include "fastjet/ActiveAreaSpec.hh"
|
22 |
|
|
|
23 |
|
|
#include <vector>
|
24 |
|
|
#include <boost/shared_ptr.hpp>
|
25 |
|
|
|
26 |
yilmaz |
1.2 |
#include "TNtuple.h"
|
27 |
yilmaz |
1.1 |
|
28 |
|
|
class MyVirtualJetProducer : public edm::EDProducer
|
29 |
|
|
{
|
30 |
|
|
protected:
|
31 |
|
|
//
|
32 |
|
|
// typedefs & structs
|
33 |
|
|
//
|
34 |
|
|
struct JetType {
|
35 |
|
|
enum Type {
|
36 |
|
|
BasicJet,
|
37 |
|
|
GenJet,
|
38 |
|
|
CaloJet,
|
39 |
|
|
PFJet,
|
40 |
|
|
TrackJet,
|
41 |
|
|
LastJetType // no real type, technical
|
42 |
|
|
};
|
43 |
|
|
static const char *names[];
|
44 |
|
|
static Type byName(const std::string &name);
|
45 |
|
|
};
|
46 |
|
|
|
47 |
|
|
JetType::Type jetTypeE;
|
48 |
|
|
|
49 |
|
|
inline bool makeCaloJet(const JetType::Type &fTag) {
|
50 |
|
|
return fTag == JetType::CaloJet;
|
51 |
|
|
}
|
52 |
|
|
inline bool makePFJet(const JetType::Type &fTag) {
|
53 |
|
|
return fTag == JetType::PFJet;
|
54 |
|
|
}
|
55 |
|
|
inline bool makeGenJet(const JetType::Type &fTag) {
|
56 |
|
|
return fTag == JetType::GenJet;
|
57 |
|
|
}
|
58 |
|
|
inline bool makeTrackJet(const JetType::Type &fTag) {
|
59 |
|
|
return fTag == JetType::TrackJet;
|
60 |
|
|
}
|
61 |
|
|
inline bool makeBasicJet(const JetType::Type &fTag) {
|
62 |
|
|
return fTag == JetType::BasicJet;
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
//
|
67 |
|
|
// construction/destruction
|
68 |
|
|
//
|
69 |
|
|
public:
|
70 |
|
|
explicit MyVirtualJetProducer(const edm::ParameterSet& iConfig);
|
71 |
|
|
virtual ~MyVirtualJetProducer();
|
72 |
|
|
|
73 |
|
|
// typedefs
|
74 |
|
|
typedef boost::shared_ptr<fastjet::ClusterSequence> ClusterSequencePtr;
|
75 |
|
|
typedef boost::shared_ptr<fastjet::JetDefinition::Plugin> PluginPtr;
|
76 |
|
|
typedef boost::shared_ptr<fastjet::JetDefinition> JetDefPtr;
|
77 |
|
|
typedef boost::shared_ptr<fastjet::ActiveAreaSpec> ActiveAreaSpecPtr;
|
78 |
|
|
typedef boost::shared_ptr<fastjet::RangeDefinition> RangeDefPtr;
|
79 |
yilmaz |
1.2 |
|
80 |
|
|
TNtuple* ntuple;
|
81 |
yilmaz |
1.1 |
|
82 |
|
|
//
|
83 |
|
|
// member functions
|
84 |
|
|
//
|
85 |
|
|
public:
|
86 |
|
|
virtual void produce(edm::Event& iEvent, const edm::EventSetup& iSetup);
|
87 |
|
|
std::string jetType() const { return jetType_; }
|
88 |
|
|
|
89 |
|
|
protected:
|
90 |
|
|
|
91 |
|
|
//
|
92 |
|
|
// Internal methods for jet production.
|
93 |
|
|
// The user can either use the defaults, or override all of these methods.
|
94 |
|
|
//
|
95 |
|
|
|
96 |
|
|
// This method creates the "produces" statement in the constructor.
|
97 |
|
|
// The default is to produce a single jet collection as per the user's request
|
98 |
|
|
// (Calo,PF,Basic, or Gen).
|
99 |
|
|
virtual void makeProduces( std::string s, std::string tag = "" );
|
100 |
|
|
|
101 |
|
|
// This method inputs the constituents from "inputs" and modifies
|
102 |
|
|
// fjInputs.
|
103 |
|
|
virtual void inputTowers();
|
104 |
|
|
|
105 |
|
|
// This checks if the tower is anomalous (if a calo tower).
|
106 |
|
|
virtual bool isAnomalousTower(reco::CandidatePtr input);
|
107 |
|
|
|
108 |
|
|
// This will copy the fastjet constituents to the jet itself.
|
109 |
|
|
virtual void copyConstituents(const std::vector<fastjet::PseudoJet>&fjConstituents,
|
110 |
|
|
reco::Jet* jet);
|
111 |
|
|
|
112 |
|
|
// This will run the actual algorithm. This method is pure virtual and
|
113 |
|
|
// has no default.
|
114 |
|
|
virtual void runAlgorithm( edm::Event& iEvent, const edm::EventSetup& iSetup) = 0;
|
115 |
|
|
|
116 |
|
|
// Do the offset correction.
|
117 |
|
|
// Only runs if "doPUOffsetCorrection_" is true.
|
118 |
|
|
void offsetCorrectJets(std::vector<fastjet::PseudoJet> & orphanInput);
|
119 |
|
|
|
120 |
|
|
// This will write the jets to the event.
|
121 |
|
|
// The default is to write out the single jet collection in the default "produces"
|
122 |
|
|
// statement.
|
123 |
|
|
// This is a function template that can be called for the five types
|
124 |
|
|
// CaloJet, PFJet, GenJet, TrackJet, BasicJet. This is not suitable
|
125 |
|
|
// for compound jets.
|
126 |
|
|
// Note: The "output" method is virtual and can be overriden.
|
127 |
|
|
// The default behavior is to call the function template "writeJets".
|
128 |
|
|
virtual void output( edm::Event & iEvent, edm::EventSetup const& iSetup );
|
129 |
|
|
template< typename T >
|
130 |
|
|
void writeJets( edm::Event & iEvent, edm::EventSetup const& iSetup );
|
131 |
|
|
|
132 |
|
|
// This method copies the constituents from the fjConstituents method
|
133 |
|
|
// to an output of CandidatePtr's.
|
134 |
|
|
virtual std::vector<reco::CandidatePtr>
|
135 |
|
|
getConstituents(const std::vector<fastjet::PseudoJet>&fjConstituents);
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
//
|
140 |
|
|
// member data
|
141 |
|
|
//
|
142 |
|
|
protected:
|
143 |
|
|
std::string moduleLabel_; // label for this module
|
144 |
|
|
edm::InputTag src_; // input constituent source
|
145 |
|
|
edm::InputTag srcPVs_; // primary vertex source
|
146 |
|
|
std::string jetType_; // type of jet (Calo,PF,Basic,Gen)
|
147 |
|
|
std::string jetAlgorithm_; // the jet algorithm to use
|
148 |
|
|
double rParam_; // the R parameter to use
|
149 |
|
|
double inputEtMin_; // minimum et of input constituents
|
150 |
|
|
double inputEMin_; // minimum e of input constituents
|
151 |
|
|
double jetPtMin_; // minimum jet pt
|
152 |
|
|
bool doPVCorrection_; // correct to primary vertex?
|
153 |
|
|
|
154 |
|
|
// for restricting inputs due to processing time
|
155 |
|
|
bool restrictInputs_; // restrict inputs to first "maxInputs" inputs.
|
156 |
|
|
unsigned int maxInputs_; // maximum number of inputs.
|
157 |
|
|
|
158 |
|
|
// for fastjet jet area calculation
|
159 |
|
|
bool doAreaFastjet_; // calculate area w/ fastjet?
|
160 |
|
|
// for fastjet rho calculation
|
161 |
|
|
bool doRhoFastjet_; // calculate rho w/ fastjet?
|
162 |
|
|
|
163 |
|
|
// for pileup offset correction
|
164 |
|
|
bool doPUOffsetCorr_; // add the pileup calculation from offset correction?
|
165 |
|
|
|
166 |
|
|
// anomalous cell cuts
|
167 |
|
|
unsigned int maxBadEcalCells_; // maximum number of bad ECAL cells
|
168 |
|
|
unsigned int maxRecoveredEcalCells_; // maximum number of recovered ECAL cells
|
169 |
|
|
unsigned int maxProblematicEcalCells_; // maximum number of problematic ECAL cells
|
170 |
|
|
unsigned int maxBadHcalCells_; // maximum number of bad HCAL cells
|
171 |
|
|
unsigned int maxRecoveredHcalCells_; // maximum number of recovered HCAL cells
|
172 |
|
|
unsigned int maxProblematicHcalCells_; // maximum number of problematic HCAL cells
|
173 |
|
|
|
174 |
|
|
std::vector<edm::Ptr<reco::Candidate> > inputs_; // input candidates [View, PtrVector and CandCollection have limitations]
|
175 |
|
|
reco::Particle::Point vertex_; // Primary vertex
|
176 |
|
|
ClusterSequencePtr fjClusterSeq_; // fastjet cluster sequence
|
177 |
|
|
JetDefPtr fjJetDefinition_; // fastjet jet definition
|
178 |
|
|
PluginPtr fjPlugin_; // fastjet plugin
|
179 |
|
|
ActiveAreaSpecPtr fjActiveArea_; // fastjet active area definition
|
180 |
|
|
RangeDefPtr fjRangeDef_; // range definition
|
181 |
|
|
std::vector<fastjet::PseudoJet> fjInputs_; // fastjet inputs
|
182 |
|
|
std::vector<fastjet::PseudoJet> fjJets_; // fastjet jets
|
183 |
|
|
|
184 |
|
|
std::string jetCollInstanceName_; // instance name for output jet collection
|
185 |
|
|
boost::shared_ptr<PileUpSubtractor> subtractor_;
|
186 |
yilmaz |
1.2 |
const CaloGeometry *geo;
|
187 |
yilmaz |
1.1 |
|
188 |
|
|
};
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
|
192 |
|
|
|
193 |
|
|
|
194 |
|
|
#endif
|