CMS 3D CMS Logo

ElectronSeedMerger.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: PFTracking
4 // Class: ElectronSeedMerger
5 //
6 // Original Author: Michele Pioppi
7 
16 
18 public:
19  explicit ElectronSeedMerger(const edm::ParameterSet&);
20 
21 private:
22  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
23 
26 };
27 
28 using namespace edm;
29 using namespace std;
30 using namespace reco;
31 
33  : ecalSeedToken_{consumes<ElectronSeedCollection>(iConfig.getParameter<InputTag>("EcalBasedSeeds"))} {
34  edm::InputTag tkSeedLabel_ = iConfig.getParameter<InputTag>("TkBasedSeeds");
35  if (!tkSeedLabel_.label().empty())
36  tkSeedToken_ = consumes<ElectronSeedCollection>(tkSeedLabel_);
37 
38  produces<ElectronSeedCollection>();
39 }
40 
41 // ------------ method called to produce the data ------------
43  //CREATE OUTPUT COLLECTION
44  auto output = std::make_unique<ElectronSeedCollection>();
45 
46  //HANDLE THE INPUT SEED COLLECTIONS
49  ElectronSeedCollection ESeed = *(EcalBasedSeeds.product());
50 
54  iEvent.getByToken(tkSeedToken_, TkBasedSeeds);
55  TSeed = *(TkBasedSeeds.product());
56  }
57 
58  //VECTOR FOR MATCHED SEEDS
59  vector<bool> TSeedMatched;
60  for (unsigned int it = 0; it < TSeed.size(); it++) {
61  TSeedMatched.push_back(false);
62  }
63 
64  //LOOP OVER THE ECAL SEED COLLECTION
65  ElectronSeedCollection::const_iterator e_beg = ESeed.begin();
66  ElectronSeedCollection::const_iterator e_end = ESeed.end();
67  for (; e_beg != e_end; ++e_beg) {
68  ElectronSeed NewSeed = *(e_beg);
69  bool AlreadyMatched = false;
70 
71  //LOOP OVER THE TK SEED COLLECTION
72  for (unsigned int it = 0; it < TSeed.size(); it++) {
73  if (AlreadyMatched)
74  continue;
75 
76  //HITS FOR ECAL SEED
77  TrajectorySeed::const_iterator eh = e_beg->recHits().first;
78  TrajectorySeed::const_iterator eh_end = e_beg->recHits().second;
79 
80  //HITS FOR TK SEED
81  unsigned int hitShared = 0;
82  unsigned int hitSeed = 0;
83  for (; eh != eh_end; ++eh) {
84  if (!eh->isValid())
85  continue;
86  hitSeed++;
87  bool Shared = false;
88  TrajectorySeed::const_iterator th = TSeed[it].recHits().first;
89  TrajectorySeed::const_iterator th_end = TSeed[it].recHits().second;
90  for (; th != th_end; ++th) {
91  if (!th->isValid())
92  continue;
93  //CHECK THE HIT COMPATIBILITY: put back sharesInput
94  // as soon Egamma solves the bug on the seed collection
95  if (eh->sharesInput(&(*th), TrackingRecHit::all))
96  Shared = true;
97  // if(eh->geographicalId() == th->geographicalId() &&
98  // (eh->localPosition() - th->localPosition()).mag() < 0.001) Shared=true;
99  }
100  if (Shared)
101  hitShared++;
102  }
103  if (hitShared == hitSeed) {
104  AlreadyMatched = true;
105  TSeedMatched[it] = true;
106  NewSeed.setCtfTrack(TSeed[it].ctfTrack());
107  }
108  if (hitShared == (hitSeed - 1)) {
109  NewSeed.setCtfTrack(TSeed[it].ctfTrack());
110  }
111  }
112 
113  output->push_back(NewSeed);
114  }
115 
116  //FILL THE COLLECTION WITH UNMATCHED TK-BASED SEED
117  for (unsigned int it = 0; it < TSeed.size(); it++) {
118  if (!TSeedMatched[it])
119  output->push_back(TSeed[it]);
120  }
121 
122  //PUT THE MERGED COLLECTION IN THE EVENT
123  iEvent.put(std::move(output));
124 }
125 
edm::StreamID
Definition: StreamID.h:30
MessageLogger.h
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:32
edm::EDGetTokenT< reco::ElectronSeedCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
TransientRecHitRecord.h
TrajectorySeed::const_iterator
recHitContainer::const_iterator const_iterator
Definition: TrajectorySeed.h:20
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
MakerMacros.h
reco::ElectronSeed
Definition: ElectronSeed.h:51
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ElectronSeedMerger::tkSeedToken_
edm::EDGetTokenT< reco::ElectronSeedCollection > tkSeedToken_
Definition: ElectronSeedMerger.cc:25
edm::EDGetTokenT::isUninitialized
bool isUninitialized() const
Definition: EDGetToken.h:70
reco::ElectronSeedCollection
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
Definition: ElectronSeedFwd.h:10
TrajectorySeed.h
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ParameterSet
Definition: ParameterSet.h:36
TrackingRecHit::all
Definition: TrackingRecHit.h:59
Event.h
mergedElectronSeeds_cfi.TkBasedSeeds
TkBasedSeeds
Definition: mergedElectronSeeds_cfi.py:6
reco::ElectronSeed::setCtfTrack
void setCtfTrack(const CtfTrackRef &)
Set additional info.
Definition: ElectronSeed.cc:39
iEvent
int iEvent
Definition: GenABIO.cc:224
ElectronSeedMerger::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: ElectronSeedMerger.cc:42
edm::EventSetup
Definition: EventSetup.h:57
ElectronSeedMerger::ecalSeedToken_
const edm::EDGetTokenT< reco::ElectronSeedCollection > ecalSeedToken_
Definition: ElectronSeedMerger.cc:24
PropagationDirection.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
ElectronSeedMerger
Definition: ElectronSeedMerger.cc:17
TrajectorySeed::recHits
range recHits() const
Definition: TrajectorySeed.h:52
ElectronSeedMerger::ElectronSeedMerger
ElectronSeedMerger(const edm::ParameterSet &)
Definition: ElectronSeedMerger.cc:32
EDProducer.h
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
mergedElectronSeeds_cfi.EcalBasedSeeds
EcalBasedSeeds
Definition: mergedElectronSeeds_cfi.py:5
ElectronSeed.h