21 EBReducedRecHits_(EBReducedRecHits),
22 EEReducedRecHits_(EEReducedRecHits),
36 vector<reco::CaloCluster> PFClust;
40 std::vector< std::pair<DetId, float> >bcCells=(*it)->hitsAndFractions();
41 DetId seedXtalId = bcCells[0].first ;
42 int detector = seedXtalId.
subdetId();
44 if(detector==1)isEb=
true;
49 for(
unsigned int i=0;
i<bcCells.size(); ++
i){
52 PFClust.push_back(calo);
59 for(
unsigned int i=0;
i<bcCells.size(); ++
i){
65 if(eb->id().rawId()==bcCells[
i].first.rawId()){
66 float cellE=eb->energy()* bcCells[
i].second;
67 ClustSum=ClustSum+cellE;
73 if(ee->id().rawId()==bcCells[
i].first.rawId()){
74 float cellE=ee->energy()* bcCells[
i].second;
75 ClustSum=ClustSum+cellE;
89 DetId seedXtalId = bcCellsPF[0].first ;
90 int detector = seedXtalId.
subdetId() ;
92 std::vector< std::pair<DetId, float> >bcCellsreco;
93 if(detector==1)isEb=
true;
96 std::vector< std::pair<DetId, float> >bcCells2=(*pit)->hitsAndFractions();
97 for(
unsigned int h=0;
h<bcCells2.size(); ++
h)bcCellsreco.push_back(bcCells2[
h]);
104 overlap=clustOverlap;
118 DetId seedXtalId = bcCellsPF[0].first ;
119 int detector = seedXtalId.
subdetId() ;
121 std::vector< std::pair<DetId, float> >bcCellsreco;
122 if(detector==1)isEb=
true;
124 for(;pit!=recoSC->clustersEnd();++pit){
125 std::vector< std::pair<DetId, float> >bcCells2=(*pit)->hitsAndFractions();
126 for(
unsigned int h=0;
h<bcCells2.size(); ++
h)bcCellsreco.push_back(bcCells2[
h]);
128 float clustOverlap=0;
133 overlap=clustOverlap;
138 std::vector< std::pair<DetId, float> >& bcCells1,
139 std::vector< std::pair<DetId, float> >& bcCells2,
142 multimap <DetId, float> pfDID;
143 multimap <DetId, float> recoDID;
144 multimap<DetId, float>::iterator pfit;
145 multimap<DetId, float>::iterator pit;
146 vector<DetId>matched;
147 vector<float>matchedfrac;
149 for(
unsigned int i=0;
i<bcCells1.size(); ++
i){
150 pfDID.insert(make_pair(bcCells1[
i].
first, bcCells1[
i].
second));
153 for(
unsigned int i=0;
i<bcCells2.size(); ++
i){
154 recoDID.insert(make_pair(bcCells2[
i].
first, bcCells2[
i].
second));
159 for(; pfit!=pfDID.end(); ++pfit){
160 pit=recoDID.find(pfit->first);
161 if(pit!=recoDID.end()){
163 matched.push_back(pfit->first);
164 matchedfrac.push_back(pfit->second);
168 for(
unsigned int m=0;
m<matched.size(); ++
m){
174 if(eb->id().rawId()==det.
rawId()){
175 float cellE=eb->energy()* matchedfrac[
m];
176 OverlapSum=OverlapSum+cellE;
183 if(ee->id().rawId()==det.
rawId()){
184 float cellE=ee->energy() * matchedfrac[
m];
185 OverlapSum=OverlapSum+cellE;
197 double Theta = -position_.theta()+0.5*
TMath::Pi();
198 double Eta = position_.eta();
203 const float X0 = 0.89;
const float T0 = 7.4;
204 double depth = X0 * (T0 +
log(clus.
energy()));
207 std::vector< std::pair<DetId, float> > crystals_vector = clus.
hitsAndFractions();
211 for (
unsigned int icry=0; icry!=crystals_vector.size(); ++icry) {
213 EBDetId crystal(crystals_vector[icry].first);
217 double EtaCentr = center_pos.
eta();
223 crystalseed = crystal;
228 ieta = crystalseed.
ieta();
229 iphi = crystalseed.
iphi();
244 if (ieta<0) phicry *= -1.;
247 double ThetaWidth = (
TMath::Pi()/180.)*TMath::Cos(ThetaCentr);
248 etacry = (Theta-ThetaCentr)/ThetaWidth;
251 if (ieta<0) etacry *= -1.;
259 double Eta = position_.eta();
261 double X = position_.x();
262 double Y = position_.y();
266 const float X0 = 0.89;
float T0 = 1.2;
268 if (TMath::Abs(clus.
eta())<1.653) T0 = 3.1;
270 double depth = X0 * (T0 +
log(clus.
energy()));
273 std::vector< std::pair<DetId, float> > crystals_vector = clus.
hitsAndFractions();
277 for (
unsigned int icry=0; icry!=crystals_vector.size(); ++icry) {
279 EEDetId crystal(crystals_vector[icry].first);
283 double EtaCentr = center_pos.
eta();
289 crystalseed = crystal;
294 ix = crystalseed.
ix();
295 iy = crystalseed.
iy();
306 double XCentr = center_pos.
x();
307 double XWidth = 2.59;
308 xcry = (X-XCentr)/XWidth;
311 double YCentr = center_pos.
y();
312 double YWidth = 2.59;
313 ycry = (Y-YCentr)/YWidth;
318 std::vector< std::pair<DetId, float> >&
323 if(
abs(i)>2 ||
abs(j)>2)
return 0;
326 float E=
e5x5_[ind1][ind2];
333 for(
int i=0;
i<5; ++
i)
341 for(
unsigned int i=0;
i<bcCells.size(); ++
i){
342 DetId id=bcCells[
i].first;
347 if(
abs(dphi)<=2 &&
abs(deta)<=2){
349 if(eb->id().rawId()==bcCells[
i].first.rawId()){
351 int ind1=EBidSeed.
ieta()-EBid.
ieta();
352 int ind2=EBid.
iphi()-EBidSeed.
iphi();
353 if(EBidSeed.
ieta() * EBid.
ieta() > 0){
363 e5x5_[iEta][iPhi]=eb->energy()* bcCells[
i].second;
372 if(
abs(dx)<=2 &&
abs(dy)<=2){
374 if(ee->id().rawId()==bcCells[
i].first.rawId()){
376 int ind1=EEid.
ix()-EEidSeed.
ix();
377 int ind2=EEid.
iy()-EEidSeed.
iy();
380 e5x5_[ix][iy]=ee->energy()* bcCells[
i].second;
392 DetId idseed=bcCells[0].first;
395 for(
unsigned int i=0;
i<bcCells.size(); ++
i){
398 if(eb->id().rawId()==bcCells[
i].first.rawId()){
399 float cellE=eb->energy()* bcCells[
i].second;
402 idseed=bcCells[
i].first;
411 if(ee->id().rawId()==bcCells[
i].first.rawId()){
412 float cellE=ee->energy()* bcCells[
i].second;
415 idseed=bcCells[
i].first;
426 vector<reco::CaloCluster>& PFClust){
427 pair<float, float> widths(0,0);
428 multimap<float, unsigned int>ClusterMap;
430 for(
unsigned int i=0;
i<PFClust.size();++
i)ClusterMap.insert(make_pair(PFClust[
i].
energy(),
i));
432 std::multimap<float, unsigned int>::reverse_iterator it;
433 it=ClusterMap.rbegin();
434 unsigned int max_c=(*it).second;
435 std::vector< std::pair<DetId, float> >bcCells=PFClust[max_c].hitsAndFractions();
438 float numeratorEtaWidth=0;
439 float numeratorPhiWidth=0;
442 DetId seedXtalId = bcCells[0].first ;
443 int detector = seedXtalId.
subdetId() ;
445 if(detector==1)isEb=
true;
450 for(
unsigned int i=0;
i<bcCells.size(); ++
i){
452 if(eb->id().rawId()==bcCells[
i].first.rawId()){
454 double energyHit = eb->energy()*bcCells[
i].second;
455 DetId id=bcCells[
i].first;
458 float dEta = eta - PFClust[max_c].eta();
459 float dPhi = phi - PFClust[max_c].phi();
462 numeratorEtaWidth=dEta*dEta*energyHit+numeratorEtaWidth;
463 numeratorPhiWidth=dPhi*dPhi*energyHit+numeratorPhiWidth;
472 for(
unsigned int i=0;
i<bcCells.size(); ++
i){
474 if(ee->id().rawId()==bcCells[
i].first.rawId()){
475 double energyHit = ee->energy()*bcCells[
i].second;
476 DetId id=bcCells[
i].first;
479 float dEta = eta - PFClust[max_c].eta();
480 float dPhi = phi - PFClust[max_c].phi();
483 numeratorEtaWidth=dEta*dEta*energyHit+numeratorEtaWidth;
484 numeratorPhiWidth=dPhi*dPhi*energyHit+numeratorPhiWidth;
491 float etaWidth=
sqrt(numeratorEtaWidth/denominator);
492 float phiWidth=
sqrt(numeratorPhiWidth/denominator);
493 widths=make_pair(etaWidth, phiWidth);
500 double PFClustCorr=PFClust.
energy();
501 float ClusEta=PFClust.
eta();
502 float ClusE=PFClust.
energy();
503 float ClusPhi=PFClust.
phi();
508 DetId seedXtalId = bcCells[0].first ;
509 int detector = seedXtalId.
subdetId();
510 if(detector==1)isEb=
true;
520 float E5x5=0;
float E3x3=0;
521 for(
int i=-2;
i<3; ++
i)
522 for(
int j=-2;
j<3; ++
j){
524 if(
abs(
i)<2)E3x3=E3x3+
e;
529 float E1x3=e5x5_[2][2]+e5x5_[2][1]+e5x5_[2][3];
530 float E1x5=e5x5_[2][2]+e5x5_[2][0]+e5x5_[2][1]+e5x5_[2][3]+e5x5_[2][4];
532 float E2x5Top=e5x5_[0][4]+e5x5_[1][4]+e5x5_[2][4]+e5x5_[3][4]+e5x5_[4][4]
533 +e5x5_[0][3]+e5x5_[1][3]+e5x5_[2][3]+e5x5_[3][3]+e5x5_[4][3];
535 float E2x5Bottom=e5x5_[0][0]+e5x5_[1][0]+e5x5_[2][0]+e5x5_[3][0]+e5x5_[4][0]
536 +e5x5_[0][1]+e5x5_[1][1]+e5x5_[2][1]+e5x5_[3][1]+e5x5_[4][1];
538 float E2x5Left=e5x5_[0][1]+e5x5_[0][1]+e5x5_[0][2]+e5x5_[0][3]+e5x5_[0][4]
539 +e5x5_[1][0]+e5x5_[1][1]+e5x5_[1][2]+e5x5_[1][3]+e5x5_[1][4];
541 float E2x5Right=e5x5_[4][0]+e5x5_[4][1]+e5x5_[4][2]+e5x5_[4][3]+e5x5_[4][4]
542 +e5x5_[3][0]+e5x5_[3][1]+e5x5_[3][2]+e5x5_[3][3]+e5x5_[3][4];
544 float centerstrip=e5x5_[2][2]+e5x5_[2][0]+e5x5_[2][1]+e5x5_[2][3]+e5x5_[2][4];
545 float rightstrip=e5x5_[3][2]+e5x5_[3][0]+e5x5_[3][1]+e5x5_[3][3]+e5x5_[3][4];
546 float leftstrip=e5x5_[1][2]+e5x5_[1][0]+e5x5_[1][1]+e5x5_[1][3]+e5x5_[1][4];
548 if(rightstrip>leftstrip)E2x5Max=rightstrip+centerstrip;
549 else E2x5Max=leftstrip+centerstrip;
552 float etacry;
float phicry;
int ieta;
int iphi;
float thetatilt;
float phitilt;
554 if(
abs(ieta)==1 ||
abs(ieta)==2 )
556 if(
abs(ieta)>2 &&
abs(ieta)<24)
566 if(
abs(ieta)>27 &&
abs(ieta)<44)
576 if(
abs(ieta)>47 &&
abs(ieta)<64)
586 if(
abs(ieta)>67 &&
abs(ieta)<84)
592 localCoordsEB(PFClust, etacry, phicry, ieta, iphi, thetatilt, phitilt);
593 inputs.push_back(beamspotZ);
594 inputs.push_back(ClusEta/fabs(ClusEta));
595 inputs.push_back(fabs(ClusEta));
596 inputs.push_back(fabs(ClusPhi));
597 inputs.push_back(
log(ClusE));
598 inputs.push_back((Eseed/ClusE));
599 inputs.push_back((Etop/ClusE));
600 inputs.push_back((Ebottom/ClusE));
601 inputs.push_back((Eleft/ClusE));
602 inputs.push_back((Eright/ClusE));
603 inputs.push_back(E3x3/ClusE);
604 inputs.push_back(E1x3/ClusE);
605 inputs.push_back(E3x1/ClusE);
606 inputs.push_back(E5x5/ClusE);
607 inputs.push_back(E1x5/ClusE);
608 inputs.push_back(E2x5Max/ClusE);
609 inputs.push_back(E2x5Top/ClusE);
610 inputs.push_back(E2x5Bottom/ClusE);
611 inputs.push_back(E2x5Left/ClusE);
612 inputs.push_back(E2x5Right/ClusE);
613 inputs.push_back(etacry);
614 inputs.push_back(phicry);
615 inputs.push_back(iphi%2);
616 inputs.push_back(ieta%5);
617 inputs.push_back(iphi%20);
618 inputs.push_back(iEtaCrack);
619 int size=inputs.size();
621 for(
int i=0;
i<
size; ++
i)PFInputs[
i]=inputs[
i];
622 PFClustCorr= ReaderLCEB->
GetResponse(PFInputs)*ClusE;
625 float xcry;
float ycry;
int ix;
int iy;
float thetatilt;
float phitilt;
626 localCoordsEE(PFClust, xcry, ycry, ix, iy, thetatilt, phitilt);
627 inputs.push_back(beamspotZ);
628 inputs.push_back(ClusEta/fabs(ClusEta));
629 inputs.push_back(fabs(ClusEta));
630 inputs.push_back(fabs(ClusPhi));
631 inputs.push_back(
log(ClusE));
632 inputs.push_back((Eseed/ClusE));
633 inputs.push_back((Etop/ClusE));
634 inputs.push_back((Ebottom/ClusE));
635 inputs.push_back((Eleft/ClusE));
636 inputs.push_back((Eright/ClusE));
637 inputs.push_back(E3x3/ClusE);
638 inputs.push_back(E1x3/ClusE);
639 inputs.push_back(E3x1/ClusE);
640 inputs.push_back(E5x5/ClusE);
641 inputs.push_back(E1x5/ClusE);
642 inputs.push_back(E2x5Max/ClusE);
643 inputs.push_back(E2x5Top/ClusE);
644 inputs.push_back(E2x5Bottom/ClusE);
645 inputs.push_back(E2x5Left/ClusE);
646 inputs.push_back(E2x5Right/ClusE);
647 inputs.push_back(xcry);
648 inputs.push_back(ycry);
649 int size=inputs.size();
651 for(
int i=0;
i<
size; ++
i)PFInputs[
i]=inputs[
i];
652 PFClustCorr= ReaderLCEE->
GetResponse(PFInputs) *ClusE;
659 std::vector<reco::PFCandidatePtr>&insideBox,
660 std::vector<DetId>& MatchedRH
662 std::vector<reco::PFCandidatePtr>Linked;
663 for(
unsigned int p=0;
p<insideBox.size(); ++
p){
670 if(insideBox[
p]->
pdgId()==22){
671 double Theta = -position_.theta()+0.5*
TMath::Pi();
672 double Eta = position_.eta();
674 double X = position_.x();
675 double Y = position_.y();
677 std::vector< std::pair<DetId, float> > crystals_vector = (*cit)->hitsAndFractions();
678 DetId seedXtalId = crystals_vector[0].first;
679 int detector = seedXtalId.
subdetId();
681 float X0 = 0.89;
float T0 = 7.4;
682 double depth = X0 * (T0 +
log((*cit)->energy()));
685 depth = X0 * (T0 +
log((*cit)->energy()));
690 if(fabs(Eta)<1.653)T0=3.1;
691 depth = X0 * (T0 +
log((*cit)->energy()));
695 crystals_vector.clear();
698 crystals_vector = (*cit)->hitsAndFractions();
701 for (
unsigned int icry=0; icry<crystals_vector.size(); ++icry){
717 double ThetaWidth = (
TMath::Pi()/180.)*TMath::Cos(ThetaCentr);
719 double etacry=(Theta-ThetaCentr)/ThetaWidth;
720 if(fabs(etacry)<0.6 && fabs(phicry)<0.6){
721 Linked.push_back(insideBox[
p]);
723 MatchedRH.push_back(crystals_vector[icry].first);
737 double XCentr = center_pos.
x();
738 double XWidth = 2.59;
739 double xcry = (X-XCentr)/XWidth;
740 double YCentr = center_pos.
y();
741 double YWidth = 2.59;
742 double ycry = (Y-YCentr)/YWidth;
743 if(fabs(xcry)<0.6 && fabs(ycry)<0.6){
744 Linked.push_back(insideBox[
p]);
745 MatchedRH.push_back(crystals_vector[icry].first);
761 DetId seedCrystal=(*cit)->hitsAndFractions()[0].first;
763 DetId crystals_vector_seed=(*cit)->hitsAndFractions()[0].first;
764 math::XYZVector photon_directionWrtVtx((*cit)->position().x()-insideBox[
p]->vx(),
765 (*cit)->position().y()-insideBox[
p]->vy(),
766 (*cit)->position().z()-insideBox[
p]->vz()
768 float dR=
deltaR(photon_directionWrtVtx.eta(), photon_directionWrtVtx.phi(), position_.eta(), position_.phi());
772 deta=fabs(photon_directionWrtVtx.eta()-position_.eta());
773 dphi=acos(
cos(photon_directionWrtVtx.phi()- position_.phi()));
774 seedCrystal=crystals_vector_seed;
777 if(deta<0.05 && dphi<0.07){
778 Linked.push_back(insideBox[
p]);
779 MatchedRH.push_back(seedCrystal);
double GetResponse(const float *vector) const
const math::XYZPoint & position() const
cluster centroid position
void addHitAndFraction(DetId id, float fraction)
static int distanceX(const EEDetId &a, const EEDetId &b)
virtual std::pair< float, float > ClusterWidth(vector< reco::CaloCluster > &PFClust)
Geom::Phi< T > phi() const
std::vector< EcalRecHit >::const_iterator const_iterator
virtual void localCoordsEE(reco::CaloCluster clus, float &xcry, float &ycry, int &ix, int &iy, float &thetatilt, float &phitilt)
const CaloSubdetectorGeometry * geomBar_
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
double Phi_mpi_pi(double x)
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
CCGFloat getPhiAxis() const
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
void BasicClusterPFCandLink(reco::SuperCluster sc, std::vector< reco::PFCandidatePtr > &insideBox, std::vector< DetId > &MatchedRH)
virtual float SumPFRecHits(std::vector< std::pair< DetId, float > > &bcCells, bool isEB)
double eta() const
pseudorapidity of cluster centroid
virtual float get5x5Element(int i, int j, std::vector< std::pair< DetId, float > > &bcCells, bool isEB)
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
double deltaR(double eta1, double phi1, double eta2, double phi2)
bool overlap(const reco::Muon &muon1, const reco::Muon &muon2, double pullX=1.0, double pullY=1.0, bool checkAdjacentChambers=false)
Handle< EcalRecHitCollection > EBReducedRecHits_
Geom::Theta< T > theta() const
float getPFSuperclusterOverlap(reco::CaloCluster PFClust, reco::SuperCluster sc)
int iphi() const
get the crystal iphi
uint32_t rawId() const
get the raw id
ggPFClusters(edm::Handle< EcalRecHitCollection > &EBReducedRecHits, edm::Handle< EcalRecHitCollection > &EEReducedRecHits, const CaloSubdetectorGeometry *geomBar, const CaloSubdetectorGeometry *geomEnd)
U second(std::pair< T, U > const &p)
virtual void Fill5x5Map(std::vector< std::pair< DetId, float > > &bcCells, bool isEB)
static int distanceEta(const EBDetId &a, const EBDetId &b)
virtual void localCoordsEB(reco::CaloCluster clus, float &etacry, float &phicry, int &ieta, int &iphi, float &thetatilt, float &phitilt)
double dPhi(double phi1, double phi2)
static int distancePhi(const EBDetId &a, const EBDetId &b)
virtual vector< reco::CaloCluster > getPFClusters(reco::SuperCluster)
Cos< T >::type cos(const T &t)
double LocalEnergyCorrection(const GBRForest *ReaderLCEB, const GBRForest *ReaderLCEE, reco::CaloCluster PFClust, float beamspotZ)
double energy() const
cluster energy
virtual DetId FindSeed(std::vector< std::pair< DetId, float > > &bcCells, bool isEB)
int ieta() const
get the crystal ieta
static int distanceY(const EEDetId &a, const EEDetId &b)
CCGFloat getThetaAxis() const
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)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
const CaloSubdetectorGeometry * geomEnd_
const GlobalPoint getPosition(CCGFloat depth) const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
A base class to handle the particular shape of Ecal Xtals. Taken from ORCA Calorimetry Code...
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
double phi() const
azimuthal angle of cluster centroid
tuple size
Write out results.
Handle< EcalRecHitCollection > EEReducedRecHits_
virtual float PFRecHitsSCOverlap(std::vector< std::pair< DetId, float > > &bcCells1, std::vector< std::pair< DetId, float > > &bcCells2, bool isEB)
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents