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::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 26 of file ElectronRecalibSuperClusterAssociator.h.

Constructor & Destructor Documentation

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

Definition at line 25 of file ElectronRecalibSuperClusterAssociator.cc.

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

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

Definition at line 51 of file ElectronRecalibSuperClusterAssociator.cc.

52 {
53 }

Member Function Documentation

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

Definition at line 56 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().

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

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

Definition at line 45 of file ElectronRecalibSuperClusterAssociator.h.

edm::InputTag ElectronRecalibSuperClusterAssociator::electronSrc_
private

Definition at line 37 of file ElectronRecalibSuperClusterAssociator.h.

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

Definition at line 43 of file ElectronRecalibSuperClusterAssociator.h.

std::string ElectronRecalibSuperClusterAssociator::outputLabel_
private

Definition at line 41 of file ElectronRecalibSuperClusterAssociator.h.

edm::InputTag ElectronRecalibSuperClusterAssociator::superClusterCollectionEB_
private

Definition at line 38 of file ElectronRecalibSuperClusterAssociator.h.

edm::InputTag ElectronRecalibSuperClusterAssociator::superClusterCollectionEE_
private

Definition at line 39 of file ElectronRecalibSuperClusterAssociator.h.