CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FindCaloHitCone.cc
Go to the documentation of this file.
3 #include <iostream>
4 
5 namespace spr {
6 
7 
8  //Ecal Endcap OR Barrel RecHits
9  std::vector<EcalRecHitCollection::const_iterator> findCone(const CaloGeometry* geo, edm::Handle<EcalRecHitCollection>& hits, const GlobalPoint& hpoint1, const GlobalPoint& point1, double dR, const GlobalVector& trackMom) {
10 
11  std::vector<EcalRecHitCollection::const_iterator> hit;
12 
13  for (EcalRecHitCollection::const_iterator j=hits->begin();
14  j!=hits->end(); j++) {
15 
16  bool keepHit = false;
17 
18  if (j->id().subdetId() == EcalEndcap) {
19  EEDetId EEid = EEDetId(j->id());
20  const GlobalPoint rechitPoint = geo->getPosition(EEid);
21  if (getDistInPlaneTrackDir(point1, trackMom, rechitPoint)<dR) keepHit = true;
22  } else if (j->id().subdetId() == EcalBarrel) {
23  EBDetId EBid = EBDetId(j->id());
24  const GlobalPoint rechitPoint = geo->getPosition(EBid);
25  if (getDistInPlaneTrackDir(point1, trackMom, rechitPoint)<dR) keepHit = true;
26  }
27 
28  if (keepHit) hit.push_back(j);
29  }
30  return hit;
31  }
32 
33  // Ecal Endcap AND Barrel RecHits
34  std::vector<EcalRecHitCollection::const_iterator> findCone(const CaloGeometry* geo, edm::Handle<EcalRecHitCollection>& barrelhits, edm::Handle<EcalRecHitCollection>& endcaphits, const GlobalPoint& hpoint1, const GlobalPoint& point1, double dR, const GlobalVector& trackMom) {
35 
36  std::vector<EcalRecHitCollection::const_iterator> hit;
37 
38  // Only check both barrel and endcap when track is near transition
39  // region: 1.479-2*0.087 < trkEta < 1.479+2*0.087
40 
41  bool doBarrel=false, doEndcap=false;
42  if ( std::abs(point1.eta()) < 1.653) doBarrel=true; // 1.479+2*0.087
43  if ( std::abs(point1.eta()) > 1.305) doEndcap=true; // 1.479-2*0.087
44 
45  if (doBarrel) {
46  for (EcalRecHitCollection::const_iterator j=barrelhits->begin();
47  j!=barrelhits->end(); j++) {
48 
49  bool keepHit = false;
50  if (j->id().subdetId() == EcalBarrel) {
51  EBDetId EBid = EBDetId(j->id());
52  const GlobalPoint rechitPoint = geo->getPosition(EBid);
53  if (getDistInPlaneTrackDir(point1, trackMom, rechitPoint)<dR) keepHit = true;
54  } else {
55  std::cout << "PROBLEM : Endcap RecHits in Barrel Collection!?"
56  << std::endl;
57  }
58  if (keepHit) hit.push_back(j);
59  }
60  } // doBarrel
61 
62  if (doEndcap) {
63 
64  for (EcalRecHitCollection::const_iterator j=endcaphits->begin();
65  j!=endcaphits->end(); j++) {
66 
67  bool keepHit = false;
68 
69  if (j->id().subdetId() == EcalEndcap) {
70  EEDetId EEid = EEDetId(j->id());
71  const GlobalPoint rechitPoint = geo->getPosition(EEid);
72  if (getDistInPlaneTrackDir(point1, trackMom, rechitPoint)<dR) keepHit = true;
73  } else {
74  std::cout << "PROBLEM : Barrel RecHits in Endcap Collection!?"
75  << std::endl;
76  }
77  if (keepHit) hit.push_back(j);
78  }
79  } // doEndcap
80 
81  return hit;
82  }
83 
84 
85  //HBHE RecHits
86  std::vector<HBHERecHitCollection::const_iterator> findCone(const CaloGeometry* geo, edm::Handle<HBHERecHitCollection>& hits, const GlobalPoint& hpoint1, const GlobalPoint& point1, double dR, const GlobalVector& trackMom) {
87 
88  std::vector<HBHERecHitCollection::const_iterator> hit;
89  // Loop over Hcal RecHits
90  for (HBHERecHitCollection::const_iterator j=hits->begin();
91  j!=hits->end(); j++) {
92  DetId detId(j->id());
93  const GlobalPoint rechitPoint = geo->getPosition(detId);
94  if (getDistInPlaneTrackDir(hpoint1, trackMom, rechitPoint)<dR) hit.push_back(j);
95  }
96  return hit;
97  }
98 
99  // PCalo SimHits
100  std::vector<edm::PCaloHitContainer::const_iterator> findCone(const CaloGeometry* geo, edm::Handle<edm::PCaloHitContainer>& hits, const GlobalPoint& hpoint1, const GlobalPoint& point1, double dR, const GlobalVector& trackMom) {
101 
102  std::vector<edm::PCaloHitContainer::const_iterator> hit;
103  edm::PCaloHitContainer::const_iterator ihit;
104  for (ihit=hits->begin(); ihit!=hits->end(); ihit++) {
105  DetId detId(ihit->id());
106  const GlobalPoint rechitPoint = geo->getPosition(detId);
107  if (getDistInPlaneTrackDir(hpoint1, trackMom, rechitPoint)<dR) {
108  hit.push_back(ihit);
109  }
110  }
111  return hit;
112  }
113 
114 }
double getDistInPlaneTrackDir(const GlobalPoint &caloPoint, const GlobalVector &caloVector, const GlobalPoint &rechitPoint)
Definition: FindDistCone.cc:8
std::vector< T >::const_iterator const_iterator
#define abs(x)
Definition: mlp_lapack.h:159
int j
Definition: DBlmapReader.cc:9
const GlobalPoint & getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:68
Definition: DetId.h:20
T eta() const
Definition: PV3DBase.h:70
tuple cout
Definition: gather_cfg.py:41
std::vector< EcalRecHitCollection::const_iterator > findCone(const CaloGeometry *geo, edm::Handle< EcalRecHitCollection > &hits, const GlobalPoint &hpoint1, const GlobalPoint &point1, double dR)