Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "RecoParticleFlow/PFTracking/interface/ElectronSeedMerger.h"
00009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00010 #include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h"
00011 #include "DataFormats/EgammaReco/interface/ElectronSeed.h"
00012 #include "DataFormats/EgammaReco/interface/ElectronSeedFwd.h"
00013 #include "DataFormats/TrajectorySeed/interface/PropagationDirection.h"
00014 #include "TrackingTools/Records/interface/TransientRecHitRecord.h"
00015 #include <string>
00016
00017
00018 using namespace edm;
00019 using namespace std;
00020 using namespace reco;
00021
00022 ElectronSeedMerger::ElectronSeedMerger(const ParameterSet& iConfig):
00023 conf_(iConfig)
00024 {
00025 LogInfo("ElectronSeedMerger")<<"Electron SeedMerger started ";
00026
00027
00028 ecalBasedSeeds_=iConfig.getParameter<InputTag>("EcalBasedSeeds");
00029 tkBasedSeeds_=iConfig.getParameter<InputTag>("TkBasedSeeds");
00030
00031 produces<ElectronSeedCollection>();
00032
00033 }
00034
00035
00036 ElectronSeedMerger::~ElectronSeedMerger()
00037 {
00038
00039
00040
00041
00042 }
00043
00044
00045
00046
00047
00048
00049
00050 void
00051 ElectronSeedMerger::produce(Event& iEvent, const EventSetup& iSetup)
00052 {
00053
00054 auto_ptr<ElectronSeedCollection> output(new ElectronSeedCollection);
00055
00056
00057 Handle<ElectronSeedCollection> EcalBasedSeeds;
00058 iEvent.getByLabel(ecalBasedSeeds_,EcalBasedSeeds);
00059 ElectronSeedCollection ESeed = *(EcalBasedSeeds.product());
00060
00061 Handle<ElectronSeedCollection> TkBasedSeeds;
00062 iEvent.getByLabel(tkBasedSeeds_,TkBasedSeeds);
00063 ElectronSeedCollection TSeed = *(TkBasedSeeds.product());
00064
00065
00066
00067 vector<bool> TSeedMatched;
00068 for (unsigned int it=0;it<TSeed.size();it++){
00069 TSeedMatched.push_back(false);
00070 }
00071
00072
00073
00074 ElectronSeedCollection::const_iterator e_beg= ESeed.begin();
00075 ElectronSeedCollection::const_iterator e_end= ESeed.end();
00076 for (;e_beg!=e_end;++e_beg){
00077
00078 ElectronSeed NewSeed=*(e_beg);
00079 bool AlreadyMatched =false;
00080
00081
00082 for (unsigned int it=0;it<TSeed.size();it++){
00083 if (AlreadyMatched) continue;
00084
00085
00086 TrajectorySeed::const_iterator eh = e_beg->recHits().first;
00087 TrajectorySeed::const_iterator eh_end = e_beg->recHits().second;
00088
00089
00090 unsigned int hitShared=0;
00091 unsigned int hitSeed=0;
00092 for (;eh!=eh_end;++eh){
00093
00094 if (!eh->isValid()) continue;
00095 hitSeed++;
00096 bool Shared=false;
00097 TrajectorySeed::const_iterator th = TSeed[it].recHits().first;
00098 TrajectorySeed::const_iterator th_end = TSeed[it].recHits().second;
00099 for (;th!=th_end;++th){
00100 if (!th->isValid()) continue;
00101
00102
00103 if (eh->sharesInput(&(*th),TrackingRecHit::all)) Shared = true;
00104
00105
00106 }
00107 if (Shared) hitShared++;
00108 }
00109 if (hitShared==hitSeed){
00110 AlreadyMatched=true;
00111 TSeedMatched[it]=true;
00112 NewSeed.setCtfTrack(TSeed[it].ctfTrack());
00113 }
00114 if ( hitShared == (hitSeed-1)){
00115 NewSeed.setCtfTrack(TSeed[it].ctfTrack());
00116 }
00117 }
00118
00119 output->push_back(NewSeed);
00120 }
00121
00122
00123 for (unsigned int it=0;it<TSeed.size();it++){
00124 if (!TSeedMatched[it]) output->push_back(TSeed[it]);
00125 }
00126
00127
00128 iEvent.put(output);
00129
00130 }