1 #ifndef MuonIsolationProducers_MuIsolatorResultProducer_H
2 #define MuonIsolationProducers_MuIsolatorResultProducer_H
30 template <
typename BT>
37 typedef typename std::vector<pair_type>
map_type;
52 template <
typename BT = reco::Cand
idate>
90 template <
typename RT>
113 template <
typename BT>
114 template <
typename RT>
119 std::vector<RT> resV(
results.size());
120 for (
unsigned int i = 0;
i < resV.size(); ++
i)
122 auto outMap = std::make_unique<edm::ValueMap<RT>>();
126 if (!candMapT.
get().empty()) {
127 filler.insert(candMapT.
handle(), resV.begin(), resV.end());
135 template <
typename BT>
140 LogDebug(
metname) <<
"Before calling writeOutMap with result type " << theIsolator->resultType();
142 if (theResultType == Isolator::ISOL_INT_TYPE)
144 if (theResultType == Isolator::ISOL_FLOAT_TYPE)
146 if (theResultType == Isolator::ISOL_BOOL_TYPE)
151 template <
typename BT>
153 if (theResultType == Isolator::ISOL_FLOAT_TYPE)
154 produces<edm::ValueMap<float>>();
155 if (theResultType == Isolator::ISOL_INT_TYPE)
156 produces<edm::ValueMap<int>>();
157 if (theResultType == Isolator::ISOL_BOOL_TYPE)
158 produces<edm::ValueMap<bool>>();
185 template <
typename BT>
188 theRemoveOtherVetos(par.getParameter<
bool>(
"RemoveOtherVetos")),
189 theIsolator(nullptr),
191 LogDebug(
"RecoMuon|MuonIsolation") <<
" MuIsolatorResultProducer CTOR";
194 std::vector<edm::ParameterSet> depositInputs = par.
getParameter<std::vector<edm::ParameterSet>>(
"InputMuIsoDeposits");
196 std::vector<double> dWeights(depositInputs.size());
197 std::vector<double> dThresholds(depositInputs.size());
199 for (
unsigned int iDep = 0; iDep < depositInputs.size(); ++iDep) {
202 dConf.
weight = depositInputs[iDep].getParameter<
double>(
"DepositWeight");
203 dConf.
threshold = depositInputs[iDep].getParameter<
double>(
"DepositThreshold");
205 dWeights[iDep] = dConf.
weight;
214 if (isolatorType ==
"IsolatorByDeposit") {
216 if (coneSizeType ==
"FixedConeSize") {
222 }
else if (coneSizeType ==
"CutsConeSize") {
228 }
else if (isolatorType ==
"IsolatorByNominalEfficiency") {
232 }
else if (isolatorType ==
"IsolatorByDepositCount") {
234 if (coneSizeType ==
"FixedConeSize") {
240 }
else if (coneSizeType ==
"CutsConeSize") {
248 edm::LogError(
"MuonIsolationProducers") <<
"Failed to initialize an isolator";
273 template <
typename BT>
277 LogDebug(
"RecoMuon|MuIsolatorResultProducer") <<
" MuIsolatorResultProducer DTOR";
280 template <
typename BT>
284 <<
" BEGINING OF EVENT "
285 <<
"================================";
290 if (theRemoveOtherVetos && !theVetoCuts.selectAll) {
291 if (theBeamlineOption ==
"BeamSpotFromEvent") {
296 event.getByLabel(theBeamSpotLabel, beamSpotH);
300 LogTrace(
metname) <<
"Extracted beam point at " << theBeam << std::endl;
312 unsigned int colSize = initAssociation(
event, candMapT);
318 std::vector<reco::IsoDeposit::Vetos*> vetoDeps(theDepositConfs.size(),
nullptr);
321 if (theRemoveOtherVetos) {
322 initVetos(vetoDeps, candMapT);
326 for (
unsigned int muI = 0; muI < colSize; ++muI) {
327 results[muI] = theIsolator->result(candMapT.
get()[muI].second, *(candMapT.
get()[muI].first));
329 if (
results[muI].typeF() != theIsolator->resultType()) {
330 edm::LogError(
"MuonIsolationProducers") <<
"Failed to get result from the isolator";
338 for (
unsigned int iDep = 0; iDep < vetoDeps.size(); ++iDep) {
340 if (vetoDeps[iDep]) {
341 delete vetoDeps[iDep];
342 vetoDeps[iDep] =
nullptr;
347 template <
typename BT>
353 for (
unsigned int iMap = 0; iMap < theDepositConfs.size(); ++iMap) {
355 event.getByLabel(theDepositConfs[iMap].
tag, depH);
363 event.get(depH->
begin().
id(), keyH);
365 typename CT::const_iterator depHCI = depH->
begin().
begin();
366 typename CT::const_iterator depEnd = depH->
begin().
end();
367 unsigned int keyI = 0;
368 for (; depHCI != depEnd; ++depHCI, ++keyI) {
374 for (; muI != candMapT.
get().end(); ++muI) {
375 if (muI->first == muPtr)
378 if (muI->first != muPtr) {
379 edm::LogError(
"MuonIsolationProducers") <<
"Failed to align muon map";
381 muI->second[iMap].dep = &*depHCI;
386 return candMapT.
get().size();
389 template <
typename BT>
393 if (theRemoveOtherVetos) {
394 LogDebug(
metname) <<
"Start checking for vetos based on input/expected vetos.size of " <<
vetos.size()
395 <<
" passed at " << &
vetos <<
" and an input map.size of " << candMapT.
get().size();
397 unsigned int muI = 0;
398 for (; muI < candMapT.
get().size(); ++muI) {
400 double d0 = ((
mu->vx() - theBeam.x()) *
mu->py() - (
mu->vy() - theBeam.y()) *
mu->px()) /
mu->pt();
402 if (theVetoCuts.selectAll || (fabs(
mu->eta()) < theVetoCuts.muAbsEtaMax &&
mu->pt() > theVetoCuts.muPtMin &&
403 fabs(
mu->vz()) < theVetoCuts.muAbsZMax && fabs(
d0) < theVetoCuts.muD0Max)) {
405 for (
unsigned int iDep = 0; iDep < candMapT.
get()[muI].second.size(); ++iDep) {
406 if (
vetos[iDep] ==
nullptr)
409 vetos[iDep]->push_back(candMapT.
get()[muI].second[iDep].dep->veto());
416 for (; muI < candMapT.
get().size(); ++muI) {
417 for (
unsigned int iDep = 0; iDep < candMapT.
get()[muI].second.size(); ++iDep) {
418 candMapT.
get()[muI].second[iDep].vetos =
vetos[iDep];