32 #include <unordered_map> 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++) {
88 template <
typename CollType,
typename RefType>
91 std::vector<RefType>& orgRefs,
92 float maxDR2 = 0.4 * 0.4)
const;
97 template <
typename RecHitCollection>
101 float maxDR2 = 0.4 * 0.4)
const;
112 template <
typename T>
119 template <
typename T>
126 for (
size_t tagNr = 0; tagNr <
inputTags.size(); tagNr++) {
130 template <
typename T>
135 const auto& collectionPSets =
pset.getParameter<std::vector<edm::ParameterSet>>(
tagname);
136 for (
const auto& collPSet : collectionPSets) {
139 tokens.emplace_back(std::make_pair(
token,
label));
144 template <
typename T,
typename H>
146 auto valueMap = std::make_unique<edm::ValueMap<T>>();
176 minPtToSaveHits_(
pset.getParameter<
double>(
"minPtToSaveHits")),
177 saveHitsPlusPi_(
pset.getParameter<
bool>(
"saveHitsPlusPi")),
178 saveHitsPlusHalfPi_(
pset.getParameter<
bool>(
"saveHitsPlusHalfPi")),
179 recHitCountThresholds_(
pset.getParameter<std::vector<double>>(
"recHitCountThresholds")) {
180 produces<L1TrackCollection>();
181 produces<L1TrackTruthPairCollection>();
182 produces<TrackingParticleCollection>();
183 produces<reco::CaloClusterCollection>(
"hgcalLayerClusters");
184 produces<edm::ValueMap<std::pair<float, float>>>(
"hgcalLayerClustersTime");
185 for (
auto& tokenLabel :
tokens_.hgcal) {
186 produces<HGCRecHitCollection>(tokenLabel.second);
187 for (
const auto& thres : recHitCountThresholds_) {
188 produces<int>(
"countHgcalRecHits" + tokenLabel.second +
"Thres" + convertToProdNameStr(thres) +
"GeV");
201 desc.add<
double>(
"minPtToSaveHits", 0.);
202 desc.add<
bool>(
"saveHitsPlusPi",
true);
203 desc.add<
bool>(
"saveHitsPlusHalfPi",
true);
204 desc.add<std::vector<double>>(
"recHitCountThresholds",
std::vector{0., 0.5, 1.0, 1.5, 2.0});
205 std::vector<edm::ParameterSet> ecalDefaults(2);
209 std::vector<edm::ParameterSet> hgcalDefaults(3);
210 hgcalDefaults[0].addParameter(
"src",
edm::InputTag(
"HGCalRecHit",
"HGCEERecHits"));
211 hgcalDefaults[0].addParameter(
"label",
std::string(
"HGCEERecHits"));
212 hgcalDefaults[1].addParameter(
"src",
edm::InputTag(
"HGCalRecHit",
"HGCHEFRecHits"));
213 hgcalDefaults[1].addParameter(
"label",
std::string(
"HGCHEFRecHits"));
214 hgcalDefaults[2].addParameter(
"src",
edm::InputTag(
"HGCalRecHit",
"HGCHEBRecHits"));
215 hgcalDefaults[2].addParameter(
"label",
std::string(
"HGCHEBRecHits"));
216 desc.addVPSet(
"hgcal", tokenLabelDesc, hgcalDefaults);
217 descriptions.
add((
"hltEgammaHLTPhase2ExtraProducer"),
desc);
232 auto handle =
event.getHandle(tokenLabel.first);
238 for (
const auto& tokenLabel : tokenLabels) {
239 auto handle =
event.getHandle(tokenLabel.first);
241 for (
size_t thresNr = 0; thresNr <
thresholds.size(); thresNr++) {
244 prefixLabel + tokenLabel.second +
"Thres" + convertToProdNameStr(thres) +
"GeV");
252 std::vector<edm::Ref<reco::CaloClusterCollection>> orgHGCalLayerClusterRefs;
254 std::vector<std::pair<float, float>> timesFiltered;
255 timesFiltered.reserve(orgHGCalLayerClusterRefs.size());
256 for (
auto& clusRef : orgHGCalLayerClusterRefs) {
257 timesFiltered.push_back((*hgcalLayerClustersTime)[clusRef]);
259 auto hgcalLayerClustersFilteredHandle =
event.put(
std::move(hgcalLayerClustersFiltered),
"hgcalLayerClusters");
260 event.put(
makeValueMap(hgcalLayerClustersFilteredHandle, timesFiltered),
"hgcalLayerClustersTime");
262 std::vector<edm::Ref<L1TrackCollection>> orgL1TrkRefs;
263 auto l1TrksFiltered =
filterObjs(*egTrigObjs, l1trks, orgL1TrkRefs);
264 std::vector<edm::Ref<TrackingParticleCollection>> orgTPRefs;
265 auto trkPartsFiltered =
filterObjs(*egTrigObjs, trkParts, orgTPRefs);
268 std::unordered_map<size_t, size_t> orgTPIndxToNewIndx;
269 for (
size_t refNr = 0; refNr < orgTPRefs.size(); refNr++) {
270 orgTPIndxToNewIndx.insert(std::make_pair(orgTPRefs[refNr].
key(), refNr));
276 auto l1TrkExtraColl = std::make_unique<L1TrackTruthPairCollection>();
278 for (
size_t l1TrkNr = 0; l1TrkNr < orgL1TrkRefs.size(); l1TrkNr++) {
279 auto orgTrkRef = orgL1TrkRefs[l1TrkNr];
282 if (l1TrkToTrkPartMap->isGenuine(orgTrkPtr))
284 if (l1TrkToTrkPartMap->isLooselyGenuine(orgTrkPtr))
286 if (l1TrkToTrkPartMap->isCombinatoric(orgTrkPtr))
288 if (l1TrkToTrkPartMap->isUnknown(orgTrkPtr))
291 auto orgTPRef = l1TrkToTrkPartMap->findTrackingParticlePtr(orgTrkPtr);
292 auto getNewTPRef = [&orgTPIndxToNewIndx, &orgTPRef, &trkPartsFiltHandle]() {
293 auto newIndexPair = orgTPIndxToNewIndx.find(orgTPRef.key());
294 if (newIndexPair != orgTPIndxToNewIndx.end()) {
299 auto newTPRef = getNewTPRef();
303 l1TrkExtraColl->push_back(l1TrkExtra);
308 template <
typename CollType,
typename RefType>
311 std::vector<RefType>& orgRefs,
312 float maxDR2)
const {
313 auto filteredObjs = std::make_unique<CollType>();
320 std::vector<std::pair<float, float>> etaPhisTmp;
321 for (
const auto& egTrigObj : egTrigObjs) {
323 etaPhisTmp.push_back({egTrigObj.eta(), egTrigObj.phi()});
325 for (
const auto& gsfTrk : egTrigObj.gsfTracks()) {
326 etaPhisTmp.push_back({gsfTrk->eta(), gsfTrk->phi()});
330 std::vector<std::pair<float, float>> etaPhis;
331 for (
const auto& etaPhi : etaPhisTmp) {
332 etaPhis.push_back(etaPhi);
334 etaPhis.push_back({etaPhi.first, etaPhi.second + 3.14159});
336 etaPhis.push_back({etaPhi.first, etaPhi.second + 3.14159 / 2.});
339 auto deltaR2Match = [&etaPhis, &maxDR2](
float eta,
float phi) {
340 for (
auto& etaPhi : etaPhis) {
347 for (
size_t objNr = 0; objNr <
objs->size(); objNr++) {
348 RefType ref(
objs, objNr);
349 if (deltaR2Match(ref->eta(), ref->phi())) {
350 filteredObjs->push_back(*ref);
351 orgRefs.push_back(ref);
357 template <
typename RecHitCollection>
362 float maxDR2)
const {
363 auto filteredHits = std::make_unique<RecHitCollection>();
367 std::vector<std::pair<float, float>> etaPhis;
368 for (
const auto& egTrigObj : egTrigObjs) {
370 etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi()});
372 etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi() + 3.14159});
374 etaPhis.push_back({egTrigObj.eta(), egTrigObj.phi() + 3.14159 / 2.});
380 for (
auto& etaPhi : etaPhis) {
391 if (deltaR2Match(cellGeom->getPosition()))
392 filteredHits->push_back(
hit);
394 throw cms::Exception(
"GeomError") <<
"could not get geometry for det id " <<
hit.
id().rawId();
std::vector< EgammaObject > EgammaObjectCollection
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
constexpr SubDetector subDetGeom[21]
uint32_t cc[maxCellsPerHit]
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
#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())
inputTags
All input tags are specified in this pset for convenience.
void add(std::string const &label, ParameterSetDescription const &psetDescription)