CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

edm::ParameterSet theConfig
 module configuration More...
 
std::vector< std::string > theDepositNames
 
bool theExtractForCandidate
 
reco::isodeposit::IsoDepositExtractortheExtractor
 
std::string theInputType
 
bool theMultipleDepositsFlag
 
edm::InputTag 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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
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 HLT_25ns14e33_v1_cff::alias, edm::EDConsumerBase::consumesCollector(), reco::get(), edm::ParameterSet::getParameter(), 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  theMuonCollectionTag = ioPSet.getParameter<edm::InputTag>("inputMuonCollection");
49  theMultipleDepositsFlag = ioPSet.getParameter<bool>("MultipleDepositsFlag");
50 
51 
52 
53  if (theMultipleDepositsFlag){
54  theDepositNames = par.getParameter<edm::ParameterSet>("ExtractorPSet")
55  .getParameter<std::vector<std::string> >("DepositInstanceLabels");
56  }
57 
58  for (unsigned int i = 0; i < theDepositNames.size(); ++i){
60  if (theDepositNames[i] != "") alias += "_" + theDepositNames[i];
61  produces<reco::IsoDepositMap>(theDepositNames[i]).setBranchAlias(alias);
62  }
63 
64  if (!theExtractor) {
65  edm::ParameterSet extractorPSet = theConfig.getParameter<edm::ParameterSet>("ExtractorPSet");
66  std::string extractorName = extractorPSet.getParameter<std::string>("ComponentName");
67  theExtractor = IsoDepositExtractorFactory::get()->create( extractorName, extractorPSet, consumesCollector());
68  LogDebug(metname)<<" Load extractor..."<<extractorName;
69  }
70 
71 
72 }
#define LogDebug(id)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< std::string > theDepositNames
const std::string metname
edm::InputTag theMuonCollectionTag
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
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 75 of file MuIsoDepositProducer.cc.

References LogDebug, and theExtractor.

75  {
76  LogDebug("RecoMuon/MuIsoDepositProducer")<<" MuIsoDepositProducer DTOR";
77  delete theExtractor;
78 }
#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 getByLabel above)

now actually fill

end if (nMuons>0)

Implements edm::stream::EDProducerBase.

Definition at line 81 of file MuIsoDepositProducer.cc.

References begin, reco::isodeposit::IsoDepositExtractor::deposit(), reco::isodeposit::IsoDepositExtractor::deposits(), end, edm::helper::Filler< Map >::fill(), i, edm::helper::Filler< Map >::insert(), LogDebug, LogTrace, metname, patZpeak::muons, susybsm::HSCParticleType::standAloneMuon, AlCaHLTBitMon_QueryRunRegistry::string, theDepositNames, theExtractForCandidate, theExtractor, theInputType, theMultipleDepositsFlag, theMuonCollectionTag, theMuonTrackRefType, and testEve_cfg::tracks.

81  {
82  std::string metname = "RecoMuon|MuonIsolationProducers|MuIsoDepositProducer";
83 
84  LogDebug(metname)<<" Muon Deposit producing..."
85  <<" BEGINING OF EVENT " <<"================================";
86 
87  unsigned int nDeps = theMultipleDepositsFlag ? theDepositNames.size() : 1;
88 
89 
90 
91  // Take the muon container
92  LogTrace(metname)<<" Taking the muons: "<<theMuonCollectionTag;
96  Handle<View<Candidate> > cands;
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.getByLabel(theMuonCollectionTag,muons);
106  nMuons = muons->size();
107  LogDebug(metname) <<"Got Muons of size "<<nMuons;
108 
109  }
110  if (readFromRecoTrack){
111  event.getByLabel(theMuonCollectionTag,tracks);
112  nMuons = tracks->size();
113  LogDebug(metname) <<"Got MuonTracks of size "<<nMuons;
114  }
115  if (readFromCandidateView || theExtractForCandidate){
116  event.getByLabel(theMuonCollectionTag,cands);
117  unsigned int nCands = cands->size();
118  if (readFromRecoMuon && theExtractForCandidate){
120  if (nMuons != nCands) 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::auto_ptr<reco::IsoDepositMap> depMaps[MAX_DEPS];
128 
129  if (nDeps >10 ) LogError(metname)<<"Unable to handle more than 10 input deposits";
130  for (unsigned int i =0;i<nDeps; ++i){
131  depMaps[i] = std::auto_ptr<reco::IsoDepositMap>(new reco::IsoDepositMap());
132  }
133 
137  if (nMuons > 0){
138 
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) deps2D[0][i] = theExtractor->deposit(event, eventSetup, (*cands)[i]);
174  else deps2D[0][i] = theExtractor->deposit(event, eventSetup, muRef);
175 
176  } else {
177  std::vector<IsoDeposit> deps(nDeps);
178  if (readFromCandidateView || theExtractForCandidate) deps = theExtractor->deposits(event, eventSetup, (*cands)[i]);
179  else deps = theExtractor->deposits(event, eventSetup, muRef);
180  for (unsigned int iDep =0; iDep<nDeps; ++iDep) {
181  deps2D[iDep][i] = deps[iDep];
182  }
183  }
184  }
185 
187  for (unsigned int iDep=0; iDep < nDeps; ++iDep){
189  for (unsigned int iMu = 0; iMu< nMuons; ++iMu){
190  LogTrace(metname)<<"Contents of "<<theDepositNames[iDep]
191  <<" for a muon at index "<<iMu;
192  LogTrace(metname)<<deps2D[iDep][iMu].print();
193  }
194 
196  reco::IsoDepositMap::Filler filler(*depMaps[iDep]);
197 
199  if (readFromRecoMuon){
200  filler.insert(muons, deps2D[iDep].begin(), deps2D[iDep].end());
201  } else if (readFromRecoTrack){
202  filler.insert(tracks, deps2D[iDep].begin(), deps2D[iDep].end());
203  } else if (readFromCandidateView){
204  filler.insert(cands, deps2D[iDep].begin(), deps2D[iDep].end());
205  } else {
206  edm::LogError(metname)<<"Inconsistent configuration: unknown type requested";
207  }
208 
210  filler.fill();
211  }
212  }
213 
214 
215  for (unsigned int iMap = 0; iMap < nDeps; ++iMap){
216  LogTrace(metname)<<"About to put a deposit named "<<theDepositNames[iMap]
217  <<" of size "<<depMaps[iMap]->size()
218  <<" into edm::Event";
219  event.put(depMaps[iMap], theDepositNames[iMap]);
220  }
221 
222  LogTrace(metname) <<" END OF EVENT " <<"================================";
223 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
std::vector< std::string > theDepositNames
const std::string metname
edm::InputTag theMuonCollectionTag
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
Definition: TrackFwd.h:31
#define end
Definition: vmac.h:37
edm::ValueMap< reco::IsoDeposit > IsoDepositMap
keep it only as a part of ValueMap
Definition: IsoDepositFwd.h:9
#define LogTrace(id)
tuple tracks
Definition: testEve_cfg.py:39
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
tuple muons
Definition: patZpeak.py:38
reco::isodeposit::IsoDepositExtractor * theExtractor
virtual reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const =0

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