CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
CandIsoDepositProducer Class Reference

#include <CandIsoDepositProducer.h>

Inheritance diagram for CandIsoDepositProducer:
edm::stream::EDProducer<>

Public Member Functions

 CandIsoDepositProducer (const edm::ParameterSet &)
 constructor with config More...
 
void produce (edm::Event &, const edm::EventSetup &) override
 build deposits More...
 
 ~CandIsoDepositProducer () override
 destructor More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Types

enum  TrackType {
  FakeT, BestT, StandAloneMuonT, CombinedMuonT,
  TrackT, GsfT, CandidateT
}
 

Private Member Functions

const reco::TrackextractTrack (const reco::Candidate &cand, reco::Track *dummyStorage) const
 

Private Attributes

edm::EDGetTokenT< edm::View< reco::Candidate > > theCandCollectionToken
 
edm::ParameterSet theConfig
 
std::vector< std::string > theDepositNames
 
std::unique_ptr< reco::isodeposit::IsoDepositExtractortheExtractor
 
bool theMultipleDepositsFlag
 
TrackType theTrackType
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 24 of file CandIsoDepositProducer.h.

Member Enumeration Documentation

◆ TrackType

Enumerator
FakeT 
BestT 
StandAloneMuonT 
CombinedMuonT 
TrackT 
GsfT 
CandidateT 

Definition at line 34 of file CandIsoDepositProducer.h.

Constructor & Destructor Documentation

◆ CandIsoDepositProducer()

CandIsoDepositProducer::CandIsoDepositProducer ( const edm::ParameterSet par)

constructor with config

Definition at line 29 of file CandIsoDepositProducer.cc.

30  : theConfig(par),
32  theDepositNames(std::vector<std::string>(1, "")),
33  theMultipleDepositsFlag(par.getParameter<bool>("MultipleDepositsFlag")) {
34  LogDebug("PhysicsTools|MuonIsolation") << " CandIsoDepositProducer CTOR";
35 
36  edm::ParameterSet extractorPSet = theConfig.getParameter<edm::ParameterSet>("ExtractorPSet");
37  std::string extractorName = extractorPSet.getParameter<std::string>("ComponentName");
38  theExtractor = IsoDepositExtractorFactory::get()->create(extractorName, extractorPSet, consumesCollector());
39 
41  produces<reco::IsoDepositMap>();
42  else {
43  theDepositNames = extractorPSet.getParameter<std::vector<std::string> >("DepositInstanceLabels");
44  if (theDepositNames.size() > 10)
45  throw cms::Exception("Configuration Error") << "This module supports only up to 10 deposits";
46  for (unsigned int iDep = 0; iDep < theDepositNames.size(); ++iDep) {
47  produces<reco::IsoDepositMap>(theDepositNames[iDep]);
48  }
49  }
50 
51  std::string trackType = par.getParameter<std::string>("trackType");
52  if (trackType == "fake")
54  else if (trackType == "best")
56  else if (trackType == "standAloneMuon")
58  else if (trackType == "combinedMuon")
60  else if (trackType == "trackerMuon")
62  else if (trackType == "track")
64  else if (trackType == "gsf")
66  else if (trackType == "candidate")
68  else
69  throw cms::Exception("Error") << "Track type " << trackType << " not valid.";
70 }

References BestT, CandidateT, CombinedMuonT, Exception, FakeT, get, edm::ParameterSet::getParameter(), GsfT, LogDebug, StandAloneMuonT, AlCaHLTBitMon_QueryRunRegistry::string, theConfig, theDepositNames, theExtractor, theMultipleDepositsFlag, theTrackType, TrackT, and PbPb_ZMuSkimMuonDPG_cff::trackType.

◆ ~CandIsoDepositProducer()

CandIsoDepositProducer::~CandIsoDepositProducer ( )
override

destructor

Definition at line 73 of file CandIsoDepositProducer.cc.

73  {
74  LogDebug("PhysicsTools/CandIsoDepositProducer") << " CandIsoDepositProducer DTOR";
75 }

References LogDebug.

Member Function Documentation

◆ extractTrack()

const reco::Track * CandIsoDepositProducer::extractTrack ( const reco::Candidate cand,
reco::Track dummyStorage 
) const
inlineprivate

Definition at line 77 of file CandIsoDepositProducer.cc.

77  {
78  if (theTrackType == CandidateT) {
79  return nullptr;
80  } else if (theTrackType == FakeT) {
81  *dummy = Track(10, 10, c.vertex(), c.momentum(), c.charge(), reco::Track::CovarianceMatrix());
82  return dummy;
83  } else {
84  const RecoCandidate *rc = dynamic_cast<const RecoCandidate *>(&c);
85  if (rc == nullptr)
86  throw cms::Exception("Error") << " Candidate is not RecoCandidate: can't get a real track from it!";
87  switch (theTrackType) {
88  case FakeT:
89  break; // to avoid warning
90  case CandidateT:
91  break; // to avoid warning
92  case BestT:
93  return rc->bestTrack();
94  break;
95  case StandAloneMuonT:
96  return &*rc->standAloneMuon();
97  break;
98  case CombinedMuonT:
99  return &*rc->combinedMuon();
100  break;
101  case TrackT:
102  return &*rc->track();
103  break;
104  case GsfT:
105  return static_cast<const Track *>(rc->gsfTrack().get());
106  break;
107  }
108  return nullptr;
109  }
110 }

