CMS 3D CMS Logo

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

#include <ElectronRecalibSuperClusterAssociator.h>

Inheritance diagram for ElectronRecalibSuperClusterAssociator:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ElectronRecalibSuperClusterAssociator (const edm::ParameterSet &conf)
 
void produce (edm::Event &e, const edm::EventSetup &c) override
 
 ~ElectronRecalibSuperClusterAssociator () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

edm::EDGetTokenT< reco::SuperClusterCollectionebScToken_
 
edm::EDGetTokenT< reco::SuperClusterCollectioneeScToken_
 
edm::InputTag electronSrc_
 
edm::EDGetTokenT< reco::GsfElectronCollectionelectronToken_
 
std::string outputLabel_
 
edm::InputTag superClusterCollectionEB_
 
edm::InputTag superClusterCollectionEE_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 25 of file ElectronRecalibSuperClusterAssociator.h.

Constructor & Destructor Documentation

ElectronRecalibSuperClusterAssociator::ElectronRecalibSuperClusterAssociator ( const edm::ParameterSet conf)
explicit

Definition at line 24 of file ElectronRecalibSuperClusterAssociator.cc.

References gather_cfg::cout, edm::ParameterSet::getParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

24  {
25 #ifdef DEBUG
26  std::cout << "ElectronRecalibSuperClusterAssociator::ElectronRecalibSuperClusterAssociator" << std::endl;
27 #endif
28 
29  //register your products
30  produces<GsfElectronCollection>();
31  produces<GsfElectronCoreCollection>();
32  // produces<SuperClusterCollection>();
33 
34  superClusterCollectionEB_ = iConfig.getParameter<edm::InputTag>("superClusterCollectionEB");
35  superClusterCollectionEE_ = iConfig.getParameter<edm::InputTag>("superClusterCollectionEE");
36 
37  outputLabel_ = iConfig.getParameter<std::string>("outputLabel");
38  electronSrc_ = iConfig.getParameter<edm::InputTag>("electronSrc");
39 
40  electronToken_ = consumes<reco::GsfElectronCollection>(electronSrc_);
41  ebScToken_ = consumes<reco::SuperClusterCollection>(superClusterCollectionEB_);
42  eeScToken_ = consumes<reco::SuperClusterCollection>(superClusterCollectionEE_);
43 
44 #ifdef DEBUG
45  std::cout << "ElectronRecalibSuperClusterAssociator::ElectronRecalibSuperClusterAssociator::end" << std::endl;
46 #endif
47 }
edm::EDGetTokenT< reco::SuperClusterCollection > ebScToken_
edm::EDGetTokenT< reco::SuperClusterCollection > eeScToken_
edm::EDGetTokenT< reco::GsfElectronCollection > electronToken_
ElectronRecalibSuperClusterAssociator::~ElectronRecalibSuperClusterAssociator ( )
override

Definition at line 49 of file ElectronRecalibSuperClusterAssociator.cc.

49 {}

Member Function Documentation

