CMS 3D CMS Logo

PreshowerPhiClusterAlgo.cc
Go to the documentation of this file.
1 #include <vector>
2 #include <map>
3 #include <iostream>
4 
12 
13 #include "TH1.h"
14 
16  HitsID* used_strips,
17  RecHitsMap* the_rechitsMap_p,
18  const CaloSubdetectorGeometry* geometry_p,
19  double deltaEta,
20  double minDeltaPhi,
21  double maxDeltaPhi) {
22  rechits_map = the_rechitsMap_p;
23  used_s = used_strips;
24 
25  int plane = strip.plane();
26 
27  // create null-cluster
28  std::vector<std::pair<DetId, float> > dummy;
29  Point posi(0, 0, 0);
30  reco::PreshowerCluster nullcluster = reco::PreshowerCluster(0., posi, dummy, plane);
31  if (strip == ESDetId(0))
32  return nullcluster; // works in case of no intersected strip found (e.g. in the Barrel)
33 
34  auto refCell = geometry_p->getGeometry(strip);
35  const GlobalPoint& refpos = refCell->getPosition();
36  double refEta = refpos.eta();
37  double refPhi = refpos.phi();
38 
39  // Collection of cluster strips
40  EcalRecHitCollection clusterRecHits;
41 
42  double x_pos = 0;
43  double y_pos = 0;
44  double z_pos = 0;
45 
46  RecHitsMap::iterator strip_it;
47  for (strip_it = rechits_map->begin(); strip_it != rechits_map->end(); ++strip_it) {
48  if (!goodStrip(strip_it))
49  continue;
50 
51  ESDetId mystrip = (strip_it->first == DetId(0)) ? ESDetId(0) : ESDetId(strip_it->first);
52  if (mystrip.plane() != plane)
53  continue;
54 
55  auto thisCell = geometry_p->getGeometry(strip_it->first);
56  const GlobalPoint& position = thisCell->getPosition();
57 
58  if (fabs(position.eta() - refEta) < deltaEta) {
59  //std::cout<<"all strips : "<<mystrip.plane()<<" "<<position.phi()<<" "<<reco::deltaPhi(position.phi(), refPhi)<<std::endl;
60 
61  if (reco::deltaPhi(position.phi(), refPhi) > 0 && reco::deltaPhi(position.phi(), refPhi) > maxDeltaPhi)
62  continue;
63  if (reco::deltaPhi(position.phi(), refPhi) < 0 && reco::deltaPhi(position.phi(), refPhi) < minDeltaPhi)
64  continue;
65 
66  //std::cout<<mystrip.zside()<<" "<<mystrip.plane()<<" "<<mystrip.six()<<" "<<mystrip.siy()<<" "<<mystrip.strip()<<" "<<position.eta()<<" "<<position.phi()<<" "<<strip_it->second.energy()<<" "<<strip_it->second.recoFlag()<<" "<<refEta<<" "<<refPhi<<" "<<reco::deltaPhi(position.phi(), refPhi)<<std::endl;
67 
68  clusterRecHits.push_back(strip_it->second);
69  used_s->insert(strip_it->first);
70 
71  x_pos += strip_it->second.energy() * position.x();
72  y_pos += strip_it->second.energy() * position.y();
73  z_pos += strip_it->second.energy() * position.z();
74  }
75  }
76 
78  double Eclust = 0;
79 
80  std::vector<std::pair<DetId, float> > usedHits;
81  for (it = clusterRecHits.begin(); it != clusterRecHits.end(); it++) {
82  Eclust += it->energy();
83  usedHits.push_back(std::pair<DetId, float>(it->id(), 1.));
84  }
85 
86  if (Eclust > 0.) {
87  x_pos /= Eclust;
88  y_pos /= Eclust;
89  z_pos /= Eclust;
90  }
91  Point pos(x_pos, y_pos, z_pos);
92 
93  reco::PreshowerCluster cluster = reco::PreshowerCluster(Eclust, pos, usedHits, plane);
94 
95  return cluster;
96 }
97 
98 // returns true if the candidate strip fulfills the requirements to be added to the cluster:
99 bool PreshowerPhiClusterAlgo::goodStrip(RecHitsMap::iterator candidate_it) {
100  if (used_s->find(candidate_it->first) != used_s->end())
101  LogTrace("PreShowerPhiClusterAlgo") << " This strip is in use";
102  if (candidate_it == rechits_map->end())
103  LogTrace("PreShowerPhiClusterAlgo") << " No such a strip in rechits_map";
104  if (candidate_it->second.energy() <= esStripEnergyCut_)
105  LogTrace("PreShowerPhiClusterAlgo") << "Strip energy" << candidate_it->second.energy() << "is below threshold";
106 
107  // crystal should not be included...
108  if ((used_s->find(candidate_it->first) != used_s->end()) || // ...if it already belongs to a cluster
109  (candidate_it == rechits_map->end()) || // ...if it corresponds to a hit
110  (candidate_it->second.energy() <= esStripEnergyCut_)) // ...if it has a negative or zero energy
111  {
112  return false;
113  }
114  return true;
115 }
MessageLogger.h
PreshowerPhiClusterAlgo::esStripEnergyCut_
float esStripEnergyCut_
Definition: PreshowerPhiClusterAlgo.h:41
reco::deltaPhi
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
pos
Definition: PixelAliasList.h:18
reco::PreshowerCluster
Definition: PreshowerCluster.h:17
edm::SortedCollection< EcalRecHit >
ESDetId
Definition: ESDetId.h:15
PreshowerPhiClusterAlgo.h
PreshowerPhiClusterAlgo::rechits_map
RecHitsMap * rechits_map
Definition: PreshowerPhiClusterAlgo.h:46
edm::SortedCollection::push_back
void push_back(T const &t)
Definition: SortedCollection.h:188
EcalRecHitCollections.h
PreshowerPhiClusterAlgo::makeOneCluster
reco::PreshowerCluster makeOneCluster(ESDetId strip, HitsID *used_strips, RecHitsMap *rechits_map, const CaloSubdetectorGeometry *geometry_p, double deltaEta, double minDeltaPhi, double maxDeltaPhi)
Definition: PreshowerPhiClusterAlgo.cc:15
DetId
Definition: DetId.h:17
spr::deltaEta
static const double deltaEta
Definition: CaloConstants.h:8
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
Point3DBase< float, GlobalTag >
EcalPreshowerNavigator.h
Point
Structure Point Contains parameters of Gaussian fits to DMRs.
Definition: DMRtrends.cc:57
CaloSubdetectorGeometry.h
edm::SortedCollection< EcalRecHit >::iterator
std::vector< EcalRecHit >::iterator iterator
Definition: SortedCollection.h:81
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
PreshowerPhiClusterAlgo::goodStrip
bool goodStrip(RecHitsMap::iterator candidate_it)
Definition: PreshowerPhiClusterAlgo.cc:99
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
CaloSubdetectorGeometry::getGeometry
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
Definition: CaloSubdetectorGeometry.cc:36
ESDetId::plane
int plane() const
Definition: ESDetId.h:41
CaloCellGeometry.h
PreshowerPhiClusterAlgo::used_s
HitsID * used_s
Definition: PreshowerPhiClusterAlgo.h:49
CommPDSkim_cfg.maxDeltaPhi
maxDeltaPhi
Definition: CommPDSkim_cfg.py:74
PreshowerPhiClusterAlgo::HitsID
std::set< DetId > HitsID
Definition: PreshowerPhiClusterAlgo.h:22
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
PreshowerPhiClusterAlgo::RecHitsMap
std::map< DetId, EcalRecHit > RecHitsMap
Definition: PreshowerPhiClusterAlgo.h:21
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
dummy
Definition: DummySelector.h:38
VBFGenJetFilter_cfi.minDeltaPhi
minDeltaPhi
Definition: VBFGenJetFilter_cfi.py:13
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
deltaPhi.h