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 =
45  associator.getFreeTrajectoryState(&iSetup.getData(parameters_.bFieldToken), *pTrack2);
46  TrackDetMatchInfo info2 = associator.associate(iEvent, iSetup, fts2, parameters_);
47  const GlobalPoint point2(info2.trkGlobPosAtEcal.x(), info2.trkGlobPosAtEcal.y(), info2.trkGlobPosAtEcal.z());
48 
49  if (info2.isGoodEcal) {
50  if (std::abs(point2.eta()) < spr::etaBEEcal) {
51  const DetId anyCell = gEB->getClosestCell(point2);
52 #ifdef EDM_ML_DEBUG
53  if (debug)
54  std::cout << "chargeIsolation:: EB cell " << (EBDetId)(anyCell) << " for pt " << pTrack2->p()
55  << std::endl;
56 #endif
57  if (!spr::chargeIsolation(anyCell, theNavigator, ieta, iphi)) {
58  if (maxNearP < pTrack2->p())
59  maxNearP = pTrack2->p();
60  }
61  } else {
62  const DetId anyCell = gEE->getClosestCell(point2);
63 #ifdef EDM_ML_DEBUG
64  if (debug)
65  std::cout << "chargeIsolation:: EE cell " << (EEDetId)(anyCell) << " for pt " << pTrack2->p()
66  << std::endl;
67 #endif
68  if (!spr::chargeIsolation(anyCell, theNavigator, ieta, iphi)) {
69  if (maxNearP < pTrack2->p())
70  maxNearP = pTrack2->p();
71  }
72  }
73  } //info2.isGoodEcal
74  }
75  }
76  return maxNearP;
77  }
78 
79  //===========================================================================================================
80 
81  bool chargeIsolation(const DetId anyCell, CaloNavigator<DetId>& navigator, int ieta, int iphi) {
82  bool isIsolated = false;
83 
84  DetId thisDet;
85 
86  for (int dx = -ieta; dx < ieta + 1; ++dx) {
87  for (int dy = -iphi; dy < iphi + 1; ++dy) {
88  thisDet = navigator.offsetBy(dx, dy);
89  navigator.home();
90 
91  if (thisDet != DetId(0)) {
92  if (thisDet == anyCell) {
93  isIsolated = false;
94  return isIsolated;
95  }
96  }
97  }
98  }
99  return isIsolated;
100  }
101 
102  //===========================================================================================================
103 
105  const edm::EventSetup& iSetup,
106  const DetId& coreDet,
107  reco::TrackCollection::const_iterator trkItr,
109  const CaloGeometry* geo,
110  const CaloTopology* caloTopology,
112  TrackAssociatorParameters& parameters_,
113  int ieta,
114  int iphi,
115  const std::string& theTrackQuality,
116  bool debug) {
119 
120  std::vector<DetId> vdets = spr::matrixECALIds(coreDet, ieta, iphi, geo, caloTopology, debug);
121 #ifdef EDM_ML_DEBUG
122  if (debug)
123  std::cout << "chargeIsolation:: eta/phi/dets " << ieta << " " << iphi << " " << vdets.size() << std::endl;
124 #endif
125  double maxNearP = -1.0;
126  reco::TrackBase::TrackQuality trackQuality_ = reco::TrackBase::qualityByName(theTrackQuality);
127 
128  // const DetId anyCell,
129  reco::TrackCollection::const_iterator trkItr2;
130  for (trkItr2 = trkCollection->begin(); trkItr2 != trkCollection->end(); ++trkItr2) {
131  const reco::Track* pTrack2 = &(*trkItr2);
132 
133  bool trkQuality = pTrack2->quality(trackQuality_);
134  if ((trkItr2 != trkItr) && trkQuality) {
135  const FreeTrajectoryState fts2 =
136  associator.getFreeTrajectoryState(&iSetup.getData(parameters_.bFieldToken), *pTrack2);
137  TrackDetMatchInfo info2 = associator.associate(iEvent, iSetup, fts2, parameters_);
138  const GlobalPoint point2(info2.trkGlobPosAtEcal.x(), info2.trkGlobPosAtEcal.y(), info2.trkGlobPosAtEcal.z());
139 
140  if (info2.isGoodEcal) {
141  if (std::abs(point2.eta()) < spr::etaBEEcal) {
142  const DetId anyCell = barrelGeom->getClosestCell(point2);
143 #ifdef EDM_ML_DEBUG
144  if (debug)
145  std::cout << "chargeIsolation:: EB cell " << (EBDetId)(anyCell) << " for pt " << pTrack2->p()
146  << std::endl;
147 #endif
148  if (!spr::chargeIsolation(anyCell, vdets)) {
149  if (maxNearP < pTrack2->p())
150  maxNearP = pTrack2->p();
151  }
152  } else {
153  const DetId anyCell = endcapGeom->getClosestCell(point2);
154 #ifdef EDM_ML_DEBUG
155  if (debug)
156  std::cout << "chargeIsolation:: EE cell " << (EEDetId)(anyCell) << " for pt " << pTrack2->p()
157  << std::endl;
158 #endif
159  if (!spr::chargeIsolation(anyCell, vdets)) {
160  if (maxNearP < pTrack2->p())
161  maxNearP = pTrack2->p();
162  }
163  }
164  } //info2.isGoodEcal
165  }
166  }
167  return maxNearP;
168  }
169 
170  //===========================================================================================================
171 
173  const edm::EventSetup& iSetup,
174  reco::TrackCollection::const_iterator trkItr,
176  const DetId ClosestCell,
177  const HcalTopology* topology,
178  const CaloSubdetectorGeometry* gHB,
180  TrackAssociatorParameters& parameters_,
181  int ieta,
182  int iphi,
183  const std::string& theTrackQuality,
184  bool debug) {
185  std::vector<DetId> dets(1, ClosestCell);
186 
187 #ifdef EDM_ML_DEBUG
188  if (debug)
189  std::cout << (HcalDetId)ClosestCell << std::endl;
190 #endif
191  std::vector<DetId> vdets = spr::matrixHCALIds(dets, topology, ieta, iphi, false, debug);
192 
193 #ifdef EDM_ML_DEBUG
194  if (debug) {
195  for (unsigned int i = 0; i < vdets.size(); i++) {
196  std::cout << "HcalDetId in " << 2 * ieta + 1 << "x" << 2 * iphi + 1 << " " << (HcalDetId)vdets[i] << std::endl;
197  }
198  }
199 #endif
200  double maxNearP = -1.0;
201  reco::TrackBase::TrackQuality trackQuality_ = reco::TrackBase::qualityByName(theTrackQuality);
202 
203  reco::TrackCollection::const_iterator trkItr2;
204  for (trkItr2 = trkCollection->begin(); trkItr2 != trkCollection->end(); ++trkItr2) {
205  const reco::Track* pTrack2 = &(*trkItr2);
206 
207  bool trkQuality = pTrack2->quality(trackQuality_);
208  if ((trkItr2 != trkItr) && trkQuality) {
209  const FreeTrajectoryState fts2 =
210  associator.getFreeTrajectoryState(&iSetup.getData(parameters_.bFieldToken), *pTrack2);
211  TrackDetMatchInfo info2 = associator.associate(iEvent, iSetup, fts2, parameters_);
212  const GlobalPoint point2(info2.trkGlobPosAtHcal.x(), info2.trkGlobPosAtHcal.y(), info2.trkGlobPosAtHcal.z());
213 
214 #ifdef EDM_ML_DEBUG
215  if (debug) {
216  std::cout << "Track2 (p,eta,phi) " << pTrack2->p() << " " << pTrack2->eta() << " " << pTrack2->phi()
217  << std::endl;
218  }
219 #endif
220  if (info2.isGoodHcal) {
221  const DetId anyCell = gHB->getClosestCell(point2);
222 #ifdef EDM_ML_DEBUG
223  if (debug)
224  std::cout << "chargeIsolation:: HCAL cell " << (HcalDetId)(anyCell) << " for pt " << pTrack2->p()
225  << std::endl;
226 #endif
227  if (!spr::chargeIsolation(anyCell, vdets)) {
228  if (maxNearP < pTrack2->p())
229  maxNearP = pTrack2->p();
230  }
231 #ifdef EDM_ML_DEBUG
232  if (debug) {
233  std::cout << "maxNearP " << maxNearP << " thisCell " << (HcalDetId)anyCell << " ("
234  << info2.trkGlobPosAtHcal.x() << "," << info2.trkGlobPosAtHcal.y() << ","
235  << info2.trkGlobPosAtHcal.z() << ")" << std::endl;
236  }
237 #endif
238  }
239  }
240  }
241  return maxNearP;
242  }
243 
244 } // namespace spr
LCToCPAssociation_cfi.associator
associator
Definition: LCToCPAssociation_cfi.py:4
ChargeIsolationExtra.h
mps_fire.i
i
Definition: mps_fire.py:428
FreeTrajectoryState.h
spr
Definition: CaloConstants.h:6
reco::TrackBase::p
double p() const
momentum vector magnitude
Definition: TrackBase.h:631
HLT_FULL_cff.navigator
navigator
Definition: HLT_FULL_cff.py:13126
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:39
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:47
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
ChargeIsolation.h
reco::Track
Definition: Track.h:27
MatrixECALDetIds.h
spr::etaBEEcal
static const double etaBEEcal
Definition: CaloConstants.h:12
Point3DBase< float, GlobalTag >
reco::TrackBase::phi
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:649
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:44
reco::TrackBase::eta
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:652
HcalDetId
Definition: HcalDetId.h:12
iEvent
int iEvent
Definition: GenABIO.cc:224
PVValHelper::dy
Definition: PVValidationHelpers.h:50
edm::EventSetup
Definition: EventSetup.h:58
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:38
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
reco::TrackBase::qualityByName
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:126
TrackDetMatchInfo
Definition: TrackDetMatchInfo.h:13
CaloNavigator
Definition: CaloNavigator.h:7
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
CaloPropagateTrack.h
FindDistCone.h
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
TrackAssociatorParameters::bFieldToken
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > bFieldToken
Definition: TrackAssociatorParameters.h:130
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TrackDetMatchInfo::isGoodEcal
bool isGoodEcal
Definition: TrackDetMatchInfo.h:46
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_ML_DEBUG
#define EDM_ML_DEBUG
Definition: AnalyzerMinbias.cc:56
edm::Event
Definition: Event.h:73
reco::TrackBase::quality
bool quality(const TrackQuality) const
Track quality.
Definition: TrackBase.h:552
PVValHelper::dx
Definition: PVValidationHelpers.h:49
TrackAssociatorParameters
Definition: TrackAssociatorParameters.h:43