void ElectronRecalibSuperClusterAssociator::produce ( edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 52 of file ElectronRecalibSuperClusterAssociator.cc.

References gather_cfg::cout, DEFINE_FWK_MODULE, reco::deltaR2(), edm::Event::getByToken(), edm::Event::getRefBeforePut(), eostools::move(), reco::GsfElectron::P4_FROM_SUPER_CLUSTER, edm::Event::put(), reco::GsfElectron::setCorrectedEcalEnergy(), reco::GsfElectron::setCorrectedEcalEnergyError(), reco::GsfElectron::setP4(), reco::GsfElectronCore::setParentSuperCluster(), reco::GsfElectronCore::setSuperCluster(), and mathSSE::sqrt().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

52  {
53 #ifdef DEBUG
54  std::cout << "GEDElectronRecalibSuperClusterAssociator::produce" << std::endl;
55 #endif
56 
57  // Create the output collections
58  auto pOutEle = std::make_unique<GsfElectronCollection>();
59  auto pOutEleCore = std::make_unique<GsfElectronCoreCollection>();
60 
61  // Get SuperClusters in EB
62  Handle<reco::SuperClusterCollection> superClusterEBHandle;
63  e.getByToken(ebScToken_, superClusterEBHandle);
64  //const reco::SuperClusterCollection* scCollection = superClusterEBHandle.product();
65 
66 #ifdef DEBUG
67  std::cout << "EB scCollection->size()" << superClusterEBHandle->size() << std::endl;
68 #endif
69 
70  // Get SuperClusters in EE
71  Handle<reco::SuperClusterCollection> superClusterEEHandle;
72  e.getByToken(eeScToken_, superClusterEEHandle);
73  // const reco::SuperClusterCollection* eeScCollection = superClusterEEHandle.product();
74 
75 #ifdef DEBUG
76  std::cout << "EE scCollection->size()" << superClusterEEHandle->size() << std::endl;
77 #endif
78 
79  // Get Electrons
81  e.getByToken(electronToken_, eleHandle);
82  // const reco::GsfElectronCollection* electronCollection = eleHandle.product();
83 
84  // GsfElectronCoreRefProd rEleCore = const_cast<edm::Event&>(iEvent).getRefBeforePut<GsfElectronCoreCollection>();
87 
88  for (reco::GsfElectronCollection::const_iterator eleIt = eleHandle->begin(); eleIt != eleHandle->end(); eleIt++) {
89  float DeltaRMineleSCbarrel(0.15); //initial minDeltaR
90  float DeltaRMineleSCendcap(0.15);
91  const reco::SuperCluster* nearestSCbarrel = nullptr;
92  const reco::SuperCluster* nearestSCendcap = nullptr;
93  int iscRef = -1, iscRefendcap = -1;
94  int iSC = 0;
95 
96  if (eleIt->trackerDrivenSeed()) {
97  edm::LogError("trackerDriven") << "skipping trackerDriven electrons";
98  continue;
99  }
100  // first loop is on EB superClusters
101  iSC = 0;
102  for (reco::SuperClusterCollection::const_iterator scIt = superClusterEBHandle->begin();
103  scIt != superClusterEBHandle->end();
104  scIt++, iSC++) {
105  double DeltaReleSC = sqrt(reco::deltaR2(eleIt->eta(), eleIt->phi(), scIt->eta(), scIt->phi()));
106 
107  if (DeltaReleSC < DeltaRMineleSCbarrel) //save the nearest SC
108  {
109  DeltaRMineleSCbarrel = DeltaReleSC;
110  nearestSCbarrel = &*scIt;
111  iscRef = iSC;
112  }
113 #ifdef DEBUG
114  std::cout << "EB: " << scIt - superClusterEBHandle->begin() << " " << iSC << " " << iscRef << "\t"
115  << std::setprecision(4) << scIt->energy() << " " << scIt->eta() << " " << scIt->phi() << "\t--\t"
116  << eleIt->energy() << " " << eleIt->eta() << " " << eleIt->phi() << "\t" << DeltaRMineleSCbarrel
117  << std::endl;
118 #endif
119  }
120 
121  // second loop is on EE superClusters
122  iSC = 0;
123  for (reco::SuperClusterCollection::const_iterator scIt = superClusterEEHandle->begin();
124  scIt != superClusterEEHandle->end();
125  scIt++, iSC++) {
126 #ifdef DEBUG
127  std::cout << "EE: " << scIt - superClusterEEHandle->begin() << " " << iSC << " " << iscRef << "\t"
128  << std::setprecision(4) << scIt->energy() << " " << scIt->eta() << " " << scIt->phi() << "\t--\t "
129  << eleIt->energy() << " " << eleIt->eta() << " " << eleIt->phi() << "\t" << DeltaRMineleSCendcap
130  << std::endl;
131 #endif
132 
133  double DeltaReleSC = sqrt(reco::deltaR2(eleIt->eta(), eleIt->phi(), scIt->eta(), scIt->phi()));
134 
135  if (DeltaReleSC < DeltaRMineleSCendcap) {
136  DeltaRMineleSCendcap = DeltaReleSC;
137  nearestSCendcap = &*scIt;
138  iscRefendcap = iSC;
139  }
140  }
142  // if(eleIt->isEB()) assert(DeltaRMineleSCbarrel < DeltaRMineleSCendcap);
143  //else assert(DeltaRMineleSCbarrel > DeltaRMineleSCendcap);
144  if (eleIt->isEB() && DeltaRMineleSCbarrel > DeltaRMineleSCendcap) {
145  edm::LogError("ElectronRecalibAssociator") << "EB electron, but nearest SC is in EE";
146  ;
147  continue;
148  }
149 
150  if (eleIt->isEB() && nearestSCbarrel) {
151  pOutEleCore->push_back(*eleIt->core()); // clone the old core and add to the collection of new cores
152  reco::GsfElectronCoreRef newEleCoreRef(rEleCore,
153  idxEleCore++); // reference to the new electron core in the new collection
154  reco::GsfElectronCore& newEleCore = pOutEleCore->back(); // pick the clone
155  //newEleCore.setGsfTrack(eleIt->gsfTrack()); // set the gsf track (not needed since it is not changed)
156  reco::SuperClusterRef scRef(reco::SuperClusterRef(superClusterEBHandle, iscRef)); // Reference to the new SC
157 #ifndef CMSSW_5_3_X
158  newEleCore.setParentSuperCluster(scRef); // mustache
159 #endif
160  newEleCore.setSuperCluster(scRef); // let's check this! if it is possible to recreate the pfSC
161 
162  pOutEle->push_back(reco::GsfElectron(*eleIt, newEleCoreRef));
163  reco::GsfElectron& newEle = pOutEle->back();
164 
165  //-- first possibility: set the new p4SC using refined SC
169  false); //*newEle.superCluster()->energy()/eleIt->superCluster()->energy());
170 
171  //-- second possibility: set the new p4SC using mustache SC
172  //newEle.setP4(reco::GsfElectron::P4_FROM_SUPER_CLUSTER, eleIt->p4(reco::GsfElectron::P4_FROM_SUPER_CLUSTER)*newEle.parentSuperCluster()->energy()/eleIt->parentSuperCluster()->energy(), eleIt->p4Error(reco::GsfElectron::P4_FROM_SUPER_CLUSTER), false);
173 
174  //-- update the correctedEcalEnergy
175  newEle.setCorrectedEcalEnergy(eleIt->ecalEnergy() *
176  (scRef->energy() / eleIt->p4(reco::GsfElectron::P4_FROM_SUPER_CLUSTER).energy()));
177  newEle.setCorrectedEcalEnergyError(eleIt->ecalEnergyError() * (scRef->energy() / eleIt->ecalEnergy()));
178 
179  } else if (!(eleIt->isEB()) && nearestSCendcap) {
180  pOutEleCore->push_back(*eleIt->core()); // clone the old core and add to the collection of new cores
181  reco::GsfElectronCoreRef newEleCoreRef(rEleCore,
182  idxEleCore++); // reference to the new electron core in the new collection
183  reco::GsfElectronCore& newEleCore = pOutEleCore->back(); // pick the clone
184  //newEleCore.setGsfTrack(eleIt->gsfTrack()); // set the gsf track (not needed since it is not changed)
185  reco::SuperClusterRef scRef(
186  reco::SuperClusterRef(superClusterEEHandle, iscRefendcap)); // Reference to the new SC
187 #ifndef CMSSW_5_3_X
188  newEleCore.setParentSuperCluster(scRef); // mustache
189 #endif
190  newEleCore.setSuperCluster(scRef); // let's check this! if it is possible to recreate the pfSC
191 
192  pOutEle->push_back(reco::GsfElectron(*eleIt, newEleCoreRef));
193  reco::GsfElectron& newEle = pOutEle->back();
194 
195  //-- first possibility: set the new p4SC using refined SC
199  false); //*newEle.superCluster()->energy()/eleIt->superCluster()->energy());
200 
201  //-- second possibility: set the new p4SC using mustache SC
202  //newEle.setP4(reco::GsfElectron::P4_FROM_SUPER_CLUSTER, eleIt->p4(reco::GsfElectron::P4_FROM_SUPER_CLUSTER)*newEle.parentSuperCluster()->energy()/eleIt->parentSuperCluster()->energy(), eleIt->p4Error(reco::GsfElectron::P4_FROM_SUPER_CLUSTER), false);
203 
204  //-- update the correctedEcalEnergy
205  newEle.setCorrectedEcalEnergy(eleIt->ecalEnergy() *
206  (scRef->energy() / eleIt->p4(reco::GsfElectron::P4_FROM_SUPER_CLUSTER).energy()));
207  newEle.setCorrectedEcalEnergyError(eleIt->ecalEnergyError() * (scRef->energy() / eleIt->ecalEnergy()));
208  } else {
209  edm::LogError("Failed SC association") << "No SC to be associated to the electron";
210  }
211  }
212 
213 #ifdef DEBUG
214  std::cout << "Filled new electrons " << pOutEle->size() << std::endl;
215  std::cout << "Filled new electronsCore " << pOutEleCore->size() << std::endl;
216  // std::cout << "Filled new endcapSC " << pOutNewEndcapSC->size() << std::endl;
217 #endif
218 
219  // put result into the Event
220 
221  e.put(std::move(pOutEle));
222  e.put(std::move(pOutEleCore));
223 
224  // e.put(std::move(pOutNewEndcapSC));
225 }
void setP4(P4Kind kind, const LorentzVector &p4, float p4Error, bool setCandidate)
Definition: GsfElectron.cc:188
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:164
edm::EDGetTokenT< reco::SuperClusterCollection > ebScToken_
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
edm::EDGetTokenT< reco::SuperClusterCollection > eeScToken_
void setSuperCluster(const SuperClusterRef &scl)
void setCorrectedEcalEnergyError(float newEnergyError)
Definition: GsfElectron.cc:170
void setParentSuperCluster(const SuperClusterRef &scl)
T sqrt(T t)
Definition: SSEVec.h:19
std::vector< GsfElectronCore > GsfElectronCoreCollection
RefProd< PROD > getRefBeforePut()
Definition: Event.h:156
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
void setCorrectedEcalEnergy(float newEnergy)
Definition: GsfElectron.cc:174
edm::EDGetTokenT< reco::GsfElectronCollection > electronToken_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

