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::EDProducer edm::ProducerBase 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::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

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::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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

References ExpressReco_HICollisions_FallBack::alias, edm::ParameterSet::getParameter(), i, LogDebug, theConfig, theDepositNames, theExtractForCandidate, theInputType, theMultipleDepositsFlag, theMuonCollectionTag, and theMuonTrackRefType.

35  :
36  theConfig(par),
37  theDepositNames(std::vector<std::string>(1,std::string())),
38  theExtractor(0)
39 {
40  LogDebug("RecoMuon|MuonIsolation")<<" MuIsoDepositProducer CTOR";
41 
42  edm::ParameterSet ioPSet = par.getParameter<edm::ParameterSet>("IOPSet");
43 
44  theInputType = ioPSet.getParameter<std::string>("InputType");
45  theExtractForCandidate = ioPSet.getParameter<bool>("ExtractForCandidate");
46  theMuonTrackRefType = ioPSet.getParameter<std::string>("MuonTrackRefType");
47  theMuonCollectionTag = ioPSet.getParameter<edm::InputTag>("inputMuonCollection");
48  theMultipleDepositsFlag = ioPSet.getParameter<bool>("MultipleDepositsFlag");
49 
50 
51 
52  if (theMultipleDepositsFlag){
53  theDepositNames = par.getParameter<edm::ParameterSet>("ExtractorPSet")
54  .getParameter<std::vector<std::string> >("DepositInstanceLabels");
55  }
56 
57  for (unsigned int i = 0; i < theDepositNames.size(); ++i){
58  std::string alias = theConfig.getParameter<std::string>("@module_label");
59  if (theDepositNames[i] != "") alias += "_" + theDepositNames[i];
60  produces<reco::IsoDepositMap>(theDepositNames[i]).setBranchAlias(alias);
61  }
62 }
#define LogDebug(id)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< std::string > theDepositNames
edm::InputTag theMuonCollectionTag
reco::isodeposit::IsoDepositExtractor * theExtractor
edm::ParameterSet theConfig
module configuration
MuIsoDepositProducer::~MuIsoDepositProducer ( )
virtual

destructor

Definition at line 65 of file MuIsoDepositProducer.cc.

References LogDebug, and theExtractor.

65  {
66  LogDebug("RecoMuon/MuIsoDepositProducer")<<" MuIsoDepositProducer DTOR";
67  delete theExtractor;
68 }
#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::EDProducer.

Definition at line 71 of file MuIsoDepositProducer.cc.

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

