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
 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
 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 (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
 
- 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)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 23 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.

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:121
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 dtNoiseDBValidation_cfg::cerr, reco::SuperCluster::clustersBegin(), reco::SuperCluster::clustersEnd(), gather_cfg::cout, 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(), reco::SuperCluster::seed(), reco::GsfElectronCore::setGsfTrack(), reco::GsfElectron::setP4(), reco::GsfElectronCore::setSuperCluster(), and mathSSE::sqrt().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::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  }
96  const reco::GsfElectronCollection* electronCollection = pElectrons.product();
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 
128  for(reco::SuperClusterCollection::const_iterator scItEndcap = scIslandCollection->begin();
129  scItEndcap != scIslandCollection->end(); scItEndcap++){
130 #ifdef DEBUG
131  std::cout << "EE " << scItEndcap->energy() << " " << scItEndcap->eta() << " " << scItEndcap->phi() << " " << eleIt->eta() << " " << eleIt->phi() << std::endl;
132 #endif
133 
134  double DeltaReleSC = sqrt ( pow( eleIt->eta() - scItEndcap->eta(),2) + pow(eleIt->phi() - scItEndcap->phi(),2));
135 
136  if(DeltaReleSC<DeltaRMineleSCendcap)
137  {
138  DeltaRMineleSCendcap = DeltaReleSC;
139  nearestSCendcap = &*scItEndcap;
140  }
141  iSC++;
142  }
144 
147 
148  if(nearestSCbarrel && !nearestSCendcap){
149  reco::GsfElectronCore newEleCore(*(eleIt->core()));
150  newEleCore.setGsfTrack(eleIt->gsfTrack());
151  reco::SuperClusterRef scRef(reco::SuperClusterRef(pSuperClusters, iscRef));
152  newEleCore.setSuperCluster(scRef);
153  reco::GsfElectronCoreRef newEleCoreRef(reco::GsfElectronCoreRef(rEleCore, idxEleCore ++));
154  pOutEleCore->push_back(newEleCore);
155  reco::GsfElectron newEle(*eleIt,newEleCoreRef,CaloClusterPtr(),
156 // TrackRef(),GsfTrackRefVector());
158  newEle.setP4(eleIt->p4()*(nearestSCbarrel->energy()/eleIt->ecalEnergy()));
159 
160  pOutEle->push_back(newEle);
161 #ifdef DEBUG
162  std::cout << "Association is with EB superCluster "<< std::endl;
163 #endif
164  }
165 
166  if(!nearestSCbarrel && nearestSCendcap)
167  {
168 #ifdef DEBUG
169  std::cout << "Starting Association is with EE superCluster "<< std::endl;
170 #endif
171 
172  float preshowerEnergy=eleIt->superCluster()->preshowerEnergy();
173 #ifdef DEBUG
174  std::cout << "preshowerEnergy"<< preshowerEnergy << std::endl;
175 #endif
176  CaloClusterPtrVector newBCRef;
178  for (CaloCluster_iterator bcRefIt=nearestSCendcap->clustersBegin();bcRefIt!=nearestSCendcap->clustersEnd();++bcRefIt){
179  CaloClusterPtr cPtr(*bcRefIt);
180  newBCRef.push_back(cPtr);
181  }
182 
183 
184  reco::SuperCluster newSC(nearestSCendcap->energy() + preshowerEnergy, nearestSCendcap->position() , nearestSCendcap->seed(),newBCRef , preshowerEnergy );
185  pOutNewEndcapSC->push_back(newSC);
186  reco::SuperClusterRef scRef(reco::SuperClusterRef(rSC, idxSC ++));
187 
188  reco::GsfElectronCore newEleCore(*(eleIt->core()));
189  newEleCore.setGsfTrack(eleIt->gsfTrack());
190  newEleCore.setSuperCluster(scRef);
191  reco::GsfElectronCoreRef newEleCoreRef(reco::GsfElectronCoreRef(rEleCore, idxEleCore ++));
192  pOutEleCore->push_back(newEleCore);
193  reco::GsfElectron newEle(*eleIt,newEleCoreRef,CaloClusterPtr(),
194 // TrackRef(),GsfTrackRefVector());
196 
197  newEle.setP4(eleIt->p4()*(newSC.energy()/eleIt->ecalEnergy())) ;
198  pOutEle->push_back(newEle);
199 
200 #ifdef DEBUG
201  std::cout << "Association is with EE superCluster "<< std::endl;
202 #endif
203  }
204 
205  if(nearestSCbarrel && nearestSCendcap){
206  reco::GsfElectronCore newEleCore(*(eleIt->core()));
207  newEleCore.setGsfTrack(eleIt->gsfTrack());
208 
209 
210  if(DeltaRMineleSCendcap>=DeltaRMineleSCbarrel)
211  {
212  reco::SuperClusterRef scRef(reco::SuperClusterRef(pSuperClusters, iscRef));
213  newEleCore.setSuperCluster(scRef);
214  reco::GsfElectronCoreRef newEleCoreRef(reco::GsfElectronCoreRef(rEleCore, idxEleCore ++));
215  pOutEleCore->push_back(newEleCore);
216  reco::GsfElectron newEle(*eleIt,newEleCoreRef,CaloClusterPtr(),
217 // TrackRef(),GsfTrackRefVector());
219  newEle.setP4(eleIt->p4()*(nearestSCbarrel->energy()/eleIt->ecalEnergy()));
220  pOutEle->push_back(newEle);
221 
222 
223 #ifdef DEBUG
224  std::cout << "Association is with EB superCluster, after quarrel "<< std::endl;
225 #endif
226  }
227  else if(DeltaRMineleSCendcap<DeltaRMineleSCbarrel)
228  {
229  float preshowerEnergy=eleIt->superCluster()->preshowerEnergy();
230  CaloClusterPtrVector newBCRef;
231  for (CaloCluster_iterator bcRefIt=nearestSCendcap->clustersBegin();bcRefIt!=nearestSCendcap->clustersEnd();++bcRefIt){
232  CaloClusterPtr cPtr(*bcRefIt);
233  newBCRef.push_back(*bcRefIt);}
234  reco::SuperCluster newSC(nearestSCendcap->energy() + preshowerEnergy, nearestSCendcap->position() , nearestSCendcap->seed(), newBCRef , preshowerEnergy );
235  pOutNewEndcapSC->push_back(newSC);
236  reco::SuperClusterRef scRef(reco::SuperClusterRef(rSC, idxSC ++));
237  newEleCore.setSuperCluster(scRef);
238  reco::GsfElectronCoreRef newEleCoreRef(reco::GsfElectronCoreRef(rEleCore, idxEleCore ++));
239  pOutEleCore->push_back(newEleCore);
240  reco::GsfElectron newEle(*eleIt,newEleCoreRef,CaloClusterPtr(),
241 // TrackRef(),GsfTrackRefVector());
243  newEle.setP4(eleIt->p4()*(newSC.energy()/eleIt->ecalEnergy())) ;
244  pOutEle->push_back(newEle);
245 #ifdef DEBUG
246  std::cout << "Association is with EE superCluster, after quarrel "<< std::endl;
247 #endif
248  }
249 
250  }
251 
252 
253  }
254 
255 
256 
257 #ifdef DEBUG
258  std::cout << "Filled new electrons " << pOutEle->size() << std::endl;
259  std::cout << "Filled new electronsCore " << pOutEleCore->size() << std::endl;
260  std::cout << "Filled new endcapSC " << pOutNewEndcapSC->size() << std::endl;
261 #endif
262 
263  // put result into the Event
264 
265  e.put(pOutEle);
266  e.put(pOutEleCore);
267  e.put(pOutNewEndcapSC);
268 
269 }
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:124
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:139
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:31
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
T sqrt(T t)
Definition: SSEVec.h:48
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:120
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:402
RefProd< PROD > getRefBeforePut()
Definition: Event.h:133
T const * product() const
Definition: Handle.h:81
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:19
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
Definition: SuperCluster.h:75
tuple cout
Definition: gather_cfg.py:121
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:66
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
boost::remove_cv< typename boost::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:170
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:78

Member Data Documentation

std::string ElectronRecalibSuperClusterAssociator::electronCollection_
private

Definition at line 42 of file ElectronRecalibSuperClusterAssociator.h.

std::string ElectronRecalibSuperClusterAssociator::electronProducer_
private

Definition at line 41 of file ElectronRecalibSuperClusterAssociator.h.

std::string ElectronRecalibSuperClusterAssociator::scCollection_
private

Definition at line 36 of file ElectronRecalibSuperClusterAssociator.h.

std::string ElectronRecalibSuperClusterAssociator::scIslandCollection_
private

Definition at line 39 of file ElectronRecalibSuperClusterAssociator.h.

std::string ElectronRecalibSuperClusterAssociator::scIslandProducer_
private

Definition at line 38 of file ElectronRecalibSuperClusterAssociator.h.

std::string ElectronRecalibSuperClusterAssociator::scProducer_
private

Definition at line 35 of file ElectronRecalibSuperClusterAssociator.h.