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 hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () 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

Constructor & Destructor Documentation

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

constructor with config

Definition at line 31 of file CandIsoDepositProducer.cc.

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

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

destructor

Definition at line 75 of file CandIsoDepositProducer.cc.

References LogDebug.

75  {
76  LogDebug("PhysicsTools/CandIsoDepositProducer") << " CandIsoDepositProducer DTOR";
77 }
#define LogDebug(id)

Member Function Documentation

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

Definition at line 79 of file CandIsoDepositProducer.cc.

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

Referenced by produce().

79  {
80  if (theTrackType == CandidateT) {
81  return nullptr;
82  } else if (theTrackType == FakeT) {
83  *dummy = Track(10, 10, c.vertex(), c.momentum(), c.charge(), reco::Track::CovarianceMatrix());
84  return dummy;
85  } else {
86  const RecoCandidate *rc = dynamic_cast<const RecoCandidate *>(&c);
87  if (rc == nullptr)
88  throw cms::Exception("Error") << " Candidate is not RecoCandidate: can't get a real track from it!";
89  switch (theTrackType) {
90  case FakeT:
91  break; // to avoid warning
92  case CandidateT:
93  break; // to avoid warning
94  case BestT:
95  return rc->bestTrack();
96  break;
97  case StandAloneMuonT:
98  return &*rc->standAloneMuon();
99  break;
100  case CombinedMuonT:
101  return &*rc->combinedMuon();
102  break;
103  case TrackT:
104  return &*rc->track();
105  break;
106  case GsfT:
107  return static_cast<const Track *>(rc->gsfTrack().get());
108  break;
109  }
110  return nullptr;
111  }
112 }
virtual reco::GsfTrackRef gsfTrack() const
reference to a GsfTrack
virtual reco::TrackRef standAloneMuon() const
reference to a stand-alone muon Track
virtual reco::TrackRef track() const
reference to a Track
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
const Track * bestTrack() const override
best track pointer
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
Definition: TrackBase.h:74
virtual reco::TrackRef combinedMuon() const
reference to a stand-alone muon Track
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 115 of file CandIsoDepositProducer.cc.

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

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

Member Data Documentation

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

Definition at line 36 of file CandIsoDepositProducer.h.

Referenced by produce().

edm::ParameterSet CandIsoDepositProducer::theConfig
private

Definition at line 35 of file CandIsoDepositProducer.h.

Referenced by CandIsoDepositProducer().

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

Definition at line 38 of file CandIsoDepositProducer.h.

Referenced by CandIsoDepositProducer(), and produce().

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

Definition at line 40 of file CandIsoDepositProducer.h.

Referenced by CandIsoDepositProducer(), and produce().

bool CandIsoDepositProducer::theMultipleDepositsFlag
private

Definition at line 39 of file CandIsoDepositProducer.h.

Referenced by CandIsoDepositProducer(), and produce().

TrackType CandIsoDepositProducer::theTrackType
private

Definition at line 37 of file CandIsoDepositProducer.h.

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