CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
MuIsolatorResultProducer< BT > Class Template Reference

BT == base type. More...

#include <MuIsolatorResultProducer.h>

Inheritance diagram for MuIsolatorResultProducer< BT >:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Classes

struct  DepositConf
 
struct  VetoCuts
 

Public Member Functions

 MuIsolatorResultProducer (const edm::ParameterSet &)
 constructor with config More...
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
virtual ~MuIsolatorResultProducer ()
 destructor More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Types

typedef muisorhelper::CandMap< BT > CandMap
 
typedef
muisorhelper::DepositContainer 
DepositContainer
 
typedef muisorhelper::Isolator Isolator
 
typedef muisorhelper::Result Result
 
typedef muisorhelper::Results Results
 
typedef muisorhelper::ResultType ResultType
 

Private Member Functions

void callWhatProduces ()
 declare what's going to be produced More...
 
unsigned int initAssociation (edm::Event &event, CandMap &candMapT) const
 
void initVetos (std::vector< reco::IsoDeposit::Vetos * > &vetos, CandMap &candMap) const
 
void writeOut (edm::Event &event, const CandMap &candMap, const Results &results) const
 choose which result type to write here More...
 
template<typename RT >
void writeOutImpl (edm::Event &event, const CandMap &candMapT, const Results &results) const
 actually do the writing here More...
 

Private Attributes

reco::TrackBase::Point theBeam
 
std::string theBeamlineOption
 beam spot More...
 
edm::InputTag theBeamSpotLabel
 
edm::ParameterSet theConfig
 
std::vector< DepositConftheDepositConfs
 
IsolatortheIsolator
 the isolator More...
 
bool theRemoveOtherVetos
 choose which muon vetos should be removed from all deposits More...
 
ResultType theResultType
 
VetoCuts theVetoCuts
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

template<typename BT = reco::Candidate>
class MuIsolatorResultProducer< BT >

BT == base type.

Definition at line 52 of file MuIsolatorResultProducer.h.

Member Typedef Documentation

template<typename BT = reco::Candidate>
typedef muisorhelper::CandMap<BT> MuIsolatorResultProducer< BT >::CandMap
private

Definition at line 68 of file MuIsolatorResultProducer.h.

template<typename BT = reco::Candidate>
typedef muisorhelper::DepositContainer MuIsolatorResultProducer< BT >::DepositContainer
private

Definition at line 66 of file MuIsolatorResultProducer.h.

template<typename BT = reco::Candidate>
typedef muisorhelper::Isolator MuIsolatorResultProducer< BT >::Isolator
private

Definition at line 62 of file MuIsolatorResultProducer.h.

template<typename BT = reco::Candidate>
typedef muisorhelper::Result MuIsolatorResultProducer< BT >::Result
private

Definition at line 63 of file MuIsolatorResultProducer.h.

template<typename BT = reco::Candidate>
typedef muisorhelper::Results MuIsolatorResultProducer< BT >::Results
private

Definition at line 65 of file MuIsolatorResultProducer.h.

template<typename BT = reco::Candidate>
typedef muisorhelper::ResultType MuIsolatorResultProducer< BT >::ResultType
private

Definition at line 64 of file MuIsolatorResultProducer.h.

Constructor & Destructor Documentation

template<typename BT >
MuIsolatorResultProducer< BT >::MuIsolatorResultProducer ( const edm::ParameterSet par)

constructor with config

read input config for deposit types and weights and thresholds to apply to them

will switch to a factory at some point

FIXME

FIXME: need to get the file name here

"other vetoes" is limited to the same collection now for non-trivial choice an external map with pre-made selection flags can be a better choice

Definition at line 186 of file MuIsolatorResultProducer.h.

References MuIsolatorResultProducer< BT >::callWhatProduces(), edm::ParameterSet::getParameter(), LogDebug, MuIsolatorResultProducer< BT >::VetoCuts::muAbsEtaMax, MuIsolatorResultProducer< BT >::VetoCuts::muAbsZMax, MuIsolatorResultProducer< BT >::VetoCuts::muD0Max, MuIsolatorResultProducer< BT >::VetoCuts::muPtMin, muonisolation::MuIsoBaseIsolator::resultType(), MuIsolatorResultProducer< BT >::VetoCuts::selectAll, MuIsolatorResultProducer< BT >::DepositConf::tag, MuIsolatorResultProducer< BT >::theBeamlineOption, MuIsolatorResultProducer< BT >::theBeamSpotLabel, MuIsolatorResultProducer< BT >::theDepositConfs, MuIsolatorResultProducer< BT >::theIsolator, MuIsolatorResultProducer< BT >::theRemoveOtherVetos, MuIsolatorResultProducer< BT >::theResultType, MuIsolatorResultProducer< BT >::theVetoCuts, MuIsolatorResultProducer< BT >::DepositConf::threshold, and MuIsolatorResultProducer< BT >::DepositConf::weight.

