CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
HiFJRhoProducer Class Reference

#include <HiJetBackground/HiFJRhoProducer/plugins/HiFJRhoProducer.cc>

Inheritance diagram for HiFJRhoProducer:
edm::stream::EDProducer<>

Public Member Functions

 HiFJRhoProducer (const edm::ParameterSet &)
 
 ~HiFJRhoProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void beginStream (edm::StreamID) override
 
double calcMd (const reco::Jet *jet)
 
double calcMedian (std::vector< double > &v)
 
void endStream () override
 
bool isPackedCandidate (const reco::Candidate *candidate)
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

bool checkJetCand
 
double etaMaxExcl2_
 
double etaMaxExcl_
 
std::vector< double > etaRanges
 
edm::EDGetTokenT< edm::View< reco::Jet > > jetsToken_
 
unsigned int nExcl2_
 
unsigned int nExcl_
 
double ptMinExcl2_
 
double ptMinExcl_
 
edm::InputTag src_
 
bool usingPackedCand
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 26 of file HiFJRhoProducer.h.

Constructor & Destructor Documentation

◆ HiFJRhoProducer()

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

Definition at line 50 of file HiFJRhoProducer.cc.

51  : src_(iConfig.getParameter<edm::InputTag>("jetSource")),
52  nExcl_(iConfig.getParameter<int>("nExcl")),
53  etaMaxExcl_(iConfig.getParameter<double>("etaMaxExcl")),
54  ptMinExcl_(iConfig.getParameter<double>("ptMinExcl")),
55  nExcl2_(iConfig.getParameter<int>("nExcl2")),
56  etaMaxExcl2_(iConfig.getParameter<double>("etaMaxExcl2")),
57  ptMinExcl2_(iConfig.getParameter<double>("ptMinExcl2")),
58  checkJetCand(true),
59  usingPackedCand(false) {
60  jetsToken_ = consumes<edm::View<reco::Jet>>(src_);
61 
62  //register your products
63  produces<std::vector<double>>("mapEtaEdges");
64  produces<std::vector<double>>("mapToRho");
65  produces<std::vector<double>>("mapToRhoM");
66  produces<std::vector<double>>("ptJets");
67  produces<std::vector<double>>("areaJets");
68  produces<std::vector<double>>("etaJets");
69  etaRanges = iConfig.getParameter<std::vector<double>>("etaRanges");
70 }

References etaRanges, edm::ParameterSet::getParameter(), jetsToken_, and src_.

◆ ~HiFJRhoProducer()

HiFJRhoProducer::~HiFJRhoProducer ( )
override

Definition at line 72 of file HiFJRhoProducer.cc.

72  {
73  // do anything here that needs to be done at desctruction time
74  // (e.g. close files, deallocate resources etc.)
75 }

Member Function Documentation

◆ beginStream()

void HiFJRhoProducer::beginStream ( edm::StreamID  )
overrideprivate

Definition at line 179 of file HiFJRhoProducer.cc.

179 {}

◆ calcMd()

double HiFJRhoProducer::calcMd ( const reco::Jet jet)
private

Definition at line 184 of file HiFJRhoProducer.cc.

184  {
185  //
186  //get md as defined in http://arxiv.org/pdf/1211.2811.pdf
187  //
188 
189  //Loop over the jet constituents
190  double sum = 0.;
191  for (auto daughter : jet->getJetConstituentsQuick()) {
192  if (isPackedCandidate(daughter)) { //packed candidate situation
193  auto part = static_cast<const pat::PackedCandidate*>(daughter);
194  sum += sqrt(part->mass() * part->mass() + part->pt() * part->pt()) - part->pt();
195  } else {
196  auto part = static_cast<const reco::PFCandidate*>(daughter);
197  sum += sqrt(part->mass() * part->mass() + part->pt() * part->pt()) - part->pt();
198  }
199  }
200 
201  return sum;
202 }

References isPackedCandidate(), metsig::jet, and mathSSE::sqrt().

Referenced by produce().

◆ calcMedian()

double HiFJRhoProducer::calcMedian ( std::vector< double > &  v)
private

Definition at line 231 of file HiFJRhoProducer.cc.

