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

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<>
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 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 begin, HLT_2018_cff::cands, symbols::deps, end, options_cfi::eventSetup, trigObjTnPSource_cfi::filler, mps_fire::i, edm::EDGetToken::index(), LogDebug, LogTrace, metname, eostools::move(), PDWG_BPHSkim_cff::muons, jets_cff::nMuons, susybsm::HSCParticleType::standAloneMuon, AlCaHLTBitMon_QueryRunRegistry::string, theDepositNames, theExtractForCandidate, theExtractor, theInputType, theMultipleDepositsFlag, theMuonCollectionTag, theMuonTrackRefType, HLT_2018_cff::track, and PDWG_EXOHSCP_cff::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().

PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
mps_fire.i
i
Definition: mps_fire.py:355
MuIsoDepositProducer::theInputType
std::string theInputType
Definition: MuIsoDepositProducer.h:31
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
end
#define end
Definition: vmac.h:39
MuIsoDepositProducer::theExtractForCandidate
bool theExtractForCandidate
Definition: MuIsoDepositProducer.h:33
jets_cff.nMuons
nMuons
Definition: jets_cff.py:209
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
edm::EDGetToken::index
unsigned int index() const
Definition: EDGetToken.h:45
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
MuIsoDepositProducer::theMuonTrackRefType
std::string theMuonTrackRefType
Definition: MuIsoDepositProducer.h:35
get
#define get
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
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:129
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
Exception
Definition: hltDiff.cc:246
options_cfi.eventSetup
eventSetup
Definition: options_cfi.py:12
HLT_2018_cff.cands
cands
Definition: HLT_2018_cff.py:13762
edm::RefToBase< reco::Track >
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
edm::helper::Filler
Definition: ValueMap.h:22
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
symbols.deps
deps
Definition: symbols.py:55
event
Definition: event.py:1
susybsm::HSCParticleType::standAloneMuon
Definition: HSCParticle.h:20
edm::InputTag
Definition: InputTag.h:15
begin
#define begin
Definition: vmac.h:32
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:43
MuIsoDepositProducer::theExtractor
std::unique_ptr< reco::isodeposit::IsoDepositExtractor > theExtractor
Definition: MuIsoDepositProducer.h:39