CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Attributes
FastjetJetProducer Class Reference

#include <FastjetJetProducer.h>

Inheritance diagram for FastjetJetProducer:
VirtualJetProducer edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 FastjetJetProducer (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
virtual ~FastjetJetProducer ()
 
- Public Member Functions inherited from VirtualJetProducer
std::string jetType () const
 
 VirtualJetProducer (const edm::ParameterSet &iConfig)
 
virtual ~VirtualJetProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Protected Member Functions

virtual void produceTrackJets (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
virtual void runAlgorithm (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
- Protected Member Functions inherited from VirtualJetProducer
virtual void copyConstituents (const std::vector< fastjet::PseudoJet > &fjConstituents, reco::Jet *jet)
 
virtual std::vector
< reco::CandidatePtr
getConstituents (const std::vector< fastjet::PseudoJet > &fjConstituents)
 
virtual void inputTowers ()
 
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 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 writeJets (edm::Event &iEvent, edm::EventSetup const &iSetup)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Private Attributes

float dxyTrVtxMax_
 
float dzTrVtxMax_
 
float maxVtxZ_
 
int minVtxNdof_
 
bool useOnlyOnePV_
 
bool useOnlyVertexTracks_
 

Additional Inherited Members

- Public Types inherited from VirtualJetProducer
typedef boost::shared_ptr
< fastjet::ActiveAreaSpec > 
ActiveAreaSpecPtr
 
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::RangeDefinition > 
RangeDefPtr
 
- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Attributes inherited from VirtualJetProducer
bool doAreaFastjet_
 
bool doFastJetNonUniform_
 
bool doPUOffsetCorr_
 
bool doPVCorrection_
 
bool doRhoFastjet_
 
ActiveAreaSpecPtr fjActiveArea_
 
ClusterSequencePtr fjClusterSeq_
 
std::vector< fastjet::PseudoJet > fjInputs_
 
JetDefPtr fjJetDefinition_
 
std::vector< fastjet::PseudoJet > fjJets_
 
PluginPtr fjPlugin_
 
RangeDefPtr fjRangeDef_
 
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 maxBadEcalCells_
 
unsigned int maxBadHcalCells_
 
unsigned int maxInputs_
 
unsigned int maxProblematicEcalCells_
 
unsigned int maxProblematicHcalCells_
 
unsigned int maxRecoveredEcalCells_
 
unsigned int maxRecoveredHcalCells_
 
std::string moduleLabel_
 
std::vector< double > puCenters_
 
std::string puSubtractorName_
 
double puWidth_
 
bool restrictInputs_
 
double rParam_
 
edm::InputTag src_
 
edm::InputTag srcPVs_
 
boost::shared_ptr
< PileUpSubtractor
subtractor_
 
reco::Particle::Point vertex_
 

Detailed Description

Definition at line 8 of file FastjetJetProducer.h.

Constructor & Destructor Documentation

FastjetJetProducer::FastjetJetProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 56 of file FastjetJetProducer.cc.

References dxyTrVtxMax_, dzTrVtxMax_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), maxVtxZ_, minVtxNdof_, useOnlyOnePV_, and useOnlyVertexTracks_.

57  : VirtualJetProducer( iConfig )
58 {
59 
60  if ( iConfig.exists("UseOnlyVertexTracks") )
61  useOnlyVertexTracks_ = iConfig.getParameter<bool>("UseOnlyVertexTracks");
62  else
63  useOnlyVertexTracks_ = false;
64 
65  if ( iConfig.exists("UseOnlyOnePV") )
66  useOnlyOnePV_ = iConfig.getParameter<bool>("UseOnlyOnePV");
67  else
68  useOnlyOnePV_ = false;
69 
70  if ( iConfig.exists("DzTrVtxMax") )
71  dzTrVtxMax_ = iConfig.getParameter<double>("DzTrVtxMax");
72  else
73  dzTrVtxMax_ = 999999.;
74  if ( iConfig.exists("DxyTrVtxMax") )
75  dxyTrVtxMax_ = iConfig.getParameter<double>("DxyTrVtxMax");
76  else
77  dxyTrVtxMax_ = 999999.;
78  if ( iConfig.exists("MinVtxNdof") )
79  minVtxNdof_ = iConfig.getParameter<int>("MinVtxNdof");
80  else
81  minVtxNdof_ = 5;
82  if ( iConfig.exists("MaxVtxZ") )
83  maxVtxZ_ = iConfig.getParameter<double>("MaxVtxZ");
84  else
85  maxVtxZ_ = 15;
86 
87 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
VirtualJetProducer(const edm::ParameterSet &iConfig)
FastjetJetProducer::~FastjetJetProducer ( )
virtual

Definition at line 91 of file FastjetJetProducer.cc.

92 {
93 }

Member Function Documentation

void FastjetJetProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Reimplemented from VirtualJetProducer.

Definition at line 100 of file FastjetJetProducer.cc.

References VirtualJetProducer::jetTypeE, VirtualJetProducer::makeTrackJet(), VirtualJetProducer::produce(), and produceTrackJets().

101 {
102 
103  // for everything but track jets
104  if (!makeTrackJet(jetTypeE)) {
105 
106  // use the default production from one collection
107  VirtualJetProducer::produce( iEvent, iSetup );
108 
109  } else { // produce trackjets from tracks grouped per primary vertex
110 
111  produceTrackJets(iEvent, iSetup);
112 
113  }
114 
115 }
JetType::Type jetTypeE
bool makeTrackJet(const JetType::Type &fTag)
virtual void produceTrackJets(edm::Event &iEvent, const edm::EventSetup &iSetup)
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
void FastjetJetProducer::produceTrackJets ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
protectedvirtual

Definition at line 118 of file FastjetJetProducer.cc.

References dxyTrVtxMax_, dzTrVtxMax_, VirtualJetProducer::fjClusterSeq_, VirtualJetProducer::fjInputs_, VirtualJetProducer::fjJets_, newFWLiteAna::found, edm::Event::getByLabel(), VirtualJetProducer::getConstituents(), i, VirtualJetProducer::inputs_, VirtualJetProducer::inputTowers(), metsig::jet, analyzePatCleaning_cfg::jets, LogDebug, maxVtxZ_, minVtxNdof_, edm::Event::put(), runAlgorithm(), reco::Jet::setJetArea(), reco::Jet::setPileup(), reco::TrackJet::setPrimaryVertex(), reco::LeafCandidate::setVertex(), VirtualJetProducer::src_, VirtualJetProducer::srcPVs_, useOnlyOnePV_, useOnlyVertexTracks_, VirtualJetProducer::vertex_, and reco::writeSpecific().

Referenced by produce().

119 {
120 
121  // read in the track candidates
123  iEvent.getByLabel(src_, inputsHandle);
124  // make collection with pointers so we can play around with it
125  std::vector<edm::Ptr<reco::RecoChargedRefCandidate> > allInputs;
126  std::vector<edm::Ptr<reco::Candidate> > origInputs;
127  for (size_t i = 0; i < inputsHandle->size(); ++i) {
128  allInputs.push_back(inputsHandle->ptrAt(i));
129  origInputs.push_back(inputsHandle->ptrAt(i));
130  }
131 
132  // read in the PV collection
134  iEvent.getByLabel(srcPVs_, pvCollection);
135  // define the overall output jet container
136  std::auto_ptr<std::vector<reco::TrackJet> > jets(new std::vector<reco::TrackJet>() );
137 
138  // loop over the good vertices, clustering for each vertex separately
139  for (reco::VertexCollection::const_iterator itVtx = pvCollection->begin(); itVtx != pvCollection->end(); ++itVtx) {
140  if (itVtx->isFake() || itVtx->ndof() < minVtxNdof_ || fabs(itVtx->z()) > maxVtxZ_) continue;
141 
142  // clear the intermediate containers
143  inputs_.clear();
144  fjInputs_.clear();
145  fjJets_.clear();
146 
147  // if only vertex-associated tracks should be used
148  if (useOnlyVertexTracks_) {
149  // loop over the tracks associated to the vertex
150  for (reco::Vertex::trackRef_iterator itTr = itVtx->tracks_begin(); itTr != itVtx->tracks_end(); ++itTr) {
151  // whether a match was found in the track candidate input
152  bool found = false;
153  // loop over input track candidates
154  for (std::vector<edm::Ptr<reco::RecoChargedRefCandidate> >::iterator itIn = allInputs.begin(); itIn != allInputs.end(); ++itIn) {
155  // match the input track candidate to the track from the vertex
156  reco::TrackRef trref(itTr->castTo<reco::TrackRef>());
157  // check if the tracks match
158  if ((*itIn)->track() == trref) {
159  found = true;
160  // add this track candidate to the input for clustering
161  inputs_.push_back(*itIn);
162  // erase the track candidate from the total list of input, so we don't reuse it later
163  allInputs.erase(itIn);
164  // found the candidate track corresponding to the vertex track, so stop the loop
165  break;
166  } // end if match found
167  } // end loop over input tracks
168  // give an info message in case no match is found (can happen if candidates are subset of tracks used for clustering)
169  if (!found) edm::LogInfo("FastjetTrackJetProducer") << "Ignoring a track at vertex which is not in input track collection!";
170  } // end loop over tracks associated to vertex
171  // if all inpt track candidates should be used
172  } else {
173  // loop over input track candidates
174  for (std::vector<edm::Ptr<reco::RecoChargedRefCandidate> >::iterator itIn = allInputs.begin(); itIn != allInputs.end(); ++itIn) {
175  // check if the track is close enough to the vertex
176  float dz = (*itIn)->track()->dz(itVtx->position());
177  float dxy = (*itIn)->track()->dxy(itVtx->position());
178  if (fabs(dz) > dzTrVtxMax_) continue;
179  if (fabs(dxy) > dxyTrVtxMax_) continue;
180  bool closervtx = false;
181  // now loop over the good vertices a second time
182  for (reco::VertexCollection::const_iterator itVtx2 = pvCollection->begin(); itVtx2 != pvCollection->end(); ++itVtx2) {
183  if (itVtx->isFake() || itVtx->ndof() < minVtxNdof_ || fabs(itVtx->z()) > maxVtxZ_) continue;
184  // and check this track is closer to any other vertex (if more than 1 vertex considered)
185  if (!useOnlyOnePV_ &&
186  itVtx != itVtx2 &&
187  fabs((*itIn)->track()->dz(itVtx2->position())) < fabs(dz)) {
188  closervtx = true;
189  break; // 1 closer vertex makes the track already not matched, so break
190  }
191  }
192  // don't add this track if another vertex is found closer
193  if (closervtx) continue;
194  // add this track candidate to the input for clustering
195  inputs_.push_back(*itIn);
196  // erase the track candidate from the total list of input, so we don't reuse it later
197  allInputs.erase(itIn);
198  // take a step back in the loop since we just erased
199  --itIn;
200  }
201  }
202 
203  // convert candidates in inputs_ to fastjet::PseudoJets in fjInputs_
204  fjInputs_.reserve(inputs_.size());
205  inputTowers();
206  LogDebug("FastjetTrackJetProducer") << "Inputted towers\n";
207 
208  // run algorithm, using fjInputs_, modifying fjJets_ and allocating fjClusterSeq_
209  runAlgorithm(iEvent, iSetup);
210  LogDebug("FastjetTrackJetProducer") << "Ran algorithm\n";
211 
212  // convert our jets and add to the overall jet vector
213  for (unsigned int ijet=0;ijet<fjJets_.size();++ijet) {
214  // get the constituents from fastjet
215  std::vector<fastjet::PseudoJet> fjConstituents = sorted_by_pt(fjClusterSeq_->constituents(fjJets_[ijet]));
216  // convert them to CandidatePtr vector
217  std::vector<reco::CandidatePtr> constituents = getConstituents(fjConstituents);
218  // fill the trackjet
220  // write the specifics to the jet (simultaneously sets 4-vector, vertex).
221  writeSpecific( jet,
222  reco::Particle::LorentzVector(fjJets_[ijet].px(), fjJets_[ijet].py(), fjJets_[ijet].pz(), fjJets_[ijet].E()),
223  vertex_, constituents, iSetup);
224  jet.setJetArea(0);
225  jet.setPileup(0);
226  jet.setPrimaryVertex(edm::Ref<reco::VertexCollection>(pvCollection, (int) (itVtx-pvCollection->begin())));
227  jet.setVertex(itVtx->position());
228  jets->push_back(jet);
229  }
230 
231  if (useOnlyOnePV_) break; // stop vertex loop if only one vertex asked for
232  } // end loop over vertices
233 
234  // put the jets in the collection
235  LogDebug("FastjetTrackJetProducer") << "Put " << jets->size() << " jets in the event.\n";
236  iEvent.put(jets);
237 
238 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
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:96
virtual void inputTowers()
virtual void runAlgorithm(edm::Event &iEvent, const edm::EventSetup &iSetup)
virtual void setJetArea(float fArea)
set jet area
Definition: Jet.h:91
std::vector< fastjet::PseudoJet > fjInputs_
std::vector< edm::Ptr< reco::Candidate > > inputs_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
ClusterSequencePtr fjClusterSeq_
void setPrimaryVertex(const reco::VertexRef &vtx)
set associated primary vertex
Definition: TrackJet.cc:81
virtual void setVertex(const Point &vertex)
set vertex
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
Jets made out of tracks.
Definition: TrackJet.h:28
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector&lt;TrackRef&gt;
Definition: Vertex.h:38
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:26
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:41
void FastjetJetProducer::runAlgorithm ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
protectedvirtual

Implements VirtualJetProducer.

Definition at line 242 of file FastjetJetProducer.cc.

References VirtualJetProducer::doAreaFastjet_, VirtualJetProducer::doRhoFastjet_, VirtualJetProducer::fjActiveArea_, VirtualJetProducer::fjClusterSeq_, VirtualJetProducer::fjInputs_, VirtualJetProducer::fjJetDefinition_, VirtualJetProducer::fjJets_, and VirtualJetProducer::jetPtMin_.

Referenced by produceTrackJets().

243 {
244  // run algorithm
245  if ( !doAreaFastjet_ && !doRhoFastjet_) {
246  fjClusterSeq_ = ClusterSequencePtr( new fastjet::ClusterSequence( fjInputs_, *fjJetDefinition_ ) );
247  } else {
248  fjClusterSeq_ = ClusterSequencePtr( new fastjet::ClusterSequenceArea( fjInputs_, *fjJetDefinition_ , *fjActiveArea_ ) );
249  }
250  fjJets_ = fastjet::sorted_by_pt(fjClusterSeq_->inclusive_jets(jetPtMin_));
251 
252 }
std::vector< fastjet::PseudoJet > fjJets_
std::vector< fastjet::PseudoJet > fjInputs_
ClusterSequencePtr fjClusterSeq_
ActiveAreaSpecPtr fjActiveArea_
boost::shared_ptr< fastjet::ClusterSequence > ClusterSequencePtr

Member Data Documentation

float FastjetJetProducer::dxyTrVtxMax_
private

Definition at line 36 of file FastjetJetProducer.h.

Referenced by FastjetJetProducer(), and produceTrackJets().

float FastjetJetProducer::dzTrVtxMax_
private

Definition at line 35 of file FastjetJetProducer.h.

Referenced by FastjetJetProducer(), and produceTrackJets().

float FastjetJetProducer::maxVtxZ_
private

Definition at line 38 of file FastjetJetProducer.h.

Referenced by FastjetJetProducer(), and produceTrackJets().

int FastjetJetProducer::minVtxNdof_
private

Definition at line 37 of file FastjetJetProducer.h.

Referenced by FastjetJetProducer(), and produceTrackJets().

bool FastjetJetProducer::useOnlyOnePV_
private

Definition at line 34 of file FastjetJetProducer.h.

Referenced by FastjetJetProducer(), and produceTrackJets().

bool FastjetJetProducer::useOnlyVertexTracks_
private

Definition at line 33 of file FastjetJetProducer.h.

Referenced by FastjetJetProducer(), and produceTrackJets().