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::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 ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Attributes

std::string electronCollection_
 
std::string electronProducer_
 
std::string scCollection_
 
std::string scIslandCollection_
 
std::string scIslandProducer_
 
std::string scProducer_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 24 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, and edm::ParameterSet::getParameter().

25 {
26 #ifdef DEBUG
27  std::cout<< "ElectronRecalibSuperClusterAssociator::ElectronRecalibSuperClusterAssociator" << std::endl;
28 #endif
29 
30  //register your products
31  produces<GsfElectronCollection>();
32  produces<GsfElectronCoreCollection>() ;
33  produces<SuperClusterCollection>();
34 
35  scProducer_ = iConfig.getParameter<std::string>("scProducer");
36  scCollection_ = iConfig.getParameter<std::string>("scCollection");
37 
38  scIslandProducer_ = iConfig.getParameter<std::string>("scIslandProducer");
39  scIslandCollection_ = iConfig.getParameter<std::string>("scIslandCollection");
40 
41  electronProducer_ = iConfig.getParameter<std::string > ("electronProducer");
42  electronCollection_ = iConfig.getParameter<std::string > ("electronCollection");
43 #ifdef DEBUG
44  std::cout<< "ElectronRecalibSuperClusterAssociator::ElectronRecalibSuperClusterAssociator::end" << std::endl;
45 #endif
46 }
tuple cout
Definition: gather_cfg.py:41
ElectronRecalibSuperClusterAssociator::~ElectronRecalibSuperClusterAssociator ( )
virtual

Definition at line 48 of file ElectronRecalibSuperClusterAssociator.cc.

49 {
50 }

Member Function Documentation

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

fixme : should have a vector of ptr of ref, to avoid copying

Implements edm::EDProducer.

Definition at line 53 of file ElectronRecalibSuperClusterAssociator.cc.

References ExpressReco_HICollisions_FallBack::cerr, reco::SuperCluster::clustersBegin(), reco::SuperCluster::clustersEnd(), gather_cfg::cout, ExpressReco_HICollisions_FallBack::electronCollection, reco::CaloCluster::energy(), edm::Event::getByLabel(), edm::Event::getRefBeforePut(), edm::HandleBase::isValid(), reco::CaloCluster::position(), funct::pow(), edm::Handle< T >::product(), edm::PtrVector< T >::push_back(), edm::Event::put(), ExpressReco_HICollisions_FallBack::scCollection, reco::SuperCluster::seed(), reco::GsfElectronCore::setGsfTrack(), reco::LeafCandidate::setP4(), reco::GsfElectronCore::setSuperCluster(), and mathSSE::sqrt().

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