edm::EDGetTokenT<reco::SuperClusterCollection> ElectronRecalibSuperClusterAssociator::ebScToken_
private

Definition at line 41 of file ElectronRecalibSuperClusterAssociator.h.

edm::EDGetTokenT<reco::SuperClusterCollection> ElectronRecalibSuperClusterAssociator::eeScToken_
private

Definition at line 42 of file ElectronRecalibSuperClusterAssociator.h.

edm::InputTag ElectronRecalibSuperClusterAssociator::electronSrc_
private

Definition at line 34 of file ElectronRecalibSuperClusterAssociator.h.

edm::EDGetTokenT<reco::GsfElectronCollection> ElectronRecalibSuperClusterAssociator::electronToken_
private

Definition at line 40 of file ElectronRecalibSuperClusterAssociator.h.

std::string ElectronRecalibSuperClusterAssociator::outputLabel_
private

Definition at line 38 of file ElectronRecalibSuperClusterAssociator.h.

edm::InputTag ElectronRecalibSuperClusterAssociator::superClusterCollectionEB_
private

Definition at line 35 of file ElectronRecalibSuperClusterAssociator.h.

edm::InputTag ElectronRecalibSuperClusterAssociator::superClusterCollectionEE_
private

Definition at line 36 of file ElectronRecalibSuperClusterAssociator.h.