71  {
72  std::string metname = "RecoMuon|MuonIsolationProducers|MuIsoDepositProducer";
73 
74  LogDebug(metname)<<" Muon Deposit producing..."
75  <<" BEGINING OF EVENT " <<"================================";
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);
81  LogDebug(metname)<<" Load extractor..."<<extractorName;
82  }
83 
84 
85  unsigned int nDeps = theMultipleDepositsFlag ? theDepositNames.size() : 1;
86 
87 
88 
89  // Take the muon container
90  LogTrace(metname)<<" Taking the muons: "<<theMuonCollectionTag;
94  Handle<View<Candidate> > cands;
95 
96  unsigned int nMuons = 0;
97 
98  bool readFromRecoTrack = theInputType == "TrackCollection";
99  bool readFromRecoMuon = theInputType == "MuonCollection";
100  bool readFromCandidateView = theInputType == "CandidateView";
101 
102  if (readFromRecoMuon){
103  event.getByLabel(theMuonCollectionTag,muons);
104  nMuons = muons->size();
105  LogDebug(metname) <<"Got Muons of size "<<nMuons;
106 
107  }
108  if (readFromRecoTrack){
109  event.getByLabel(theMuonCollectionTag,tracks);
110  nMuons = tracks->size();
111  LogDebug(metname) <<"Got MuonTracks of size "<<nMuons;
112  }
113  if (readFromCandidateView || theExtractForCandidate){
114  event.getByLabel(theMuonCollectionTag,cands);
115  unsigned int nCands = cands->size();
116  if (readFromRecoMuon && theExtractForCandidate){
118  if (nMuons != nCands) edm::LogError(metname)<<"Inconsistent configuration or failure to read Candidate-muon view";
119  }
120  nMuons = nCands;
121  LogDebug(metname)<< "Got candidate view with size "<<nMuons;
122  }
123 
124  static const unsigned int MAX_DEPS=10;
125  std::auto_ptr<reco::IsoDepositMap> depMaps[MAX_DEPS];
126 
127  if (nDeps >10 ) LogError(metname)<<"Unable to handle more than 10 input deposits";
128  for (unsigned int i =0;i<nDeps; ++i){
129  depMaps[i] = std::auto_ptr<reco::IsoDepositMap>(new reco::IsoDepositMap());
130  }
131 
135  if (nMuons > 0){
136 
137  std::vector<std::vector<IsoDeposit> > deps2D(nDeps, std::vector<IsoDeposit>(nMuons));
138 
139  for (unsigned int i=0; i< nMuons; ++i) {
140  TrackBaseRef muRef;
141  if (readFromRecoMuon){
142  if (theMuonTrackRefType == "track"){
143  muRef = TrackBaseRef((*muons)[i].track());
144  } else if (theMuonTrackRefType == "standAloneMuon"){
145  muRef = TrackBaseRef((*muons)[i].standAloneMuon());
146  } else if (theMuonTrackRefType == "combinedMuon"){
147  muRef = TrackBaseRef((*muons)[i].combinedMuon());
148  } else if (theMuonTrackRefType == "bestGlbTrkSta"){
149  if (!(*muons)[i].combinedMuon().isNull()){
150  muRef = TrackBaseRef((*muons)[i].combinedMuon());
151  } else if (!(*muons)[i].track().isNull()){
152  muRef = TrackBaseRef((*muons)[i].track());
153  } else {
154  muRef = TrackBaseRef((*muons)[i].standAloneMuon());
155  }
156  } else if (theMuonTrackRefType == "bestTrkSta"){
157  if (!(*muons)[i].track().isNull()){
158  muRef = TrackBaseRef((*muons)[i].track());
159  } else {
160  muRef = TrackBaseRef((*muons)[i].standAloneMuon());
161  }
162  }else {
163  edm::LogWarning(metname)<<"Wrong track type is supplied: breaking";
164  break;
165  }
166  } else if (readFromRecoTrack){
167  muRef = TrackBaseRef(tracks, i);
168  }
169 
171  if (readFromCandidateView || theExtractForCandidate) deps2D[0][i] = theExtractor->deposit(event, eventSetup, (*cands)[i]);
172  else deps2D[0][i] = theExtractor->deposit(event, eventSetup, muRef);
173 
174  } else {
175  std::vector<IsoDeposit> deps(nDeps);
176  if (readFromCandidateView || theExtractForCandidate) deps = theExtractor->deposits(event, eventSetup, (*cands)[i]);
177  else deps = theExtractor->deposits(event, eventSetup, muRef);
178  for (unsigned int iDep =0; iDep<nDeps; ++iDep) {
179  deps2D[iDep][i] = deps[iDep];
180  }
181  }
182  }
183 
185  for (unsigned int iDep=0; iDep < nDeps; ++iDep){
187  for (unsigned int iMu = 0; iMu< nMuons; ++iMu){
188  LogTrace(metname)<<"Contents of "<<theDepositNames[iDep]
189  <<" for a muon at index "<<iMu;
190  LogTrace(metname)<<deps2D[iDep][iMu].print();
191  }
192 
194  reco::IsoDepositMap::Filler filler(*depMaps[iDep]);
195 
197  if (readFromRecoMuon){
198  filler.insert(muons, deps2D[iDep].begin(), deps2D[iDep].end());
199  } else if (readFromRecoTrack){
200  filler.insert(tracks, deps2D[iDep].begin(), deps2D[iDep].end());
201  } else if (readFromCandidateView){
202  filler.insert(cands, deps2D[iDep].begin(), deps2D[iDep].end());
203  } else {
204  edm::LogError(metname)<<"Inconsistent configuration: unknown type requested";
205  }
206 
208  filler.fill();
209  }
210  }
211 
212 
213  for (unsigned int iMap = 0; iMap < nDeps; ++iMap){
214  LogTrace(metname)<<"About to put a deposit named "<<theDepositNames[iMap]
215  <<" of size "<<depMaps[iMap]->size()
216  <<" into edm::Event";
217  event.put(depMaps[iMap], theDepositNames[iMap]);
218  }
219 
220  LogTrace(metname) <<" END OF EVENT " <<"================================";
221 }
#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
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
Definition: TrackFwd.h:22
#define end
Definition: vmac.h:38
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
#define begin
Definition: vmac.h:31
reco::isodeposit::IsoDepositExtractor * theExtractor
edm::ParameterSet theConfig
module configuration
T get(const Candidate &c)
Definition: component.h:56

Member Data Documentation

edm::ParameterSet MuIsoDepositProducer::theConfig
private

module configuration

Definition at line 28 of file MuIsoDepositProducer.h.

Referenced by MuIsoDepositProducer(), and produce().

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