CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
CandIsoDepositProducer Class Reference
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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

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<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 22 of file CandIsoDepositProducer.cc.

Member Enumeration Documentation

◆ TrackType

Constructor & Destructor Documentation

◆ CandIsoDepositProducer()

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

constructor with config

Definition at line 45 of file CandIsoDepositProducer.cc.

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.

46  : theConfig(par),
48  theDepositNames(std::vector<std::string>(1, "")),
49  theMultipleDepositsFlag(par.getParameter<bool>("MultipleDepositsFlag")) {
50  LogDebug("PhysicsTools|MuonIsolation") << " CandIsoDepositProducer CTOR";
51 
52  edm::ParameterSet extractorPSet = theConfig.getParameter<edm::ParameterSet>("ExtractorPSet");
53  std::string extractorName = extractorPSet.getParameter<std::string>("ComponentName");
54  theExtractor = IsoDepositExtractorFactory::get()->create(extractorName, extractorPSet, consumesCollector());
55 
57  produces<reco::IsoDepositMap>();
58  else {
59  theDepositNames = extractorPSet.getParameter<std::vector<std::string> >("DepositInstanceLabels");
60  if (theDepositNames.size() > 10)
61  throw cms::Exception("Configuration Error") << "This module supports only up to 10 deposits";
62  for (unsigned int iDep = 0; iDep < theDepositNames.size(); ++iDep) {
63  produces<reco::IsoDepositMap>(theDepositNames[iDep]);
64  }
65  }
66 
67  std::string trackType = par.getParameter<std::string>("trackType");
68  if (trackType == "fake")
70  else if (trackType == "best")
72  else if (trackType == "standAloneMuon")
74  else if (trackType == "combinedMuon")
76  else if (trackType == "trackerMuon")
78  else if (trackType == "track")
80  else if (trackType == "gsf")
82  else if (trackType == "candidate")
84  else
85  throw cms::Exception("Error") << "Track type " << trackType << " not valid.";
86 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< edm::View< reco::Candidate > > theCandCollectionToken
std::vector< std::string > theDepositNames
std::unique_ptr< reco::isodeposit::IsoDepositExtractor > theExtractor
#define get
#define LogDebug(id)

◆ ~CandIsoDepositProducer()

CandIsoDepositProducer::~CandIsoDepositProducer ( )
override

destructor

Definition at line 89 of file CandIsoDepositProducer.cc.

References LogDebug.

89  {
90  LogDebug("PhysicsTools/CandIsoDepositProducer") << " CandIsoDepositProducer DTOR";
91 }
#define LogDebug(id)

Member Function Documentation

◆ extractTrack()

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

Definition at line 93 of file CandIsoDepositProducer.cc.

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().

93  {
94  if (theTrackType == CandidateT) {
95  return nullptr;
96  } else if (theTrackType == FakeT) {
97  *dummy = Track(10, 10, c.vertex(), c.momentum(), c.charge(), reco::Track::CovarianceMatrix());
98  return dummy;
99  } else {
100  const RecoCandidate *rc = dynamic_cast<const RecoCandidate *>(&c);
101  if (rc == nullptr)
102  throw cms::Exception("Error") << " Candidate is not RecoCandidate: can't get a real track from it!";
103  switch (theTrackType) {
104  case FakeT:
105  break; // to avoid warning
106  case CandidateT:
107  break; // to avoid warning
108  case BestT:
109  return rc->bestTrack();
110  break;
111  case StandAloneMuonT:
112  return &*rc->standAloneMuon();
113  break;
114  case CombinedMuonT:
115  return &*rc->combinedMuon();
116  break;
117  case TrackT:
118  return &*rc->track();
119  break;
120  case GsfT:
121  return static_cast<const Track *>(rc->gsfTrack().get());
122  break;
123  }
124  return nullptr;
125  }
126 }
virtual reco::GsfTrackRef gsfTrack() const
reference to a GsfTrack
const Track * bestTrack() const override
best track pointer
virtual reco::TrackRef track() const
reference to a Track
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
virtual reco::TrackRef combinedMuon() const
reference to a stand-alone muon Track
math::Error< dimension >::type CovarianceMatrix
5 parameter covariance matrix
Definition: TrackBase.h:74
virtual reco::TrackRef standAloneMuon() const
reference to a stand-alone muon Track

◆ 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 129 of file CandIsoDepositProducer.cc.

References HltBtagPostValidation_cff::c, CandidateT, symbols::deps, mps_fire::end, options_cfi::eventSetup, 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_2022v15_cff::track.

129  {
130  static const std::string metname = "CandIsoDepositProducer";
131 
133  event.getByToken(theCandCollectionToken, hCands);
134 
135  unsigned int nDeps = theMultipleDepositsFlag ? theDepositNames.size() : 1;
136 
137  static const unsigned int MAX_DEPS = 10;
138 
139  if (nDeps > MAX_DEPS)
140  LogError(metname) << "Unable to handle more than 10 input deposits";
141 
145  size_t nMuons = hCands->size();
146  std::vector<std::vector<IsoDeposit> > deps2D(nDeps, std::vector<IsoDeposit>(nMuons));
147 
148  if (nMuons > 0) {
149  theExtractor->initEvent(event, eventSetup);
150 
151  Track dummy;
152  for (size_t i = 0; i < nMuons; ++i) {
153  const Candidate &c = (*hCands)[i];
154  const Track *track = extractTrack(c, &dummy);
155  if ((theTrackType != CandidateT) && (!track)) {
156  edm::LogWarning("CandIsoDepositProducer")
157  << "Candidate #" << i << " has no bestTrack(), it will produce no deposit";
158  reco::IsoDeposit emptyDep;
159  for (size_t iDep = 0; iDep < nDeps; ++iDep) {
160  deps2D[iDep][i] = emptyDep;
161  }
162  continue;
163  }
165  deps2D[0][i] = ((theTrackType == CandidateT) ? theExtractor->deposit(event, eventSetup, c)
166  : theExtractor->deposit(event, eventSetup, *track));
167  } else {
168  std::vector<IsoDeposit> deps =
170  : theExtractor->deposits(event, eventSetup, *track));
171  for (unsigned int iDep = 0; iDep < nDeps; ++iDep) {
172  deps2D[iDep][i] = deps[iDep];
173  }
174  }
175  }
176  } //if (nMuons>0)
177 
179  for (unsigned int iDep = 0; iDep < nDeps; ++iDep) {
181  for (unsigned int iMu = 0; iMu < nMuons; ++iMu) {
182  LogTrace(metname) << "Contents of " << theDepositNames[iDep] << " for a muon at index " << iMu;
183  LogTrace(metname) << deps2D[iDep][iMu].print();
184  }
185 
187  auto depMap = std::make_unique<reco::IsoDepositMap>();
189  filler.insert(hCands, deps2D[iDep].begin(), deps2D[iDep].end());
190  deps2D[iDep].clear();
191  filler.fill();
192  event.put(std::move(depMap), theDepositNames[iDep]);
193  }
194 }
const std::string metname
edm::EDGetTokenT< edm::View< reco::Candidate > > theCandCollectionToken
std::vector< std::string > theDepositNames
Log< level::Error, false > LogError
#define LogTrace(id)
const reco::Track * extractTrack(const reco::Candidate &cand, reco::Track *dummyStorage) const
std::unique_ptr< reco::isodeposit::IsoDepositExtractor > theExtractor
Log< level::Warning, false > LogWarning
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1

Member Data Documentation

◆ theCandCollectionToken

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

Definition at line 34 of file CandIsoDepositProducer.cc.

Referenced by produce().

◆ theConfig

edm::ParameterSet CandIsoDepositProducer::theConfig
private

Definition at line 33 of file CandIsoDepositProducer.cc.

Referenced by CandIsoDepositProducer().

◆ theDepositNames

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

Definition at line 36 of file CandIsoDepositProducer.cc.

Referenced by CandIsoDepositProducer(), and produce().

◆ theExtractor

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

Definition at line 38 of file CandIsoDepositProducer.cc.

Referenced by CandIsoDepositProducer(), and produce().

◆ theMultipleDepositsFlag

bool CandIsoDepositProducer::theMultipleDepositsFlag
private

Definition at line 37 of file CandIsoDepositProducer.cc.

Referenced by CandIsoDepositProducer(), and produce().

◆ theTrackType

TrackType CandIsoDepositProducer::theTrackType
private

Definition at line 35 of file CandIsoDepositProducer.cc.

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