1 #ifndef MuonIsolationProducers_MuIsolatorResultProducer_H 2 #define MuonIsolationProducers_MuIsolatorResultProducer_H 36 typedef typename std::vector<pair_type >
map_type;
39 map_type&
get() {
return cMap_;}
40 const map_type&
get()
const {
return cMap_;}
41 const handle_type&
handle()
const {
return handle_;}
42 void setHandle(
const handle_type& rhs) { handle_ = rhs;}
51 template <
typename BT= reco::Cand
idate>
86 void callWhatProduces();
88 unsigned int initAssociation(
edm::Event&
event, CandMap& candMapT)
const;
90 void initVetos(std::vector<reco::IsoDeposit::Vetos*>&
vetos, CandMap& candMap)
const;
92 template <
typename RT>
117 template<
typename BT>
118 template<
typename RT>
inline 122 std::vector<RT> resV(results.size());
123 for (
unsigned int i = 0;
i< resV.size(); ++
i) resV[
i] = results[
i].val<RT>();
124 auto outMap = std::make_unique<edm::ValueMap<RT>>();
128 if (!candMapT.
get().empty()){
129 filler.insert(candMapT.
handle(), resV.begin(), resV.end());
138 template<
typename BT>
144 LogDebug(metname)<<
"Before calling writeOutMap with result type "<<theIsolator->resultType();
146 if (theResultType == Isolator::ISOL_INT_TYPE) writeOutImpl<int>(
event, candMapT,
results);
147 if (theResultType == Isolator::ISOL_FLOAT_TYPE) writeOutImpl<float>(
event, candMapT,
results);
148 if (theResultType == Isolator::ISOL_BOOL_TYPE) writeOutImpl<bool>(
event, candMapT,
results);
153 template<
typename BT>
155 if (theResultType == Isolator::ISOL_FLOAT_TYPE) produces<edm::ValueMap<float> >();
156 if (theResultType == Isolator::ISOL_INT_TYPE ) produces<edm::ValueMap<int> >();
157 if (theResultType == Isolator::ISOL_BOOL_TYPE ) produces<edm::ValueMap<bool> >();
185 template<
typename BT>
188 theRemoveOtherVetos(par.getParameter<
bool>(
"RemoveOtherVetos")),
192 LogDebug(
"RecoMuon|MuonIsolation")<<
" MuIsolatorResultProducer CTOR";
195 std::vector<edm::ParameterSet> depositInputs =
196 par.
getParameter<std::vector<edm::ParameterSet> >(
"InputMuIsoDeposits");
198 std::vector<double> dWeights( depositInputs.size());
199 std::vector<double> dThresholds( depositInputs.size());
201 for (
unsigned int iDep = 0; iDep < depositInputs.size(); ++iDep){
204 dConf.
weight = depositInputs[iDep].getParameter<
double>(
"DepositWeight");
205 dConf.
threshold = depositInputs[iDep].getParameter<
double>(
"DepositThreshold");
207 dWeights[iDep] = dConf.
weight;
216 if ( isolatorType ==
"IsolatorByDeposit"){
218 if (coneSizeType ==
"FixedConeSize"){
224 }
else if (coneSizeType ==
"CutsConeSize"){
230 }
else if ( isolatorType ==
"IsolatorByNominalEfficiency"){
233 }
else if ( isolatorType ==
"IsolatorByDepositCount"){
235 if (coneSizeType ==
"FixedConeSize"){
241 }
else if (coneSizeType ==
"CutsConeSize"){
249 edm::LogError(
"MuonIsolationProducers")<<
"Failed to initialize an isolator";
274 template<
typename BT>
277 LogDebug(
"RecoMuon|MuIsolatorResultProducer")<<
" MuIsolatorResultProducer DTOR";
281 template<
typename BT>
285 LogDebug(metname)<<
" Muon Deposit producing..." 286 <<
" BEGINING OF EVENT " <<
"================================";
319 std::vector<reco::IsoDeposit::Vetos*> vetoDeps(
theDepositConfs.size(),
nullptr);
328 for (
unsigned int muI=0; muI < colSize; ++muI){
332 edm::LogError(
"MuonIsolationProducers")<<
"Failed to get result from the isolator";
338 LogDebug(metname)<<
"Ready to write out results of size "<<results.size();
341 for(
unsigned int iDep = 0; iDep< vetoDeps.size(); ++iDep){
344 delete vetoDeps[iDep];
345 vetoDeps[iDep] =
nullptr;
350 template<
typename BT>
360 LogDebug(metname) <<
"Got Deposits of size "<<depH->
size();
361 if (depH->
empty())
continue;
366 event.get(depH->
begin().id(), keyH);
368 typename CT::const_iterator depHCI = depH->
begin().begin();
369 typename CT::const_iterator depEnd = depH->
begin().end();
371 for (; depHCI != depEnd; ++depHCI, ++keyI){
377 for (; muI != candMapT.
get().end(); ++muI){
378 if (muI->first == muPtr)
break;
380 if (muI->first != muPtr){
381 edm::LogError(
"MuonIsolationProducers")<<
"Failed to align muon map";
383 muI->second[iMap].dep = &*depHCI;
387 LogDebug(metname)<<
"Picked and aligned nDeps = "<<candMapT.
get().size();
388 return candMapT.
get().size();
391 template <
typename BT >
397 LogDebug(metname)<<
"Start checking for vetos based on input/expected vetos.size of "<<vetos.size()
398 <<
" passed at "<<&vetos
399 <<
" and an input map.size of "<<candMapT.
get().size();
401 unsigned int muI = 0;
402 for (; muI < candMapT.
get().size(); ++muI) {
404 double d0 = ( (mu->vx() -
theBeam.x() )* mu->py() - (mu->vy() -
theBeam.y())* mu->px() ) / mu->pt();
405 LogDebug(metname)<<
"Muon at index "<<muI;
413 LogDebug(metname)<<
"muon passes the cuts";
414 for (
unsigned int iDep =0; iDep < candMapT.
get()[muI].second.size(); ++iDep){
417 vetos[iDep]->push_back(candMapT.
get()[muI].second[iDep].dep->veto());
422 LogDebug(metname)<<
"Assigning vetos";
424 for (; muI < candMapT.
get().size(); ++muI) {
425 for(
unsigned int iDep =0; iDep < candMapT.
get()[muI].second.size(); ++iDep){
426 candMapT.
get()[muI].second[iDep].vetos = vetos[iDep];
429 LogDebug(metname)<<
"Done with vetos";
T getParameter(std::string const &) const
muisorhelper::ResultType ResultType
std::pair< key_type, value_type > pair_type
MuIsolatorResultProducer(const edm::ParameterSet &)
constructor with config
std::vector< Result > Results
const std::string metname
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
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
void initVetos(std::vector< reco::IsoDeposit::Vetos * > &vetos, CandMap &candMap) const
muisorhelper::Isolator Isolator
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
virtual ResultType resultType() const =0
muisorhelper::DepositContainer DepositContainer
edm::InputTag theBeamSpotLabel
std::vector< DepositAndVetos > DepositContainer
Isolator::ResultType ResultType
const_iterator begin() const
unsigned int initAssociation(edm::Event &event, CandMap &candMapT) const
Isolator::DepositContainer DepositContainer
std::vector< pair_type > map_type
std::vector< Veto > Vetos
std::vector< value_type > container
virtual Result result(const DepositContainer &deposits, const edm::Event *=0) const =0
Compute and return the isolation variable.
DepositContainer value_type
const Point & position() const
position
void writeOutImpl(edm::Event &event, const CandMap &candMapT, const Results &results) const
actually do the writing here
const handle_type & handle() const
void writeOut(edm::Event &event, const CandMap &candMap, const Results &results) const
choose which result type to write here
~MuIsolatorResultProducer() override
destructor
edm::ParameterSet theConfig
reco::TrackBase::Point theBeam
muisorhelper::Results Results
muisorhelper::CandMap< BT > CandMap
muisorhelper::Result Result