#include <RecoMuon/MuonIsolationProducers/plugins/MuIsoDepositProducer.h>
Public Member Functions | |
MuIsoDepositProducer (const edm::ParameterSet &) | |
constructor | |
virtual void | produce (edm::Event &, const edm::EventSetup &) |
data making method | |
virtual | ~MuIsoDepositProducer () |
destructor | |
Private Attributes | |
edm::ParameterSet | theConfig |
module configuration | |
std::vector< std::string > | theDepositNames |
bool | theExtractForCandidate |
reco::isodeposit::IsoDepositExtractor * | theExtractor |
std::string | theInputType |
input type. | |
bool | theMultipleDepositsFlag |
edm::InputTag | theMuonCollectionTag |
std::string | theMuonTrackRefType |
Definition at line 13 of file MuIsoDepositProducer.h.
MuIsoDepositProducer::MuIsoDepositProducer | ( | const edm::ParameterSet & | par | ) |
constructor
constructor with config
Definition at line 35 of file MuIsoDepositProducer.cc.
References edm::ParameterSet::getParameter(), i, LogDebug, theConfig, theDepositNames, theExtractForCandidate, theInputType, theMultipleDepositsFlag, theMuonCollectionTag, and theMuonTrackRefType.
00035 : 00036 theConfig(par), 00037 theDepositNames(std::vector<std::string>(1,std::string())), 00038 theExtractor(0) 00039 { 00040 LogDebug("RecoMuon|MuonIsolation")<<" MuIsoDepositProducer CTOR"; 00041 00042 edm::ParameterSet ioPSet = par.getParameter<edm::ParameterSet>("IOPSet"); 00043 00044 theInputType = ioPSet.getParameter<std::string>("InputType"); 00045 theExtractForCandidate = ioPSet.getParameter<bool>("ExtractForCandidate"); 00046 theMuonTrackRefType = ioPSet.getParameter<std::string>("MuonTrackRefType"); 00047 theMuonCollectionTag = ioPSet.getParameter<edm::InputTag>("inputMuonCollection"); 00048 theMultipleDepositsFlag = ioPSet.getParameter<bool>("MultipleDepositsFlag"); 00049 00050 00051 00052 if (theMultipleDepositsFlag){ 00053 theDepositNames = par.getParameter<edm::ParameterSet>("ExtractorPSet") 00054 .getParameter<std::vector<std::string> >("DepositInstanceLabels"); 00055 } 00056 00057 for (uint i = 0; i < theDepositNames.size(); ++i){ 00058 std::string alias = theConfig.getParameter<std::string>("@module_label"); 00059 if (theDepositNames[i] != "") alias += "_" + theDepositNames[i]; 00060 produces<reco::IsoDepositMap>(theDepositNames[i]).setBranchAlias(alias); 00061 } 00062 }
MuIsoDepositProducer::~MuIsoDepositProducer | ( | ) | [virtual] |
destructor
Definition at line 65 of file MuIsoDepositProducer.cc.
References LogDebug, and theExtractor.
00065 { 00066 LogDebug("RecoMuon/MuIsoDepositProducer")<<" MuIsoDepositProducer DTOR"; 00067 delete theExtractor; 00068 }
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(), DBSPlugin::get(), edm::ParameterSet::getParameter(), i, edm::helper::Filler< Map >::insert(), LogDebug, LogTrace, muons_cfi::muons, theConfig, theDepositNames, theExtractForCandidate, theExtractor, theInputType, theMultipleDepositsFlag, theMuonCollectionTag, theMuonTrackRefType, track, and tracks.
00071 { 00072 std::string metname = "RecoMuon|MuonIsolationProducers|MuIsoDepositProducer"; 00073 00074 LogDebug(metname)<<" Muon Deposit producing..." 00075 <<" BEGINING OF EVENT " <<"================================"; 00076 00077 if (!theExtractor) { 00078 edm::ParameterSet extractorPSet = theConfig.getParameter<edm::ParameterSet>("ExtractorPSet"); 00079 std::string extractorName = extractorPSet.getParameter<std::string>("ComponentName"); 00080 theExtractor = IsoDepositExtractorFactory::get()->create( extractorName, extractorPSet); 00081 LogDebug(metname)<<" Load extractor..."<<extractorName; 00082 } 00083 00084 00085 uint nDeps = theMultipleDepositsFlag ? theDepositNames.size() : 1; 00086 00087 00088 00089 // Take the muon container 00090 LogTrace(metname)<<" Taking the muons: "<<theMuonCollectionTag; 00091 Handle<View<Track> > tracks; 00093 Handle<View<RecoCandidate> > muons; 00094 Handle<View<Candidate> > cands; 00095 00096 uint nMuons = 0; 00097 00098 bool readFromRecoTrack = theInputType == "TrackCollection"; 00099 bool readFromRecoMuon = theInputType == "MuonCollection"; 00100 bool readFromCandidateView = theInputType == "CandidateView"; 00101 00102 if (readFromRecoMuon){ 00103 event.getByLabel(theMuonCollectionTag,muons); 00104 nMuons = muons->size(); 00105 LogDebug(metname) <<"Got Muons of size "<<nMuons; 00106 00107 } 00108 if (readFromRecoTrack){ 00109 event.getByLabel(theMuonCollectionTag,tracks); 00110 nMuons = tracks->size(); 00111 LogDebug(metname) <<"Got MuonTracks of size "<<nMuons; 00112 } 00113 if (readFromCandidateView || theExtractForCandidate){ 00114 event.getByLabel(theMuonCollectionTag,cands); 00115 uint nCands = cands->size(); 00116 if (readFromRecoMuon && theExtractForCandidate){ 00118 if (nMuons != nCands) edm::LogError(metname)<<"Inconsistent configuration or failure to read Candidate-muon view"; 00119 } 00120 LogDebug(metname)<< "Got candidate view with size "<<nMuons; 00121 } 00122 00123 static const uint MAX_DEPS=10; 00124 std::auto_ptr<reco::IsoDepositMap> depMaps[MAX_DEPS]; 00125 00126 if (nDeps >10 ) LogError(metname)<<"Unable to handle more than 10 input deposits"; 00127 for (uint i =0;i<nDeps; ++i){ 00128 depMaps[i] = std::auto_ptr<reco::IsoDepositMap>(new reco::IsoDepositMap()); 00129 } 00130 00134 if (nMuons > 0){ 00135 00136 std::vector<std::vector<IsoDeposit> > deps2D(nDeps, std::vector<IsoDeposit>(nMuons)); 00137 00138 for (uint i=0; i< nMuons; ++i) { 00139 TrackBaseRef muRef; 00140 if (readFromRecoMuon){ 00141 if (theMuonTrackRefType == "track"){ 00142 muRef = TrackBaseRef((*muons)[i].track()); 00143 } else if (theMuonTrackRefType == "standAloneMuon"){ 00144 muRef = TrackBaseRef((*muons)[i].standAloneMuon()); 00145 } else if (theMuonTrackRefType == "combinedMuon"){ 00146 muRef = TrackBaseRef((*muons)[i].combinedMuon()); 00147 } else if (theMuonTrackRefType == "bestGlbTrkSta"){ 00148 if (!(*muons)[i].combinedMuon().isNull()){ 00149 muRef = TrackBaseRef((*muons)[i].combinedMuon()); 00150 } else if (!(*muons)[i].track().isNull()){ 00151 muRef = TrackBaseRef((*muons)[i].track()); 00152 } else { 00153 muRef = TrackBaseRef((*muons)[i].standAloneMuon()); 00154 } 00155 } else if (theMuonTrackRefType == "bestTrkSta"){ 00156 if (!(*muons)[i].track().isNull()){ 00157 muRef = TrackBaseRef((*muons)[i].track()); 00158 } else { 00159 muRef = TrackBaseRef((*muons)[i].standAloneMuon()); 00160 } 00161 }else { 00162 edm::LogWarning(metname)<<"Wrong track type is supplied: breaking"; 00163 break; 00164 } 00165 } else if (readFromRecoTrack){ 00166 muRef = TrackBaseRef(tracks, i); 00167 } 00168 00169 if (! theMultipleDepositsFlag){ 00170 if (theExtractForCandidate) deps2D[0][i] = theExtractor->deposit(event, eventSetup, (*cands)[i]); 00171 else deps2D[0][i] = theExtractor->deposit(event, eventSetup, muRef); 00172 00173 } else { 00174 std::vector<IsoDeposit> deps(nDeps); 00175 if (theExtractForCandidate) deps = theExtractor->deposits(event, eventSetup, (*cands)[i]); 00176 else deps = theExtractor->deposits(event, eventSetup, muRef); 00177 for (uint iDep =0; iDep<nDeps; ++iDep) { 00178 deps2D[iDep][i] = deps[iDep]; 00179 } 00180 } 00181 } 00182 00184 for (uint iDep=0; iDep < nDeps; ++iDep){ 00186 for (uint iMu = 0; iMu< nMuons; ++iMu){ 00187 LogTrace(metname)<<"Contents of "<<theDepositNames[iDep] 00188 <<" for a muon at index "<<iMu; 00189 LogTrace(metname)<<deps2D[iDep][iMu].print(); 00190 } 00191 00193 reco::IsoDepositMap::Filler filler(*depMaps[iDep]); 00194 00196 if (readFromRecoMuon){ 00197 filler.insert(muons, deps2D[iDep].begin(), deps2D[iDep].end()); 00198 } else if (readFromRecoTrack){ 00199 filler.insert(tracks, deps2D[iDep].begin(), deps2D[iDep].end()); 00200 } else if (readFromCandidateView){ 00201 filler.insert(cands, deps2D[iDep].begin(), deps2D[iDep].end()); 00202 } else { 00203 edm::LogError(metname)<<"Inconsistent configuration: unknown type requested"; 00204 } 00205 00207 filler.fill(); 00208 } 00209 } 00210 00211 00212 for (uint iMap = 0; iMap < nDeps; ++iMap){ 00213 LogTrace(metname)<<"About to put a deposit named "<<theDepositNames[iMap] 00214 <<" of size "<<depMaps[iMap]->size() 00215 <<" into edm::Event"; 00216 event.put(depMaps[iMap], theDepositNames[iMap]); 00217 } 00218 00219 LogTrace(metname) <<" END OF EVENT " <<"================================"; 00220 }
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().
Definition at line 34 of file MuIsoDepositProducer.h.
Referenced by MuIsoDepositProducer(), and produce().
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().
Definition at line 39 of file MuIsoDepositProducer.h.
Referenced by MuIsoDepositProducer(), and produce().
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().