186  :
187  theConfig(par),
188  theRemoveOtherVetos(par.getParameter<bool>("RemoveOtherVetos")),
189  theIsolator(0),
190  theBeam(0,0,0)
191 {
192  LogDebug("RecoMuon|MuonIsolation")<<" MuIsolatorResultProducer CTOR";
193 
195  std::vector<edm::ParameterSet> depositInputs =
196  par.getParameter<std::vector<edm::ParameterSet> >("InputMuIsoDeposits");
197 
198  std::vector<double> dWeights( depositInputs.size());
199  std::vector<double> dThresholds( depositInputs.size());
200 
201  for (unsigned int iDep = 0; iDep < depositInputs.size(); ++iDep){
202  DepositConf dConf;
203  dConf.tag = depositInputs[iDep].getParameter<edm::InputTag>("DepositTag");
204  dConf.weight = depositInputs[iDep].getParameter<double>("DepositWeight");
205  dConf.threshold = depositInputs[iDep].getParameter<double>("DepositThreshold");
206 
207  dWeights[iDep] = dConf.weight;
208  dThresholds[iDep] = dConf.threshold;
209 
210  theDepositConfs.push_back(dConf);
211  }
212 
213  edm::ParameterSet isoPset = par.getParameter<edm::ParameterSet>("IsolatorPSet");
215  std::string isolatorType = isoPset.getParameter<std::string>("ComponentName");
216  if ( isolatorType == "IsolatorByDeposit"){
217  std::string coneSizeType = isoPset.getParameter<std::string>("ConeSizeType");
218  if (coneSizeType == "FixedConeSize"){
219  float coneSize(isoPset.getParameter<double>("coneSize"));
220 
221  theIsolator = new muonisolation::IsolatorByDeposit(coneSize, dWeights, dThresholds);
222 
223  // theIsolator = new IsolatorByDeposit(isoPset);
224  } else if (coneSizeType == "CutsConeSize"){
226 // Cuts cuts(isoPset.getParameter<edm::ParameterSet>("CutsPSet"));
227 
228 // theIsolator = new IsolatorByDeposit(coneSize, dWeights, dThresholds);
229  }
230  } else if ( isolatorType == "IsolatorByNominalEfficiency"){
232  theIsolator = new muonisolation::IsolatorByNominalEfficiency("noname", std::vector<std::string>(1,"8:0.97"), dWeights);
233  } else if ( isolatorType == "IsolatorByDepositCount"){
234  std::string coneSizeType = isoPset.getParameter<std::string>("ConeSizeType");
235  if (coneSizeType == "FixedConeSize"){
236  float coneSize(isoPset.getParameter<double>("coneSize"));
237 
238  theIsolator = new muonisolation::IsolatorByDepositCount(coneSize, dThresholds);
239 
240  // theIsolator = new IsolatorByDeposit(isoPset);
241  } else if (coneSizeType == "CutsConeSize"){
242  // Cuts cuts(isoPset.getParameter<edm::ParameterSet>("CutsPSet"));
243 
244  // theIsolator = new IsolatorByDeposit(coneSize, dWeights, dThresholds);
245  }
246  }
247 
248  if (theIsolator == 0 ){
249  edm::LogError("MuonIsolationProducers")<<"Failed to initialize an isolator";
250  }
252 
254 
255  if (theRemoveOtherVetos){
256  edm::ParameterSet vetoPSet = par.getParameter<edm::ParameterSet>("VetoPSet");
257  theVetoCuts.selectAll = vetoPSet.getParameter<bool>("SelectAll");
258 
262  if (! theVetoCuts.selectAll){
263  theVetoCuts.muAbsEtaMax = vetoPSet.getParameter<double>("MuAbsEtaMax");
264  theVetoCuts.muPtMin = vetoPSet.getParameter<double>("MuPtMin");
265  theVetoCuts.muAbsZMax = vetoPSet.getParameter<double>("MuAbsZMax");
266  theVetoCuts.muD0Max = vetoPSet.getParameter<double>("MuD0Max");
267  theBeamlineOption = par.getParameter<std::string>("BeamlineOption");
268  theBeamSpotLabel = par.getParameter<edm::InputTag>("BeamSpotLabel");
269  }
270  }
271 }
#define LogDebug(id)
T getParameter(std::string const &) const
std::vector< DepositConf > theDepositConfs
bool theRemoveOtherVetos
choose which muon vetos should be removed from all deposits
void callWhatProduces()
declare what&#39;s going to be produced
Isolator * theIsolator
the isolator
std::string theBeamlineOption
beam spot
virtual ResultType resultType() const =0
reco::TrackBase::Point theBeam
template<typename BT >
MuIsolatorResultProducer< BT >::~MuIsolatorResultProducer ( )
virtual