References BestT, reco::RecoCandidate::bestTrack(), HltBtagPostValidation_cff::c, CandidateT, reco::RecoCandidate::combinedMuon(), CombinedMuonT, Exception, FakeT, edm::Ref< C, T, F >::get(), GsfT, reco::RecoCandidate::gsfTrack(), reco::RecoCandidate::standAloneMuon(), StandAloneMuonT, theTrackType, reco::RecoCandidate::track(), and TrackT.

Referenced by produce().

◆ produce()

void CandIsoDepositProducer::produce ( edm::Event event,
const edm::EventSetup eventSetup 
)
override

build deposits

OK, now we know how many deps for how many muons each we will create might linearize this at some point (lazy) do it in case some muons are there only

well, it is empty already by construction, but still

for(i<nMuons)

now fill in selectively

some debugging stuff

fill the maps here

for(iDep<nDeps)

Definition at line 113 of file CandIsoDepositProducer.cc.

113  {
114  static const std::string metname = "CandIsoDepositProducer";
115 
117  event.getByToken(theCandCollectionToken, hCands);
118 
119  unsigned int nDeps = theMultipleDepositsFlag ? theDepositNames.size() : 1;
120 
121  static const unsigned int MAX_DEPS = 10;
122 
123  if (nDeps > MAX_DEPS)
124  LogError(metname) << "Unable to handle more than 10 input deposits";
125 
129  size_t nMuons = hCands->size();
130  std::vector<std::vector<IsoDeposit> > deps2D(nDeps, std::vector<IsoDeposit>(nMuons));
131 
132  if (nMuons > 0) {
133  theExtractor->initEvent(event, eventSetup);
134 
135  Track dummy;
136  for (size_t i = 0; i < nMuons; ++i) {
137  const Candidate &c = (*hCands)[i];
138  const Track *track = extractTrack(c, &dummy);
139  if ((theTrackType != CandidateT) && (!track)) {
140  edm::LogWarning("CandIsoDepositProducer")
141  << "Candidate #" << i << " has no bestTrack(), it will produce no deposit";
142  reco::IsoDeposit emptyDep;
143  for (size_t iDep = 0; iDep < nDeps; ++iDep) {
144  deps2D[iDep][i] = emptyDep;
145  }
146  continue;
147  }
149  deps2D[0][i] = ((theTrackType == CandidateT) ? theExtractor->deposit(event, eventSetup, c)
150  : theExtractor->deposit(event, eventSetup, *track));
151  } else {
152  std::vector<IsoDeposit> deps =
153  ((theTrackType == CandidateT) ? theExtractor->deposits(event, eventSetup, c)
154  : theExtractor->deposits(event, eventSetup, *track));
155  for (unsigned int iDep = 0; iDep < nDeps; ++iDep) {
156  deps2D[iDep][i] = deps[iDep];
157  }
158  }
159  }
160  } //if (nMuons>0)
161 
163  for (unsigned int iDep = 0; iDep < nDeps; ++iDep) {
165  for (unsigned int iMu = 0; iMu < nMuons; ++iMu) {
166  LogTrace(metname) << "Contents of " << theDepositNames[iDep] << " for a muon at index " << iMu;
167  LogTrace(metname) << deps2D[iDep][iMu].print();
168  }
169 
171  auto depMap = std::make_unique<reco::IsoDepositMap>();
173  filler.insert(hCands, deps2D[iDep].begin(), deps2D[iDep].end());
174  deps2D[iDep].clear();
175  filler.fill();
176  event.put(std::move(depMap), theDepositNames[iDep]);
177  }
178 }

References HltBtagPostValidation_cff::c, CandidateT, symbols::deps, mps_fire::end, extractTrack(), trigObjTnPSource_cfi::filler, mps_fire::i, LogTrace, metname, eostools::move(), custom_jme_cff::nMuons, AlCaHLTBitMon_QueryRunRegistry::string, theCandCollectionToken, theDepositNames, theExtractor, theMultipleDepositsFlag, theTrackType, and HLT_FULL_cff::track.

Member Data Documentation

◆ theCandCollectionToken

edm::EDGetTokenT<edm::View<reco::Candidate> > CandIsoDepositProducer::theCandCollectionToken
private

Definition at line 36 of file CandIsoDepositProducer.h.

Referenced by produce().

◆ theConfig

edm::ParameterSet CandIsoDepositProducer::theConfig
private

Definition at line 35 of file CandIsoDepositProducer.h.

