27 std::cout<<
"ElectronRecalibSuperClusterAssociator::ElectronRecalibSuperClusterAssociator" << std::endl;
31 produces<GsfElectronCollection>();
32 produces<GsfElectronCoreCollection>() ;
33 produces<SuperClusterCollection>();
35 scProducer_ = iConfig.
getParameter<std::string>(
"scProducer");
36 scCollection_ = iConfig.
getParameter<std::string>(
"scCollection");
38 scIslandProducer_ = iConfig.
getParameter<std::string>(
"scIslandProducer");
39 scIslandCollection_ = iConfig.
getParameter<std::string>(
"scIslandCollection");
41 electronProducer_ = iConfig.
getParameter<std::string > (
"electronProducer");
42 electronCollection_ = iConfig.
getParameter<std::string > (
"electronCollection");
44 std::cout<<
"ElectronRecalibSuperClusterAssociator::ElectronRecalibSuperClusterAssociator::end" << std::endl;
56 std::cout<<
"ElectronRecalibSuperClusterAssociator::produce" << std::endl;
68 e.
getByLabel(scProducer_, scCollection_, pSuperClusters);
69 if (!pSuperClusters.
isValid()) {
70 std::cerr <<
"Error! can't get the product SuperClusterCollection "<< std::endl;
75 std::cout<<
"scCollection->size()"<<scCollection->size()<<std::endl;
80 e.
getByLabel(scIslandProducer_, scIslandCollection_, pIslandSuperClusters);
81 if (!pIslandSuperClusters.
isValid()) {
82 std::cerr <<
"Error! can't get the product IslandSuperClusterCollection "<< std::endl;
87 std::cout<<
"scEECollection->size()"<<scIslandCollection->size()<<std::endl;
92 e.
getByLabel(electronProducer_, electronCollection_, pElectrons);
94 std::cerr <<
"Error! can't get the product ElectronCollection "<< std::endl;
98 for(reco::GsfElectronCollection::const_iterator eleIt = electronCollection->begin(); eleIt != electronCollection->end(); eleIt++)
100 float DeltaRMineleSCbarrel(0.15);
101 float DeltaRMineleSCendcap(0.15);
108 for(reco::SuperClusterCollection::const_iterator scIt = scCollection->begin();
109 scIt != scCollection->end(); scIt++){
111 std::cout << scIt->energy() <<
" " << scIt->eta() <<
" " << scIt->phi() <<
" " << eleIt->eta() <<
" " << eleIt->phi() << std::endl;
114 double DeltaReleSC =
sqrt (
pow( eleIt->eta() - scIt->eta(),2) +
pow(eleIt->phi() - scIt->phi(),2));
116 if(DeltaReleSC<DeltaRMineleSCbarrel)
118 DeltaRMineleSCbarrel = DeltaReleSC;
119 nearestSCbarrel = &*scIt;
128 for(reco::SuperClusterCollection::const_iterator scItEndcap = scIslandCollection->begin();
129 scItEndcap != scIslandCollection->end(); scItEndcap++){
131 std::cout <<
"EE " << scItEndcap->energy() <<
" " << scItEndcap->eta() <<
" " << scItEndcap->phi() <<
" " << eleIt->eta() <<
" " << eleIt->phi() << std::endl;
134 double DeltaReleSC =
sqrt (
pow( eleIt->eta() - scItEndcap->eta(),2) +
pow(eleIt->phi() - scItEndcap->phi(),2));
136 if(DeltaReleSC<DeltaRMineleSCendcap)
138 DeltaRMineleSCendcap = DeltaReleSC;
139 nearestSCendcap = &*scItEndcap;
148 if(nearestSCbarrel && !nearestSCendcap){
154 pOutEleCore->push_back(newEleCore);
158 newEle.
setP4(eleIt->p4()*(nearestSCbarrel->
energy()/eleIt->ecalEnergy()));
160 pOutEle->push_back(newEle);
162 std::cout <<
"Association is with EB superCluster "<< std::endl;
166 if(!nearestSCbarrel && nearestSCendcap)
169 std::cout <<
"Starting Association is with EE superCluster "<< std::endl;
172 float preshowerEnergy=eleIt->superCluster()->preshowerEnergy();
174 std::cout <<
"preshowerEnergy"<< preshowerEnergy << std::endl;
185 pOutNewEndcapSC->push_back(newSC);
192 pOutEleCore->push_back(newEleCore);
197 newEle.
setP4(eleIt->p4()*(newSC.energy()/eleIt->ecalEnergy())) ;
198 pOutEle->push_back(newEle);
201 std::cout <<
"Association is with EE superCluster "<< std::endl;
205 if(nearestSCbarrel && nearestSCendcap){
210 if(DeltaRMineleSCendcap>=DeltaRMineleSCbarrel)
215 pOutEleCore->push_back(newEleCore);
219 newEle.
setP4(eleIt->p4()*(nearestSCbarrel->
energy()/eleIt->ecalEnergy()));
220 pOutEle->push_back(newEle);
224 std::cout <<
"Association is with EB superCluster, after quarrel "<< std::endl;
227 else if(DeltaRMineleSCendcap<DeltaRMineleSCbarrel)
229 float preshowerEnergy=eleIt->superCluster()->preshowerEnergy();
235 pOutNewEndcapSC->push_back(newSC);
239 pOutEleCore->push_back(newEleCore);
243 newEle.
setP4(eleIt->p4()*(newSC.energy()/eleIt->ecalEnergy())) ;
244 pOutEle->push_back(newEle);
246 std::cout <<
"Association is with EE superCluster, after quarrel "<< std::endl;
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;
267 e.
put(pOutNewEndcapSC);
T getParameter(std::string const &) const
const math::XYZPoint & position() const
cluster centroid position
void setP4(P4Kind kind, const LorentzVector &p4, float p4Error, bool setCandidate)
void setGsfTrack(const GsfTrackRef &gsfTrack)
void push_back(Ptr< T > const &iPtr)
edm::Ptr< CaloCluster > CaloClusterPtr
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
ElectronRecalibSuperClusterAssociator(const edm::ParameterSet &conf)
void setSuperCluster(const SuperClusterRef &scl)
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
virtual void produce(edm::Event &e, const edm::EventSetup &c)
std::vector< GsfElectronCore > GsfElectronCoreCollection
edm::RefVector< GsfTrackCollection > GsfTrackRefVector
vector of reference to GsfTrack in the same collection
double energy() const
cluster energy
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
RefProd< PROD > getRefBeforePut()
virtual ~ElectronRecalibSuperClusterAssociator()
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
T const * product() const
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
const CaloClusterPtr & seed() const
seed BasicCluster
boost::remove_cv< typename boost::remove_reference< argument_type >::type >::type key_type
Power< A, B >::type pow(const A &a, const B &b)
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents