CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
virtual void produce (edm::Event &e, const edm::EventSetup &c)
 
virtual ~ElectronRecalibSuperClusterAssociator ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

edm::EDGetTokenT
< reco::SuperClusterCollection
ebScToken_
 
edm::EDGetTokenT
< reco::SuperClusterCollection
eeScToken_
 
edm::InputTag electronSrc_
 
edm::EDGetTokenT
< reco::GsfElectronCollection
electronToken_
 
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
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)
 
- 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 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_
tuple cout
Definition: gather_cfg.py:145
edm::EDGetTokenT< reco::GsfElectronCollection > electronToken_
ElectronRecalibSuperClusterAssociator::~ElectronRecalibSuperClusterAssociator ( )
virtual

Definition at line 51 of file ElectronRecalibSuperClusterAssociator.cc.

52 {
53 }

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 56 of file ElectronRecalibSuperClusterAssociator.cc.

References gather_cfg::cout, reco::deltaR2(), edm::Event::getByToken(), edm::Event::getRefBeforePut(), 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  std::auto_ptr<GsfElectronCollection> pOutEle(new GsfElectronCollection);
64  std::auto_ptr<GsfElectronCoreCollection> pOutEleCore(new 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=0;
98  const reco::SuperCluster* nearestSCendcap=0;
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(pOutEle);
229  e.put(pOutEleCore);
230 
231  // e.put(pOutNewEndcapSC);
232 
233 }
void setP4(P4Kind kind, const LorentzVector &p4, float p4Error, bool setCandidate)
Definition: GsfElectron.cc:198
edm::EDGetTokenT< reco::SuperClusterCollection > ebScToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
edm::EDGetTokenT< reco::SuperClusterCollection > eeScToken_
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
void setSuperCluster(const SuperClusterRef &scl)
void setCorrectedEcalEnergyError(float newEnergyError)
Definition: GsfElectron.cc:178
void setParentSuperCluster(const SuperClusterRef &scl)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
T sqrt(T t)
Definition: SSEVec.h:18
std::vector< GsfElectronCore > GsfElectronCoreCollection
RefProd< PROD > getRefBeforePut()
Definition: Event.h:141
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36
void setCorrectedEcalEnergy(float newEnergy)
Definition: GsfElectron.cc:181
tuple cout
Definition: gather_cfg.py:145
edm::EDGetTokenT< reco::GsfElectronCollection > electronToken_
boost::remove_cv< typename boost::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:168

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.