CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes
cms::SubEventGenJetProducer Class Reference

#include <SubEventGenJetProducer.h>

Inheritance diagram for cms::SubEventGenJetProducer:
VirtualJetProducer edm::stream::EDProducer<>

Public Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 
void runAlgorithm (edm::Event &, const edm::EventSetup &) override
 
 SubEventGenJetProducer (const edm::ParameterSet &ps)
 
 ~SubEventGenJetProducer () override
 
- Public Member Functions inherited from VirtualJetProducer
std::string jetType () const
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 VirtualJetProducer (const edm::ParameterSet &iConfig)
 
 ~VirtualJetProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Protected Member Functions

void inputTowers () override
 
- Protected Member Functions inherited from VirtualJetProducer
virtual void addHTTTopJetTagInfoCollection (edm::Event &iEvent, const edm::EventSetup &iSetup, edm::OrphanHandle< reco::BasicJetCollection > &oh)
 
virtual void copyConstituents (const std::vector< fastjet::PseudoJet > &fjConstituents, reco::Jet *jet)
 
virtual std::vector< reco::CandidatePtrgetConstituents (const std::vector< fastjet::PseudoJet > &fjConstituents)
 
virtual bool isAnomalousTower (reco::CandidatePtr input)
 
bool makeBasicJet (const JetType::Type &fTag)
 
bool makeCaloJet (const JetType::Type &fTag)
 
bool makeGenJet (const JetType::Type &fTag)
 
bool makePFClusterJet (const JetType::Type &fTag)
 
bool makePFJet (const JetType::Type &fTag)
 
virtual void makeProduces (std::string s, std::string tag="")
 
bool makeTrackJet (const JetType::Type &fTag)
 
void offsetCorrectJets (std::vector< fastjet::PseudoJet > &orphanInput)
 
virtual void output (edm::Event &iEvent, edm::EventSetup const &iSetup)
 
template<typename T >
void writeCompoundJets (edm::Event &iEvent, edm::EventSetup const &iSetup)
 function template to write out the outputs More...
 
template<typename T >
void writeJets (edm::Event &iEvent, edm::EventSetup const &iSetup)
 
template<typename T >
void writeJetsWithConstituents (edm::Event &iEvent, edm::EventSetup const &iSetup)
 function template to write out the outputs More...
 

Protected Attributes

std::vector< int > hydroTag_
 
bool ignoreHydro_
 
std::vector< int > nSubParticles_
 
std::vector< std::vector< fastjet::PseudoJet > > subInputs_
 
std::vector< reco::GenJet > * subJets_
 
- Protected Attributes inherited from VirtualJetProducer
int activeAreaRepeats_
 
bool doAreaDiskApprox_
 
bool doAreaFastjet_
 
bool doFastJetNonUniform_
 
bool doPUOffsetCorr_
 
bool doPVCorrection_
 
bool doRhoFastjet_
 
ActiveAreaSpecPtr fjActiveArea_
 
AreaDefinitionPtr fjAreaDefinition_
 
ClusterSequencePtr fjClusterSeq_
 
std::vector< fastjet::PseudoJet > fjInputs_
 
JetDefPtr fjJetDefinition_
 
std::vector< fastjet::PseudoJet > fjJets_
 
PluginPtr fjPlugin_
 
SelectorPtr fjSelector_
 
bool fromHTTTopJetProducer_ = false
 
double ghostArea_
 
double ghostEtaMax_
 
edm::EDGetTokenT< reco::VertexCollectioninput_vertex_token_
 
double inputEMin_
 
double inputEtMin_
 
std::vector< edm::Ptr< reco::Candidate > > inputs_
 
std::string jetAlgorithm_
 
std::string jetCollInstanceName_
 
double jetPtMin_
 
std::string jetType_
 
JetType::Type jetTypeE
 
unsigned int maxInputs_
 
unsigned int minSeed_
 
std::string moduleLabel_
 
unsigned int nExclude_
 
std::vector< double > puCenters_
 
std::string puSubtractorName_
 
double puWidth_
 
bool restrictInputs_
 
double rhoEtaMax_
 
double rParam_
 
edm::InputTag src_
 
edm::InputTag srcPVs_
 
boost::shared_ptr< PileUpSubtractorsubtractor_
 
