CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
ElectronSeedMerger Class Reference

#include <ElectronSeedMerger.h>

Inheritance diagram for ElectronSeedMerger:
edm::stream::EDProducer<>

Public Member Functions

 ElectronSeedMerger (const edm::ParameterSet &)
 
 ~ElectronSeedMerger () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::ParameterSet conf_
 
edm::EDGetTokenT< reco::ElectronSeedCollectionecalSeedToken_
 SEED COLLECTIONS. More...
 
edm::EDGetTokenT< reco::ElectronSeedCollectiontkSeedToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 14 of file ElectronSeedMerger.h.

Constructor & Destructor Documentation

ElectronSeedMerger::ElectronSeedMerger ( const edm::ParameterSet iConfig)
explicit

Definition at line 20 of file ElectronSeedMerger.cc.

References ecalSeedToken_, edm::ParameterSet::getParameter(), edm::InputTag::label(), and tkSeedToken_.

20  : conf_(iConfig) {
21  LogInfo("ElectronSeedMerger") << "Electron SeedMerger started ";
22 
23  ecalSeedToken_ = consumes<ElectronSeedCollection>(iConfig.getParameter<InputTag>("EcalBasedSeeds"));
24  edm::InputTag tkSeedLabel_ = iConfig.getParameter<InputTag>("TkBasedSeeds");
25  if (!tkSeedLabel_.label().empty())
26  tkSeedToken_ = consumes<ElectronSeedCollection>(tkSeedLabel_);
27 
28  produces<ElectronSeedCollection>();
29 }
T getParameter(std::string const &) const
edm::ParameterSet conf_
edm::EDGetTokenT< reco::ElectronSeedCollection > ecalSeedToken_
SEED COLLECTIONS.
std::string const & label() const
Definition: InputTag.h:36
edm::EDGetTokenT< reco::ElectronSeedCollection > tkSeedToken_
ElectronSeedMerger::~ElectronSeedMerger ( )
override

Definition at line 31 of file ElectronSeedMerger.cc.

31  {
32  // do anything here that needs to be done at desctruction time
33  // (e.g. close files, deallocate resources etc.)
34 }

Member Function Documentation

void ElectronSeedMerger::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 41 of file ElectronSeedMerger.cc.

References TrackingRecHit::all, mergedElectronSeeds_cfi::EcalBasedSeeds, ecalSeedToken_, edm::Event::getByToken(), edm::EDGetTokenT< T >::isUninitialized(), eostools::move(), convertSQLitetoXML_cfg::output, edm::Handle< T >::product(), edm::Event::put(), TrajectorySeed::recHits(), reco::ElectronSeed::setCtfTrack(), mergedElectronSeeds_cfi::TkBasedSeeds, and tkSeedToken_.

41  {
42  //CREATE OUTPUT COLLECTION
43  auto output = std::make_unique<ElectronSeedCollection>();
44 
45  //HANDLE THE INPUT SEED COLLECTIONS
47  iEvent.getByToken(ecalSeedToken_, EcalBasedSeeds);
48  ElectronSeedCollection ESeed = *(EcalBasedSeeds.product());
49 
53  iEvent.getByToken(tkSeedToken_, TkBasedSeeds);
54  TSeed = *(TkBasedSeeds.product());
55  }
56 
57  //VECTOR FOR MATCHED SEEDS
58  vector<bool> TSeedMatched;
59  for (unsigned int it = 0; it < TSeed.size(); it++) {
60  TSeedMatched.push_back(false);
61  }
62 
63  //LOOP OVER THE ECAL SEED COLLECTION
64  ElectronSeedCollection::const_iterator e_beg = ESeed.begin();
65  ElectronSeedCollection::const_iterator e_end = ESeed.end();
66  for (; e_beg != e_end; ++e_beg) {
67  ElectronSeed NewSeed = *(e_beg);
68  bool AlreadyMatched = false;
69 
70  //LOOP OVER THE TK SEED COLLECTION
71  for (unsigned int it = 0; it < TSeed.size(); it++) {
72  if (AlreadyMatched)
73  continue;
74 
75  //HITS FOR ECAL SEED
76  TrajectorySeed::const_iterator eh = e_beg->recHits().first;
77  TrajectorySeed::const_iterator eh_end = e_beg->recHits().second;
78 
79  //HITS FOR TK SEED
80  unsigned int hitShared = 0;
81  unsigned int hitSeed = 0;
82  for (; eh != eh_end; ++eh) {
83  if (!eh->isValid())
84  continue;
85  hitSeed++;
86  bool Shared = false;
87  TrajectorySeed::const_iterator th = TSeed[it].recHits().first;
88  TrajectorySeed::const_iterator th_end = TSeed[it].recHits().second;
89  for (; th != th_end; ++th) {
90  if (!th->isValid())
91  continue;
92  //CHECK THE HIT COMPATIBILITY: put back sharesInput
93  // as soon Egamma solves the bug on the seed collection
94  if (eh->sharesInput(&(*th), TrackingRecHit::all))
95  Shared = true;
96  // if(eh->geographicalId() == th->geographicalId() &&
97  // (eh->localPosition() - th->localPosition()).mag() < 0.001) Shared=true;
98  }
99  if (Shared)
100  hitShared++;
101  }
102  if (hitShared == hitSeed) {
103  AlreadyMatched = true;
104  TSeedMatched[it] = true;
105  NewSeed.setCtfTrack(TSeed[it].ctfTrack());
106  }
107  if (hitShared == (hitSeed - 1)) {
108  NewSeed.setCtfTrack(TSeed[it].ctfTrack());
109  }
110  }
111 
112  output->push_back(NewSeed);
113  }
114 
115  //FILL THE COLLECTION WITH UNMATCHED TK-BASED SEED
116  for (unsigned int it = 0; it < TSeed.size(); it++) {
117  if (!TSeedMatched[it])
118  output->push_back(TSeed[it]);
119  }
120 
121  //PUT THE MERGED COLLECTION IN THE EVENT
122  iEvent.put(std::move(output));
123 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
void setCtfTrack(const CtfTrackRef &)
Set additional info.
Definition: ElectronSeed.cc:39
recHitContainer::const_iterator const_iterator
edm::EDGetTokenT< reco::ElectronSeedCollection > ecalSeedToken_
SEED COLLECTIONS.
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
T const * product() const
Definition: Handle.h:69
range recHits() const
edm::EDGetTokenT< reco::ElectronSeedCollection > tkSeedToken_
bool isUninitialized() const
Definition: EDGetToken.h:70
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

edm::ParameterSet ElectronSeedMerger::conf_
private

Definition at line 22 of file ElectronSeedMerger.h.

edm::EDGetTokenT<reco::ElectronSeedCollection> ElectronSeedMerger::ecalSeedToken_
private

SEED COLLECTIONS.

Definition at line 25 of file ElectronSeedMerger.h.

Referenced by ElectronSeedMerger(), and produce().

edm::EDGetTokenT<reco::ElectronSeedCollection> ElectronSeedMerger::tkSeedToken_
private

Definition at line 26 of file ElectronSeedMerger.h.

Referenced by ElectronSeedMerger(), and produce().