CMS 3D CMS Logo

HFJetShowerShape.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HFJetShowerShape/HFJetShowerShape
4 // Class: HFJetShowerShape
5 //
13 //
14 // Original Author: Laurent Thomas
15 // Created: Tue, 25 Aug 2020 09:17:42 GMT
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
25 
28 
31 
34 
36 
37 #include <iostream>
38 
39 //
40 // class declaration
41 //
42 
44 public:
45  explicit HFJetShowerShape(const edm::ParameterSet&);
46 
47  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
48 
49 private:
50  void produce(edm::Event&, const edm::EventSetup&) override;
51  template <typename T>
52  void putInEvent(const std::string&, const edm::Handle<edm::View<reco::Jet>>&, std::vector<T>, edm::Event&) const;
53 
56 
57  //Jet pt/eta thresholds
59  //HF geometry
61  //Variables for PU subtraction
63  //Pt thresholds for showershape variable calculation
65 };
66 
67 //
68 // constants, enums and typedefs
69 //
70 
71 //
72 // static data member definitions
73 //
74 
75 //
76 // constructors and destructor
77 //
79  : jets_token_(consumes<edm::View<reco::Jet>>(iConfig.getParameter<edm::InputTag>("jets"))),
80  vertices_token_(consumes<std::vector<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("vertices"))),
81  jetPtThreshold_(iConfig.getParameter<double>("jetPtThreshold")),
82  jetEtaThreshold_(iConfig.getParameter<double>("jetEtaThreshold")),
83  hfTowerEtaWidth_(iConfig.getParameter<double>("hfTowerEtaWidth")),
84  hfTowerPhiWidth_(iConfig.getParameter<double>("hfTowerPhiWidth")),
85  vertexRecoEffcy_(iConfig.getParameter<double>("vertexRecoEffcy")),
86  offsetPerPU_(iConfig.getParameter<double>("offsetPerPU")),
87  jetReferenceRadius_(iConfig.getParameter<double>("jetReferenceRadius")),
88  stripPtThreshold_(iConfig.getParameter<double>("stripPtThreshold")),
89  widthPtThreshold_(iConfig.getParameter<double>("widthPtThreshold")) {
90  produces<edm::ValueMap<float>>("sigmaEtaEta");
91  produces<edm::ValueMap<float>>("sigmaPhiPhi");
92  produces<edm::ValueMap<int>>("centralEtaStripSize");
93  produces<edm::ValueMap<int>>("adjacentEtaStripsSize");
94 }
95 
96 //
97 // member functions
98 //
99 
100 // ------------ method called to produce the data ------------
102  using namespace edm;
103 
104  //Jets
105  auto theJets = iEvent.getHandle(jets_token_);
106 
107  //Vertices
108  int nPV = iEvent.get(vertices_token_).size();
109 
110  //Products
111  std::vector<float> v_sigmaEtaEta, v_sigmaPhiPhi;
112  v_sigmaEtaEta.reserve(theJets->size());
113  v_sigmaPhiPhi.reserve(theJets->size());
114  std::vector<int> v_size_CentralEtaStrip, v_size_AdjacentEtaStrips;
115  v_size_CentralEtaStrip.reserve(theJets->size());
116  v_size_AdjacentEtaStrips.reserve(theJets->size());
117 
118  //Et offset for HF PF candidates
119  double puoffset = offsetPerPU_ / (M_PI * jetReferenceRadius_ * jetReferenceRadius_) * nPV / vertexRecoEffcy_ *
121 
122  for (auto const& jet : *theJets) {
123  double pt_jet = jet.pt();
124  double eta_jet = jet.eta();
125 
126  //If central or low pt jets, fill with dummy variables
127  if (pt_jet <= jetPtThreshold_ || std::abs(eta_jet) <= jetEtaThreshold_) {
128  v_sigmaEtaEta.push_back(-1.);
129  v_sigmaPhiPhi.push_back(-1.);
130  v_size_CentralEtaStrip.push_back(0);
131  v_size_AdjacentEtaStrips.push_back(0);
132  } else {
133  //First loop over PF candidates to compute some global variables needed for shower shape calculations
134  double sumptPFcands = 0.;
135 
136  for (unsigned i = 0; i < jet.numberOfSourceCandidatePtrs(); ++i) {
137  const reco::Candidate* icand = jet.sourceCandidatePtr(i).get();
138  //Only look at pdgId =1,2 (HF PF cands)
139  if (std::abs(icand->pdgId()) > 2)
140  continue;
141  double pt_PUsub = icand->pt() - puoffset;
142  if (pt_PUsub < widthPtThreshold_)
143  continue;
144  sumptPFcands += pt_PUsub;
145  }
146 
147  //Second loop to compute the various shower shape variables
148  int size_CentralEtaStrip(0.), size_AdjacentEtaStrips(0.);
149  double sigmaEtaEtaSq(0.), sigmaPhiPhiSq(0.);
150  double sumweightsPFcands = 0;
151  for (unsigned i = 0; i < jet.numberOfSourceCandidatePtrs(); ++i) {
152  const reco::Candidate* icand = jet.sourceCandidatePtr(i).get();
153  //Only look at pdgId =1,2 (HF PF cands)
154  if (std::abs(icand->pdgId()) > 2)
155  continue;
156 
157  double deta = std::abs(icand->eta() - jet.eta());
158  double dphi = std::abs(deltaPhi(icand->phi(), jet.phi()));
159  double pt_PUsub = icand->pt() - puoffset;
160 
161  //This is simply the size of the central eta strip and the adjacent strips
162  if (pt_PUsub >= stripPtThreshold_) {
163  if (dphi <= hfTowerPhiWidth_ * 0.5)
164  size_CentralEtaStrip++;
165  else if (dphi <= hfTowerPhiWidth_ * 1.5)
166  size_AdjacentEtaStrips++;
167  }
168 
169  //Now computing sigmaEtaEta/PhiPhi
170  if (pt_PUsub >= widthPtThreshold_ && sumptPFcands > 0) {
171  double weight = pt_PUsub / sumptPFcands;
172  sigmaEtaEtaSq += deta * deta * weight;
173  sigmaPhiPhiSq += dphi * dphi * weight;
174  sumweightsPFcands += weight;
175  }
176  }
177 
178  v_size_CentralEtaStrip.push_back(size_CentralEtaStrip);
179  v_size_AdjacentEtaStrips.push_back(size_AdjacentEtaStrips);
180 
181  if (sumweightsPFcands > 0 && sigmaEtaEtaSq > 0 && sigmaPhiPhiSq > 0) {
182  v_sigmaEtaEta.push_back(sqrt(sigmaEtaEtaSq / sumweightsPFcands));
183  v_sigmaPhiPhi.push_back(sqrt(sigmaPhiPhiSq / sumweightsPFcands));
184  } else {
185  v_sigmaEtaEta.push_back(-1.);
186  v_sigmaPhiPhi.push_back(-1.);
187  }
188 
189  } //End loop over jets
190  }
191 
192  putInEvent("sigmaEtaEta", theJets, v_sigmaEtaEta, iEvent);
193  putInEvent("sigmaPhiPhi", theJets, v_sigmaPhiPhi, iEvent);
194  putInEvent("centralEtaStripSize", theJets, v_size_CentralEtaStrip, iEvent);
195  putInEvent("adjacentEtaStripsSize", theJets, v_size_AdjacentEtaStrips, iEvent);
196 }
197 
199 template <typename T>
202  std::vector<T> product,
203  edm::Event& iEvent) const {
204  auto out = std::make_unique<edm::ValueMap<T>>();
206  filler.insert(jets, product.begin(), product.end());
207  filler.fill();
208  iEvent.put(std::move(out), name);
209 }
210 
211 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
214  desc.add<edm::InputTag>("jets", edm::InputTag("ak4PFJetsCHS"));
215  desc.add<edm::InputTag>("vertices", edm::InputTag("offlineSlimmedPrimaryVertices"));
216  desc.add<double>("jetPtThreshold", 25.);
217  desc.add<double>("jetEtaThreshold", 2.9);
218  desc.add<double>("hfTowerEtaWidth", 0.175);
219  desc.add<double>("hfTowerPhiWidth", 0.175);
220  desc.add<double>("vertexRecoEffcy", 0.7);
221  desc.add<double>("offsetPerPU", 0.4);
222  desc.add<double>("jetReferenceRadius", 0.4);
223  desc.add<double>("stripPtThreshold", 10.);
224  desc.add<double>("widthPtThreshold", 3.);
225  descriptions.add("hfJetShowerShape", desc);
226 }
227 
228 //define this as a plug-in
HFJetShowerShape::offsetPerPU_
const double offsetPerPU_
Definition: HFJetShowerShape.cc:62
mps_fire.i
i
Definition: mps_fire.py:428
HFJetShowerShape::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HFJetShowerShape.cc:212
HFJetShowerShape::jets_token_
const edm::EDGetTokenT< edm::View< reco::Jet > > jets_token_
Definition: HFJetShowerShape.cc:54
HFJetShowerShape::jetPtThreshold_
const double jetPtThreshold_
Definition: HFJetShowerShape.cc:58
sistrip::View
View
Definition: ConstantsForView.h:26
HFJetShowerShape::vertices_token_
const edm::EDGetTokenT< std::vector< reco::Vertex > > vertices_token_
Definition: HFJetShowerShape.cc:55
deltaPhi.h
reco::Candidate::eta
virtual double eta() const =0
momentum pseudorapidity
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
mps_merge.weight
weight
Definition: mps_merge.py:88
PFJet.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
reco::Candidate::pt
virtual double pt() const =0
transverse momentum
EDProducer.h
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
HFJetShowerShape::HFJetShowerShape
HFJetShowerShape(const edm::ParameterSet &)
Definition: HFJetShowerShape.cc:78
HFJetShowerShape::stripPtThreshold_
const double stripPtThreshold_
Definition: HFJetShowerShape.cc:64
HFJetShowerShape::jetEtaThreshold_
const double jetEtaThreshold_
Definition: HFJetShowerShape.cc:58
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Jet
Definition: Jet.py:1
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HFJetShowerShape::hfTowerEtaWidth_
const double hfTowerEtaWidth_
Definition: HFJetShowerShape.cc:60
HFJetShowerShape::jetReferenceRadius_
const double jetReferenceRadius_
Definition: HFJetShowerShape.cc:62
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Vertex.h
edm::View
Definition: CaloClusterFwd.h:14
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
iEvent
int iEvent
Definition: GenABIO.cc:224
HFJetShowerShape::vertexRecoEffcy_
const double vertexRecoEffcy_
Definition: HFJetShowerShape.cc:62
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:58
HFJetShowerShape
Definition: HFJetShowerShape.cc:43
reco::Candidate::pdgId
virtual int pdgId() const =0
PDG identifier.
HFJetShowerShape::widthPtThreshold_
const double widthPtThreshold_
Definition: HFJetShowerShape.cc:64
reco::Candidate
Definition: Candidate.h:27
HFJetShowerShape::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: HFJetShowerShape.cc:101
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
HltBtagValidation_cff.Vertex
Vertex
Definition: HltBtagValidation_cff.py:32
Frameworkfwd.h
metsig::jet
Definition: SignAlgoResolutions.h:47
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
edm::helper::Filler
Definition: ValueMap.h:22
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
edm::Event
Definition: Event.h:73
reco::Candidate::phi
virtual double phi() const =0
momentum azimuthal angle
StreamID.h
HFJetShowerShape::putInEvent
void putInEvent(const std::string &, const edm::Handle< edm::View< reco::Jet >> &, std::vector< T >, edm::Event &) const
Function to put product into event.
Definition: HFJetShowerShape.cc:200
HFJetShowerShape::hfTowerPhiWidth_
const double hfTowerPhiWidth_
Definition: HFJetShowerShape.cc:60
edm::InputTag
Definition: InputTag.h:15
weight
Definition: weight.py:1