bool useDeterministicSeed_
 
bool useExplicitGhosts_
 
int verbosity_
 
reco::Particle::Point vertex_
 
double voronoiRfact_
 
bool writeCompound_
 
bool writeJetsWithConst_
 

Private Attributes

edm::EDGetTokenT< reco::CandidateViewinput_cand_token_
 

Additional Inherited Members

- Public Types inherited from VirtualJetProducer
typedef boost::shared_ptr< fastjet::GhostedAreaSpec > ActiveAreaSpecPtr
 
typedef boost::shared_ptr< fastjet::AreaDefinition > AreaDefinitionPtr
 
typedef boost::shared_ptr< fastjet::ClusterSequence > ClusterSequencePtr
 
typedef boost::shared_ptr< fastjet::JetDefinition > JetDefPtr
 
typedef boost::shared_ptr< fastjet::JetDefinition::Plugin > PluginPtr
 
typedef boost::shared_ptr< fastjet::Selector > SelectorPtr
 
- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Static Public Member Functions inherited from VirtualJetProducer
static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
static void fillDescriptionsFromVirtualJetProducer (edm::ParameterSetDescription &desc)
 

Detailed Description

Definition at line 19 of file SubEventGenJetProducer.h.

Constructor & Destructor Documentation

SubEventGenJetProducer::SubEventGenJetProducer ( const edm::ParameterSet ps)

Definition at line 34 of file SubEventGenJetProducer.cc.

References edm::ParameterSet::getUntrackedParameter(), ignoreHydro_, input_cand_token_, and VirtualJetProducer::src_.

34  :
35  VirtualJetProducer( conf )
36 {
37  // mapSrc_ = conf.getParameter<edm::InputTag>( "srcMap");
38  ignoreHydro_ = conf.getUntrackedParameter<bool>("ignoreHydro", true);
39  produces<reco::BasicJetCollection>();
40  // the subjet collections are set through the config file in the "jetCollInstanceName" field.
41 
42  input_cand_token_ = consumes<reco::CandidateView>(src_);
43 
44 }
edm::EDGetTokenT< reco::CandidateView > input_cand_token_
VirtualJetProducer(const edm::ParameterSet &iConfig)
cms::SubEventGenJetProducer::~SubEventGenJetProducer ( )
inlineoverride

Definition at line 24 of file SubEventGenJetProducer.h.

References produce(), and runAlgorithm().

24 {}

Member Function Documentation

void SubEventGenJetProducer::inputTowers ( )
overrideprotectedvirtual

Reimplemented from VirtualJetProducer.

Definition at line 47 of file SubEventGenJetProducer.cc.

References reco::GenParticle::collisionId(), reco::Candidate::energy(), reco::Candidate::et(), edm::Ptr< T >::get(), hydroTag_, mps_fire::i, input, VirtualJetProducer::inputEMin_, VirtualJetProducer::inputEtMin_, VirtualJetProducer::inputs_, createfilelist::int, VirtualJetProducer::isAnomalousTower(), edm::isNotFinite(), LogDebug, reco::Candidate::pt(), reco::Candidate::px(), reco::Candidate::py(), reco::Candidate::pz(), and subInputs_.

Referenced by produce().

