CMS 3D CMS Logo

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

#include <VoronoiSubtractor.h>

Inheritance diagram for VoronoiSubtractor:
PileUpSubtractor

Public Member Functions

virtual void calculateOrphanInput (std::vector< fastjet::PseudoJet > &orphanInput)
 
virtual void calculatePedestal (std::vector< fastjet::PseudoJet > const &coll)
 
bool match (fastjet::PseudoJet, fastjet::PseudoJet)
 
virtual void offsetCorrectJets ()
 
virtual void setupGeometryMap (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
virtual void subtractPedestal (std::vector< fastjet::PseudoJet > &coll)
 
 VoronoiSubtractor (const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
 
 ~VoronoiSubtractor ()
 
- Public Member Functions inherited from PileUpSubtractor
virtual double getCone (double cone, double eta, double phi, double &et, double &pu)
 
virtual double getMeanAtTower (const reco::CandidatePtr &in) const
 
int getN (const reco::CandidatePtr &in) const
 
int getNwithJets (const reco::CandidatePtr &in) const
 
virtual double getPileUpAtTower (const reco::CandidatePtr &in) const
 
virtual double getPileUpEnergy (int ijet) const
 
virtual double getSigmaAtTower (const reco::CandidatePtr &in) const
 
int ieta (const reco::CandidatePtr &in) const
 
int iphi (const reco::CandidatePtr &in) const
 
 PileUpSubtractor (const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
 
virtual void reset (std::vector< edm::Ptr< reco::Candidate > > &input, std::vector< fastjet::PseudoJet > &towers, std::vector< fastjet::PseudoJet > &output)
 
virtual void setDefinition (JetDefPtr const &jetDef)
 
virtual ~PileUpSubtractor ()
 

Private Attributes

bool addNegative_
 
bool addNegativesFromCone_
 
edm::Handle< reco::VoronoiMapbackgrounds_
 
edm::Handle< reco::CandidateViewcandidates_
 
std::vector< int > droppedCandidates_
 
bool dropZeroTowers_
 
double infinitesimalPt_
 
double rParam_
 
edm::EDGetTokenT
< reco::CandidateView
srcCand_
 
edm::EDGetTokenT
< edm::ValueMap
< reco::VoronoiBackground > > 
srcVor_
 

Additional Inherited Members

- Public Types inherited from PileUpSubtractor
typedef boost::shared_ptr
< fastjet::GhostedAreaSpec > 
ActiveAreaSpecPtr
 
typedef boost::shared_ptr
< fastjet::ClusterSequence > 
ClusterSequencePtr
 
typedef boost::shared_ptr
< fastjet::JetDefinition > 
JetDefPtr
 
typedef boost::shared_ptr
< fastjet::RangeDefinition > 
RangeDefPtr
 
- Protected Attributes inherited from PileUpSubtractor
std::vector< HcalDetIdallgeomid_
 
bool doAreaFastjet_
 
bool doRhoFastjet_
 
std::map< int, double > emean_
 
std::map< int, double > esigma_
 
ActiveAreaSpecPtr fjActiveArea_
 
ClusterSequencePtr fjClusterSeq_
 
std::vector< fastjet::PseudoJet > * fjInputs_
 
JetDefPtr fjJetDefinition_
 
std::vector< fastjet::PseudoJet > * fjJets_
 
std::vector< fastjet::PseudoJet > fjOriginalInputs_
 
RangeDefPtr fjRangeDef_
 
CaloGeometry const * geo_
 
std::map< int, int > geomtowers_
 
int ietamax_
 
int ietamin_
 
std::vector< edm::Ptr
< reco::Candidate > > * 
inputs_
 
std::vector< double > jetOffset_
 
double jetPtMin_
 
double nSigmaPU_
 
std::map< int, int > ntowersWithJets_
 
double puPtMin_
 
double radiusPU_
 
bool reRunAlgo_
 

Detailed Description

Definition at line 8 of file VoronoiSubtractor.h.

Constructor & Destructor Documentation

VoronoiSubtractor::VoronoiSubtractor ( const edm::ParameterSet iConfig,
edm::ConsumesCollector &&  iC 
)

Definition at line 13 of file VoronoiSubtractor.cc.

13  :
14  PileUpSubtractor(iConfig, std::move(iC)),
17  dropZeroTowers_(iConfig.getParameter<bool>("dropZeros")),
18  addNegative_(iConfig.getParameter<bool>("addNegative")),
19  addNegativesFromCone_(iConfig.getParameter<bool>("addNegativesFromCone")),
20  infinitesimalPt_(iConfig.getParameter<double>("infinitesimalPt")),
21  rParam_(iConfig.getParameter<double>("rParam"))
22 {
23 
24 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::ValueMap< reco::VoronoiBackground > > srcVor_
edm::EDGetTokenT< reco::CandidateView > srcCand_
def move
Definition: eostools.py:510
PileUpSubtractor(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
VoronoiSubtractor::~VoronoiSubtractor ( )
inline

Definition at line 19 of file VoronoiSubtractor.h.

19 {;}

Member Function Documentation

void VoronoiSubtractor::calculateOrphanInput ( std::vector< fastjet::PseudoJet > &  orphanInput)
virtual

Reimplemented from PileUpSubtractor.

Definition at line 184 of file VoronoiSubtractor.cc.

References LogDebug.

185 {
186  LogDebug("VoronoiSubtractor")<<"do nothing...\n";
187 }
#define LogDebug(id)
void VoronoiSubtractor::calculatePedestal ( std::vector< fastjet::PseudoJet > const &  coll)
virtual

Reimplemented from PileUpSubtractor.

Definition at line 178 of file VoronoiSubtractor.cc.

References LogDebug.

179 {
180  LogDebug("VoronoiSubtractor")<<"do nothing...\n";
181 }
#define LogDebug(id)
bool VoronoiSubtractor::match ( fastjet::PseudoJet  cand1,
fastjet::PseudoJet  cand2 
)

Definition at line 8 of file VoronoiSubtractor.cc.

Referenced by offsetCorrectJets().

8  {
9  return (cand1.delta_R(cand2) < rParam_);
10 }
void VoronoiSubtractor::offsetCorrectJets ( )
virtual

Reimplemented from PileUpSubtractor.

Definition at line 41 of file VoronoiSubtractor.cc.

References addNegative_, addNegativesFromCone_, candidates_, droppedCandidates_, PileUpSubtractor::fjJets_, i, cmsHarvester::index, PileUpSubtractor::jetOffset_, LogDebug, match(), reco::VoronoiBackground::pt(), and reco::VoronoiBackground::pt_subtracted().

42 {
43 
44  LogDebug("VoronoiSubtractor")<<"finalizing the output...\n";
45 
46  jetOffset_.reserve(fjJets_->size());
47 
48  for (unsigned int ijet = 0;ijet <fjJets_->size();++ijet) {
49  fastjet::PseudoJet& fjJet = (*fjJets_)[ijet];
50 
51  LogDebug("VoronoiSubtractor")<<"fjJets_ "<<ijet<<" pt : "<<fjJet.pt()
52  <<" --- eta : "<<fjJet.eta()<<" --- phi : "<<fjJet.phi()<<endl;
53 
54  fastjet::PseudoJet subtracted;
55  fastjet::PseudoJet unsubtracted;
56  fastjet::PseudoJet unsubtractedDropped;
57  jetOffset_[ijet] = 0;
58 
59  // Loop over constituents to determine the momentum
60  // before and after subtraction
61 
62  std::vector<fastjet::PseudoJet> fjConstituents = fastjet::sorted_by_pt(fjJet.constituents());
63  for (unsigned int i=0;i<fjConstituents.size();++i) {
64  unsigned int index = fjConstituents[i].user_index();
65 
67  const reco::VoronoiBackground& voronoi = (*backgrounds_)[ref];
68 
69  fastjet::PseudoJet candidate(ref->px(),ref->py(),ref->pz(),ref->energy());
70  double orpt = candidate.perp();
71  unsubtracted += candidate;
72  if(addNegative_ || voronoi.pt() > 0){
73  candidate.reset_PtYPhiM(addNegative_ ? voronoi.pt_subtracted() : voronoi.pt(),ref->rapidity(),ref->phi(),ref->mass());
74  LogDebug("VoronoiSubtractor")<<"candidate "<<index
75  <<" --- original pt : "<<orpt
76  <<" --- voronoi pt : "<<voronoi.pt()
77  <<" --- ref pt : "<<ref->pt()
78  <<" --- constituent "<<index
79  <<" --- pt : "<<fjConstituents[i].perp()
80  <<" --- eta : "<<fjConstituents[i].pseudorapidity()
81  <<" --- phi : "<<fjConstituents[i].phi()
82  <<" --- mass : "<<fjConstituents[i].m()<<endl;
83  subtracted += candidate;
84  }
85  }
86 
87  // Loop over dropped candidates to see whether there is any of them
88  // that would belong to this jet:
90  for(unsigned int i=0; i < droppedCandidates_.size(); ++i){
92  fastjet::PseudoJet dropcand(ref->px(),ref->py(),ref->pz(),ref->energy());
93 
94  if(match(fjJet,dropcand)){
95  unsubtractedDropped += dropcand;
96  unsubtracted += dropcand;
97  }
98  }
99  }
100 
101  fjJet.reset_momentum(subtracted);
102 
103  LogDebug("VoronoiSubtractor")<<"fjJets_ "<<ijet<<" unsubtracted : "<<unsubtracted.pt()<<endl;
104  LogDebug("VoronoiSubtractor")<<"fjJets_ "<<ijet<<" subtracted : "<<subtracted.pt()<<endl;
105  LogDebug("VoronoiSubtractor")<<"fjJets_ "<<ijet<<" dropped : "<<unsubtractedDropped.pt()<<endl;
106  jetOffset_[ijet] = unsubtracted.pt() - fjJet.pt();
107 
108  }
109 
110 
111 
112 
113 
114 
115 
116 
117 
118 
119 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
std::vector< double > jetOffset_
std::vector< fastjet::PseudoJet > * fjJets_
std::vector< int > droppedCandidates_
bool match(fastjet::PseudoJet, fastjet::PseudoJet)
double pt_subtracted() const
edm::Handle< reco::CandidateView > candidates_
void VoronoiSubtractor::setupGeometryMap ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Reimplemented from PileUpSubtractor.

Definition at line 28 of file VoronoiSubtractor.cc.

References backgrounds_, candidates_, droppedCandidates_, PileUpSubtractor::geo_, edm::Event::getByToken(), PileUpSubtractor::jetOffset_, LogDebug, srcCand_, and srcVor_.

29 {
30 
31  LogDebug("VoronoiSubtractor")<<"The subtractor retrieving Voronoi background...\n";
32  geo_ = 0;
33  droppedCandidates_.clear();
34  jetOffset_.clear();
35 
38 
39 }
#define LogDebug(id)
std::vector< double > jetOffset_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
edm::EDGetTokenT< edm::ValueMap< reco::VoronoiBackground > > srcVor_
edm::Handle< reco::VoronoiMap > backgrounds_
std::vector< int > droppedCandidates_
edm::EDGetTokenT< reco::CandidateView > srcCand_
CaloGeometry const * geo_
edm::Handle< reco::CandidateView > candidates_
void VoronoiSubtractor::subtractPedestal ( std::vector< fastjet::PseudoJet > &  coll)
virtual

Reimplemented from PileUpSubtractor.

Definition at line 121 of file VoronoiSubtractor.cc.

References candidates_, droppedCandidates_, cmsHarvester::index, infinitesimalPt_, LogDebug, and reco::VoronoiBackground::pt().

122 {
123 
124  LogDebug("VoronoiSubtractor")<<"The subtractor subtracting pedestals...\n";
125  vector<fastjet::PseudoJet> newcoll;
126 
127  for (vector<fastjet::PseudoJet>::iterator input_object = coll.begin (),
128  fjInputsEnd = coll.end();
129  input_object != fjInputsEnd; ++input_object) {
130 
131  reco::CandidateViewRef ref(candidates_,input_object->user_index());
132  const reco::VoronoiBackground& voronoi = (*backgrounds_)[ref];
133 
134  double ptold = input_object->pt();
135  double ptnew = voronoi.pt();
136 
137  LogDebug("VoronoiSubtractor")<<"pt old : "<<ptold<<" ; pt new : "<<ptnew
138  <<" E : "<<input_object->e()
139  <<" rap : "<<input_object->rapidity()
140  <<" phi : "<<input_object->phi()
141  <<" MASS : "<<input_object->m()<<endl;
142 
143  // Treatment of candidates with negative pt after subtraction
144  if(ptnew < infinitesimalPt_){
145  if(infinitesimalPt_ > 0){
146  // Low-pt candidate is assigned a very small finite pt
147  // so that the jet clustering includes the candidate
148  // and can associate it to the jet.
149  // The original candidate pt is restored
150  // in the offsetCorrectJets() function.
151  ptnew = infinitesimalPt_;
152  }else{
153  // Low-pt candidate is removed from the input collection,
154  // so that the jet clustering algorithm can function properly.
155  // However, we need to keep track of these candidates
156  // in order to determine how much energy has been subtracted in total.
157  droppedCandidates_.push_back(input_object->user_index());
158  continue;
159  }
160  }
161 
162  int index = input_object->user_index();
163 
164  fastjet::PseudoJet ps(input_object->four_mom());
165  ps.reset_PtYPhiM(ptnew,input_object->rapidity(),input_object->phi(),input_object->m());
166  ps.set_user_index(index);
167 
168  LogDebug("VoronoiSubtractor")<<"New momentum : "<<ps.pt()
169  <<" rap : "<<ps.rap()
170  <<" phi : "<<ps.phi()
171  <<" MASS : "<<ps.m()<<endl;
172 
173  newcoll.push_back(ps);
174  }
175  coll = newcoll;
176 }
#define LogDebug(id)
std::vector< int > droppedCandidates_
JetCorrectorParametersCollection coll
Definition: classes.h:10
edm::Handle< reco::CandidateView > candidates_

Member Data Documentation

bool VoronoiSubtractor::addNegative_
private

Definition at line 28 of file VoronoiSubtractor.h.

Referenced by offsetCorrectJets().

bool VoronoiSubtractor::addNegativesFromCone_
private

Definition at line 29 of file VoronoiSubtractor.h.

Referenced by offsetCorrectJets().

edm::Handle<reco::VoronoiMap> VoronoiSubtractor::backgrounds_
private

Definition at line 23 of file VoronoiSubtractor.h.

Referenced by setupGeometryMap().

edm::Handle<reco::CandidateView> VoronoiSubtractor::candidates_
private

Definition at line 22 of file VoronoiSubtractor.h.

Referenced by offsetCorrectJets(), setupGeometryMap(), and subtractPedestal().

std::vector<int> VoronoiSubtractor::droppedCandidates_
private

Definition at line 26 of file VoronoiSubtractor.h.

Referenced by offsetCorrectJets(), setupGeometryMap(), and subtractPedestal().

bool VoronoiSubtractor::dropZeroTowers_
private

Definition at line 27 of file VoronoiSubtractor.h.

double VoronoiSubtractor::infinitesimalPt_
private

Definition at line 30 of file VoronoiSubtractor.h.

Referenced by subtractPedestal().

double VoronoiSubtractor::rParam_
private

Definition at line 31 of file VoronoiSubtractor.h.

edm::EDGetTokenT<reco::CandidateView> VoronoiSubtractor::srcCand_
private

Definition at line 24 of file VoronoiSubtractor.h.

Referenced by setupGeometryMap().

edm::EDGetTokenT<edm::ValueMap<reco::VoronoiBackground> > VoronoiSubtractor::srcVor_
private

Definition at line 25 of file VoronoiSubtractor.h.

Referenced by setupGeometryMap().