1 #ifndef MuonIsolationProducers_MuIsolatorResultProducer_H
2 #define MuonIsolationProducers_MuIsolatorResultProducer_H
36 typedef typename std::vector<pair_type >
map_type;
51 template <
typename BT= reco::Cand
idate>
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>();
128 if (candMapT.
get().size()>0){
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>
276 if (theIsolator)
delete theIsolator;
277 LogDebug(
"RecoMuon|MuIsolatorResultProducer")<<
" MuIsolatorResultProducer DTOR";
281 template<
typename BT>
285 LogDebug(metname)<<
" Muon Deposit producing..."
286 <<
" BEGINING OF EVENT " <<
"================================";
291 if(theRemoveOtherVetos && ! theVetoCuts.selectAll){
292 if (theBeamlineOption.compare(
"BeamSpotFromEvent") == 0){
297 event.getByLabel(theBeamSpotLabel,beamSpotH);
300 theBeam = beamSpotH->position();
301 LogTrace(metname)<<
"Extracted beam point at "<<theBeam<<std::endl;
313 unsigned int colSize = initAssociation(event, candMapT);
319 std::vector<reco::IsoDeposit::Vetos*> vetoDeps(theDepositConfs.size(), 0);
322 if (theRemoveOtherVetos){
324 initVetos(vetoDeps, candMapT);
328 for (
unsigned int muI=0; muI < colSize; ++muI){
329 results[muI] = theIsolator->result(candMapT.
get()[muI].second, *(candMapT.
get()[muI].first));
331 if (results[muI].typeF()!= theIsolator->resultType()){
332 edm::LogError(
"MuonIsolationProducers")<<
"Failed to get result from the isolator";
338 LogDebug(metname)<<
"Ready to write out results of size "<<results.size();
339 writeOut(event, candMapT, results);
341 for(
unsigned int iDep = 0; iDep< vetoDeps.size(); ++iDep){
344 delete vetoDeps[iDep];
350 template<
typename BT>
357 for (
unsigned int iMap = 0; iMap < theDepositConfs.size(); ++iMap){
359 event.getByLabel(theDepositConfs[iMap].
tag, depH);
360 LogDebug(metname) <<
"Got Deposits of size "<<depH->size();
361 if (depH->size()==0)
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 >
396 if (theRemoveOtherVetos){
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;
406 if (theVetoCuts.selectAll
407 || (fabs(mu->eta()) < theVetoCuts.muAbsEtaMax
408 && mu->pt() > theVetoCuts.muPtMin
409 && fabs(mu->vz()) < theVetoCuts.muAbsZMax
410 && fabs(d0) < theVetoCuts.muD0Max
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
void insert(const H &h, I begin, I end)
muonisolation::MuIsoBaseIsolator Isolator
edm::RefToBase< BT > key_type
Isolator * theIsolator
the isolator
std::string theBeamlineOption
beam spot
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
virtual ~MuIsolatorResultProducer()
destructor
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
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
DepositContainer value_type
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
edm::ParameterSet theConfig
reco::TrackBase::Point theBeam
muisorhelper::Results Results
virtual void produce(edm::Event &, const edm::EventSetup &)
muisorhelper::CandMap< BT > CandMap
muisorhelper::Result Result