destructor

Definition at line 275 of file MuIsolatorResultProducer.h.

References LogDebug.

275  {
276  if (theIsolator) delete theIsolator;
277  LogDebug("RecoMuon|MuIsolatorResultProducer")<<" MuIsolatorResultProducer DTOR";
278 }
#define LogDebug(id)
Isolator * theIsolator
the isolator

Member Function Documentation

template<typename BT >
void MuIsolatorResultProducer< BT >::callWhatProduces ( )
inlineprivate

declare what's going to be produced

Definition at line 154 of file MuIsolatorResultProducer.h.

Referenced by MuIsolatorResultProducer< BT >::MuIsolatorResultProducer().

template<typename BT >
unsigned int MuIsolatorResultProducer< BT >::initAssociation ( edm::Event event,
CandMap candMapT 
) const
private

WARNING: the input ValueMaps are better be for a single key product ID no effort is done (FIXME) for more complex cases

init {muon, {[deposit,veto]_type}} container

Definition at line 352 of file MuIsolatorResultProducer.h.

References muisorhelper::CandMap< BT >::get(), edm::HandleBase::id(), LogDebug, metname, muisorhelper::CandMap< BT >::setHandle(), and GlobalPosition_Frontier_DevDB_cff::tag.

352  {
353  std::string metname = "RecoMuon|MuonIsolationProducers";
354 
356 
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;
362 
365  typename CandMap::handle_type keyH;
366  event.get(depH->begin().id(), keyH);
367  candMapT.setHandle(keyH);
368  typename CT::const_iterator depHCI = depH->begin().begin();
369  typename CT::const_iterator depEnd = depH->begin().end();
370  unsigned int keyI=0;
371  for (; depHCI != depEnd; ++depHCI, ++keyI){
372 
373  typename CandMap::key_type muPtr(keyH->refAt(keyI));
375  if (iMap == 0) candMapT.get().push_back(typename CandMap::pair_type(muPtr, DepositContainer(theDepositConfs.size())));
376  typename CandMap::iterator muI = candMapT.get().begin();
377  for (; muI != candMapT.get().end(); ++muI){
378  if (muI->first == muPtr) break;
379  }
380  if (muI->first != muPtr){
381  edm::LogError("MuonIsolationProducers")<<"Failed to align muon map";
382  }
383  muI->second[iMap].dep = &*depHCI;
384  }
385  }
386 
387  LogDebug(metname)<<"Picked and aligned nDeps = "<<candMapT.get().size();
388  return candMapT.get().size();
389 }
#define LogDebug(id)
std::pair< key_type, value_type > pair_type
ProductID id() const
Definition: HandleBase.cc:15
const std::string metname
std::vector< DepositConf > theDepositConfs
edm::RefToBase< BT > key_type
edm::Handle< edm::View< BT > > handle_type
muisorhelper::DepositContainer DepositContainer
std::vector< value_type > container
Definition: ValueMap.h:101
template<typename BT >
void MuIsolatorResultProducer< BT >::initVetos ( std::vector< reco::IsoDeposit::Vetos * > &  vetos,
CandMap candMap 
) const
private

Definition at line 392 of file MuIsolatorResultProducer.h.

References debug_cff::d0, muisorhelper::CandMap< BT >::get(), LogDebug, and metname.

