21 pfPhotons_(pfPhotons),
22 EBReducedRecHits_(EBReducedRecHits),
23 EEReducedRecHits_(EEReducedRecHits),
24 ESRecHits_(ESRecHits),
27 beamSpotHandle_(beamSpotHandle),
37 reco::PhotonCollection::const_iterator pfphot=
pfPhotons_->begin();
45 reco::GsfElectronCollection::const_iterator pfele=pfElectrons->begin();
46 for(;pfele!=pfElectrons->end();++pfele){
47 if(pfele->superCluster().isNull())
continue;
50 if(pfele->pflowSuperCluster().isNull())
continue;
58 for(PFCandidateCollection::const_iterator pfParticle =pfCandidates->begin(); pfParticle!=pfCandidates->end(); pfParticle++){
59 if(
abs(pfParticle->pdgId())!=11)
continue;
60 if(pfParticle->superClusterRef().isNull())
continue;
61 double dR=
deltaR(pfParticle->superClusterRef()->eta(),
62 pfParticle->superClusterRef()->phi(),
65 if(pfele->superCluster()==pfParticle->superClusterRef() &&dR<0.1){
87 std::pair<float, float>
SLPoint(0,0);
121 std::vector<unsigned int> insideMust;
122 std::vector<unsigned int> outsideMust;
129 std::multimap<float, unsigned int>OrderedClust;
131 for(
unsigned int i=0;
i<insideMust.size(); ++
i){
132 unsigned int index=insideMust[
i];
137 float MustacheEOut=0;
138 float MustacheEtOut=0;
139 for(
unsigned int i=0;
i<outsideMust.size(); ++
i){
140 unsigned int index=outsideMust[
i];
149 std::multimap<float, unsigned int>::iterator it;
150 it=OrderedClust.begin();
151 unsigned int lowEindex=(*it).second;
161 std::vector<CaloCluster>MustacheNLClust;
162 for(it=OrderedClust.begin(); it!=OrderedClust.end(); ++it){
163 unsigned int index=(*it).second;
164 if(index==lowEindex)
continue;
167 if(insideMust.size()>3){
171 if(insideMust.size()==2){
176 if(insideMust.size()==1){
184 vector<reco::PreshowerCluster>PFPS;
189 for(
unsigned int i=0;
i<PFPS.size(); ++
i){
190 if(PFPS[
i].plane()==1)PFPS1=PFPS1+PFPS[
i].
energy();
191 if(PFPS[
i].plane()==2)PFPS2=PFPS2+PFPS[
i].
energy();
204 float PFPhoPhi=PFPhoton.
phi();
205 float PFPhoEta=PFPhoton.
eta();
207 float PFClusPhiRMS=0;
208 float PFClusEtaRMS=0;
209 std::pair<double, double> RMS;
210 for(
unsigned int c=0;
c<PFClust.size(); ++
c){
211 delPhi2=(acos(
cos(PFPhoPhi-PFClust[
c].
phi()))* acos(
cos(PFPhoPhi-PFClust[
c].
phi())) )+delPhi2;
212 delPhiSum=delPhiSum+ acos(
cos(PFPhoPhi-PFClust[
c].
phi()))*PFClust[
c].energy();
213 delEta2=(PFPhoEta-PFClust[
c].eta())*(PFPhoEta-PFClust[
c].
eta()) *PFClust[
c].
energy() + delEta2;
214 delEtaSum=delEtaSum+((PFPhoEta-PFClust[
c].eta())*PFClust[
c].
energy());
215 ClusSum=ClusSum+PFClust[
c].energy();
217 double meandPhi=delPhiSum/ClusSum;
218 PFClusPhiRMS=
sqrt(fabs(delPhi2/ClusSum - (meandPhi*meandPhi)));
219 double meandEta=delEtaSum/ClusSum;
220 PFClusEtaRMS=
sqrt(fabs(delEta2/ClusSum - (meandEta*meandEta)));
221 RMS.first=PFClusEtaRMS;
222 RMS.second=PFClusPhiRMS;
229 float beamspotZ=bs.Z();
237 std::vector<unsigned int> insideMust;
238 std::vector<unsigned int> outsideMust;
241 for(
unsigned int i=0;
i<insideMust.size();++
i){
242 unsigned int index=insideMust[
i];
267 double etabound=Boundary.first;
268 double phibound=Boundary.second;
271 for (PFCandidateCollection::const_iterator pfParticle =pfCandidates->begin(); pfParticle!=pfCandidates->end(); pfParticle++){
272 if(pfParticle->pdgId()!=22)
continue;
274 float dphi=acos(
cos(seedPhi-pfParticle->phi()));
275 float deta=fabs(seedEta-pfParticle->eta());
278 if(deta<etabound && dphi<phibound){
281 math::XYZPoint position(pfParticle->positionAtECALEntrance().X(), pfParticle->positionAtECALEntrance().Y(), pfParticle->positionAtECALEntrance().Z()) ;
284 PFPreShower1_=PFPreShower1_+pfParticle->pS1Energy();
293 std::vector<unsigned int> insideMust;
294 std::vector<unsigned int> outsideMust;
298 std::multimap<float, unsigned int>OrderedClust;
300 for(
unsigned int i=0;
i<insideMust.size(); ++
i){
301 unsigned int index=insideMust[
i];
306 float MustacheEOut=0;
307 float MustacheEtOut=0;
308 for(
unsigned int i=0;
i<outsideMust.size(); ++
i){
309 unsigned int index=outsideMust[
i];
318 std::multimap<float, unsigned int>::iterator it;
319 it=OrderedClust.begin();
320 unsigned int lowEindex=(*it).second;
326 if(insideMust.size()==1){
333 std::vector<CaloCluster>MustacheNLClust;
334 for(it=OrderedClust.begin(); it!=OrderedClust.end(); ++it){
335 unsigned int index=(*it).second;
336 if(index==lowEindex)
continue;
339 if(insideMust.size()>3){
343 if(insideMust.size()==2){
348 if(insideMust.size()==1){
361 std::pair<double, double>SCsize(0.1,0.4);
365 double seedeta=recoSC->seed()->eta();
366 double seedphi=recoSC->seed()->phi();
372 for(;cit!=recoSC->clustersEnd();++cit){
373 std::vector< std::pair<DetId, float> >bcCells=(*cit)->hitsAndFractions();
375 for(
unsigned int i=0;
i<bcCells.size(); ++
i){
377 if(eb->id().rawId()==bcCells[
i].first.rawId()){
378 DetId id=bcCells[
i].first;
380 float dEta = fabs(seedeta-eta);
384 float dPhi = acos(
cos( seedphi-phi));
395 for(
unsigned int i=0;
i<bcCells.size(); ++
i){
397 if(ee->id().rawId()==bcCells[
i].first.rawId()){
398 DetId id=bcCells[
i].first;
401 float dR=
deltaR(eta, phi, seedeta, seedphi);
404 MaxEta=fabs(seedeta-eta);
405 MaxPhi= acos(
cos(seedphi-phi));
418 std::vector<reco::PFCandidatePtr>&insideMust,
419 std::vector<reco::PFCandidatePtr>&outsideMust,
427 std::vector<reco::PFCandidatePtr>PFCand;
428 double seedEta=sc.
seed()->eta();
429 double seedPhi=sc.
seed()->phi();
430 for(PFCandidateCollection::const_iterator pfParticle =pfCandidates->begin(); pfParticle!=pfCandidates->end(); pfParticle++){
431 unsigned int index=pfParticle - pfCandidates->begin();
432 if(pfParticle->pdgId()!=22)
continue;
434 float dphi=acos(
cos(seedPhi-pfParticle->phi()));
435 float deta=fabs(seedEta-pfParticle->eta());
436 if(deta<etabound && dphi<phibound){
439 math::XYZPoint position(pfParticle->positionAtECALEntrance().X(), pfParticle->positionAtECALEntrance().Y(), pfParticle->positionAtECALEntrance().Z()) ;
441 PFClusters.push_back(calo);
443 PFCand.push_back(pfRef);
448 std::vector<unsigned int> insideMustindex;
449 std::vector<unsigned int> outsideMustindex;
450 Must.
MustacheClust(PFClusters, insideMustindex, outsideMustindex);
451 for(
unsigned int i=0;
i<insideMustindex.size(); ++
i){
452 unsigned int index=insideMustindex[
i];
453 insideMust.push_back(PFCand[index]);
455 for(
unsigned int i=0;
i<outsideMustindex.size(); ++
i){
456 unsigned int index=outsideMustindex[
i];
457 outsideMust.push_back(PFCand[index]);
467 std::pair<double, double>SCsize(0.1,0.4);
470 double seedeta=sc.
eta();
471 double seedphi=sc.
phi();
477 std::vector< std::pair<DetId, float> >bcCells=(*cit)->hitsAndFractions();
478 DetId seedXtalId = bcCells[0].first ;
479 int detector = seedXtalId.
subdetId();
481 if(detector==1)isEb=
true;
484 for(
unsigned int i=0;
i<bcCells.size(); ++
i){
485 for(eb=EBReducedRecHits->begin();eb!= EBReducedRecHits->end();++eb){
486 if(eb->id().rawId()==bcCells[
i].first.rawId()){
487 DetId id=bcCells[
i].first;
489 float dEta = fabs(seedeta-eta);
493 float dPhi = acos(
cos( seedphi-phi));
504 for(
unsigned int i=0;
i<bcCells.size(); ++
i){
505 for(ee=EEReducedRecHits->begin();ee!= EEReducedRecHits->end();++ee){
506 if(ee->id().rawId()==bcCells[
i].first.rawId()){
507 DetId id=bcCells[
i].first;
509 float dEta = fabs(seedeta-eta);
514 float dPhi = acos(
cos(seedphi-phi));
532 std::vector<reco::PFCandidatePtr>&insideBox,
534 vector<reco::CaloCluster> &PFClust,
535 std::vector<DetId>& MatchedRH
538 std::vector<reco::PFCandidatePtr>ChgHad;
539 std::vector<reco::PFCandidatePtr>PFPho;
541 double etabound=scSize.first;
542 double phibound=scSize.second;
543 double dRbound=
sqrt(etabound*etabound+phibound*phibound);
544 double seedEta=sc.
eta();
545 double seedPhi=sc.
phi();
546 for(PFCandidateCollection::const_iterator pfParticle =pfCandidates->begin(); pfParticle!=pfCandidates->end(); pfParticle++){
547 if(pfParticle->pdgId()==130)
continue;
548 unsigned int index=pfParticle - pfCandidates->begin();
550 sc.
y() - pfParticle->vy(),
551 sc.
z() - pfParticle->vz());
552 seedEta= photon_directionWrtVtx.Eta();
553 seedPhi=photon_directionWrtVtx.Phi();
554 double dphi=acos(
cos(seedPhi-pfParticle->momentum().Phi()));
555 double deta=fabs(seedEta-pfParticle->momentum().Eta());
558 insideBox.push_back(pfRef);
559 if(pfParticle->pdgId()==22)PFPho.push_back(pfRef);
560 if(
abs(pfParticle->pdgId())==211)ChgHad.push_back(pfRef);
562 double dR=
deltaR(seedEta,seedPhi, pfParticle->momentum().Eta(), pfParticle->momentum().Phi());
566 insideBox.push_back(pfRef);
567 if(pfParticle->pdgId()==22)PFPho.push_back(pfRef);
568 if(
abs(pfParticle->pdgId())==211)ChgHad.push_back(pfRef);
574 std::vector<reco::PFCandidatePtr>
copy=insideBox;
579 for(
unsigned int i=0;
i<insideBox.size(); ++
i){
580 if(insideBox[
i]->
pdgId()==22)PFPho.push_back(insideBox[
i]);
581 if(
abs(insideBox[i]->
pdgId())==211)ChgHad.push_back(insideBox[i]);
584 std::vector<unsigned int > orbitPho;
585 std::vector<unsigned int > overlapChgHad;
586 std::vector<float > fractionShared;
587 for(
unsigned int c=0;
c<ChgHad.size(); ++
c){
594 ChgHad[
c]->positionAtECALEntrance().
y()-ChgHad[
c]->vy(),
595 ChgHad[
c]->positionAtECALEntrance().
z()-ChgHad[
c]->vz());
597 float dR=
deltaR((*cit)->eta(), (*cit)->phi(), positionvtx.eta(), positionvtx.phi());
604 for(
unsigned int ipho=0; ipho<PFPho.size(); ++ipho){
605 double deta=fabs(ChgHad[
c]->positionAtECALEntrance().
Eta()- PFPho[ipho]->positionAtECALEntrance().
Eta());
606 double dphi=acos(
cos(ChgHad[
c]->positionAtECALEntrance().
Phi()-PFPho[ipho]->positionAtECALEntrance().
Phi()));
608 if(deta<0.05 && dphi<0.07){
609 orbitPho.push_back(ipho);
610 frac=ChgHad[
c]->ecalEnergy()/(PFPho[ipho]->ecalEnergy()+ChgHad[
c]->ecalEnergy());
611 fractionShared.push_back(frac);
616 calo.
setEnergy(frac*ChgHad[
c]->rawEcalEnergy());
621 PFClust.push_back(calo);
623 for(
unsigned int ipho=0; ipho<PFPho.size(); ++ipho){
627 PFPho[ipho]->positionAtECALEntrance().
y(),
628 PFPho[ipho]->positionAtECALEntrance().
z());
630 for(
unsigned int i=0;
i<orbitPho.size(); ++
i){
631 if(ipho==orbitPho[
i]){
632 frac=1-fractionShared[
i];
636 calo.
setEnergy(frac*PFPho[ipho]->rawEcalEnergy());
637 PFClust.push_back(calo);
reco::SuperClusterRef pfSuperCluster() const
Ref to PFlow SuperCluster.
reco::GsfElectron PFElectron_
const CaloSubdetectorGeometry * geomBar_
void PhotonPFCandMatch(reco::SuperCluster sc, std::vector< reco::PFCandidatePtr > &insideBox, edm::Handle< PFCandidateCollection > &pfCandidates, vector< reco::CaloCluster > &PFClust, std::vector< DetId > &MatchedRH)
std::pair< double, double > SuperClusterSize(reco::Photon phot)
void setPosition(const math::XYZPoint &p)
Sin< T >::type sin(const T &t)
Geom::Phi< T > phi() const
std::vector< EcalRecHit >::const_iterator const_iterator
Geom::Theta< T > theta() const
std::vector< reco::CaloCluster > PFClusters_
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
void setEnergy(double energy)
bool PFElectronVeto(edm::Handle< reco::ConversionCollection > &convH, edm::Handle< reco::GsfElectronCollection > &gsfElectronsHandle)
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
std::pair< float, float > SLCombZVtx(reco::Photon phot, bool &hasSL)
virtual double eta() const
momentum pseudorapidity
double z() const
z coordinate of cluster centroid
static int position[TOTALCHAMBERS][3]
void BasicClusterPFCandLink(reco::SuperCluster sc, std::vector< reco::PFCandidatePtr > &insideBox, std::vector< DetId > &MatchedRH)
double eta() const
pseudorapidity of cluster centroid
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
std::pair< float, float > SLPoint()
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
float getPFSuperclusterOverlap(reco::CaloCluster PFClust, reco::SuperCluster sc)
std::vector< reco::CaloCluster > PFClusters()
const CaloSubdetectorGeometry * geomEnd_
ggPFPhotons(reco::Photon phot, edm::Handle< reco::PhotonCollection > &pfPhotons, edm::Handle< reco::GsfElectronCollection > &pfElectrons, edm::Handle< PFCandidateCollection > &pfCandidates, edm::Handle< EcalRecHitCollection > &EBReducedRecHits, edm::Handle< EcalRecHitCollection > &EEReducedRecHits, edm::Handle< EcalRecHitCollection > &ESRecHits, const CaloSubdetectorGeometry *geomBar, const CaloSubdetectorGeometry *geomEnd, edm::Handle< BeamSpot > &beamSpotHandle)
void MustacheClust(std::vector< CaloCluster >clusters, std::vector< unsigned int > &insideMust, std::vector< unsigned int > &outsideMust)
double dPhi(double phi1, double phi2)
virtual SuperClusterRef superCluster() const
reference to a SuperCluster
virtual vector< reco::CaloCluster > getPFClusters(reco::SuperCluster)
Cos< T >::type cos(const T &t)
Handle< BeamSpot > beamSpotHandle_
double LocalEnergyCorrection(const GBRForest *ReaderLCEB, const GBRForest *ReaderLCEE, reco::CaloCluster PFClust, float beamspotZ)
std::pair< double, double > CalcRMS(vector< reco::CaloCluster > PFClust, reco::Photon PFPhoton)
double x() const
x coordinate of cluster centroid
reco::Photon matchedPhot_
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
double deltaR(double eta1, double eta2, double phi1, double phi2)
std::pair< float, float > gsfElectronProj(reco::GsfElectron gsf)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
std::vector< reco::CaloCluster > recoPhotonClusterLink(reco::Photon phot, edm::Handle< PFCandidateCollection > &pfCandidates)
virtual vector< reco::PreshowerCluster > getPFESClusters(reco::SuperCluster sc)
Handle< EcalRecHitCollection > ESRecHits_
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
double PFPhoLocallyCorrE_
Handle< EcalRecHitCollection > EBReducedRecHits_
Handle< reco::PhotonCollection > pfPhotons_
const CaloClusterPtr & seed() const
seed BasicCluster
double y() const
y coordinate of cluster centroid
double phi() const
azimuthal angle of cluster centroid
virtual double phi() const
momentum azimuthal angle
SuperClusterRef pflowSuperCluster() const
Handle< EcalRecHitCollection > EEReducedRecHits_
double getPFPhoECorr(std::vector< reco::CaloCluster >PFClusters, const GBRForest *ReaderLCEB, const GBRForest *ReaderLCEE)
std::vector< reco::CaloCluster > PFSCFootprintClusters_
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents