Go to the documentation of this file.00001 #include <vector>
00002 #include <map>
00003 #include <iostream>
00004
00005 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00006 #include "RecoEcal/EgammaClusterAlgos/interface/PreshowerPhiClusterAlgo.h"
00007 #include "RecoCaloTools/Navigation/interface/EcalPreshowerNavigator.h"
00008 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00009 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011 #include "DataFormats/Math/interface/deltaPhi.h"
00012
00013 #include "TH1.h"
00014
00015 reco::PreshowerCluster PreshowerPhiClusterAlgo::makeOneCluster(ESDetId strip,
00016 HitsID *used_strips,
00017 RecHitsMap *the_rechitsMap_p,
00018 const CaloSubdetectorGeometry*& geometry_p,
00019 CaloSubdetectorTopology*& topology_p,
00020 double deltaEta, double minDeltaPhi, double maxDeltaPhi)
00021 {
00022
00023 rechits_map = the_rechitsMap_p;
00024 used_s = used_strips;
00025
00026 int plane = strip.plane();
00027
00028
00029 std::vector< std::pair<DetId,float> > dummy;
00030 Point posi(0,0,0);
00031 reco::PreshowerCluster nullcluster = reco::PreshowerCluster(0., posi, dummy, plane);
00032 if (strip == ESDetId(0)) return nullcluster;
00033
00034 const CaloCellGeometry *refCell = geometry_p->getGeometry(strip);
00035 GlobalPoint refpos = refCell->getPosition();
00036 double refEta = refpos.eta();
00037 double refPhi = refpos.phi();
00038
00039
00040 EcalRecHitCollection clusterRecHits;
00041
00042 double x_pos = 0;
00043 double y_pos = 0;
00044 double z_pos = 0;
00045
00046 RecHitsMap::iterator strip_it;
00047 for (strip_it = rechits_map->begin(); strip_it != rechits_map->end(); ++strip_it) {
00048
00049 if (!goodStrip(strip_it)) continue;
00050
00051 ESDetId mystrip = (strip_it->first == DetId(0)) ? ESDetId(0) : ESDetId(strip_it->first);
00052 if (mystrip.plane() != plane) continue;
00053
00054 const CaloCellGeometry *thisCell = geometry_p->getGeometry(strip_it->first);
00055 GlobalPoint position = thisCell->getPosition();
00056
00057 if (fabs(position.eta() - refEta) < deltaEta) {
00058
00059
00060
00061 if (reco::deltaPhi(position.phi(), refPhi) > 0 && reco::deltaPhi(position.phi(), refPhi) > maxDeltaPhi) continue;
00062 if (reco::deltaPhi(position.phi(), refPhi) < 0 && reco::deltaPhi(position.phi(), refPhi) < minDeltaPhi) continue;
00063
00064
00065
00066 clusterRecHits.push_back(strip_it->second);
00067 used_s->insert(strip_it->first);
00068
00069 x_pos += strip_it->second.energy() * position.x();
00070 y_pos += strip_it->second.energy() * position.y();
00071 z_pos += strip_it->second.energy() * position.z();
00072 }
00073
00074 }
00075
00076 EcalRecHitCollection::iterator it;
00077 double Eclust = 0;
00078
00079 std::vector<std::pair<DetId,float > > usedHits;
00080 for (it=clusterRecHits.begin(); it != clusterRecHits.end(); it++) {
00081 Eclust += it->energy();
00082 usedHits.push_back(std::pair<DetId,float > (it->id(), 1.));
00083 }
00084
00085 if (Eclust > 0.) {
00086 x_pos /= Eclust;
00087 y_pos /= Eclust;
00088 z_pos /= Eclust;
00089 }
00090 Point pos(x_pos,y_pos,z_pos);
00091
00092 reco::PreshowerCluster cluster = reco::PreshowerCluster(Eclust, pos, usedHits, plane);
00093 used_strips = used_s;
00094
00095 return cluster;
00096 }
00097
00098
00099 bool PreshowerPhiClusterAlgo::goodStrip(RecHitsMap::iterator candidate_it) {
00100
00101 if ( used_s->find(candidate_it->first) != used_s->end())
00102 LogTrace("PreShowerPhiClusterAlgo") << " This strip is in use";
00103 if (candidate_it == rechits_map->end() )
00104 LogTrace("PreShowerPhiClusterAlgo") << " No such a strip in rechits_map";
00105 if (candidate_it->second.energy() <= esStripEnergyCut_)
00106 LogTrace("PreShowerPhiClusterAlgo") << "Strip energy" << candidate_it->second.energy() <<"is below threshold";
00107
00108
00109 if ( (used_s->find(candidate_it->first) != used_s->end()) ||
00110 (candidate_it == rechits_map->end() ) ||
00111 (candidate_it->second.energy() <= esStripEnergyCut_ ) )
00112 {
00113 return false;
00114 }
00115 return true;
00116 }
00117