44 std::ostringstream valOStr;
47 while (valStr.size() > 1 && valStr.back() ==
'0') {
50 if (valStr.size() > 1 && valStr.back() ==
'.') {
53 auto decPoint = valStr.find(
'.');
54 if (decPoint != std::string::npos) {
55 valStr.replace(decPoint, 1,
"p");
58 valStr.replace(0, 1,
"M");
63 std::vector<std::unique_ptr<int>> countRecHits(
const T& recHitHandle,
const std::vector<double>&
thresholds) {
66 count = std::make_unique<int>(0);
67 if (recHitHandle.isValid()) {
68 for (
const auto&
recHit : *recHitHandle) {
69 for (
size_t thresNr = 0; thresNr <
thresholds.size(); thresNr++) {
101 template <
typename RecHitCollection>
103 const std::vector<std::unique_ptr<trigger::EgammaObjectCollection>>& egTrigObjs,
106 float maxDR2 = 0.4 * 0.4)
const;
108 std::unique_ptr<reco::TrackCollection>
filterTrks(
109 const std::vector<std::unique_ptr<trigger::EgammaObjectCollection>>& egTrigObjs,
111 float maxDR2 = 0.4 * 0.4)
const;
114 const std::vector<std::unique_ptr<trigger::EgammaObjectCollection>>& egTrigObjs,
116 float maxDR2 = 0.4 * 0.4)
const;
125 std::vector<std::pair<EgObjTokens, std::string>>
egCands;
132 template <
typename T>
139 template <
typename T>
146 for (
size_t tagNr = 0; tagNr <
inputTags.size(); tagNr++) {
150 template <
typename T>
155 const auto& collectionPSets =
pset.getParameter<std::vector<edm::ParameterSet>>(
tagname);
156 for (
const auto& collPSet : collectionPSets) {
167 const auto& collectionPSets =
pset.getParameter<std::vector<edm::ParameterSet>>(
tagname);
168 for (
const auto& collPSet : collectionPSets) {
202 minPtToSaveHits_(
pset.getParameter<
double>(
"minPtToSaveHits")),
203 saveHitsPlusPi_(
pset.getParameter<
bool>(
"saveHitsPlusPi")),
204 saveHitsPlusHalfPi_(
pset.getParameter<
bool>(
"saveHitsPlusHalfPi")),
205 recHitCountThresholds_(
pset.getParameter<std::vector<double>>(
"recHitCountThresholds")) {
207 callWhenNewProductsRegistered(getterOfProducts_);
208 for (
auto& tokenLabel :
tokens_.egCands) {
209 produces<trigger::EgammaObjectCollection>(tokenLabel.second);
211 for (
auto& tokenLabel :
tokens_.ecal) {
212 produces<EcalRecHitCollection>(tokenLabel.second);
213 for (
const auto& thres : recHitCountThresholds_) {
214 produces<int>(
"countEcalRecHits" + tokenLabel.second +
"Thres" + convertToProdNameStr(thres) +
"GeV");
217 for (
auto& tokenLabel :
tokens_.hcal) {
218 produces<HBHERecHitCollection>(tokenLabel.second);
219 for (
const auto& thres : recHitCountThresholds_) {
220 produces<int>(
"countHcalRecHits" + tokenLabel.second +
"Thres" + convertToProdNameStr(thres) +
"GeV");
223 for (
auto& tokenLabel :
tokens_.trks) {
224 produces<reco::TrackCollection>(tokenLabel.second);
226 for (
auto& tokenLabel :
tokens_.pfClusIso) {
227 produces<reco::PFClusterCollection>(tokenLabel.second);
233 desc.add<
double>(
"minPtToSaveHits", 0.);
234 desc.add<
bool>(
"saveHitsPlusPi",
false);
235 desc.add<
bool>(
"saveHitsPlusHalfPi",
true);
236 desc.add<std::vector<double>>(
"recHitCountThresholds",
std::vector{0., 0.5, 1.0, 1.5, 2.0});
243 std::vector<edm::ParameterSet> egCandsDefaults(1);
244 egCandsDefaults[0].addParameter(
"ecalCands",
edm::InputTag(
"hltEgammaCandidates"));
245 egCandsDefaults[0].addParameter(
"pixelSeeds",
edm::InputTag(
"hltEgammaElectronPixelSeeds"));
246 egCandsDefaults[0].addParameter(
"gsfTracks",
edm::InputTag(
"hltEgammaGsfTracks"));
247 egCandsDefaults[0].addParameter(
"label",
std::string(
""));
252 std::vector<edm::ParameterSet> ecalDefaults(2);
253 ecalDefaults[0].addParameter(
"src",
edm::InputTag(
"hltEcalRecHit",
"EcalRecHitsEB"));
254 ecalDefaults[0].addParameter(
"label",
std::string(
"EcalRecHitsEB"));
255 ecalDefaults[1].addParameter(
"src",
edm::InputTag(
"hltEcalRecHit",
"EcalRecHitsEE"));
256 ecalDefaults[1].addParameter(
"label",
std::string(
"EcalRecHitsEE"));
257 std::vector<edm::ParameterSet> hcalDefaults(1);
258 hcalDefaults[0].addParameter(
"src",
edm::InputTag(
"hltHbhereco"));
259 hcalDefaults[0].addParameter(
"label",
std::string(
""));
260 std::vector<edm::ParameterSet> trksDefaults(1);
261 trksDefaults[0].addParameter(
"src",
edm::InputTag(
"generalTracks"));
262 trksDefaults[0].addParameter(
"label",
std::string(
""));
263 std::vector<edm::ParameterSet> pfClusIsoDefaults(3);
264 pfClusIsoDefaults[0].addParameter(
"src",
edm::InputTag(
"hltParticleFlowClusterECALL1Seeded"));
265 pfClusIsoDefaults[0].addParameter(
"label",
std::string(
"Ecal"));
266 pfClusIsoDefaults[1].addParameter(
"src",
edm::InputTag(
"hltParticleFlowClusterECALUnseeded"));
267 pfClusIsoDefaults[1].addParameter(
"label",
std::string(
"EcalUnseeded"));
268 pfClusIsoDefaults[2].addParameter(
"src",
edm::InputTag(
"hltParticleFlowClusterHCAL"));
269 pfClusIsoDefaults[2].addParameter(
"label",
std::string(
"Hcal"));
271 desc.addVPSet(
"egCands", egCandsDesc, egCandsDefaults);
272 desc.addVPSet(
"ecal", tokenLabelDesc, ecalDefaults);
273 desc.addVPSet(
"hcal", tokenLabelDesc, hcalDefaults);
274 desc.addVPSet(
"trks", tokenLabelDesc, trksDefaults);
275 desc.addVPSet(
"pfClusIso", tokenLabelDesc, pfClusIsoDefaults);
277 descriptions.
add((
"hltEgammaHLTExtraProducer"),
desc);
283 std::vector<edm::Handle<reco::RecoEcalCandidateIsolationMap>> valueMapHandles;
285 std::vector<std::unique_ptr<trigger::EgammaObjectCollection>> egTrigObjColls;
287 auto ecalCandsHandle =
event.getHandle(egCandsToken.first.ecalCands);
288 auto gsfTrksHandle =
event.getHandle(egCandsToken.first.gsfTracks);
289 auto pixelSeedsHandle =
event.getHandle(egCandsToken.first.pixelSeeds);
291 auto egTrigObjs = std::make_unique<trigger::EgammaObjectCollection>();
292 for (
size_t candNr = 0; ecalCandsHandle.isValid() && candNr < ecalCandsHandle->size(); candNr++) {
294 egTrigObjs->push_back(*candRef);
295 auto& egTrigObj = egTrigObjs->back();
296 setVars(egTrigObj, candRef, valueMapHandles);
298 setSeeds(egTrigObj, pixelSeedsHandle);
300 egTrigObjColls.emplace_back(
std::move(egTrigObjs));
305 auto filterAndStoreRecHits = [caloGeomHandle, &
event,
this](
const auto& egTrigObjs,
const auto& tokenLabels) {
306 for (
const auto& tokenLabel : tokenLabels) {
307 auto handle =
event.getHandle(tokenLabel.first);
314 for (
const auto& tokenLabel : tokenLabels) {
315 auto handle =
event.getHandle(tokenLabel.first);
317 for (
size_t thresNr = 0; thresNr <
thresholds.size(); thresNr++) {
320 prefixLabel + tokenLabel.second +
"Thres" + convertToProdNameStr(thres) +
"GeV");
325 auto filterAndStore = [&
event,
this](
const auto& egTrigObjs,
const auto& tokenLabels,
auto filterFunc) {
326 for (
const auto& tokenLabel : tokenLabels) {
327 auto handle =
event.getHandle(tokenLabel.first);
328 auto filtered = (this->*filterFunc)(egTrigObjs,
handle, 0.4 * 0.4);
333 filterAndStoreRecHits(egTrigObjColls,
tokens_.
ecal);
334 filterAndStoreRecHits(egTrigObjColls,
tokens_.
hcal);
340 for (
size_t collNr = 0; collNr < egTrigObjColls.size(); collNr++) {
349 std::vector<std::pair<std::string, float>>
vars;
350 for (
auto& valueMapHandle : valueMapHandles) {
351 auto mapIt = valueMapHandle->find(ecalCandRef);
352 if (mapIt != valueMapHandle->end()) {
354 if (!valueMapHandle.provenance()->productInstanceName().empty()) {
355 name +=
"_" + valueMapHandle.provenance()->productInstanceName();
365 if (!gsfTrksHandle.
isValid()) {
370 for (
size_t trkNr = 0; gsfTrksHandle.
isValid() && trkNr < gsfTrksHandle->size(); trkNr++) {
376 if (scRefFromTrk == scRef) {
377 gsfTrkRefs.push_back(trkRef);
390 if (!eleSeedsHandle.
isValid()) {
395 for (
size_t seedNr = 0; eleSeedsHandle.
isValid() && seedNr < eleSeedsHandle->size(); seedNr++) {
401 trigObjSeeds.push_back(eleSeed);
408 template <
typename RecHitCollection>
410 const std::vector<std::unique_ptr<trigger::EgammaObjectCollection>>& egTrigObjColls,
413 float maxDR2)
const {
414 auto filteredHits = std::make_unique<RecHitCollection>();
418 std::vector<std::pair<float, float>> etaPhis;
419 for (
const auto& egTrigObjs : egTrigObjColls) {
420 for (
const auto& egTrigObj : *egTrigObjs) {
422 etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi()});
424 etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi() + 3.14159});
426 etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi() + 3.14159 / 2.});
433 for (
auto& etaPhi : etaPhis) {
444 if (deltaR2Match(cellGeom->getPosition()))
445 filteredHits->push_back(
hit);
447 throw cms::Exception(
"GeomError") <<
"could not get geometry for det id " <<
hit.
id().rawId();
454 const std::vector<std::unique_ptr<trigger::EgammaObjectCollection>>& egTrigObjColls,
456 float maxDR2)
const {
457 auto filteredTrks = std::make_unique<reco::TrackCollection>();
463 std::vector<std::pair<float, float>> etaPhisTmp;
464 for (
const auto& egTrigObjs : egTrigObjColls) {
465 for (
const auto& egTrigObj : *egTrigObjs) {
467 etaPhisTmp.push_back({egTrigObj.eta(), egTrigObj.phi()});
469 for (
const auto& gsfTrk : egTrigObj.gsfTracks()) {
470 etaPhisTmp.push_back({gsfTrk->eta(), gsfTrk->phi()});
475 std::vector<std::pair<float, float>> etaPhis;
476 for (
const auto& etaPhi : etaPhisTmp) {
477 etaPhis.push_back(etaPhi);
479 etaPhis.push_back({etaPhi.first, etaPhi.second + 3.14159});
481 etaPhis.push_back({etaPhi.first, etaPhi.second + 3.14159 / 2.});
484 auto deltaR2Match = [&etaPhis, &maxDR2](
float eta,
float phi) {
485 for (
auto& etaPhi : etaPhis) {
492 for (
auto& trk : *
trks) {
493 if (deltaR2Match(trk.eta(), trk.phi()))
494 filteredTrks->push_back(trk);
500 const std::vector<std::unique_ptr<trigger::EgammaObjectCollection>>& egTrigObjColls,
502 float maxDR2)
const {
503 auto filteredPFClus = std::make_unique<reco::PFClusterCollection>();
505 return filteredPFClus;
507 std::vector<std::pair<float, float>> etaPhis;
508 for (
const auto& egTrigObjs : egTrigObjColls) {
509 for (
const auto& egTrigObj : *egTrigObjs) {
511 etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi()});
513 etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi() + 3.14159});
515 etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi() + 3.14159 / 2.});
519 auto deltaR2Match = [&etaPhis, &maxDR2](
float eta,
float phi) {
520 for (
auto& etaPhi : etaPhis) {
527 for (
auto& clus : *pfClus) {
528 if (deltaR2Match(clus.eta(), clus.phi()))
529 filteredPFClus->push_back(clus);
531 return filteredPFClus;
const reco::SuperClusterRef & superCluster() const
constexpr SubDetector subDetGeom[21]
void setVars(std::vector< std::pair< std::string, float >> vars)
uint32_t cc[maxCellsPerHit]
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
void setGsfTracks(reco::GsfTrackRefVector trks)
edm::RefVector< GsfTrackCollection > GsfTrackRefVector
vector of reference to GsfTrack in the same collection
#define DEFINE_FWK_MODULE(type)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< edm::EDGetTokenT< int > > tokens_
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
void setSeeds(reco::ElectronSeedRefVector seeds)
inputTags
All input tags are specified in this pset for convenience.
void add(std::string const &label, ParameterSetDescription const &psetDescription)