231  {
232  //post-condition: After returning, the elements in v may be reordered and the resulting order is implementation defined.
233  //works for even and odd collections
234  if (v.empty()) {
235  return 0.0;
236  }
237  auto n = v.size() / 2;
238  std::nth_element(v.begin(), v.begin() + n, v.end());
239  auto med = v[n];
240  if (!(v.size() & 1)) { //If the set size is even
241  auto max_it = std::max_element(v.begin(), v.begin() + n);
242  med = (*max_it + med) / 2.0;
243  }
244  return med;
245 }

References dqmiodumpmetadata::n, and findQualityFiles::v.

Referenced by produce().

◆ endStream()

void HiFJRhoProducer::endStream ( )
overrideprivate

Definition at line 182 of file HiFJRhoProducer.cc.

182 {}

◆ fillDescriptions()

void HiFJRhoProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 217 of file HiFJRhoProducer.cc.

217  {
219  desc.add<edm::InputTag>("jetSource", edm::InputTag("kt4PFJets"));
220  desc.add<int>("nExcl", 2);
221  desc.add<double>("etaMaxExcl", 2.);
222  desc.add<double>("ptMinExcl", 20.);
223  desc.add<int>("nExcl2", 2);
224  desc.add<double>("etaMaxExcl2", 2.);
225  desc.add<double>("ptMinExcl2", 20.);
226  desc.add<std::vector<double>>("etaRanges", {});
227  descriptions.add("hiFJRhoProducer", desc);
228 }

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and HLT_FULL_cff::InputTag.

◆ isPackedCandidate()

bool HiFJRhoProducer::isPackedCandidate ( const reco::Candidate candidate)
private

Definition at line 204 of file HiFJRhoProducer.cc.

204  {
205  if (checkJetCand) {
206  if (typeid(pat::PackedCandidate) == typeid(*candidate))
207  usingPackedCand = true;
208  else if (typeid(reco::PFCandidate) == typeid(*candidate))
209  usingPackedCand = false;
210  else
211  throw cms::Exception("WrongJetCollection", "Jet constituents are not particle flow candidates");
212  checkJetCand = false;
213  }
214  return usingPackedCand;
215 }

References checkJetCand, Exception, and usingPackedCand.

Referenced by calcMd().

◆ produce()

void HiFJRhoProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 78 of file HiFJRhoProducer.cc.

