CMS 3D CMS Logo

GsfElectronCoreProducer.cc
Go to the documentation of this file.
1 
3 
7 
16 
17 #include <map>
18 
19 using namespace reco ;
20 
21 // void GsfElectronCoreProducer::fillDescriptions( edm::ConfigurationDescriptions & descriptions )
22 // {
23 // edm::ParameterSetDescription desc ;
24 // GsfElectronCoreBaseProducer::fillDescriptions(desc) ;
25 // desc.add<edm::InputTag>("ecalDrivenGsfElectronCoresTag",edm::InputTag("ecalDrivenGsfElectronCores")) ;
26 // desc.add<edm::InputTag>("pflowDrivenGsfElectronCoresTag",edm::InputTag("pflowGsfElectronCores")) ;
27 // desc.add<edm::InputTag>("pfSuperClusters",edm::InputTag("pfElectronTranslator:pf")) ;
28 // desc.add<edm::InputTag>("pfSuperClusterTrackMap",edm::InputTag("pfElectronTranslator:pf")) ;
29 // descriptions.add("produceGsfElectronCores",desc) ;
30 // }
31 
34  {
35  edCoresTag_ = consumes<reco::GsfElectronCoreCollection>(config.getParameter<edm::InputTag>("ecalDrivenGsfElectronCoresTag"));
36  pfCoresTag_ = consumes<reco::GsfElectronCoreCollection>(config.getParameter<edm::InputTag>("pflowGsfElectronCoresTag"));
37 // pfSuperClustersTag_ = config.getParameter<edm::InputTag>("pfSuperClusters") ;
38 // pfSuperClusterTrackMapTag_ = config.getParameter<edm::InputTag>("pfSuperClusterTrackMap") ;
39  }
40 
42  {
43  // base input
45 
46  // transient output
47  std::list<GsfElectronCore *> electrons ;
48 
49  // event input
50  event.getByToken(edCoresTag_,edCoresH_) ;
51  event.getByToken(pfCoresTag_,pfCoresH_) ;
52 // event.getByToken(pfSuperClustersTag_,pfClustersH_) ;
53 // event.getByToken(pfSuperClusterTrackMapTag_,pfClusterTracksH_) ;
54 
55  // loop on pure tracker driven tracks
57  {
58  const GsfPFRecTrackCollection * gsfPfRecTrackCollection = gsfPfRecTracksH_.product() ;
59  GsfPFRecTrackCollection::const_iterator gsfPfRecTrack ;
60  for ( gsfPfRecTrack=gsfPfRecTrackCollection->begin() ;
61  gsfPfRecTrack!=gsfPfRecTrackCollection->end() ;
62  ++gsfPfRecTrack )
63  {
64  const GsfTrackRef gsfTrackRef = gsfPfRecTrack->gsfTrackRef() ;
65  produceTrackerDrivenCore(gsfTrackRef,electrons) ;
66  }
67  }
68  else
69  {
70  const GsfTrackCollection * gsfTrackCollection = gsfTracksH_.product() ;
71  for ( unsigned int i=0 ; i<gsfTrackCollection->size() ; ++i )
72  {
74  produceTrackerDrivenCore(gsfTrackRef,electrons) ;
75  }
76  }
77 
78  // clone ecal driven electrons
79  const GsfElectronCoreCollection * edCoresCollection = edCoresH_.product() ;
80  GsfElectronCoreCollection::const_iterator edCoreIter ;
81  for
82  ( edCoreIter = edCoresCollection->begin() ;
83  edCoreIter != edCoresCollection->end() ;
84  edCoreIter++ )
85  { electrons.push_back(edCoreIter->clone()) ; }
86 
87  // add pflow info
88  const GsfElectronCoreCollection * pfCoresCollection = pfCoresH_.product() ;
89  GsfElectronCoreCollection::const_iterator pfCoreIter ;
90  std::list<GsfElectronCore *>::iterator eleCore ;
91  bool found ;
92  for ( eleCore = electrons.begin() ; eleCore != electrons.end() ; eleCore++ )
93  {
94 // (*eleCore)->setParentSuperCluster((*pfClusterTracksH_)[(*eleCore)->gsfTrack()]) ;
95  found = false ;
96  for
97  ( pfCoreIter = pfCoresCollection->begin() ;
98  pfCoreIter != pfCoresCollection->end() ;
99  pfCoreIter++ )
100  {
101  if (pfCoreIter->gsfTrack()==(*eleCore)->gsfTrack())
102  {
103  if (found)
104  {
105  edm::LogWarning("GsfElectronCoreProducer")<<"associated pfGsfElectronCore already found" ;
106  }
107  else
108  {
109  found = true ;
110  (*eleCore)->setParentSuperCluster(pfCoreIter->parentSuperCluster()) ;
111  }
112  }
113  }
114  }
115 
116  // store
117  auto collection = std::make_unique<GsfElectronCoreCollection>();
118  for ( eleCore = electrons.begin() ; eleCore != electrons.end() ; eleCore++ )
119  {
120  if ((*eleCore)->superCluster().isNull())
121  { LogDebug("GsfElectronCoreProducer")<<"GsfTrack with no associated SuperCluster at all." ; }
122  else
123  { collection->push_back(**eleCore) ; }
124  delete (*eleCore) ;
125  }
126  event.put(std::move(collection));
127  }
128 
129 void GsfElectronCoreProducer::produceTrackerDrivenCore( const GsfTrackRef & gsfTrackRef, std::list<GsfElectronCore *> & electrons )
130  {
131  GsfElectronCore * eleCore = new GsfElectronCore(gsfTrackRef) ;
132  if (eleCore->ecalDrivenSeed())
133  { delete eleCore ; return ; }
135  electrons.push_back(eleCore) ;
136  }
137 
139  {}
140 
#define LogDebug(id)
void initEvent(edm::Event &event, const edm::EventSetup &setup)
T getParameter(std::string const &) const
bool ecalDrivenSeed() const
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
edm::Handle< reco::GsfElectronCoreCollection > edCoresH_
Definition: config.py:1
void produceTrackerDrivenCore(const reco::GsfTrackRef &gsfTrackRef, std::list< reco::GsfElectronCore * > &electrons)
return((rh^lh)&mask)
edm::Handle< reco::GsfTrackCollection > gsfTracksH_
std::vector< GsfPFRecTrack > GsfPFRecTrackCollection
collection of GsfPFRecTrack objects
std::vector< GsfElectronCore > GsfElectronCoreCollection
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
edm::EDGetTokenT< reco::GsfElectronCoreCollection > pfCoresTag_
GsfElectronCoreProducer(const edm::ParameterSet &)
T const * product() const
Definition: Handle.h:74
edm::EDGetTokenT< reco::GsfElectronCoreCollection > edCoresTag_
edm::Handle< reco::GsfPFRecTrackCollection > gsfPfRecTracksH_
fixed size matrix
edm::Handle< reco::GsfElectronCoreCollection > pfCoresH_
void produce(edm::Event &, const edm::EventSetup &) override
void fillElectronCore(reco::GsfElectronCore *)
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1