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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Attributes

edm::ParameterSet theConfig
 module configuration More...
 
std::vector< std::string > theDepositNames
 
bool theExtractForCandidate
 
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 13 of file MuIsoDepositProducer.h.

Constructor & Destructor Documentation

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

constructor

constructor with config

Definition at line 36 of file MuIsoDepositProducer.cc.

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

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

destructor

Definition at line 89 of file MuIsoDepositProducer.cc.

References LogDebug, and theExtractor.

89  {
90  LogDebug("RecoMuon/MuIsoDepositProducer")<<" MuIsoDepositProducer DTOR";
91  delete theExtractor;
92 }
#define LogDebug(id)
reco::isodeposit::IsoDepositExtractor * theExtractor

Member Function Documentation

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

References begin, egammaForCoreTracking_cff::cands, DEFINE_FWK_MODULE, reco::isodeposit::IsoDepositExtractor::deposit(), reco::isodeposit::IsoDepositExtractor::deposits(), symbols::deps, end, edm::helper::Filler< Map >::fill(), objects.autophobj::filler, mps_fire::i, edm::EDGetToken::index(), edm::helper::Filler< Map >::insert(), LogDebug, LogTrace, metname, eostools::move(), extraflags_cff::muons, jets_cff::nMuons, susybsm::HSCParticleType::standAloneMuon, AlCaHLTBitMon_QueryRunRegistry::string, theDepositNames, theExtractForCandidate, theExtractor, theInputType, theMultipleDepositsFlag, theMuonCollectionTag, theMuonTrackRefType, HiIsolationCommonParameters_cff::track, and l1t::tracks.

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

Member Data Documentation

edm::ParameterSet MuIsoDepositProducer::theConfig
private

module configuration

Definition at line 28 of file MuIsoDepositProducer.h.

Referenced by MuIsoDepositProducer().

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

Definition at line 38 of file MuIsoDepositProducer.h.

Referenced by MuIsoDepositProducer(), and produce().

bool MuIsoDepositProducer::theExtractForCandidate
private

Definition at line 34 of file MuIsoDepositProducer.h.

Referenced by MuIsoDepositProducer(), and produce().

reco::isodeposit::IsoDepositExtractor* MuIsoDepositProducer::theExtractor
private

Definition at line 40 of file MuIsoDepositProducer.h.

Referenced by MuIsoDepositProducer(), produce(), and ~MuIsoDepositProducer().

std::string MuIsoDepositProducer::theInputType
private

input type. Choose from:

Definition at line 32 of file MuIsoDepositProducer.h.

Referenced by MuIsoDepositProducer(), and produce().

bool MuIsoDepositProducer::theMultipleDepositsFlag
private

Definition at line 39 of file MuIsoDepositProducer.h.

Referenced by MuIsoDepositProducer(), and produce().

edm::EDGetToken MuIsoDepositProducer::theMuonCollectionTag
private

Definition at line 37 of file MuIsoDepositProducer.h.

Referenced by MuIsoDepositProducer(), and produce().

std::string MuIsoDepositProducer::theMuonTrackRefType
private

Definition at line 36 of file MuIsoDepositProducer.h.

Referenced by MuIsoDepositProducer(), and produce().