78  {
79  // Get the vector of jets
81  iEvent.getByToken(jetsToken_, jets);
82 
83  int neta = (int)etaRanges.size();
84  auto mapEtaRangesOut = std::make_unique<std::vector<double>>(neta, -999.);
85 
86  for (int ieta = 0; ieta < neta; ieta++) {
87  mapEtaRangesOut->at(ieta) = etaRanges[ieta];
88  }
89  auto mapToRhoOut = std::make_unique<std::vector<double>>(neta - 1, 1e-6);
90  auto mapToRhoMOut = std::make_unique<std::vector<double>>(neta - 1, 1e-6);
91 
92  int njets = jets->size();
93 
94  auto ptJetsOut = std::make_unique<std::vector<double>>(njets, 1e-6);
95  auto areaJetsOut = std::make_unique<std::vector<double>>(njets, 1e-6);
96  auto etaJetsOut = std::make_unique<std::vector<double>>(njets, 1e-6);
97 
98  double rhoVec[999];
99  double rhomVec[999];
100  double etaVec[999];
101 
102  // int neta = (int)mapEtaRangesOut->size();
103  int nacc = 0;
104  unsigned int njetsEx = 0;
105  unsigned int njetsEx2 = 0;
106  for (auto jet = jets->begin(); jet != jets->end(); ++jet) {
107  if (njetsEx < nExcl_ && fabs(jet->eta()) < etaMaxExcl_ && jet->pt() > ptMinExcl_) {
108  njetsEx++;
109  continue;
110  }
111  if (njetsEx2 < nExcl2_ && fabs(jet->eta()) < etaMaxExcl2_ && fabs(jet->eta()) > etaMaxExcl_ &&
112  jet->pt() > ptMinExcl2_) {
113  njetsEx2++;
114  continue;
115  }
116  float pt = jet->pt();
117  float area = jet->jetArea();
118  float eta = jet->eta();
119 
120  if (eta < mapEtaRangesOut->at(0) || eta > mapEtaRangesOut->at(neta - 1))
121  continue;
122  if (area > 0.) {
123  rhoVec[nacc] = pt / area;
124  rhomVec[nacc] = calcMd(&*jet) / area;
125  etaVec[nacc] = eta;
126  ptJetsOut->at(nacc) = pt;
127  areaJetsOut->at(nacc) = area;
128  etaJetsOut->at(nacc) = eta;
129  ++nacc;
130  }
131  }
132 
133  ptJetsOut->resize(nacc);
134  areaJetsOut->resize(nacc);
135  etaJetsOut->resize(nacc);
136  //calculate rho and rhom in eta ranges
137  double radius = 0.2; //distance kt clusters needs to be from edge
138  for (int ieta = 0; ieta < (neta - 1); ieta++) {
139  std::vector<double> rhoVecCur;
140  std::vector<double> rhomVecCur;
141 
142  double etaMin = mapEtaRangesOut->at(ieta) + radius;
143  double etaMax = mapEtaRangesOut->at(ieta + 1) - radius;
144 
145  int naccCur = 0;
146  double rhoCurSum = 0.;
147  double rhomCurSum = 0.;
148  for (int i = 0; i < nacc; i++) {
149  if (etaVec[i] >= etaMin && etaVec[i] < etaMax) {
150  rhoVecCur.push_back(rhoVec[i]);
151  rhomVecCur.push_back(rhomVec[i]);
152 
153  rhoCurSum += rhoVec[i];
154  rhomCurSum += rhomVec[i];
155  ++naccCur;
156  } //eta selection
157  } //accepted jet loop
158 
159  if (naccCur > 0) {
160  double rhoCur = calcMedian(rhoVecCur);
161  double rhomCur = calcMedian(rhomVecCur);
162  mapToRhoOut->at(ieta) = rhoCur;
163  mapToRhoMOut->at(ieta) = rhomCur;
164  }
165  } //eta ranges
166 
167  iEvent.put(std::move(mapEtaRangesOut), "mapEtaEdges");
168  iEvent.put(std::move(mapToRhoOut), "mapToRho");
169  iEvent.put(std::move(mapToRhoMOut), "mapToRhoM");
170 
171  iEvent.put(std::move(ptJetsOut), "ptJets");
172  iEvent.put(std::move(areaJetsOut), "areaJets");
173  iEvent.put(std::move(etaJetsOut), "etaJets");
174 
175  return;
176 }

References custom_jme_cff::area, calcMd(), calcMedian(), MillePedeFileConverter_cfg::e, PVValHelper::eta, ALCARECOTkAlBeamHalo_cff::etaMax, etaMaxExcl2_, etaMaxExcl_, ALCARECOTkAlBeamHalo_cff::etaMin, etaRanges, mps_fire::i, LEDCalibrationChannels::ieta, iEvent, createfilelist::int, metsig::jet, singleTopDQM_cfi::jets, jetsToken_, eostools::move(), neta, nExcl2_, nExcl_, BTaggingMonitoring_cff::njets, DiDispStaMuonMonitor_cfi::pt, ptMinExcl2_, ptMinExcl_, and CosmicsPD_Skims::radius.

Member Data Documentation

◆ checkJetCand

bool HiFJRhoProducer::checkJetCand
private

Definition at line 55 of file HiFJRhoProducer.h.

Referenced by isPackedCandidate().

◆ etaMaxExcl2_

double HiFJRhoProducer::etaMaxExcl2_
private

Definition at line 52 of file HiFJRhoProducer.h.

Referenced by produce().

◆ etaMaxExcl_

double HiFJRhoProducer::etaMaxExcl_
private

Definition at line 49 of file HiFJRhoProducer.h.

Referenced by produce().

◆ etaRanges

std::vector<double> HiFJRhoProducer::etaRanges
private

Definition at line 54 of file HiFJRhoProducer.h.

Referenced by HiFJRhoProducer(), and produce().

◆ jetsToken_

edm::EDGetTokenT<edm::View<reco::Jet> > HiFJRhoProducer::jetsToken_
private

Definition at line 44 of file HiFJRhoProducer.h.

