CMS 3D CMS Logo

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

#include <MuIsoDepositProducer.h>

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

Public Member Functions

 MuIsoDepositProducer (const edm::ParameterSet &)
 constructor More...
 
void produce (edm::Event &, const edm::EventSetup &) override
 data making method More...
 
 ~MuIsoDepositProducer () 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 Attributes

std::vector< std::string > theDepositNames
 
bool theExtractForCandidate
 
std::unique_ptr< reco::isodeposit::IsoDepositExtractortheExtractor
 
std::string theInputType
 
bool theMultipleDepositsFlag
 
edm::EDGetToken theMuonCollectionTag
 
std::string theMuonTrackRefType
 

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 17 of file MuIsoDepositProducer.h.

Constructor & Destructor Documentation

◆ MuIsoDepositProducer()

MuIsoDepositProducer::MuIsoDepositProducer ( const edm::ParameterSet par)

constructor

constructor with config

Definition at line 34 of file MuIsoDepositProducer.cc.

35  : theDepositNames(std::vector<std::string>(1, std::string())) {
36  static const std::string metname = "RecoMuon|MuonIsolationProducers|MuIsoDepositProducer";
37  LogDebug(metname) << " MuIsoDepositProducer CTOR";
38 
39  edm::ParameterSet ioPSet = par.getParameter<edm::ParameterSet>("IOPSet");
40 
41  theInputType = ioPSet.getParameter<std::string>("InputType");
42  theExtractForCandidate = ioPSet.getParameter<bool>("ExtractForCandidate");
43  theMuonTrackRefType = ioPSet.getParameter<std::string>("MuonTrackRefType");
44 
45  bool readFromRecoTrack = theInputType == "TrackCollection";
46  bool readFromRecoMuon = theInputType == "MuonCollection";
47  bool readFromCandidateView = theInputType == "CandidateView";
48  if (readFromRecoTrack) {
49  theMuonCollectionTag = consumes<View<Track>>(ioPSet.getParameter<edm::InputTag>("inputMuonCollection"));
50  } else if (readFromRecoMuon) {
51  theMuonCollectionTag = consumes<View<RecoCandidate>>(ioPSet.getParameter<edm::InputTag>("inputMuonCollection"));
52  } else if (readFromCandidateView) {
53  theMuonCollectionTag = consumes<View<Candidate>>(ioPSet.getParameter<edm::InputTag>("inputMuonCollection"));
54  } else {
55  throw cms::Exception("Configuration") << "Inconsistent configuration or failure to read Candidate-muon view";
56  }
57 
58  theMultipleDepositsFlag = ioPSet.getParameter<bool>("MultipleDepositsFlag");
59 
61  theDepositNames = par.getParameter<edm::ParameterSet>("ExtractorPSet")
62  .getParameter<std::vector<std::string>>("DepositInstanceLabels");
63  }
64 
65  for (unsigned int i = 0; i < theDepositNames.size(); ++i) {
66  std::string alias = par.getParameter<std::string>("@module_label");
67  if (!theDepositNames[i].empty())
68  alias += "_" + theDepositNames[i];
69  produces<reco::IsoDepositMap>(theDepositNames[i]).setBranchAlias(alias);
70  }
71 
72  edm::ParameterSet extractorPSet = par.getParameter<edm::ParameterSet>("ExtractorPSet");
73  std::string extractorName = extractorPSet.getParameter<std::string>("ComponentName");
74  theExtractor = IsoDepositExtractorFactory::get()->create(extractorName, extractorPSet, consumesCollector());
75  LogDebug(metname) << " Load extractor..." << extractorName;
76 }

References SiStripOfflineCRack_cfg::alias, relativeConstraints::empty, Exception, get, edm::ParameterSet::getParameter(), mps_fire::i, LogDebug, metname, AlCaHLTBitMon_QueryRunRegistry::string, theDepositNames, theExtractForCandidate, theExtractor, theInputType, theMultipleDepositsFlag, theMuonCollectionTag, and theMuonTrackRefType.

◆ ~MuIsoDepositProducer()

MuIsoDepositProducer::~MuIsoDepositProducer ( )
override

destructor

Definition at line 79 of file MuIsoDepositProducer.cc.

79  {
80  LogDebug("RecoMuon/MuIsoDepositProducer") << " MuIsoDepositProducer DTOR";
81 }

References LogDebug.

Member Function Documentation

◆ produce()

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

data making method

build deposits

read them as RecoCandidates: need to have track() standAloneMuon() etc in the interface

get rid of this at some point and use the cands

expect nMuons set already

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

end for (nMuons)

now fill in selectively

some debugging stuff

fill the maps here

now figure out the source handle (see getByToken above)

now actually fill

end if (nMuons>0)

Definition at line 84 of file MuIsoDepositProducer.cc.

84  {
85  static const std::string metname = "RecoMuon|MuonIsolationProducers|MuIsoDepositProducer";
86 
87  LogDebug(metname) << " Muon Deposit producing..."
88  << " BEGINING OF EVENT "
89  << "================================";
90 
91  unsigned int nDeps = theMultipleDepositsFlag ? theDepositNames.size() : 1;
92 
93  // Take the muon container
94  LogTrace(metname) << " Taking the muons: "
95  << theMuonCollectionTag.index(); //a more friendly print would use "inputMuonCollection"
100 
101  unsigned int nMuons = 0;
102 
103  bool readFromRecoTrack = theInputType == "TrackCollection";
104  bool readFromRecoMuon = theInputType == "MuonCollection";
105  bool readFromCandidateView = theInputType == "CandidateView";
106 
107  if (readFromRecoMuon) {
108  event.getByToken(theMuonCollectionTag, muons);
109  nMuons = muons->size();
110  LogDebug(metname) << "Got Muons of size " << nMuons;
111  }
112  if (readFromRecoTrack) {
113  event.getByToken(theMuonCollectionTag, tracks);
114  nMuons = tracks->size();
115  LogDebug(metname) << "Got MuonTracks of size " << nMuons;
116  }
117  if (readFromCandidateView || theExtractForCandidate) {
118  event.getByToken(theMuonCollectionTag, cands);
119  unsigned int nCands = cands->size();
120  if (readFromRecoMuon && theExtractForCandidate) {
122  if (nMuons != nCands)
123  edm::LogError(metname) << "Inconsistent configuration or failure to read Candidate-muon view";
124  }
125  nMuons = nCands;
126  LogDebug(metname) << "Got candidate view with size " << nMuons;
127  }
128 
129  static const unsigned int MAX_DEPS = 10;
130  std::unique_ptr<reco::IsoDepositMap> depMaps[MAX_DEPS];
131 
132  if (nDeps > 10)
133  LogError(metname) << "Unable to handle more than 10 input deposits";
134  for (unsigned int i = 0; i < nDeps; ++i) {
135  depMaps[i] = std::make_unique<reco::IsoDepositMap>();
136  }
137 
141  if (nMuons > 0) {
142  std::vector<std::vector<IsoDeposit>> deps2D(nDeps, std::vector<IsoDeposit>(nMuons));
143 
144  for (unsigned int i = 0; i < nMuons; ++i) {
145  TrackBaseRef muRef;
146  if (readFromRecoMuon) {
147  if (theMuonTrackRefType == "track") {
148  muRef = TrackBaseRef((*muons)[i].track());
149  } else if (theMuonTrackRefType == "standAloneMuon") {
150  muRef = TrackBaseRef((*muons)[i].standAloneMuon());
151  } else if (theMuonTrackRefType == "combinedMuon") {
152  muRef = TrackBaseRef((*muons)[i].combinedMuon());
153  } else if (theMuonTrackRefType == "bestGlbTrkSta") {
154  if (!(*muons)[i].combinedMuon().isNull()) {
155  muRef = TrackBaseRef((*muons)[i].combinedMuon());
156  } else if (!(*muons)[i].track().isNull()) {
157  muRef = TrackBaseRef((*muons)[i].track());
158  } else {
159  muRef = TrackBaseRef((*muons)[i].standAloneMuon());
160  }
161  } else if (theMuonTrackRefType == "bestTrkSta") {
162  if (!(*muons)[i].track().isNull()) {
163  muRef = TrackBaseRef((*muons)[i].track());
164  } else {
165  muRef = TrackBaseRef((*muons)[i].standAloneMuon());
166  }
167  } else {
168  edm::LogWarning(metname) << "Wrong track type is supplied: breaking";
169  break;
170  }
171  } else if (readFromRecoTrack) {
172  muRef = TrackBaseRef(tracks, i);
173  }
174 
176  if (readFromCandidateView || theExtractForCandidate)
177  deps2D[0][i] = theExtractor->deposit(event, eventSetup, (*cands)[i]);
178  else
179  deps2D[0][i] = theExtractor->deposit(event, eventSetup, muRef);
180 
181  } else {
182  std::vector<IsoDeposit> deps(nDeps);
183  if (readFromCandidateView || theExtractForCandidate)
184  deps = theExtractor->deposits(event, eventSetup, (*cands)[i]);
185  else
186  deps = theExtractor->deposits(event, eventSetup, muRef);
187  for (unsigned int iDep = 0; iDep < nDeps; ++iDep) {
188  deps2D[iDep][i] = deps[iDep];
189  }
190  }
191  }
192 
194  for (unsigned int iDep = 0; iDep < nDeps; ++iDep) {
196  for (unsigned int iMu = 0; iMu < nMuons; ++iMu) {
197  LogTrace(metname) << "Contents of " << theDepositNames[iDep] << " for a muon at index " << iMu;
198  LogTrace(metname) << deps2D[iDep][iMu].print();
199  }
200 
202  reco::IsoDepositMap::Filler filler(*depMaps[iDep]);
203 
205  if (readFromRecoMuon) {
206  filler.insert(muons, deps2D[iDep].begin(), deps2D[iDep].end());
207  } else if (readFromRecoTrack) {
208  filler.insert(tracks, deps2D[iDep].begin(), deps2D[iDep].end());
209  } else if (readFromCandidateView) {
210  filler.insert(cands, deps2D[iDep].begin(), deps2D[iDep].end());
211  } else {
212  edm::LogError(metname) << "Inconsistent configuration: unknown type requested";
213  }
214 
216  filler.fill();
217  }
218  }
219 
220  for (unsigned int iMap = 0; iMap < nDeps; ++iMap) {
221  LogTrace(metname) << "About to put a deposit named " << theDepositNames[iMap] << " of size "
222  << depMaps[iMap]->size() << " into edm::Event";
223  event.put(std::move(depMaps[iMap]), theDepositNames[iMap]);
224  }
225 
226  LogTrace(metname) << " END OF EVENT "
227  << "================================";
228 }

