CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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::IsoDepositExtractor
theExtractor
 
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 24 of file CandIsoDepositProducer.cc.

Member Enumeration Documentation

Constructor & Destructor Documentation

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

constructor with config

Definition at line 47 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, and TrackT.

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

destructor

Definition at line 91 of file CandIsoDepositProducer.cc.

References LogDebug.

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

Member Function Documentation

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

Definition at line 95 of file CandIsoDepositProducer.cc.

References BestT, reco::RecoCandidate::bestTrack(), 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().

95  {
96  if (theTrackType == CandidateT) {
97  return nullptr;
98  } else if (theTrackType == FakeT) {
99  *dummy = Track(10, 10, c.vertex(), c.momentum(), c.charge(), reco::Track::CovarianceMatrix());
100  return dummy;
101  } else {
102  const RecoCandidate *rc = dynamic_cast<const RecoCandidate *>(&c);
103  if (rc == nullptr)
104  throw cms::Exception("Error") << " Candidate is not RecoCandidate: can't get a real track from it!";
105  switch (theTrackType) {
106  case FakeT:
107  break; // to avoid warning
108  case CandidateT:
109  break; // to avoid warning
110  case BestT:
111  return rc->bestTrack();
112  break;
113  case StandAloneMuonT:
114  return &*rc->standAloneMuon();
115  break;
116  case CombinedMuonT:
117  return &*rc->combinedMuon();
118  break;
119  case TrackT:
120  return &*rc->track();
121  break;
122  case GsfT:
123  return static_cast<const Track *>(rc->gsfTrack().get());
124  break;
125  }
126  return nullptr;
127  }
128 }
virtual reco::GsfTrackRef gsfTrack() const
reference to a GsfTrack
const edm::EventSetup & c
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 131 of file CandIsoDepositProducer.cc.

References SplitLinear::begin, c, CandidateT, symbols::deps, dataset::end, extractTrack(), mps_fire::i, LogTrace, metname, eostools::move(), AlCaHLTBitMon_QueryRunRegistry::string, theCandCollectionToken, theDepositNames, theExtractor, theMultipleDepositsFlag, theTrackType, and HLT_FULL_cff::track.

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

Member Data Documentation

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

Definition at line 36 of file CandIsoDepositProducer.cc.

Referenced by produce().

edm::ParameterSet CandIsoDepositProducer::theConfig
private

Definition at line 35 of file CandIsoDepositProducer.cc.

Referenced by CandIsoDepositProducer().

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

Definition at line 38 of file CandIsoDepositProducer.cc.

Referenced by CandIsoDepositProducer(), and produce().

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

Definition at line 40 of file CandIsoDepositProducer.cc.

Referenced by CandIsoDepositProducer(), and produce().

bool CandIsoDepositProducer::theMultipleDepositsFlag
private

Definition at line 39 of file CandIsoDepositProducer.cc.

Referenced by CandIsoDepositProducer(), and produce().

TrackType CandIsoDepositProducer::theTrackType
private

Definition at line 37 of file CandIsoDepositProducer.cc.

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