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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 MuIsoDepositProducer (const edm::ParameterSet &)
 constructor More...
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 data making method More...
 
virtual ~MuIsoDepositProducer ()
 destructor More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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

destructor

Definition at line 88 of file MuIsoDepositProducer.cc.

References LogDebug, and theExtractor.

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

Member Function Documentation

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

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

References begin, 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::helper::Filler< Map >::insert(), LogDebug, LogTrace, metname, eostools::move(), electronCleaner_cfi::muons, susybsm::HSCParticleType::standAloneMuon, AlCaHLTBitMon_QueryRunRegistry::string, theDepositNames, theExtractForCandidate, theExtractor, theInputType, theMultipleDepositsFlag, theMuonCollectionTag, theMuonTrackRefType, HiIsolationCommonParameters_cff::track, and l1t::tracks.

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