Referenced by CandIsoDepositProducer().

◆ theDepositNames

std::vector<std::string> CandIsoDepositProducer::theDepositNames
private

Definition at line 38 of file CandIsoDepositProducer.h.

Referenced by CandIsoDepositProducer(), and produce().

◆ theExtractor

std::unique_ptr<reco::isodeposit::IsoDepositExtractor> CandIsoDepositProducer::theExtractor
private

Definition at line 40 of file CandIsoDepositProducer.h.

Referenced by CandIsoDepositProducer(), and produce().

◆ theMultipleDepositsFlag

bool CandIsoDepositProducer::theMultipleDepositsFlag
private

Definition at line 39 of file CandIsoDepositProducer.h.

Referenced by CandIsoDepositProducer(), and produce().

◆ theTrackType

TrackType CandIsoDepositProducer::theTrackType
private

Definition at line 37 of file CandIsoDepositProducer.h.

Referenced by CandIsoDepositProducer(), extractTrack(), and produce().

CandIsoDepositProducer::FakeT
Definition: CandIsoDepositProducer.h:34
mps_fire.i
i
Definition: mps_fire.py:428
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11779
CandIsoDepositProducer::CombinedMuonT
Definition: CandIsoDepositProducer.h:34
custom_jme_cff.nMuons
nMuons
Definition: custom_jme_cff.py:148
reco::RecoCandidate::combinedMuon
virtual reco::TrackRef combinedMuon() const
reference to a stand-alone muon Track
Definition: RecoCandidate.cc:23
CandIsoDepositProducer::theExtractor
std::unique_ptr< reco::isodeposit::IsoDepositExtractor > theExtractor
Definition: CandIsoDepositProducer.h:40
edm::Ref::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
reco::RecoCandidate::standAloneMuon
virtual reco::TrackRef standAloneMuon() const
reference to a stand-alone muon Track
Definition: RecoCandidate.cc:21
edm::Handle
Definition: AssociativeIterator.h:50
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
reco::RecoCandidate::gsfTrack
virtual reco::GsfTrackRef gsfTrack() const
reference to a GsfTrack
Definition: RecoCandidate.cc:19
reco::RecoCandidate::track
virtual reco::TrackRef track() const
reference to a Track
Definition: RecoCandidate.cc:13
CandIsoDepositProducer::BestT
Definition: CandIsoDepositProducer.h:34
CandIsoDepositProducer::TrackT
Definition: CandIsoDepositProducer.h:34
reco::RecoCandidate::bestTrack
const Track * bestTrack() const override
best track pointer
Definition: RecoCandidate.cc:29
mps_fire.end
end
Definition: mps_fire.py:242
reco::Track
Definition: Track.h:27
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::View
Definition: CaloClusterFwd.h:14
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edm::ParameterSet
Definition: ParameterSet.h:47
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
CandIsoDepositProducer::StandAloneMuonT
Definition: CandIsoDepositProducer.h:34
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
reco::RecoCandidate
Definition: RecoCandidate.h:20
CandIsoDepositProducer::theDepositNames
std::vector< std::string > theDepositNames
Definition: CandIsoDepositProducer.h:38
get
#define get
CandIsoDepositProducer::CandidateT
Definition: CandIsoDepositProducer.h:34
PbPb_ZMuSkimMuonDPG_cff.trackType
trackType
Definition: PbPb_ZMuSkimMuonDPG_cff.py:36
reco::Candidate
Definition: Candidate.h:27
eostools.move
def move(src, dest)
Definition: eostools.py:511
CandIsoDepositProducer::theCandCollectionToken
edm::EDGetTokenT< edm::View< reco::Candidate > > theCandCollectionToken
Definition: CandIsoDepositProducer.h:36
Exception
Definition: hltDiff.cc:246
reco::IsoDeposit
Definition: IsoDeposit.h:49
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
CandIsoDepositProducer::theConfig
edm::ParameterSet theConfig
Definition: CandIsoDepositProducer.h:35
CandIsoDepositProducer::GsfT
Definition: CandIsoDepositProducer.h:34
cms::Exception
Definition: Exception.h:70
edm::helper::Filler
Definition: ValueMap.h:22
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
dummy
Definition: DummySelector.h:38
symbols.deps
deps
Definition: symbols.py:55
CandIsoDepositProducer::theTrackType
TrackType theTrackType
Definition: CandIsoDepositProducer.h:37
event
Definition: event.py:1
reco::TrackBase::CovarianceMatrix
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
Definition: TrackBase.h:74
CandIsoDepositProducer::extractTrack
const reco::Track * extractTrack(const reco::Candidate &cand, reco::Track *dummyStorage) const
Definition: CandIsoDepositProducer.cc:77
CandIsoDepositProducer::theMultipleDepositsFlag
bool theMultipleDepositsFlag
Definition: CandIsoDepositProducer.h:39
edm::InputTag
Definition: InputTag.h:15
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:40