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