CMS 3D CMS Logo

ChargeIsolationExtra.cc
Go to the documentation of this file.
9 
10 #include <iostream>
11 
12 //#define EDM_ML_DEBUG
13 
14 namespace spr {
15 
17  const edm::EventSetup& iSetup,
18  CaloNavigator<DetId>& theNavigator,
19  reco::TrackCollection::const_iterator trkItr,
21  const CaloSubdetectorGeometry* gEB,
22  const CaloSubdetectorGeometry* gEE,
24  TrackAssociatorParameters& parameters_,
25  int ieta,
26  int iphi,
27  const std::string& theTrackQuality,
28  bool
29 #ifdef EDM_ML_DEBUG
30  debug
31 #endif
32  ) {
33 
34  double maxNearP = -1.0;
35  reco::TrackBase::TrackQuality trackQuality_ = reco::TrackBase::qualityByName(theTrackQuality);
36 
37  // const DetId anyCell,
38  reco::TrackCollection::const_iterator trkItr2;
39  for (trkItr2 = trkCollection->begin(); trkItr2 != trkCollection->end(); ++trkItr2) {
40  const reco::Track* pTrack2 = &(*trkItr2);
41 
42  bool trkQuality = pTrack2->quality(trackQuality_);
43  if ((trkItr2 != trkItr) && trkQuality) {
44  const FreeTrajectoryState fts2 = associator.getFreeTrajectoryState(iSetup, *pTrack2);
45  TrackDetMatchInfo info2 = associator.associate(iEvent, iSetup, fts2, parameters_);
46  const GlobalPoint point2(info2.trkGlobPosAtEcal.x(), info2.trkGlobPosAtEcal.y(), info2.trkGlobPosAtEcal.z());
47 
48  if (info2.isGoodEcal) {
49  if (std::abs(point2.eta()) < spr::etaBEEcal) {
50  const DetId anyCell = gEB->getClosestCell(point2);
51 #ifdef EDM_ML_DEBUG
52  if (debug)
53  std::cout << "chargeIsolation:: EB cell " << (EBDetId)(anyCell) << " for pt " << pTrack2->p()
54  << std::endl;
55 #endif
56  if (!spr::chargeIsolation(anyCell, theNavigator, ieta, iphi)) {
57  if (maxNearP < pTrack2->p())
58  maxNearP = pTrack2->p();
59  }
60  } else {
61  const DetId anyCell = gEE->getClosestCell(point2);
62 #ifdef EDM_ML_DEBUG
63  if (debug)
64  std::cout << "chargeIsolation:: EE cell " << (EEDetId)(anyCell) << " for pt " << pTrack2->p()
65  << std::endl;
66 #endif
67  if (!spr::chargeIsolation(anyCell, theNavigator, ieta, iphi)) {
68  if (maxNearP < pTrack2->p())
69  maxNearP = pTrack2->p();
70  }
71  }
72  } //info2.isGoodEcal
73  }
74  }
75  return maxNearP;
76  }
77 
78  //===========================================================================================================
79 
80  bool chargeIsolation(const DetId anyCell, CaloNavigator<DetId>& navigator, int ieta, int iphi) {
81  bool isIsolated = false;
82 
83  DetId thisDet;
84 
85  for (int dx = -ieta; dx < ieta + 1; ++dx) {
86  for (int dy = -iphi; dy < iphi + 1; ++dy) {
87  thisDet = navigator.offsetBy(dx, dy);
88  navigator.home();
89 
90  if (thisDet != DetId(0)) {
91  if (thisDet == anyCell) {
92  isIsolated = false;
93  return isIsolated;
94  }
95  }
96  }
97  }
98  return isIsolated;
99  }
100 
101  //===========================================================================================================
102 
104  const edm::EventSetup& iSetup,
105  const DetId& coreDet,
106  reco::TrackCollection::const_iterator trkItr,
108  const CaloGeometry* geo,
109  const CaloTopology* caloTopology,
111  TrackAssociatorParameters& parameters_,
112  int ieta,
113  int iphi,
114  const std::string& theTrackQuality,
115  bool debug) {
118 
119  std::vector<DetId> vdets = spr::matrixECALIds(coreDet, ieta, iphi, geo, caloTopology, debug);
120 #ifdef EDM_ML_DEBUG
121  if (debug)
122  std::cout << "chargeIsolation:: eta/phi/dets " << ieta << " " << iphi << " " << vdets.size() << std::endl;
123 #endif
124  double maxNearP = -1.0;
125  reco::TrackBase::TrackQuality trackQuality_ = reco::TrackBase::qualityByName(theTrackQuality);
126 
127  // const DetId anyCell,
128  reco::TrackCollection::const_iterator trkItr2;
129  for (trkItr2 = trkCollection->begin(); trkItr2 != trkCollection->end(); ++trkItr2) {
130  const reco::Track* pTrack2 = &(*trkItr2);
131 
132  bool trkQuality = pTrack2->quality(trackQuality_);
133  if ((trkItr2 != trkItr) && trkQuality) {
134  const FreeTrajectoryState fts2 = associator.getFreeTrajectoryState(iSetup, *pTrack2);
135  TrackDetMatchInfo info2 = associator.associate(iEvent, iSetup, fts2, parameters_);
136  const GlobalPoint point2(info2.trkGlobPosAtEcal.x(), info2.trkGlobPosAtEcal.y(), info2.trkGlobPosAtEcal.z());
137 
138  if (info2.isGoodEcal) {
139  if (std::abs(point2.eta()) < spr::etaBEEcal) {
140  const DetId anyCell = barrelGeom->getClosestCell(point2);
141 #ifdef EDM_ML_DEBUG
142  if (debug)
143  std::cout << "chargeIsolation:: EB cell " << (EBDetId)(anyCell) << " for pt " << pTrack2->p()
144  << std::endl;
145 #endif
146  if (!spr::chargeIsolation(anyCell, vdets)) {
147  if (maxNearP < pTrack2->p())
148  maxNearP = pTrack2->p();
149  }
150  } else {
151  const DetId anyCell = endcapGeom->getClosestCell(point2);
152 #ifdef EDM_ML_DEBUG
153  if (debug)
154  std::cout << "chargeIsolation:: EE cell " << (EEDetId)(anyCell) << " for pt " << pTrack2->p()
155  << std::endl;
156 #endif
157  if (!spr::chargeIsolation(anyCell, vdets)) {
158  if (maxNearP < pTrack2->p())
159  maxNearP = pTrack2->p();
160  }
161  }
162  } //info2.isGoodEcal
163  }
164  }
165  return maxNearP;
166  }
167 
168  //===========================================================================================================
169 
171  const edm::EventSetup& iSetup,
172  reco::TrackCollection::const_iterator trkItr,
174  const DetId ClosestCell,
175  const HcalTopology* topology,
176  const CaloSubdetectorGeometry* gHB,
178  TrackAssociatorParameters& parameters_,
179  int ieta,
180  int iphi,
181  const std::string& theTrackQuality,
182  bool debug) {
183  std::vector<DetId> dets(1, ClosestCell);
184 
185 #ifdef EDM_ML_DEBUG
186  if (debug)
187  std::cout << (HcalDetId)ClosestCell << std::endl;
188 #endif
189  std::vector<DetId> vdets = spr::matrixHCALIds(dets, topology, ieta, iphi, false, debug);
190 
191 #ifdef EDM_ML_DEBUG
192  if (debug) {
193  for (unsigned int i = 0; i < vdets.size(); i++) {
194  std::cout << "HcalDetId in " << 2 * ieta + 1 << "x" << 2 * iphi + 1 << " " << (HcalDetId)vdets[i] << std::endl;
195  }
196  }
197 #endif
198  double maxNearP = -1.0;
199  reco::TrackBase::TrackQuality trackQuality_ = reco::TrackBase::qualityByName(theTrackQuality);
200 
201  reco::TrackCollection::const_iterator trkItr2;
202  for (trkItr2 = trkCollection->begin(); trkItr2 != trkCollection->end(); ++trkItr2) {
203  const reco::Track* pTrack2 = &(*trkItr2);
204 
205  bool trkQuality = pTrack2->quality(trackQuality_);
206  if ((trkItr2 != trkItr) && trkQuality) {
207  const FreeTrajectoryState fts2 = associator.getFreeTrajectoryState(iSetup, *pTrack2);
208  TrackDetMatchInfo info2 = associator.associate(iEvent, iSetup, fts2, parameters_);
209  const GlobalPoint point2(info2.trkGlobPosAtHcal.x(), info2.trkGlobPosAtHcal.y(), info2.trkGlobPosAtHcal.z());
210 
211 #ifdef EDM_ML_DEBUG
212  if (debug) {
213  std::cout << "Track2 (p,eta,phi) " << pTrack2->p() << " " << pTrack2->eta() << " " << pTrack2->phi()
214  << std::endl;
215  }
216 #endif
217  if (info2.isGoodHcal) {
218  const DetId anyCell = gHB->getClosestCell(point2);
219 #ifdef EDM_ML_DEBUG
220  if (debug)
221  std::cout << "chargeIsolation:: HCAL cell " << (HcalDetId)(anyCell) << " for pt " << pTrack2->p()
222  << std::endl;
223 #endif
224  if (!spr::chargeIsolation(anyCell, vdets)) {
225  if (maxNearP < pTrack2->p())
226  maxNearP = pTrack2->p();
227  }
228 #ifdef EDM_ML_DEBUG
229  if (debug) {
230  std::cout << "maxNearP " << maxNearP << " thisCell " << (HcalDetId)anyCell << " ("
231  << info2.trkGlobPosAtHcal.x() << "," << info2.trkGlobPosAtHcal.y() << ","
232  << info2.trkGlobPosAtHcal.z() << ")" << std::endl;
233  }
234 #endif
235  }
236  }
237  }
238  return maxNearP;
239  }
240 
241 } // namespace spr
ChargeIsolationExtra.h
mps_fire.i
i
Definition: mps_fire.py:355
FreeTrajectoryState.h
spr
Definition: CaloConstants.h:6
reco::TrackBase::p
double p() const
momentum vector magnitude
Definition: TrackBase.h:605
EBDetId
Definition: EBDetId.h:17
CaloConstants.h
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HcalTopology
Definition: HcalTopology.h:26
TrackDetMatchInfo::trkGlobPosAtHcal
math::XYZPoint trkGlobPosAtHcal
Definition: TrackDetMatchInfo.h:40
CaloGeometry::getSubdetectorGeometry
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
reco::TrackBase::TrackQuality
TrackQuality
track quality
Definition: TrackBase.h:150
spr::matrixECALIds
void matrixECALIds(const DetId &det, int ieta, int iphi, const CaloGeometry *geo, const CaloTopology *caloTopology, std::vector< DetId > &vdets, bool debug=false, bool igNoreTransition=true)
Definition: MatrixECALDetIds.cc:16
edm::Handle< reco::TrackCollection >
TrackDetMatchInfo::isGoodHcal
bool isGoodHcal
Definition: TrackDetMatchInfo.h:48
CaloTopology
Definition: CaloTopology.h:19
EcalBarrel
Definition: EcalSubdetector.h:10
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
DetId
Definition: DetId.h:17
CaloGeometry
Definition: CaloGeometry.h:21
debug
#define debug
Definition: HDRShower.cc:19
spr::matrixHCALIds
std::vector< DetId > matrixHCALIds(std::vector< DetId > &dets, const HcalTopology *topology, int ieta, int iphi, bool includeHO=false, bool debug=false)
Definition: MatrixHCALDetIds.cc:15
spr::chargeIsolationHcal
double chargeIsolationHcal(unsigned int trkIndex, std::vector< spr::propagatedTrackID > &vdetIds, const HcalTopology *topology, int ieta, int iphi, bool debug=false)
Definition: ChargeIsolation.cc:114
ecaldqm::topology
const CaloTopology * topology(nullptr)
HLT_2018_cff.navigator
navigator
Definition: HLT_2018_cff.py:11734
ChargeIsolation.h
reco::Track
Definition: Track.h:27
MatrixECALDetIds.h
spr::etaBEEcal
static const double etaBEEcal
Definition: CaloConstants.h:12
EDM_ML_DEBUG
#define EDM_ML_DEBUG
Definition: HcalHBHEMuonSimAnalyzer.cc:41
ctfWithMaterialTrackMCMatch_cfi.associator
associator
Definition: ctfWithMaterialTrackMCMatch_cfi.py:7
Point3DBase< float, GlobalTag >
reco::TrackBase::phi
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:620
EEDetId
Definition: EEDetId.h:14
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalEndcap
Definition: EcalSubdetector.h:10
MatrixHCALDetIds.h
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
spr::chargeIsolation
bool chargeIsolation(const DetId anyCell, std::vector< DetId > &vdets)
Definition: ChargeIsolation.cc:213
TrackDetectorAssociator
Definition: TrackDetectorAssociator.h:49
reco::TrackBase::eta
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:623
HcalDetId
Definition: HcalDetId.h:12
iEvent
int iEvent
Definition: GenABIO.cc:224
PVValHelper::dy
Definition: PVValidationHelpers.h:49
edm::EventSetup
Definition: EventSetup.h:57
CaloSubdetectorGeometry::getClosestCell
virtual DetId getClosestCell(const GlobalPoint &r) const
Definition: CaloSubdetectorGeometry.cc:44
DetId::Ecal
Definition: DetId.h:27
TrackDetMatchInfo::trkGlobPosAtEcal
math::XYZPoint trkGlobPosAtEcal
Track position at different parts of the calorimeter.
Definition: TrackDetMatchInfo.h:39
reco::TrackBase::qualityByName
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:126
TrackDetMatchInfo
Definition: TrackDetMatchInfo.h:14
CaloNavigator
Definition: CaloNavigator.h:7
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
CaloPropagateTrack.h
FindDistCone.h
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TrackDetMatchInfo::isGoodEcal
bool isGoodEcal
Definition: TrackDetMatchInfo.h:47
spr::chargeIsolationEcal
double chargeIsolationEcal(unsigned int trkIndex, std::vector< spr::propagatedTrackID > &vdetIds, const CaloGeometry *geo, const CaloTopology *caloTopology, int ieta, int iphi, bool debug=false)
Definition: ChargeIsolation.cc:15
edm::Event
Definition: Event.h:73
reco::TrackBase::quality
bool quality(const TrackQuality) const
Track quality.
Definition: TrackBase.h:537
PVValHelper::dx
Definition: PVValidationHelpers.h:48
TrackAssociatorParameters
Definition: TrackAssociatorParameters.h:34