35 #include "fastjet/SISConePlugin.hh"
36 #include "fastjet/CMSIterativeConePlugin.hh"
37 #include "fastjet/ATLASConePlugin.hh"
38 #include "fastjet/CDFMidPointPlugin.hh"
53 bool operator()(
const fastjet::PseudoJet & t1,
const fastjet::PseudoJet & t2 )
const {
54 return t1.perp() > t2.perp();
63 "BasicJet",
"GenJet",
"CaloJet",
"PFJet",
"TrackJet",
"PFClusterJet"
72 if (pos ==
names + LastJetType) {
73 std::string errorMessage=
"Requested jetType not supported: "+name+
"\n";
82 if (makeCaloJet(jetTypeE)) {
83 produces<reco::CaloJetCollection>(
tag).setBranchAlias(alias);
85 else if (makePFJet(jetTypeE)) {
86 produces<reco::PFJetCollection>(
tag).setBranchAlias(alias);
88 else if (makeGenJet(jetTypeE)) {
89 produces<reco::GenJetCollection>(
tag).setBranchAlias(alias);
91 else if (makeTrackJet(jetTypeE)) {
92 produces<reco::TrackJetCollection>(
tag).setBranchAlias(alias);
94 else if (makePFClusterJet(jetTypeE)) {
95 produces<reco::PFClusterJetCollection>(
tag).setBranchAlias(alias);
97 else if (makeBasicJet(jetTypeE)) {
98 produces<reco::BasicJetCollection>(
tag).setBranchAlias(alias);
108 : moduleLabel_ (iConfig.getParameter<string> (
"@module_label"))
109 , src_ (iConfig.getParameter<edm::InputTag>(
"src"))
110 , srcPVs_ (iConfig.getParameter<edm::InputTag>(
"srcPVs"))
111 , jetType_ (iConfig.getParameter<string> (
"jetType"))
112 , jetAlgorithm_ (iConfig.getParameter<string> (
"jetAlgorithm"))
113 , rParam_ (iConfig.getParameter<double> (
"rParam"))
114 , inputEtMin_ (iConfig.getParameter<double> (
"inputEtMin"))
115 , inputEMin_ (iConfig.getParameter<double> (
"inputEMin"))
116 , jetPtMin_ (iConfig.getParameter<double> (
"jetPtMin"))
117 , doPVCorrection_(iConfig.getParameter<bool> (
"doPVCorrection"))
118 , restrictInputs_(
false)
119 , maxInputs_(99999999)
120 , doAreaFastjet_ (iConfig.getParameter<bool> (
"doAreaFastjet"))
121 , doAreaDiskApprox_ (
false)
122 , doRhoFastjet_ (iConfig.getParameter<bool> (
"doRhoFastjet"))
124 , doPUOffsetCorr_(iConfig.getParameter<bool> (
"doPUOffsetCorr"))
127 , jetCollInstanceName_ (
"")
139 fastjet::SISConePlugin::SM_pttilde) );
166 <<
"Jet algorithm for VirtualJetProducer is invalid, Abort!\n";
170 if ( iConfig.
exists(
"jetCollInstanceName") ) {
176 throw cms::Exception(
"InvalidInput") <<
"Can only offset correct jets of type CaloJet";
183 edm::LogWarning(
"VirtualJetProducer") <<
"Pile Up correction on; however, pile up type is not specified. Using default... \n";
191 if (iConfig.
exists(
"doAreaDiskApprox")) {
194 throw cms::Exception(
"Conflicting area calculations") <<
"Both the calculation of jet area via fastjet and via an analytical disk approximation have been requested. Please decide on one.\n";
199 if (iConfig.
exists(
"voronoiRfact"))
207 double rhoEtaMax=iConfig.
getParameter<
double>(
"Rho_EtaMax");
209 double ghostEtaMax = iConfig.
getParameter<
double>(
"Ghost_EtaMax");
211 int activeAreaRepeats = iConfig.
getParameter<
int> (
"Active_Area_Repeats");
213 double ghostArea = iConfig.
getParameter<
double> (
"GhostArea");
220 if ( iConfig.
exists(
"restrictInputs") ) {
241 if ( iConfig.
exists(
"useDeterministicSeed") ) {
246 produces<std::vector<double> >(
"rhos");
247 produces<std::vector<double> >(
"sigmas");
248 produces<double>(
"rho");
249 produces<double>(
"sigma");
273 fastjet::GhostedAreaSpec gas;
274 std::vector<int> seeds(2);
277 gas.set_random_status(seeds);
280 LogDebug(
"VirtualJetProducer") <<
"Entered produce\n";
284 LogDebug(
"VirtualJetProducer") <<
"Adding PV info\n";
287 if (pvCollection->size()>0)
vertex_=pvCollection->begin()->position();
297 LogDebug(
"VirtualJetProducer") <<
"Clear data\n";
305 for (
size_t i = 0;
i < inputsHandle->size(); ++
i) {
306 inputs_.push_back(inputsHandle->ptrAt(
i));
308 LogDebug(
"VirtualJetProducer") <<
"Got inputs\n";
315 LogDebug(
"VirtualJetProducer") <<
"Inputted towers\n";
323 LogDebug(
"VirtualJetProducer") <<
"Subtracted pedestal\n";
333 LogDebug(
"VirtualJetProducer") <<
"Ran algorithm\n";
342 LogDebug(
"VirtualJetProducer") <<
"Do PUOffsetCorr\n";
343 vector<fastjet::PseudoJet> orphanInput;
354 LogDebug(
"VirtualJetProducer") <<
"Wrote jets\n";
363 std::vector<edm::Ptr<reco::Candidate> >::const_iterator inBegin =
inputs_.begin(),
365 for (;
i != inEnd; ++
i ) {
371 if (input->pt() == 0) {
372 edm::LogError(
"NullTransverseMomentum") <<
"dropping input candidate with pt=0";
378 fjInputs_.push_back(fastjet::PseudoJet(ct.px(),ct.py(),ct.pz(),ct.energy()));
381 fjInputs_.push_back(fastjet::PseudoJet(input->px(),input->py(),input->pz(),
391 edm::LogWarning(
"JetRecoTooManyEntries") <<
"Too many inputs in the event, limiting to first " <<
maxInputs_ <<
". Output is suspect.";
414 for (
unsigned int i=0;
i<fjConstituents.size();++
i)
420 vector<reco::CandidatePtr>
423 vector<reco::CandidatePtr>
result;
424 for (
unsigned int i=0;
i<fjConstituents.size();
i++) {
425 int index = fjConstituents[
i].user_index();
427 result.push_back(candidate);
441 writeJets<reco::CaloJet>(
iEvent, iSetup);
444 writeJets<reco::PFJet>(
iEvent, iSetup);
447 writeJets<reco::GenJet>(
iEvent, iSetup);
450 writeJets<reco::TrackJet>(
iEvent, iSetup);
453 writeJets<reco::PFClusterJet>(
iEvent, iSetup);
456 writeJets<reco::BasicJet>(
iEvent, iSetup);
459 throw cms::Exception(
"InvalidInput") <<
"invalid jet type in VirtualJetProducer\n";
465 template<
typename T >
471 std::vector<fastjet::PseudoJet> fjexcluded_jets;
474 if(fjexcluded_jets.size()>2) fjexcluded_jets.resize(
nExclude_);
477 std::auto_ptr<std::vector<double> > rhos(
new std::vector<double>);
478 std::auto_ptr<std::vector<double> > sigmas(
new std::vector<double>);
481 sigmas->reserve(nEta);
482 fastjet::ClusterSequenceAreaBase
const* clusterSequenceWithArea =
483 dynamic_cast<fastjet::ClusterSequenceAreaBase
const *
> ( &*
fjClusterSeq_ );
486 for(
int ie = 0; ie < nEta; ++ie){
490 fastjet::RangeDefinition range_rho(etamin,etamax);
493 rhos->push_back(bkgestim.
rho());
494 sigmas->push_back(bkgestim.
sigma());
496 iEvent.
put(rhos,
"rhos");
497 iEvent.
put(sigmas,
"sigmas");
499 std::auto_ptr<double>
rho(
new double(0.0));
500 std::auto_ptr<double> sigma(
new double(0.0));
501 double mean_area = 0;
503 fastjet::ClusterSequenceAreaBase
const* clusterSequenceWithArea =
504 dynamic_cast<fastjet::ClusterSequenceAreaBase
const *
> ( &*
fjClusterSeq_ );
505 clusterSequenceWithArea->get_median_rho_and_sigma(*
fjRangeDef_,
false,*rho,*sigma,mean_area);
506 iEvent.
put(rho,
"rho");
507 iEvent.
put(sigma,
"sigma");
513 using namespace reco;
515 std::auto_ptr<std::vector<T> >
jets(
new std::vector<T>() );
520 std::vector<std::vector<double> > rij(
fjJets_.size());
522 for (
unsigned int ijet=0;ijet<
fjJets_.size();++ijet) {
526 const fastjet::PseudoJet& fjJet =
fjJets_[ijet];
528 std::vector<fastjet::PseudoJet> fjConstituents =
531 std::vector<CandidatePtr> constituents =
537 fastjet::ClusterSequenceAreaBase
const * clusterSequenceWithArea =
538 dynamic_cast<fastjet::ClusterSequenceAreaBase
const *
>(&*
fjClusterSeq_);
539 jetArea = clusterSequenceWithArea->area(fjJet);
546 std::vector<double>& distance = rij[ijet];
547 distance.resize(ijet);
548 for (
unsigned jJet = 0; jJet < ijet; ++jJet) {
551 for (
unsigned kJet = 0; kJet < jJet; ++kJet) {
569 constituents, iSetup);
571 jet.setJetArea (jetArea);
580 jets->push_back(jet);
void writeJets(edm::Event &iEvent, edm::EventSetup const &iSetup)
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
reco::Particle::Point vertex_
math::PtEtaPhiMLorentzVector p4(double vtxZ) const
virtual std::vector< reco::CandidatePtr > getConstituents(const std::vector< fastjet::PseudoJet > &fjConstituents)
std::vector< fastjet::PseudoJet > fjJets_
virtual void inputTowers()
Base class for all types of Jets.
boost::shared_ptr< fastjet::JetDefinition::Plugin > PluginPtr
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::string puSubtractorName_
std::vector< double > puCenters_
virtual void copyConstituents(const std::vector< fastjet::PseudoJet > &fjConstituents, reco::Jet *jet)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
virtual void runAlgorithm(edm::Event &iEvent, const edm::EventSetup &iSetup)=0
double deltaR(double eta1, double phi1, double eta2, double phi2)
bool operator()(const fastjet::PseudoJet &t1, const fastjet::PseudoJet &t2) const
boost::shared_ptr< fastjet::RangeDefinition > RangeDefPtr
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
virtual bool isAnomalousTower(reco::CandidatePtr input)
static const char * names[]
std::vector< fastjet::PseudoJet > fjInputs_
std::string jetCollInstanceName_
boost::shared_ptr< PileUpSubtractor > subtractor_
double intersection(double r12)
std::vector< edm::Ptr< reco::Candidate > > inputs_
virtual ~VirtualJetProducer()
T const * get() const
Returns C++ pointer to the item.
const T & max(const T &a, const T &b)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
ClusterSequencePtr fjClusterSeq_
virtual void makeProduces(std::string s, std::string tag="")
std::string jetAlgorithm_
void set_excluded_jets(const std::vector< PseudoJet > &excluded_jets)
boost::shared_ptr< fastjet::JetDefinition > JetDefPtr
bool useDeterministicSeed_
std::auto_ptr< AnomalousTower > anomalousTowerDef_
ActiveAreaSpecPtr fjActiveArea_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
double rho()
synonym for median rho [[do we have this? Both?]]
double sigma()
get the sigma
VirtualJetProducer(const edm::ParameterSet &iConfig)
void addDaughter(const CandidatePtr &)
add a daughter via a reference
virtual void output(edm::Event &iEvent, edm::EventSetup const &iSetup)
boost::shared_ptr< fastjet::ActiveAreaSpec > ActiveAreaSpecPtr
static const HistoName names[]
math::XYZTLorentzVector LorentzVector
Lorentz vector.
bool makeCaloJet(const JetType::Type &fTag)
static Type byName(const std::string &name)
T get(const Candidate &c)
bool doFastJetNonUniform_
math::XYZPoint Point
point in the space
void writeSpecific(reco::CaloJet &jet, reco::Particle::LorentzVector const &p4, reco::Particle::Point const &point, std::vector< reco::CandidatePtr > const &constituents, edm::EventSetup const &c)
JetDefPtr fjJetDefinition_