392  {
393  std::string metname = "RecoMuon|MuonIsolationProducers";
394 
395 
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();
400 
401  unsigned int muI = 0;
402  for (; muI < candMapT.get().size(); ++muI) {
403  typename CandMap::key_type mu = candMapT.get()[muI].first;
404  double d0 = ( (mu->vx() - theBeam.x() )* mu->py() - (mu->vy() - theBeam.y())* mu->px() ) / mu->pt();
405  LogDebug(metname)<<"Muon at index "<<muI;
407  || (fabs(mu->eta()) < theVetoCuts.muAbsEtaMax
408  && mu->pt() > theVetoCuts.muPtMin
409  && fabs(mu->vz()) < theVetoCuts.muAbsZMax
410  && fabs(d0) < theVetoCuts.muD0Max
411  )
412  ){
413  LogDebug(metname)<<"muon passes the cuts";
414  for (unsigned int iDep =0; iDep < candMapT.get()[muI].second.size(); ++iDep){
415  if (vetos[iDep] == 0) vetos[iDep] = new reco::IsoDeposit::Vetos();
416 
417  vetos[iDep]->push_back(candMapT.get()[muI].second[iDep].dep->veto());
418  }
419  }
420  }
421 
422  LogDebug(metname)<<"Assigning vetos";
423  muI = 0;
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];
427  }
428  }
429  LogDebug(metname)<<"Done with vetos";
430  }
431 }
#define LogDebug(id)
tuple d0
Definition: debug_cff.py:3
const std::string metname
bool theRemoveOtherVetos
choose which muon vetos should be removed from all deposits
edm::RefToBase< BT > key_type
std::vector< Veto > Vetos
Definition: IsoDeposit.h:58
reco::TrackBase::Point theBeam
template<typename BT >
void MuIsolatorResultProducer< BT >::produce ( edm::Event event,
const edm::EventSetup eventSetup 
)
virtual

do it only if needed

"smart" container used to repackage deposits_type_candIndex into deposits_candIndex_type have to have it for veto removal (could do away without it otherwise) IMPORTANT: ALL THE REFERENCING BUSINESS IS DONE THROUGH POINTERS Access to the mapped values as reference type HAS TO BE AVAILABLE

isolator results will be here

extra vetos will be filled here

call the isolator result, passing {[deposit,vetos]_type} set and the candidate

do cleanup

Implements edm::EDProducer.

Definition at line 282 of file MuIsolatorResultProducer.h.

References ExpressReco_HICollisions_FallBack::beamSpot, muisorhelper::CandMap< BT >::get(), edm::HandleBase::isValid(), LogDebug, LogTrace, metname, and python.entryComment::results.

282  {
283 
284  std::string metname = "RecoMuon|MuonIsolationProducers";
285  LogDebug(metname)<<" Muon Deposit producing..."
286  <<" BEGINING OF EVENT " <<"================================";
287 
288  theBeam = reco::TrackBase::Point(0,0, 0);
289 
292  if (theBeamlineOption.compare("BeamSpotFromEvent") == 0){
293  //pick beamSpot
295  edm::Handle<reco::BeamSpot> beamSpotH;
296 
297  event.getByLabel(theBeamSpotLabel,beamSpotH);
298 
299  if (beamSpotH.isValid()){
300  theBeam = beamSpotH->position();
301  LogTrace(metname)<<"Extracted beam point at "<<theBeam<<std::endl;
302  }
303  }
304  }
305 
311  CandMap candMapT;
312 
313  unsigned int colSize = initAssociation(event, candMapT);
314 
316  Results results(colSize);
317 
319  std::vector<reco::IsoDeposit::Vetos*> vetoDeps(theDepositConfs.size(), 0);
320 
321  if (colSize != 0){
322  if (theRemoveOtherVetos){
323 
324  initVetos(vetoDeps, candMapT);
325  }
326 
328  for (unsigned int muI=0; muI < colSize; ++muI){
329  results[muI] = theIsolator->result(candMapT.get()[muI].second, *(candMapT.get()[muI].first));
330 
331  if (results[muI].typeF()!= theIsolator->resultType()){
332  edm::LogError("MuonIsolationProducers")<<"Failed to get result from the isolator";
333  }
334  }
335 
336  }
337 
338  LogDebug(metname)<<"Ready to write out results of size "<<results.size();
339  writeOut(event, candMapT, results);
340 
341  for(unsigned int iDep = 0; iDep< vetoDeps.size(); ++iDep){
343  if (vetoDeps[iDep]){
344  delete vetoDeps[iDep];
345  vetoDeps[iDep] = 0;
346  }
347  }
348 }
#define LogDebug(id)
const std::string metname
std::vector< DepositConf > theDepositConfs
bool theRemoveOtherVetos
choose which muon vetos should be removed from all deposits
Isolator * theIsolator
the isolator
std::string theBeamlineOption
beam spot
virtual Result result(DepositContainer deposits) const =0
Compute and return the isolation variable.
math::XYZPoint Point
point in the space
Definition: TrackBase.h:75
void initVetos(std::vector< reco::IsoDeposit::Vetos * > &vetos, CandMap &candMap) const
bool isValid() const
Definition: HandleBase.h:76
virtual ResultType resultType() const =0
#define LogTrace(id)
unsigned int initAssociation(edm::Event &event, CandMap &candMapT) const
void writeOut(edm::Event &event, const CandMap &candMap, const Results &results) const
choose which result type to write here
reco::TrackBase::Point theBeam
muisorhelper::CandMap< BT > CandMap
template<typename BT >
void MuIsolatorResultProducer< BT >::writeOut ( edm::Event event,
const CandMap candMap,
const Results results 
) const
inlineprivate

