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 31 of file MuIsoDepositProducer.cc.

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.

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

◆ ~MuIsoDepositProducer()

MuIsoDepositProducer::~MuIsoDepositProducer ( )
override

destructor

Definition at line 76 of file MuIsoDepositProducer.cc.

References LogDebug.

76  {
77  LogDebug("RecoMuon/MuIsoDepositProducer") << " MuIsoDepositProducer DTOR";
78 }
#define LogDebug(id)

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 81 of file MuIsoDepositProducer.cc.

References HLT_2022v15_cff::cands, symbols::deps, mps_fire::end, options_cfi::eventSetup, 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_2022v15_cff::track, and pwdgSkimBPark_cfi::tracks.

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

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