48 {
49  std::vector<edm::Ptr<reco::Candidate> >::const_iterator inBegin = inputs_.begin(),
50  inEnd = inputs_.end(), i = inBegin;
51  for (; i != inEnd; ++i ) {
52  reco::CandidatePtr input = inputs_[i - inBegin];
53  if (edm::isNotFinite(input->pt())) continue;
54  if (input->et() <inputEtMin_) continue;
55  if (input->energy()<inputEMin_) continue;
56  if (isAnomalousTower(input)) continue;
57 
58  edm::Ptr<reco::Candidate> p = inputs_[i - inBegin];
59  const GenParticle * pref = dynamic_cast<const GenParticle *>(p.get());
60  int subevent = pref->collisionId();
61  LogDebug("SubEventContainers")<<"SubEvent is : "<<subevent<<endl;
62  LogDebug("SubEventContainers")<<"SubSize is : "<<subInputs_.size()<<endl;
63 
64  if(subevent >= (int)subInputs_.size()){
65  hydroTag_.resize(subevent+1, -1);
66  subInputs_.resize(subevent+1);
67  LogDebug("SubEventContainers")<<"SubSize is : "<<subInputs_.size()<<endl;
68  LogDebug("SubEventContainers")<<"HydroTagSize is : "<<hydroTag_.size()<<endl;
69  }
70 
71  LogDebug("SubEventContainers")<<"HydroTag is : "<<hydroTag_[subevent]<<endl;
72  if(hydroTag_[subevent] != 0) hydroTag_[subevent] = (int)checkHydro(pref);
73 
74  subInputs_[subevent].push_back(fastjet::PseudoJet(input->px(),input->py(),input->pz(),
75  input->energy()));
76 
77  subInputs_[subevent].back().set_user_index(i - inBegin);
78 
79  }
80 
81 }
#define LogDebug(id)
virtual double pz() const =0
z coordinate of momentum vector
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:159
int collisionId() const
Definition: GenParticle.h:39
static std::string const input
Definition: EdmProvDump.cc:48
virtual bool isAnomalousTower(reco::CandidatePtr input)
virtual double et() const =0
transverse energy
virtual double energy() const =0
energy
virtual double py() const =0
y coordinate of momentum vector
std::vector< edm::Ptr< reco::Candidate > > inputs_
virtual double pt() const =0
transverse momentum
std::vector< std::vector< fastjet::PseudoJet > > subInputs_
virtual double px() const =0
x coordinate of momentum vector
void SubEventGenJetProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 83 of file SubEventGenJetProducer.cc.

References VirtualJetProducer::fjInputs_, VirtualJetProducer::fjJets_, edm::Event::getByToken(), hydroTag_, mps_fire::i, ignoreHydro_, input_cand_token_, VirtualJetProducer::inputs_, inputTowers(), fwrapper::jets, LogDebug, eostools::move(), nSubParticles_, edm::View< T >::ptrAt(), edm::Event::put(), runAlgorithm(), edm::View< T >::size(), subInputs_, and subJets_.

Referenced by ~SubEventGenJetProducer().

83  {
84  LogDebug("VirtualJetProducer") << "Entered produce\n";
85 
86  fjJets_.clear();
87  subInputs_.clear();
88  nSubParticles_.clear();
89  hydroTag_.clear();
90  inputs_.clear();
91 
92  // get inputs and convert them to the fastjet format (fastjet::PeudoJet)
94  iEvent.getByToken(input_cand_token_, inputsHandle);
95  for (size_t i = 0; i < inputsHandle->size(); ++i) {
96  inputs_.push_back(inputsHandle->ptrAt(i));
97  }
98  LogDebug("VirtualJetProducer") << "Got inputs\n";
99 
100  inputTowers();
101  // Convert candidates to fastjet::PseudoJets.
102  // Also correct to Primary Vertex. Will modify fjInputs_
103  // and use inputs_
104 
106 
107  auto jets = std::make_unique<std::vector<GenJet>>();
108  subJets_ = jets.get();
109 
110  LogDebug("VirtualJetProducer") << "Inputted towers\n";
111 
112  size_t nsub = subInputs_.size();
113 
114  for(size_t isub = 0; isub < nsub; ++isub){
115  if(ignoreHydro_ && hydroTag_[isub]) continue;
116  fjJets_.clear();
117  fjInputs_.clear();
118  fjInputs_ = subInputs_[isub];
119  runAlgorithm( iEvent, iSetup );
120  }
121 
122  //Finalize
123  LogDebug("SubEventJetProducer") << "Wrote jets\n";
124 
125  iEvent.put(std::move(jets));
126  return;
127 }
#define LogDebug(id)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
void runAlgorithm(edm::Event &, const edm::EventSetup &) override
std::vector< fastjet::PseudoJet > fjJets_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
edm::EDGetTokenT< reco::CandidateView > input_cand_token_
Ptr< value_type > ptrAt(size_type i) const
size_type size() const
std::vector< reco::GenJet > * subJets_
std::vector< fastjet::PseudoJet > fjInputs_
std::vector< edm::Ptr< reco::Candidate > > inputs_
vector< PseudoJet > jets
std::vector< std::vector< fastjet::PseudoJet > > subInputs_
def move(src, dest)
Definition: eostools.py:511
void SubEventGenJetProducer::runAlgorithm ( edm::Event ,
const edm::EventSetup  
)
overridevirtual

