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;
129 for(reco::SuperClusterCollection::const_iterator scItEndcap = scIslandCollection->begin();
130 scItEndcap != scIslandCollection->end(); scItEndcap++){
132 std::cout <<
"EE " << scItEndcap->energy() <<
" " << scItEndcap->eta() <<
" " << scItEndcap->phi() <<
" " << eleIt->eta() <<
" " << eleIt->phi() << std::endl;
135 double DeltaReleSC =
sqrt (
pow( eleIt->eta() - scItEndcap->eta(),2) +
pow(eleIt->phi() - scItEndcap->phi(),2));
137 if(DeltaReleSC<DeltaRMineleSCendcap)
139 DeltaRMineleSCendcap = DeltaReleSC;
140 nearestSCendcap = &*scItEndcap;
150 if(nearestSCbarrel && !nearestSCendcap){
156 pOutEleCore->push_back(newEleCore);
160 newEle.
setP4(eleIt->p4()*(nearestSCbarrel->
energy()/eleIt->ecalEnergy()));
162 pOutEle->push_back(newEle);
164 std::cout <<
"Association is with EB superCluster "<< std::endl;
168 if(!nearestSCbarrel && nearestSCendcap)
171 std::cout <<
"Starting Association is with EE superCluster "<< std::endl;
174 float preshowerEnergy=eleIt->superCluster()->preshowerEnergy();
176 std::cout <<
"preshowerEnergy"<< preshowerEnergy << std::endl;
187 pOutNewEndcapSC->push_back(newSC);
194 pOutEleCore->push_back(newEleCore);
199 newEle.
setP4(eleIt->p4()*(newSC.energy()/eleIt->ecalEnergy())) ;
200 pOutEle->push_back(newEle);
203 std::cout <<
"Association is with EE superCluster "<< std::endl;
207 if(nearestSCbarrel && nearestSCendcap){
212 if(DeltaRMineleSCendcap>=DeltaRMineleSCbarrel)
217 pOutEleCore->push_back(newEleCore);
221 newEle.
setP4(eleIt->p4()*(nearestSCbarrel->
energy()/eleIt->ecalEnergy()));
222 pOutEle->push_back(newEle);
226 std::cout <<
"Association is with EB superCluster, after quarrel "<< std::endl;
229 else if(DeltaRMineleSCendcap<DeltaRMineleSCbarrel)
231 float preshowerEnergy=eleIt->superCluster()->preshowerEnergy();
237 pOutNewEndcapSC->push_back(newSC);
241 pOutEleCore->push_back(newEleCore);
245 newEle.
setP4(eleIt->p4()*(newSC.energy()/eleIt->ecalEnergy())) ;
246 pOutEle->push_back(newEle);
248 std::cout <<
"Association is with EE superCluster, after quarrel "<< std::endl;
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;
269 e.
put(pOutNewEndcapSC);
T getParameter(std::string const &) const
const math::XYZPoint & position() const
cluster centroid position
void setGsfTrack(const GsfTrackRef &gsfTrack)
void push_back(Ptr< T > const &iPtr)
virtual void setP4(const LorentzVector &p4)
set 4-momentum
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