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 TK SEED
77  unsigned int hitShared = 0;
78  unsigned int hitSeed = 0;
79  for (auto const& eh : e_beg->recHits()) {
80  if (!eh.isValid())
81  continue;
82  hitSeed++;
83  bool Shared = false;
84  for (auto const& th : TSeed[it].recHits()) {
85  if (!th.isValid())
86  continue;
87  //CHECK THE HIT COMPATIBILITY: put back sharesInput
88  // as soon Egamma solves the bug on the seed collection
89  if (eh.sharesInput(&th, TrackingRecHit::all))
90  Shared = true;
91  // if(eh->geographicalId() == th->geographicalId() &&
92  // (eh->localPosition() - th->localPosition()).mag() < 0.001) Shared=true;
93  }
94  if (Shared)
95  hitShared++;
96  }
97  if (hitShared == hitSeed) {
98  AlreadyMatched = true;
99  TSeedMatched[it] = true;
100  NewSeed.setCtfTrack(TSeed[it].ctfTrack());
101  }
102  if (hitShared == (hitSeed - 1)) {
103  NewSeed.setCtfTrack(TSeed[it].ctfTrack());
104  }
105  }
106 
107  output->push_back(NewSeed);
108  }
109 
110  //FILL THE COLLECTION WITH UNMATCHED TK-BASED SEED
111  for (unsigned int it = 0; it < TSeed.size(); it++) {
112  if (!TSeedMatched[it])
113  output->push_back(TSeed[it]);
114  }
115 
116  //PUT THE MERGED COLLECTION IN THE EVENT
117  iEvent.put(std::move(output));
118 }
119 
edm::StreamID
Definition: StreamID.h:30
MessageLogger.h
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
edm::EDGetTokenT< reco::ElectronSeedCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
TransientRecHitRecord.h
edm::EDGetTokenT::isUninitialized
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
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
reco::ElectronSeedCollection
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
Definition: ElectronSeedFwd.h:10
TrajectorySeed.h
edm::global::EDProducer
Definition: EDProducer.h:32
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
edm::ParameterSet
Definition: ParameterSet.h:47
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
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
ElectronSeedMerger
Definition: ElectronSeedMerger.cc:17
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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