Referenced by HiFJRhoProducer(), and produce().

◆ nExcl2_

unsigned int HiFJRhoProducer::nExcl2_
private

Definition at line 51 of file HiFJRhoProducer.h.

Referenced by produce().

◆ nExcl_

unsigned int HiFJRhoProducer::nExcl_
private

Definition at line 48 of file HiFJRhoProducer.h.

Referenced by produce().

◆ ptMinExcl2_

double HiFJRhoProducer::ptMinExcl2_
private

Definition at line 53 of file HiFJRhoProducer.h.

Referenced by produce().

◆ ptMinExcl_

double HiFJRhoProducer::ptMinExcl_
private

Definition at line 50 of file HiFJRhoProducer.h.

Referenced by produce().

◆ src_

edm::InputTag HiFJRhoProducer::src_
private

Definition at line 47 of file HiFJRhoProducer.h.

Referenced by HiFJRhoProducer().

◆ usingPackedCand

bool HiFJRhoProducer::usingPackedCand
private

Definition at line 55 of file HiFJRhoProducer.h.

Referenced by isPackedCandidate().

neta
const int neta
Definition: CMTRawAnalyzer.h:423
ALCARECOTkAlBeamHalo_cff.etaMin
etaMin
GeV.
Definition: ALCARECOTkAlBeamHalo_cff.py:32
mps_fire.i
i
Definition: mps_fire.py:428
HiFJRhoProducer::ptMinExcl2_
double ptMinExcl2_
Definition: HiFJRhoProducer.h:53
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
HiFJRhoProducer::calcMd
double calcMd(const reco::Jet *jet)
Definition: HiFJRhoProducer.cc:184
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
findQualityFiles.v
v
Definition: findQualityFiles.py:179
edm::Handle
Definition: AssociativeIterator.h:50
HiFJRhoProducer::src_
edm::InputTag src_
Definition: HiFJRhoProducer.h:47
part
part
Definition: HCALResponse.h:20
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
HiFJRhoProducer::usingPackedCand
bool usingPackedCand
Definition: HiFJRhoProducer.h:55
PVValHelper::eta
Definition: PVValidationHelpers.h:70
HiFJRhoProducer::nExcl2_
unsigned int nExcl2_
Definition: HiFJRhoProducer.h:51
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HiFJRhoProducer::calcMedian
double calcMedian(std::vector< double > &v)
Definition: HiFJRhoProducer.cc:231
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
HiFJRhoProducer::etaRanges
std::vector< double > etaRanges
Definition: HiFJRhoProducer.h:54
HiFJRhoProducer::etaMaxExcl2_
double etaMaxExcl2_
Definition: HiFJRhoProducer.h:52
HiFJRhoProducer::isPackedCandidate
bool isPackedCandidate(const reco::Candidate *candidate)
Definition: HiFJRhoProducer.cc:204
pat::PackedCandidate
Definition: PackedCandidate.h:22
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
HiFJRhoProducer::etaMaxExcl_
double etaMaxExcl_
Definition: HiFJRhoProducer.h:49
HiFJRhoProducer::ptMinExcl_
double ptMinExcl_
Definition: HiFJRhoProducer.h:50
HiFJRhoProducer::jetsToken_
edm::EDGetTokenT< edm::View< reco::Jet > > jetsToken_
Definition: HiFJRhoProducer.h:44
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
HiFJRhoProducer::nExcl_
unsigned int nExcl_
Definition: HiFJRhoProducer.h:48
eostools.move
def move(src, dest)
Definition: eostools.py:511
HiFJRhoProducer::checkJetCand
bool checkJetCand
Definition: HiFJRhoProducer.h:55
BTaggingMonitoring_cff.njets
njets
Definition: BTaggingMonitoring_cff.py:10
metsig::jet
Definition: SignAlgoResolutions.h:47
Exception
Definition: hltDiff.cc:245
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
ALCARECOTkAlBeamHalo_cff.etaMax
etaMax
Definition: ALCARECOTkAlBeamHalo_cff.py:33
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
reco::PFCandidate
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
custom_jme_cff.area
area
Definition: custom_jme_cff.py:140
edm::InputTag
Definition: InputTag.h:15
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37