CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
l1tpf::PFClusterProducerFromHGC3DClusters Class Reference
Inheritance diagram for l1tpf::PFClusterProducerFromHGC3DClusters:
edm::stream::EDProducer<>

Public Member Functions

 PFClusterProducerFromHGC3DClusters (const edm::ParameterSet &)
 
 ~PFClusterProducerFromHGC3DClusters () 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
 

Private Types

enum  UseEmInterp { UseEmInterp::No, UseEmInterp::EmOnly, UseEmInterp::AllKeepHad, UseEmInterp::AllKeepTot }
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

l1tpf::corrector corrector_
 
bool emOnly_
 
l1tpf::HGC3DClusterEgID emVsPionID_
 
l1tpf::HGC3DClusterEgID emVsPUID_
 
double etCut_
 
bool hasEmId_
 
StringCutObjectSelector< l1t::HGCalMulticlusterpreEmId_
 
l1tpf::ParametricResolution resol_
 
UseEmInterp scenario_
 
edm::EDGetTokenT< l1t::HGCalMulticlusterBxCollectionsrc_
 

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

Definition at line 17 of file PFClusterProducerFromHGC3DClusters.cc.

Member Enumeration Documentation

◆ UseEmInterp

Enumerator
No 
EmOnly 
AllKeepHad 
AllKeepTot 

Definition at line 23 of file PFClusterProducerFromHGC3DClusters.cc.

23 { No, EmOnly, AllKeepHad, AllKeepTot };

Constructor & Destructor Documentation

◆ PFClusterProducerFromHGC3DClusters()

l1tpf::PFClusterProducerFromHGC3DClusters::PFClusterProducerFromHGC3DClusters ( const edm::ParameterSet iConfig)
explicit

Definition at line 40 of file PFClusterProducerFromHGC3DClusters.cc.

References AllKeepHad, AllKeepTot, EmOnly, emOnly_, emVsPionID_, emVsPUID_, Exception, edm::ParameterSet::getParameter(), hasEmId_, l1tpf::HGC3DClusterEgID::method(), l1tpf::HGC3DClusterEgID::prepareTMVA(), scenario_, and AlCaHLTBitMon_QueryRunRegistry::string.