References HLT_FULL_cff::cands, symbols::deps, mps_fire::end, trigObjTnPSource_cfi::filler, mps_fire::i, edm::EDGetToken::index(), LogDebug, LogTrace, metname, eostools::move(), PDWG_BPHSkim_cff::muons, custom_jme_cff::nMuons, susybsm::HSCParticleType::standAloneMuon, AlCaHLTBitMon_QueryRunRegistry::string, theDepositNames, theExtractForCandidate, theExtractor, theInputType, theMultipleDepositsFlag, theMuonCollectionTag, theMuonTrackRefType, HLT_FULL_cff::track, and tracks.

Member Data Documentation

◆ theDepositNames

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

Definition at line 37 of file MuIsoDepositProducer.h.

Referenced by MuIsoDepositProducer(), and produce().

◆ theExtractForCandidate

bool MuIsoDepositProducer::theExtractForCandidate
private

Definition at line 33 of file MuIsoDepositProducer.h.

Referenced by MuIsoDepositProducer(), and produce().

◆ theExtractor

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

Definition at line 39 of file MuIsoDepositProducer.h.

Referenced by MuIsoDepositProducer(), and produce().

◆ theInputType

std::string MuIsoDepositProducer::theInputType
private

input type. Choose from:

Definition at line 31 of file MuIsoDepositProducer.h.

Referenced by MuIsoDepositProducer(), and produce().

◆ theMultipleDepositsFlag

bool MuIsoDepositProducer::theMultipleDepositsFlag
private

Definition at line 38 of file MuIsoDepositProducer.h.

Referenced by MuIsoDepositProducer(), and produce().

◆ theMuonCollectionTag

edm::EDGetToken MuIsoDepositProducer::theMuonCollectionTag
private

Definition at line 36 of file MuIsoDepositProducer.h.

Referenced by MuIsoDepositProducer(), and produce().

◆ theMuonTrackRefType

std::string MuIsoDepositProducer::theMuonTrackRefType
private

Definition at line 35 of file MuIsoDepositProducer.h.

Referenced by MuIsoDepositProducer(), and produce().

edm::EDGetToken::index
constexpr unsigned int index() const noexcept
Definition: EDGetToken.h:50
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
mps_fire.i
i
Definition: mps_fire.py:428
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11724
MuIsoDepositProducer::theInputType
std::string theInputType
Definition: MuIsoDepositProducer.h:31
custom_jme_cff.nMuons
nMuons
Definition: custom_jme_cff.py:148
MuIsoDepositProducer::theMuonCollectionTag
edm::EDGetToken theMuonCollectionTag
Definition: MuIsoDepositProducer.h:36
reco::TrackBaseRef
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
Definition: TrackFwd.h:35
edm::Handle
Definition: AssociativeIterator.h:50
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
MuIsoDepositProducer::theExtractForCandidate
bool theExtractForCandidate
Definition: MuIsoDepositProducer.h:33
mps_fire.end
end
Definition: mps_fire.py:242
HLT_FULL_cff.cands
cands
Definition: HLT_FULL_cff.py:15161
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:176
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
MuIsoDepositProducer::theMuonTrackRefType
std::string theMuonTrackRefType
Definition: MuIsoDepositProducer.h:35
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
get
#define get
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MuIsoDepositProducer::theDepositNames
std::vector< std::string > theDepositNames
Definition: MuIsoDepositProducer.h:37
eostools.move
def move(src, dest)
Definition: eostools.py:511
MuIsoDepositProducer::theMultipleDepositsFlag
bool theMultipleDepositsFlag
Definition: MuIsoDepositProducer.h:38
SiStripOfflineCRack_cfg.alias
alias
Definition: SiStripOfflineCRack_cfg.py:128
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
Exception
Definition: hltDiff.cc:245
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::RefToBase< reco::Track >
edm::helper::Filler
Definition: ValueMap.h:22
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
symbols.deps
deps
Definition: symbols.py:61
event
Definition: event.py:1
susybsm::HSCParticleType::standAloneMuon
Definition: HSCParticle.h:20
edm::InputTag
Definition: InputTag.h:15
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:40
MuIsoDepositProducer::theExtractor
std::unique_ptr< reco::isodeposit::IsoDepositExtractor > theExtractor
Definition: MuIsoDepositProducer.h:39