Implements VirtualJetProducer.

Definition at line 129 of file SubEventGenJetProducer.cc.

References DEFINE_FWK_MODULE, VirtualJetProducer::fjClusterSeq_, VirtualJetProducer::fjInputs_, VirtualJetProducer::fjJetDefinition_, VirtualJetProducer::fjJets_, VirtualJetProducer::getConstituents(), metsig::jet, VirtualJetProducer::jetPtMin_, muons2muons_cfi::pu, reco::Jet::setJetArea(), reco::Jet::setPileup(), subJets_, VirtualJetProducer::vertex_, and reco::writeSpecific().

Referenced by produce(), and ~SubEventGenJetProducer().

130 {
131  // run algorithm
132  fjJets_.clear();
133 
134  fjClusterSeq_ = ClusterSequencePtr( new fastjet::ClusterSequence( fjInputs_, *fjJetDefinition_ ) );
135  fjJets_ = fastjet::sorted_by_pt(fjClusterSeq_->inclusive_jets(jetPtMin_));
136 
137  using namespace reco;
138 
139  for (unsigned int ijet=0;ijet<fjJets_.size();++ijet) {
140 
141  GenJet jet;
142  const fastjet::PseudoJet& fjJet = fjJets_[ijet];
143 
144  std::vector<fastjet::PseudoJet> fjConstituents =
145  sorted_by_pt(fjClusterSeq_->constituents(fjJet));
146 
147  std::vector<CandidatePtr> constituents =
148  getConstituents(fjConstituents);
149 
150  double px=fjJet.px();
151  double py=fjJet.py();
152  double pz=fjJet.pz();
153  double E=fjJet.E();
154  double jetArea=0.0;
155  double pu=0.;
156 
157  writeSpecific( jet,
158  Particle::LorentzVector(px, py, pz, E),
159  vertex_,
160  constituents, iSetup);
161 
162  jet.setJetArea (jetArea);
163  jet.setPileup (pu);
164 
165  subJets_->push_back(jet);
166  }
167 }
reco::Particle::Point vertex_
virtual std::vector< reco::CandidatePtr > getConstituents(const std::vector< fastjet::PseudoJet > &fjConstituents)
std::vector< fastjet::PseudoJet > fjJets_
virtual void setPileup(float fEnergy)
Set pileup energy contribution as calculated by algorithm.
Definition: Jet.h:108
std::vector< reco::GenJet > * subJets_
virtual void setJetArea(float fArea)
set jet area
Definition: Jet.h:103
std::vector< fastjet::PseudoJet > fjInputs_
ClusterSequencePtr fjClusterSeq_
Jets made from MC generator particles.
Definition: GenJet.h:25
fixed size matrix
boost::shared_ptr< fastjet::ClusterSequence > ClusterSequencePtr
math::PtEtaPhiELorentzVectorF LorentzVector
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)
Definition: JetSpecific.cc:38

Member Data Documentation

std::vector<int> cms::SubEventGenJetProducer::hydroTag_
protected

Definition at line 31 of file SubEventGenJetProducer.h.

Referenced by inputTowers(), and produce().

bool cms::SubEventGenJetProducer::ignoreHydro_
protected

Definition at line 33 of file SubEventGenJetProducer.h.

Referenced by produce(), and SubEventGenJetProducer().

edm::EDGetTokenT<reco::CandidateView> cms::SubEventGenJetProducer::input_cand_token_
private

Definition at line 42 of file SubEventGenJetProducer.h.

Referenced by produce(), and SubEventGenJetProducer().

std::vector<int> cms::SubEventGenJetProducer::nSubParticles_
protected

Definition at line 32 of file SubEventGenJetProducer.h.

Referenced by produce().

std::vector<std::vector<fastjet::PseudoJet> > cms::SubEventGenJetProducer::subInputs_
protected

Definition at line 29 of file SubEventGenJetProducer.h.

Referenced by inputTowers(), and produce().

std::vector<reco::GenJet>* cms::SubEventGenJetProducer::subJets_
protected

Definition at line 30 of file SubEventGenJetProducer.h.

Referenced by produce(), and runAlgorithm().