54 {
55 #ifdef DEBUG
56  std::cout<< "ElectronRecalibSuperClusterAssociator::produce" << std::endl;
57 #endif
58  // Create the output collections
59  std::auto_ptr<GsfElectronCollection> pOutEle(new GsfElectronCollection);
60  std::auto_ptr<GsfElectronCoreCollection> pOutEleCore(new GsfElectronCoreCollection);
61  std::auto_ptr<SuperClusterCollection> pOutNewEndcapSC(new SuperClusterCollection);
62 
65 
66  //Get Hybrid SuperClusters
68  e.getByLabel(scProducer_, scCollection_, pSuperClusters);
69  if (!pSuperClusters.isValid()) {
70  std::cerr << "Error! can't get the product SuperClusterCollection "<< std::endl;
71  }
72  const reco::SuperClusterCollection* scCollection = pSuperClusters.product();
73 
74 #ifdef DEBUG
75  std::cout<<"scCollection->size()"<<scCollection->size()<<std::endl;
76 #endif
77 
78  //Get Island SuperClusters
79  Handle<reco::SuperClusterCollection> pIslandSuperClusters;
80  e.getByLabel(scIslandProducer_, scIslandCollection_, pIslandSuperClusters);
81  if (!pIslandSuperClusters.isValid()) {
82  std::cerr << "Error! can't get the product IslandSuperClusterCollection "<< std::endl;
83  }
84  const reco::SuperClusterCollection* scIslandCollection = pIslandSuperClusters.product();
85 
86 #ifdef DEBUG
87  std::cout<<"scEECollection->size()"<<scIslandCollection->size()<<std::endl;
88 #endif
89 
90  // Get Electrons
93  if (!pElectrons.isValid()) {
94  std::cerr << "Error! can't get the product ElectronCollection "<< std::endl;
95  }
97 
98  for(reco::GsfElectronCollection::const_iterator eleIt = electronCollection->begin(); eleIt != electronCollection->end(); eleIt++)
99  {
100  float DeltaRMineleSCbarrel(0.15);
101  float DeltaRMineleSCendcap(0.15);
102  const reco::SuperCluster* nearestSCbarrel=0;
103  const reco::SuperCluster* nearestSCendcap=0;
104  int iscRef=-1;
105  int iSC=0;
106 
107  // first loop is on EB superClusters
108  for(reco::SuperClusterCollection::const_iterator scIt = scCollection->begin();
109  scIt != scCollection->end(); scIt++){
110 #ifdef DEBUG
111  std::cout << scIt->energy() << " " << scIt->eta() << " " << scIt->phi() << " " << eleIt->eta() << " " << eleIt->phi() << std::endl;
112 #endif
113 
114  double DeltaReleSC = sqrt ( pow( eleIt->eta() - scIt->eta(),2) + pow(eleIt->phi() - scIt->phi(),2));
115 
116  if(DeltaReleSC<DeltaRMineleSCbarrel)
117  {
118  DeltaRMineleSCbarrel = DeltaReleSC;
119  nearestSCbarrel = &*scIt;
120  iscRef = iSC;
121  }
122  iSC++;
123  }
124  iSC = 0;
125 
126  // second loop is on EE superClusters
127  int iscRefendcap=-1;
128 
129  for(reco::SuperClusterCollection::const_iterator scItEndcap = scIslandCollection->begin();
130  scItEndcap != scIslandCollection->end(); scItEndcap++){
131 #ifdef DEBUG
132  std::cout << "EE " << scItEndcap->energy() << " " << scItEndcap->eta() << " " << scItEndcap->phi() << " " << eleIt->eta() << " " << eleIt->phi() << std::endl;
133 #endif
134 
135  double DeltaReleSC = sqrt ( pow( eleIt->eta() - scItEndcap->eta(),2) + pow(eleIt->phi() - scItEndcap->phi(),2));
136 
137  if(DeltaReleSC<DeltaRMineleSCendcap)
138  {
139  DeltaRMineleSCendcap = DeltaReleSC;
140  nearestSCendcap = &*scItEndcap;
141  iscRefendcap = iSC;
142  }
143  iSC++;
144  }
146 
149 
150  if(nearestSCbarrel && !nearestSCendcap){
151  reco::GsfElectronCore newEleCore(*(eleIt->core()));
152  newEleCore.setGsfTrack(eleIt->gsfTrack());
153  reco::SuperClusterRef scRef(reco::SuperClusterRef(pSuperClusters, iscRef));
154  newEleCore.setSuperCluster(scRef);
155  reco::GsfElectronCoreRef newEleCoreRef(reco::GsfElectronCoreRef(rEleCore, idxEleCore ++));
156  pOutEleCore->push_back(newEleCore);
157  reco::GsfElectron newEle(*eleIt,newEleCoreRef,CaloClusterPtr(),
158 // TrackRef(),GsfTrackRefVector());
160  newEle.setP4(eleIt->p4()*(nearestSCbarrel->energy()/eleIt->ecalEnergy()));
161 
162  pOutEle->push_back(newEle);
163 #ifdef DEBUG
164  std::cout << "Association is with EB superCluster "<< std::endl;
165 #endif
166  }
167 
168  if(!nearestSCbarrel && nearestSCendcap)
169  {
170 #ifdef DEBUG
171  std::cout << "Starting Association is with EE superCluster "<< std::endl;
172 #endif
173 
174  float preshowerEnergy=eleIt->superCluster()->preshowerEnergy();
175 #ifdef DEBUG
176  std::cout << "preshowerEnergy"<< preshowerEnergy << std::endl;
177 #endif
178  CaloClusterPtrVector newBCRef;
180  for (CaloCluster_iterator bcRefIt=nearestSCendcap->clustersBegin();bcRefIt!=nearestSCendcap->clustersEnd();++bcRefIt){
181  CaloClusterPtr cPtr(*bcRefIt);
182  newBCRef.push_back(cPtr);
183  }
184 
185 
186  reco::SuperCluster newSC(nearestSCendcap->energy() + preshowerEnergy, nearestSCendcap->position() , nearestSCendcap->seed(),newBCRef , preshowerEnergy );
187  pOutNewEndcapSC->push_back(newSC);
188  reco::SuperClusterRef scRef(reco::SuperClusterRef(rSC, idxSC ++));
189 
190  reco::GsfElectronCore newEleCore(*(eleIt->core()));
191  newEleCore.setGsfTrack(eleIt->gsfTrack());
192  newEleCore.setSuperCluster(scRef);
193  reco::GsfElectronCoreRef newEleCoreRef(reco::GsfElectronCoreRef(rEleCore, idxEleCore ++));
194  pOutEleCore->push_back(newEleCore);
195  reco::GsfElectron newEle(*eleIt,newEleCoreRef,CaloClusterPtr(),
196 // TrackRef(),GsfTrackRefVector());
198 
199  newEle.setP4(eleIt->p4()*(newSC.energy()/eleIt->ecalEnergy())) ;
200  pOutEle->push_back(newEle);
201 
202 #ifdef DEBUG
203  std::cout << "Association is with EE superCluster "<< std::endl;
204 #endif
205  }
206 
207  if(nearestSCbarrel && nearestSCendcap){
208  reco::GsfElectronCore newEleCore(*(eleIt->core()));
209  newEleCore.setGsfTrack(eleIt->gsfTrack());
210 
211 
212  if(DeltaRMineleSCendcap>=DeltaRMineleSCbarrel)
213  {
214  reco::SuperClusterRef scRef(reco::SuperClusterRef(pSuperClusters, iscRef));
215  newEleCore.setSuperCluster(scRef);
216  reco::GsfElectronCoreRef newEleCoreRef(reco::GsfElectronCoreRef(rEleCore, idxEleCore ++));
217  pOutEleCore->push_back(newEleCore);
218  reco::GsfElectron newEle(*eleIt,newEleCoreRef,CaloClusterPtr(),
219 // TrackRef(),GsfTrackRefVector());
221  newEle.setP4(eleIt->p4()*(nearestSCbarrel->energy()/eleIt->ecalEnergy()));
222  pOutEle->push_back(newEle);
223 
224 
225 #ifdef DEBUG
226  std::cout << "Association is with EB superCluster, after quarrel "<< std::endl;
227 #endif
228  }
229  else if(DeltaRMineleSCendcap<DeltaRMineleSCbarrel)
230  {
231  float preshowerEnergy=eleIt->superCluster()->preshowerEnergy();
232  CaloClusterPtrVector newBCRef;
233  for (CaloCluster_iterator bcRefIt=nearestSCendcap->clustersBegin();bcRefIt!=nearestSCendcap->clustersEnd();++bcRefIt){
234  CaloClusterPtr cPtr(*bcRefIt);
235  newBCRef.push_back(*bcRefIt);}
236  reco::SuperCluster newSC(nearestSCendcap->energy() + preshowerEnergy, nearestSCendcap->position() , nearestSCendcap->seed(), newBCRef , preshowerEnergy );
237  pOutNewEndcapSC->push_back(newSC);
238  reco::SuperClusterRef scRef(reco::SuperClusterRef(rSC, idxSC ++));
239  newEleCore.setSuperCluster(scRef);
240  reco::GsfElectronCoreRef newEleCoreRef(reco::GsfElectronCoreRef(rEleCore, idxEleCore ++));
241  pOutEleCore->push_back(newEleCore);
242  reco::GsfElectron newEle(*eleIt,newEleCoreRef,CaloClusterPtr(),
243 // TrackRef(),GsfTrackRefVector());
245  newEle.setP4(eleIt->p4()*(newSC.energy()/eleIt->ecalEnergy())) ;
246  pOutEle->push_back(newEle);
247 #ifdef DEBUG
248  std::cout << "Association is with EE superCluster, after quarrel "<< std::endl;
249 #endif
250  }
251 
252  }
253 
254 
255  }
256 
257 
258 
259 #ifdef DEBUG
260  std::cout << "Filled new electrons " << pOutEle->size() << std::endl;
261  std::cout << "Filled new electronsCore " << pOutEleCore->size() << std::endl;
262  std::cout << "Filled new endcapSC " << pOutNewEndcapSC->size() << std::endl;
263 #endif
264 
265  // put result into the Event
266 
267  e.put(pOutEle);
268  e.put(pOutEleCore);
269  e.put(pOutNewEndcapSC);
270 
271 }
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:112
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:135
edm::Ptr< CaloCluster > CaloClusterPtr
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
Definition: TrackFwd.h:22
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
T sqrt(T t)
Definition: SSEVec.h:28
std::vector< GsfElectronCore > GsfElectronCoreCollection
edm::RefVector< GsfTrackCollection > GsfTrackRefVector
vector of reference to GsfTrack in the same collection
Definition: GsfTrackFwd.h:17
double energy() const
cluster energy
Definition: CaloCluster.h:109
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
RefProd< PROD > getRefBeforePut()
Definition: Event.h:96
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
T const * product() const
Definition: Handle.h:74
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
Definition: SuperCluster.h:64
tuple cout
Definition: gather_cfg.py:41
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:61
boost::remove_cv< typename boost::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:167
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:67

Member Data Documentation

std::string ElectronRecalibSuperClusterAssociator::electronCollection_
private

Definition at line 43 of file ElectronRecalibSuperClusterAssociator.h.

std::string ElectronRecalibSuperClusterAssociator::electronProducer_
private

Definition at line 42 of file ElectronRecalibSuperClusterAssociator.h.

std::string ElectronRecalibSuperClusterAssociator::scCollection_
private

Definition at line 37 of file ElectronRecalibSuperClusterAssociator.h.

std::string ElectronRecalibSuperClusterAssociator::scIslandCollection_
private

Definition at line 40 of file ElectronRecalibSuperClusterAssociator.h.

std::string ElectronRecalibSuperClusterAssociator::scIslandProducer_
private

Definition at line 39 of file ElectronRecalibSuperClusterAssociator.h.

std::string ElectronRecalibSuperClusterAssociator::scProducer_
private

Definition at line 36 of file ElectronRecalibSuperClusterAssociator.h.