CMS 3D CMS Logo

L1EGammaEEProducer.cc
Go to the documentation of this file.
5 
11 
12 namespace l1tp2 {
13  // we sort the clusters in pt
15  return cl1->pt() > cl2->pt();
16  }
17 }; // namespace l1tp2
18 
20  static float constexpr eta_min = 1.;
21  static float constexpr eta_max = 4.;
22  static unsigned constexpr n_eta_bins = 150;
23  int eta_bin = floor((std::abs(cl->eta()) - eta_min) / ((eta_max - eta_min) / n_eta_bins));
24  if (cl->eta() < 0)
25  return -1 * eta_bin; // bin 0 doesn't exist
26  return eta_bin;
27 }
28 
30  static constexpr float phi_min = -M_PI;
31  static constexpr float phi_max = M_PI;
32  static constexpr unsigned n_phi_bins = 63;
33  return floor(std::abs(reco::deltaPhi(cl->phi(), phi_min)) / ((phi_max - phi_min) / n_phi_bins));
34 }
35 
36 pair<int, int> get_eta_phi_bin(const l1t::HGCalMulticluster *cl) { return std::make_pair(etaBin(cl), get_phi_bin(cl)); }
37 
39 public:
40  explicit L1EGammaEEProducer(const edm::ParameterSet &);
41 
42 private:
43  void produce(edm::Event &, const edm::EventSetup &) override;
44 
47 };
48 
50  : multiclusters_token_(
51  consumes<l1t::HGCalMulticlusterBxCollection>(iConfig.getParameter<edm::InputTag>("Multiclusters"))),
52  calibrator_(iConfig.getParameter<edm::ParameterSet>("calibrationConfig")) {
53  produces<BXVector<l1t::EGamma>>("L1EGammaCollectionBXVWithCuts");
54 }
55 
57  float minEt_ = 0;
58 
59  std::unique_ptr<BXVector<l1t::EGamma>> l1EgammaBxCollection(new l1t::EGammaBxCollection);
60 
61  // retrieve clusters 3D
63  iEvent.getByToken(multiclusters_token_, multiclusters_h);
64  const l1t::HGCalMulticlusterBxCollection &multiclusters = *multiclusters_h;
65 
66  std::vector<const l1t::HGCalMulticluster *> selected_multiclusters;
67  std::map<std::pair<int, int>, std::vector<const l1t::HGCalMulticluster *>> etaphi_bins;
68 
69  // here we loop on the TPGs
70  for (auto cl3d = multiclusters.begin(0); cl3d != multiclusters.end(0); cl3d++) {
71  if (cl3d->hwQual()) {
72  if (cl3d->et() > minEt_) {
73  int hw_quality = 1; // baseline EG ID passed
74  if (std::abs(cl3d->eta()) >= 1.52) {
75  hw_quality = 2; // baseline EG ID passed + cleanup of transition region
76  }
77 
78  float calib_factor = calibrator_.calibrationFactor(cl3d->pt(), cl3d->eta());
79  l1t::EGamma eg =
80  l1t::EGamma(reco::Candidate::PolarLorentzVector(cl3d->pt() / calib_factor, cl3d->eta(), cl3d->phi(), 0.));
81  eg.setHwQual(hw_quality);
82  eg.setHwIso(1);
83  eg.setIsoEt(-1); // just temporarily as a dummy value
84  l1EgammaBxCollection->push_back(0, eg);
85  if (hw_quality == 2) {
86  // we build the EM interpreted EG object
88  cl3d->iPt(l1t::HGCalMulticluster::EnergyInterpretation::EM), cl3d->eta(), cl3d->phi(), 0.));
89  eg_emint.setHwQual(4);
90  eg_emint.setHwIso(1);
91  eg_emint.setIsoEt(-1); // just temporarily as a dummy value
92  l1EgammaBxCollection->push_back(0, eg_emint);
93  // we also prepare for the brem recovery procedure
94  selected_multiclusters.push_back(&(*cl3d));
95  auto eta_phi_bin = get_eta_phi_bin(&(*cl3d));
96  auto bucket = etaphi_bins.find(eta_phi_bin);
97  if (bucket == etaphi_bins.end()) {
98  std::vector<const l1t::HGCalMulticluster *> vec;
99  vec.push_back(&(*cl3d));
100  etaphi_bins[eta_phi_bin] = vec;
101  } else {
102  bucket->second.push_back(&(*cl3d));
103  }
104  }
105  }
106  }
107  }
108 
109  std::sort(selected_multiclusters.begin(), selected_multiclusters.end(), l1tp2::compare_cluster_pt);
110  std::set<const l1t::HGCalMulticluster *> used_clusters;
111  for (const auto &cl3d : selected_multiclusters) {
112  if (used_clusters.find(cl3d) == used_clusters.end()) {
113  float pt = cl3d->pt();
114  // we drop the Had component of the energy
115  if (cl3d->hOverE() != -1)
116  pt = cl3d->pt() / (1 + cl3d->hOverE());
117  reco::Candidate::PolarLorentzVector mom(pt, cl3d->eta(), cl3d->phi(), 0.);
119  cl3d->iPt(l1t::HGCalMulticluster::EnergyInterpretation::EM), cl3d->eta(), cl3d->phi(), 0.);
120 
121  // this is not yet used
122  used_clusters.insert(cl3d);
123  auto eta_phi_bin = get_eta_phi_bin(cl3d);
124 
125  for (int eta_bin : {eta_phi_bin.first - 1, eta_phi_bin.first, eta_phi_bin.first + 1}) {
126  for (int phi_bin : {eta_phi_bin.second - 1, eta_phi_bin.second, eta_phi_bin.second + 1}) {
127  auto bucket = etaphi_bins.find(std::make_pair(eta_bin, phi_bin));
128  if (bucket != etaphi_bins.end()) {
129  // this bucket is not empty
130  for (const auto &other_cl_ptr : bucket->second) {
131  if (used_clusters.find(other_cl_ptr) == used_clusters.end()) {
132  if (std::abs(other_cl_ptr->eta() - cl3d->eta()) < 0.02) {
133  if (std::abs(reco::deltaPhi(other_cl_ptr->phi(), cl3d->phi())) < 0.1) {
134  float pt_other = other_cl_ptr->pt();
135  if (other_cl_ptr->hOverE() != -1)
136  pt_other = other_cl_ptr->pt() / (1 + other_cl_ptr->hOverE());
137  mom += reco::Candidate::PolarLorentzVector(pt_other, other_cl_ptr->eta(), other_cl_ptr->phi(), 0.);
139  other_cl_ptr->iPt(l1t::HGCalMulticluster::EnergyInterpretation::EM),
140  other_cl_ptr->eta(),
141  other_cl_ptr->phi(),
142  0.);
143  used_clusters.insert(other_cl_ptr);
144  }
145  }
146  }
147  }
148  }
149  }
150  }
151  float calib_factor = calibrator_.calibrationFactor(mom.pt(), mom.eta());
152  l1t::EGamma eg =
153  l1t::EGamma(reco::Candidate::PolarLorentzVector(mom.pt() / calib_factor, mom.eta(), mom.phi(), 0.));
154  eg.setHwQual(3);
155  eg.setHwIso(1);
156  l1EgammaBxCollection->push_back(0, eg);
157 
158  l1t::EGamma eg_emint_brec =
159  l1t::EGamma(reco::Candidate::PolarLorentzVector(mom_eint.pt(), mom_eint.eta(), mom_eint.phi(), 0.));
160  eg_emint_brec.setHwQual(5);
161  eg_emint_brec.setHwIso(1);
162  l1EgammaBxCollection->push_back(0, eg_emint_brec);
163  }
164  }
165 
166  iEvent.put(std::move(l1EgammaBxCollection), "L1EGammaCollectionBXVWithCuts");
167 }
168 
L1EGammaEEProducer
Definition: L1EGammaEEProducer.cc:38
ESHandle.h
etaBin
int etaBin(const l1t::HGCalMulticluster *cl)
Definition: L1EGammaEEProducer.cc:19
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
reco::deltaPhi
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
deltaPhi.h
edm
HLT enums.
Definition: AlignableModifier.h:19
reco::Candidate::PolarLorentzVector
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:38
egammaIdentification.eta_min
eta_min
Definition: egammaIdentification.py:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
l1t::HGCalMulticlusterBxCollection
BXVector< HGCalMulticluster > HGCalMulticlusterBxCollection
Definition: HGCalMulticluster.h:95
EDProducer.h
l1t::EGamma::setIsoEt
void setIsoEt(short int iso)
Definition: EGamma.cc:34
L1EGammaEEProducer::calibrator_
L1EGammaEECalibrator calibrator_
Definition: L1EGammaEEProducer.cc:46
GetRecoTauVFromDQM_MC_cff.cl2
cl2
Definition: GetRecoTauVFromDQM_MC_cff.py:44
get_eta_phi_bin
pair< int, int > get_eta_phi_bin(const l1t::HGCalMulticluster *cl)
Definition: L1EGammaEEProducer.cc:36
reco::LeafCandidate::pt
double pt() const final
transverse momentum
Definition: LeafCandidate.h:146
L1EGammaEEProducer::L1EGammaEEProducer
L1EGammaEEProducer(const edm::ParameterSet &)
Definition: L1EGammaEEProducer.cc:49
edm::Handle
Definition: AssociativeIterator.h:50
L1EGammaEEProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: L1EGammaEEProducer.cc:56
BXVector
Definition: BXVector.h:15
GetRecoTauVFromDQM_MC_cff.cl
cl
Definition: GetRecoTauVFromDQM_MC_cff.py:38
l1t::HGCalMulticluster
Definition: HGCalMulticluster.h:13
MakerMacros.h
HGCalMulticluster.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
EGamma.h
l1t::L1Candidate::setHwQual
void setHwQual(int qual)
Definition: L1Candidate.h:31
BXVector::begin
const_iterator begin(int bx) const
egammaIdentification.eta_max
eta_max
Definition: egammaIdentification.py:19
BXVector::end
const_iterator end(int bx) const
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
ParameterSet
Definition: Functions.h:16
L1EGammaEECalibrator::calibrationFactor
float calibrationFactor(const float &pt, const float &eta) const
Definition: L1EGammaEECalibrator.cc:54
l1t
delete x;
Definition: CaloConfig.h:22
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
iEvent
int iEvent
Definition: GenABIO.cc:224
l1tp2::compare_cluster_pt
bool compare_cluster_pt(const l1t::HGCalMulticluster *cl1, const l1t::HGCalMulticluster *cl2)
Definition: L1EGammaEEProducer.cc:14
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
edm::stream::EDProducer
Definition: EDProducer.h:36
L1EGammaEECalibrator
Definition: L1EGammaEECalibrator.h:9
l1t::EGamma
Definition: EGamma.h:20
edm::EventSetup
Definition: EventSetup.h:58
edm::EDGetToken
Definition: EDGetToken.h:35
get_phi_bin
int get_phi_bin(const l1t::HGCalMulticluster *cl)
Definition: L1EGammaEEProducer.cc:29
eostools.move
def move(src, dest)
Definition: eostools.py:511
L1EGammaEECalibrator.h
L1EGammaEEProducer::multiclusters_token_
edm::EDGetToken multiclusters_token_
Definition: L1EGammaEEProducer.cc:45
HLT_FULL_cff.EGamma
EGamma
Definition: HLT_FULL_cff.py:3928
l1t::L1Candidate::setHwIso
void setHwIso(int iso)
Definition: L1Candidate.h:32
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
n_eta_bins
static constexpr int n_eta_bins
Definition: L1EGammaCrystalsEmulatorProducer.cc:61
edm::Event
Definition: Event.h:73
l1tp2
Definition: CaloCrystalCluster.h:11