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