choose which result type to write here

Definition at line 139 of file MuIsolatorResultProducer.h.

References event(), LogDebug, metname, and python.entryComment::results.

141  {
142 
143  std::string metname = "RecoMuon|MuonIsolationProducers";
144  LogDebug(metname)<<"Before calling writeOutMap with result type "<<theIsolator->resultType();
145 
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);
149 }
#define LogDebug(id)
const std::string metname
Isolator * theIsolator
the 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
template<typename BT >
template<typename RT >
void MuIsolatorResultProducer< BT >::writeOutImpl ( edm::Event event,
const CandMap candMapT,
const Results results 
) const
inlineprivate

actually do the writing here

make an output vec of what's to be written with a concrete type

fill/insert of non-empty values only

Definition at line 119 of file MuIsolatorResultProducer.h.

References edm::helper::Filler< Map >::fill(), muisorhelper::CandMap< BT >::get(), muisorhelper::CandMap< BT >::handle(), i, and edm::helper::Filler< Map >::insert().

120  {
122  std::vector<RT> resV(results.size());
123  for (unsigned int i = 0; i< resV.size(); ++i) resV[i] = results[i].val<RT>();
124  std::auto_ptr<edm::ValueMap<RT> > outMap(new edm::ValueMap<RT>());
125  typename edm::ValueMap<RT>::Filler filler(*outMap);
126 
128  if (candMapT.get().size()>0){
129  filler.insert(candMapT.handle(), resV.begin(), resV.end());
130  filler.fill();
131  }
132 
133  event.put(outMap);
134 }
int i
Definition: DBlmapReader.cc:9

Member Data Documentation

template<typename BT = reco::Candidate>
reco::TrackBase::Point MuIsolatorResultProducer< BT >::theBeam
private

Definition at line 112 of file MuIsolatorResultProducer.h.

template<typename BT = reco::Candidate>
std::string MuIsolatorResultProducer< BT >::theBeamlineOption
private
template<typename BT = reco::Candidate>
edm::InputTag MuIsolatorResultProducer< BT >::theBeamSpotLabel
private
template<typename BT = reco::Candidate>
edm::ParameterSet MuIsolatorResultProducer< BT >::theConfig
private

Definition at line 97 of file MuIsolatorResultProducer.h.

template<typename BT = reco::Candidate>
std::vector<DepositConf> MuIsolatorResultProducer< BT >::theDepositConfs
private
template<typename BT = reco::Candidate>
Isolator* MuIsolatorResultProducer< BT >::theIsolator
private

the isolator

Definition at line 105 of file MuIsolatorResultProducer.h.

Referenced by MuIsolatorResultProducer< BT >::MuIsolatorResultProducer().

template<typename BT = reco::Candidate>
bool MuIsolatorResultProducer< BT >::theRemoveOtherVetos
private

choose which muon vetos should be removed from all deposits

Definition at line 101 of file MuIsolatorResultProducer.h.

Referenced by MuIsolatorResultProducer< BT >::MuIsolatorResultProducer().

template<typename BT = reco::Candidate>
ResultType MuIsolatorResultProducer< BT >::theResultType
private
template<typename BT = reco::Candidate>
VetoCuts MuIsolatorResultProducer< BT >::theVetoCuts
private