41  : src_(consumes<l1t::HGCalMulticlusterBxCollection>(iConfig.getParameter<edm::InputTag>("src"))),
43  emOnly_(iConfig.getParameter<bool>("emOnly")),
44  etCut_(iConfig.getParameter<double>("etMin")),
45  preEmId_(iConfig.getParameter<std::string>("preEmId")),
46  emVsPionID_(iConfig.getParameter<edm::ParameterSet>("emVsPionID")),
47  emVsPUID_(iConfig.getParameter<edm::ParameterSet>("emVsPUID")),
48  hasEmId_((iConfig.existsAs<std::string>("preEmId") && !iConfig.getParameter<std::string>("preEmId").empty()) ||
49  !emVsPionID_.method().empty()),
50  corrector_(iConfig.getParameter<std::string>("corrector"),
51  emOnly_ || iConfig.getParameter<std::string>("corrector").empty()
52  ? -1
53  : iConfig.getParameter<double>("correctorEmfMax")),
54  resol_(iConfig.getParameter<edm::ParameterSet>("resol")) {
55  if (!emVsPionID_.method().empty()) {
57  }
58  if (!emVsPUID_.method().empty()) {
60  }
61 
62  produces<l1t::PFClusterCollection>();
63  produces<l1t::PFClusterCollection>("egamma");
64  if (hasEmId_) {
65  produces<l1t::PFClusterCollection>("em");
66  produces<l1t::PFClusterCollection>("had");
67  }
68 
69  std::string scenario = iConfig.getParameter<std::string>("useEMInterpretation");
70  if (scenario == "emOnly") {
72  } else if (scenario == "allKeepHad") {
74  if (emOnly_) {
75  throw cms::Exception("Configuration", "Unsupported emOnly = True when useEMInterpretation is " + scenario);
76  }
77  } else if (scenario == "allKeepTot") {
79  if (emOnly_) {
80  throw cms::Exception("Configuration", "Unsupported emOnly = True when useEMInterpretation is " + scenario);
81  }
82  } else if (scenario != "no") {
83  throw cms::Exception("Configuration", "Unsupported useEMInterpretation scenario " + scenario);
84  }
85 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
scenario
Definition: constants.h:173
edm::EDGetTokenT< l1t::HGCalMulticlusterBxCollection > src_
StringCutObjectSelector< l1t::HGCalMulticluster > preEmId_

◆ ~PFClusterProducerFromHGC3DClusters()

l1tpf::PFClusterProducerFromHGC3DClusters::~PFClusterProducerFromHGC3DClusters ( )
inlineoverride

Definition at line 20 of file PFClusterProducerFromHGC3DClusters.cc.

20 {}

Member Function Documentation

◆ produce()

void l1tpf::PFClusterProducerFromHGC3DClusters::produce ( edm::Event iEvent,
const edm::EventSetup  
)
overrideprivate

Definition at line 87 of file PFClusterProducerFromHGC3DClusters.cc.

References funct::abs(), BXVector< T >::begin(), BXVector< T >::end(), electrons_cff::hoe, iEvent, BXVector< T >::key(), eostools::move(), MillePedeFileConverter_cfg::out, DiDispStaMuonMonitor_cfi::pt, push_back(), and l1t::L1Candidate::setHwQual().

87  {
88  auto out = std::make_unique<l1t::PFClusterCollection>();
89  auto outEgamma = std::make_unique<l1t::PFClusterCollection>();
90  std::unique_ptr<l1t::PFClusterCollection> outEm, outHad;
91  if (hasEmId_) {
92  outEm = std::make_unique<l1t::PFClusterCollection>();
93  outHad = std::make_unique<l1t::PFClusterCollection>();
94  }
96  iEvent.getByToken(src_, multiclusters);
97 
98  for (auto it = multiclusters->begin(0), ed = multiclusters->end(0); it != ed; ++it) {
99  float pt = it->pt(), hoe = it->hOverE();
100  bool isEM = hasEmId_ ? preEmId_(*it) : emOnly_;
101  if (emOnly_) {
102  if (hoe == -1)
103  continue;
104  pt /= (1 + hoe);
105  hoe = 0;
106  }
107  if (pt <= etCut_)
108  continue;
109 
110  // this block below is to support the older EG emulators, and is not used in newer ones
111  if (it->hwQual()) { // this is the EG ID shipped with the HGC TPs
112  // we use the EM interpretation of the cluster energy
113  l1t::PFCluster egcluster(
114  it->iPt(l1t::HGCalMulticluster::EnergyInterpretation::EM), it->eta(), it->phi(), hoe, false);
115  egcluster.setHwQual(it->hwQual());
116  egcluster.addConstituent(edm::Ptr<l1t::L1Candidate>(multiclusters, multiclusters->key(it)));
117  outEgamma->push_back(egcluster);
118  }
119 
120  l1t::PFCluster cluster(pt, it->eta(), it->phi(), hoe);
121  if (scenario_ == UseEmInterp::EmOnly) { // for emID objs, use EM interp as pT and set H = 0
122  if (isEM) {
123  float pt_new = it->iPt(l1t::HGCalMulticluster::EnergyInterpretation::EM);
124  float hoe_new = 0.;
125  cluster = l1t::PFCluster(pt_new, it->eta(), it->phi(), hoe_new, /*isEM=*/isEM);
126  }
127  } else if (scenario_ == UseEmInterp::AllKeepHad) { // for all objs, replace EM part with EM interp, preserve H
128  float had_old = pt - cluster.emEt();
129  //float em_old = cluster.emEt();
130  float em_new = it->iPt(l1t::HGCalMulticluster::EnergyInterpretation::EM);
131  float pt_new = had_old + em_new;
132  // FIXME: -1 can be a problem for later stages of the processing. For now we set it to something which saturates the hoe variable
133  float hoe_new = em_new > 0 ? (had_old / em_new) : 999;
134  cluster = l1t::PFCluster(pt_new, it->eta(), it->phi(), hoe_new, /*isEM=*/isEM);
135  //printf("Scenario %d: pt %7.2f eta %+5.3f em %7.2f, EMI %7.2f, h/e % 8.3f --> pt %7.2f, em %7.2f, h/e % 8.3f\n",
136  // 2, pt, it->eta(), em_old, em_new, hoe, cluster.pt(), cluster.emEt(), cluster.hOverE());
137  } else if (scenario_ == UseEmInterp::AllKeepTot) { // for all objs, replace EM part with EM interp, preserve pT
138  //float em_old = cluster.emEt();
139  float em_new = it->iPt(l1t::HGCalMulticluster::EnergyInterpretation::EM);
140  float hoe_new = em_new > 0 ? (it->pt() / em_new - 1) : -1;
141  cluster = l1t::PFCluster(it->pt(), it->eta(), it->phi(), hoe_new, /*isEM=*/isEM);
142  //printf("Scenario %d: pt %7.2f eta %+5.3f em %7.2f, EMI %7.2f, h/e % 8.3f --> pt %7.2f, em %7.2f, h/e % 8.3f\n",
143  // 3, pt, it->eta(), em_old, em_new, hoe, cluster.pt(), cluster.emEt(), cluster.hOverE());
144  }
145 
146  if (!emVsPUID_.method().empty()) {
147  if (!emVsPUID_.passID(*it, cluster)) {
148  continue;
149  }
150  }
151  if (!emOnly_ && !emVsPionID_.method().empty()) {
152  isEM = emVsPionID_.passID(*it, cluster);
153  }
154  cluster.setHwQual((isEM ? 1 : 0) + (it->hwQual() << 1));
155 
156  if (corrector_.valid())
157  corrector_.correctPt(cluster);
158  cluster.setPtError(resol_(cluster.pt(), std::abs(cluster.eta())));
159 
160  // We se the cluster shape variables used downstream
161  cluster.setAbsZBarycenter(fabs(it->zBarycenter()));
162  cluster.setSigmaRR(it->sigmaRRTot());
163 
164  out->push_back(cluster);
165  out->back().addConstituent(edm::Ptr<l1t::L1Candidate>(multiclusters, multiclusters->key(it)));
166  if (hasEmId_) {
167  (isEM ? outEm : outHad)->push_back(out->back());
168  }
169  }
170 
171  iEvent.put(std::move(out));
172  iEvent.put(std::move(outEgamma), "egamma");
173  if (hasEmId_) {
174  iEvent.put(std::move(outEm), "em");
175  iEvent.put(std::move(outHad), "had");
176  }
177 }
bool valid() const
Definition: corrector.h:39
unsigned int key(const_iterator &iter) const
Definition: BXVector.h:101
void setHwQual(int qual)
Definition: L1Candidate.h:31
const_iterator begin(int bx) const
int iEvent
Definition: GenABIO.cc:224
void correctPt(l1t::PFCluster &cluster, float preserveEmEt=true) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDGetTokenT< l1t::HGCalMulticlusterBxCollection > src_
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
const_iterator end(int bx) const
StringCutObjectSelector< l1t::HGCalMulticluster > preEmId_
float passID(l1t::HGCalMulticluster c, l1t::PFCluster &cpf)
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ corrector_

l1tpf::corrector l1tpf::PFClusterProducerFromHGC3DClusters::corrector_
private

Definition at line 32 of file PFClusterProducerFromHGC3DClusters.cc.

◆ emOnly_

bool l1tpf::PFClusterProducerFromHGC3DClusters::emOnly_
private

◆ emVsPionID_

l1tpf::HGC3DClusterEgID l1tpf::PFClusterProducerFromHGC3DClusters::emVsPionID_
private

◆ emVsPUID_

l1tpf::HGC3DClusterEgID l1tpf::PFClusterProducerFromHGC3DClusters::emVsPUID_
private

◆ etCut_

double l1tpf::PFClusterProducerFromHGC3DClusters::etCut_
private

Definition at line 28 of file PFClusterProducerFromHGC3DClusters.cc.

◆ hasEmId_

bool l1tpf::PFClusterProducerFromHGC3DClusters::hasEmId_
private

◆ preEmId_

StringCutObjectSelector<l1t::HGCalMulticluster> l1tpf::PFClusterProducerFromHGC3DClusters::preEmId_
private

Definition at line 29 of file PFClusterProducerFromHGC3DClusters.cc.

◆ resol_

l1tpf::ParametricResolution l1tpf::PFClusterProducerFromHGC3DClusters::resol_
private

Definition at line 33 of file PFClusterProducerFromHGC3DClusters.cc.

◆ scenario_

UseEmInterp l1tpf::PFClusterProducerFromHGC3DClusters::scenario_
private

◆ src_

edm::EDGetTokenT<l1t::HGCalMulticlusterBxCollection> l1tpf::PFClusterProducerFromHGC3DClusters::src_
private

Definition at line 25 of file PFClusterProducerFromHGC3DClusters.cc.