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>
89 std::vector<reco::IsoDeposit::Vetos*>&
vetos,
92 template <
typename RT>
114 template <
typename BT>
115 template <
typename RT>
120 std::vector<RT> resV(
results.size());
121 for (
unsigned int i = 0;
i < resV.size(); ++
i)
123 auto outMap = std::make_unique<edm::ValueMap<RT>>();
127 if (!candMapT.
get().empty()) {
128 filler.insert(candMapT.
handle(), resV.begin(), resV.end());
136 template <
typename BT>
141 LogDebug(
metname) <<
"Before calling writeOutMap with result type " << theIsolator->resultType();
143 if (theResultType == Isolator::ISOL_INT_TYPE)
145 if (theResultType == Isolator::ISOL_FLOAT_TYPE)
147 if (theResultType == Isolator::ISOL_BOOL_TYPE)
152 template <
typename BT>
154 if (theResultType == Isolator::ISOL_FLOAT_TYPE)
155 produces<edm::ValueMap<float>>();
156 if (theResultType == Isolator::ISOL_INT_TYPE)
157 produces<edm::ValueMap<int>>();
158 if (theResultType == Isolator::ISOL_BOOL_TYPE)
159 produces<edm::ValueMap<bool>>();
185 template <
typename BT>
187 : theConfig(par), theRemoveOtherVetos(par.getParameter<
bool>(
"RemoveOtherVetos")), theIsolator(nullptr) {
188 LogDebug(
"RecoMuon|MuonIsolation") <<
" MuIsolatorResultProducer CTOR";
191 std::vector<edm::ParameterSet> depositInputs = par.
getParameter<std::vector<edm::ParameterSet>>(
"InputMuIsoDeposits");
193 std::vector<double> dWeights(depositInputs.size());
194 std::vector<double> dThresholds(depositInputs.size());
196 for (
unsigned int iDep = 0; iDep < depositInputs.size(); ++iDep) {
199 dConf.
weight = depositInputs[iDep].getParameter<
double>(
"DepositWeight");
200 dConf.
threshold = depositInputs[iDep].getParameter<
double>(
"DepositThreshold");
202 dWeights[iDep] = dConf.
weight;
211 if (isolatorType ==
"IsolatorByDeposit") {
213 if (coneSizeType ==
"FixedConeSize") {
219 }
else if (coneSizeType ==
"CutsConeSize") {
225 }
else if (isolatorType ==
"IsolatorByNominalEfficiency") {
229 }
else if (isolatorType ==
"IsolatorByDepositCount") {
231 if (coneSizeType ==
"FixedConeSize") {
237 }
else if (coneSizeType ==
"CutsConeSize") {
245 edm::LogError(
"MuonIsolationProducers") <<
"Failed to initialize an isolator";
270 template <
typename BT>
274 LogDebug(
"RecoMuon|MuIsolatorResultProducer") <<
" MuIsolatorResultProducer DTOR";
277 template <
typename BT>
281 <<
" BEGINING OF EVENT " 282 <<
"================================";
287 if (theRemoveOtherVetos && !theVetoCuts.selectAll) {
288 if (theBeamlineOption ==
"BeamSpotFromEvent") {
293 event.getByLabel(theBeamSpotLabel, beamSpotH);
297 LogTrace(
metname) <<
"Extracted beam point at " << theBeam << std::endl;
309 unsigned int colSize = initAssociation(
event, candMapT);
315 std::vector<reco::IsoDeposit::Vetos*> vetoDeps(theDepositConfs.size(),
nullptr);
318 if (theRemoveOtherVetos) {
319 initVetos(theBeam, vetoDeps, candMapT);
323 for (
unsigned int muI = 0; muI < colSize; ++muI) {
324 results[muI] = theIsolator->result(candMapT.
get()[muI].second, *(candMapT.
get()[muI].first));
326 if (
results[muI].typeF() != theIsolator->resultType()) {
327 edm::LogError(
"MuonIsolationProducers") <<
"Failed to get result from the isolator";
335 for (
unsigned int iDep = 0; iDep < vetoDeps.size(); ++iDep) {
337 if (vetoDeps[iDep]) {
338 delete vetoDeps[iDep];
339 vetoDeps[iDep] =
nullptr;
344 template <
typename BT>
350 for (
unsigned int iMap = 0; iMap < theDepositConfs.size(); ++iMap) {
352 event.getByLabel(theDepositConfs[iMap].
tag, depH);
360 event.get(depH->
begin().
id(), keyH);
362 typename CT::const_iterator depHCI = depH->
begin().
begin();
363 typename CT::const_iterator depEnd = depH->
begin().
end();
364 unsigned int keyI = 0;
365 for (; depHCI != depEnd; ++depHCI, ++keyI) {
371 for (; muI != candMapT.
get().end(); ++muI) {
372 if (muI->first == muPtr)
375 if (muI->first != muPtr) {
376 edm::LogError(
"MuonIsolationProducers") <<
"Failed to align muon map";
378 muI->second[iMap].dep = &*depHCI;
383 return candMapT.
get().size();
386 template <
typename BT>
388 std::vector<reco::IsoDeposit::Vetos*>&
vetos,
392 if (theRemoveOtherVetos) {
393 LogDebug(
metname) <<
"Start checking for vetos based on input/expected vetos.size of " <<
vetos.size()
394 <<
" passed at " << &
vetos <<
" and an input map.size of " << candMapT.
get().size();
396 unsigned int muI = 0;
397 for (; muI < candMapT.
get().size(); ++muI) {
399 double d0 = ((
mu->vx() - theBeam.x()) *
mu->py() - (
mu->vy() - theBeam.y()) *
mu->px()) /
mu->pt();
401 if (theVetoCuts.selectAll || (fabs(
mu->eta()) < theVetoCuts.muAbsEtaMax &&
mu->pt() > theVetoCuts.muPtMin &&
402 fabs(
mu->vz()) < theVetoCuts.muAbsZMax && fabs(
d0) < theVetoCuts.muD0Max)) {
404 for (
unsigned int iDep = 0; iDep < candMapT.
get()[muI].second.size(); ++iDep) {
405 if (
vetos[iDep] ==
nullptr)
408 vetos[iDep]->push_back(candMapT.
get()[muI].second[iDep].dep->veto());
415 for (; muI < candMapT.
get().size(); ++muI) {
416 for (
unsigned int iDep = 0; iDep < candMapT.
get()[muI].second.size(); ++iDep) {
417 candMapT.
get()[muI].second[iDep].vetos =
vetos[iDep];
muisorhelper::ResultType ResultType
T getParameter(std::string const &) const
std::pair< key_type, value_type > pair_type
const Point & position() const
position
MuIsolatorResultProducer(const edm::ParameterSet &)
constructor with config
std::vector< Result > Results
const std::string metname
void initVetos(reco::TrackBase::Point const &theBeam, std::vector< reco::IsoDeposit::Vetos *> &vetos, CandMap &candMap) const
map_type::iterator iterator
std::vector< DepositConf > theDepositConfs
bool theRemoveOtherVetos
choose which muon vetos should be removed from all deposits
void callWhatProduces()
declare what's going to be produced
Log< level::Error, false > LogError
std::vector< pair_type > map_type
muonisolation::MuIsoBaseIsolator Isolator
edm::RefToBase< BT > key_type
Isolator * theIsolator
the isolator
std::string theBeamlineOption
beam spot
void produce(edm::Event &, const edm::EventSetup &) override
void setHandle(const handle_type &rhs)
edm::Handle< edm::View< BT > > handle_type
math::XYZPoint Point
point in the space
muisorhelper::Isolator Isolator
virtual ResultType resultType() const =0
container::const_iterator end() const
const_iterator begin() const
container::const_iterator begin() const
muisorhelper::DepositContainer DepositContainer
static constexpr float d0
edm::InputTag theBeamSpotLabel
void writeOut(edm::Event &event, const CandMap &candMap, const Results &results) const
choose which result type to write here
std::vector< DepositAndVetos > DepositContainer
Isolator::ResultType ResultType
unsigned int initAssociation(edm::Event &event, CandMap &candMapT) const
Isolator::DepositContainer DepositContainer
std::vector< Veto > Vetos
const handle_type & handle() const
std::vector< value_type > container
DepositContainer value_type
void writeOutImpl(edm::Event &event, const CandMap &candMapT, const Results &results) const
actually do the writing here
~MuIsolatorResultProducer() override
destructor
edm::ParameterSet theConfig
muisorhelper::Results Results
muisorhelper::CandMap< BT > CandMap
muisorhelper::Result Result