CMS 3D CMS Logo

GenSimInfo.cc
Go to the documentation of this file.
6 
7 #include <iostream>
8 
9 //#define EDM_ML_DEBUG
10 
11 namespace spr {
12 
13  void eGenSimInfo(const DetId& coreDet,
14  HepMC::GenEvent::particle_const_iterator trkItr,
15  std::vector<spr::propagatedGenTrackID>& trackIds,
16  const CaloGeometry* geo,
17  const CaloTopology* caloTopology,
18  int ieta,
19  int iphi,
21  bool debug) {
22 #ifdef EDM_ML_DEBUG
23  if (debug)
24  std::cout << "eGenSimInfo:: For track " << (*trkItr)->momentum().rho() << "/" << (*trkItr)->momentum().eta()
25  << "/" << (*trkItr)->momentum().phi() << " with ieta:iphi " << ieta << ":" << iphi << std::endl;
26 #endif
27  std::vector<DetId> vdets = spr::matrixECALIds(coreDet, ieta, iphi, geo, caloTopology, false);
28 #ifdef EDM_ML_DEBUG
29  if (debug)
30  spr::debugEcalDets(0, vdets);
31 #endif
32  spr::cGenSimInfo(vdets, trkItr, trackIds, true, info, debug);
33  }
34 
35  void eGenSimInfo(const DetId& coreDet,
36  HepMC::GenEvent::particle_const_iterator trkItr,
37  std::vector<spr::propagatedGenTrackID>& trackIds,
38  const CaloGeometry* geo,
39  const CaloTopology* caloTopology,
40  double dR,
41  const GlobalVector& trackMom,
43  bool debug) {
44 #ifdef EDM_ML_DEBUG
45  if (debug)
46  std::cout << "eGenSimInfo:: For track " << (*trkItr)->momentum().rho() << "/" << (*trkItr)->momentum().eta()
47  << "/" << (*trkItr)->momentum().phi() << " with dR,tMom " << dR << " " << trackMom << std::endl;
48 #endif
49  std::vector<DetId> vdets = spr::matrixECALIds(coreDet, dR, trackMom, geo, caloTopology, false);
50 #ifdef EDM_ML_DEBUG
51  if (debug)
52  spr::debugEcalDets(0, vdets);
53 #endif
54  spr::cGenSimInfo(vdets, trkItr, trackIds, true, info, debug);
55  }
56 
57  void eGenSimInfo(const DetId& coreDet,
58  reco::GenParticleCollection::const_iterator trkItr,
59  std::vector<spr::propagatedGenParticleID>& trackIds,
60  const CaloGeometry* geo,
61  const CaloTopology* caloTopology,
62  int ieta,
63  int iphi,
65  bool debug) {
66 #ifdef EDM_ML_DEBUG
67  if (debug)
68  std::cout << "eGenSimInfo:: For track " << trkItr->momentum().R() << "/" << trkItr->momentum().eta() << "/"
69  << trkItr->momentum().phi() << " with ieta:iphi " << ieta << ":" << iphi << std::endl;
70 #endif
71  std::vector<DetId> vdets = spr::matrixECALIds(coreDet, ieta, iphi, geo, caloTopology, false);
72 #ifdef EDM_ML_DEBUG
73  if (debug)
74  spr::debugEcalDets(0, vdets);
75 #endif
76  spr::cGenSimInfo(vdets, trkItr, trackIds, true, info, debug);
77  }
78 
79  void eGenSimInfo(const DetId& coreDet,
80  reco::GenParticleCollection::const_iterator trkItr,
81  std::vector<spr::propagatedGenParticleID>& trackIds,
82  const CaloGeometry* geo,
83  const CaloTopology* caloTopology,
84  double dR,
85  const GlobalVector& trackMom,
87  bool debug) {
88 #ifdef EDM_ML_DEBUG
89  if (debug)
90  std::cout << "eGenSimInfo:: For track " << trkItr->momentum().R() << "/" << trkItr->momentum().eta() << "/"
91  << trkItr->momentum().phi() << " with dR,tMom " << dR << " " << trackMom << std::endl;
92 #endif
93  std::vector<DetId> vdets = spr::matrixECALIds(coreDet, dR, trackMom, geo, caloTopology, false);
94 #ifdef EDM_ML_DEBUG
95  if (debug)
96  spr::debugEcalDets(0, vdets);
97 #endif
98  spr::cGenSimInfo(vdets, trkItr, trackIds, true, info, debug);
99  }
100 
101  void hGenSimInfo(const DetId& coreDet,
102  HepMC::GenEvent::particle_const_iterator trkItr,
103  std::vector<spr::propagatedGenTrackID>& trackIds,
104  const HcalTopology* topology,
105  int ieta,
106  int iphi,
107  genSimInfo& info,
108  bool includeHO,
109  bool debug) {
110 #ifdef EDM_ML_DEBUG
111  if (debug)
112  std::cout << "hGenSimInfo:: For track " << (*trkItr)->momentum().rho() << "/" << (*trkItr)->momentum().eta()
113  << "/" << (*trkItr)->momentum().phi() << " with ieta:iphi " << ieta << ":" << iphi << std::endl;
114 #endif
115  std::vector<DetId> dets;
116  dets.push_back(coreDet);
117  std::vector<DetId> vdets = spr::matrixHCALIds(dets, topology, ieta, iphi, includeHO, false);
118 #ifdef EDM_ML_DEBUG
119  if (debug)
120  spr::debugHcalDets(0, vdets);
121 #endif
122  spr::cGenSimInfo(vdets, trkItr, trackIds, false, info, debug);
123  }
124 
125  void hGenSimInfo(const DetId& coreDet,
126  HepMC::GenEvent::particle_const_iterator trkItr,
127  std::vector<spr::propagatedGenTrackID>& trackIds,
128  const CaloGeometry* geo,
129  const HcalTopology* topology,
130  double dR,
131  const GlobalVector& trackMom,
133  bool includeHO,
134  bool debug) {
135 #ifdef EDM_ML_DEBUG
136  if (debug)
137  std::cout << "hGenSimInfo:: For track " << (*trkItr)->momentum().rho() << "/" << (*trkItr)->momentum().eta()
138  << "/" << (*trkItr)->momentum().phi() << " with dR,tMom " << dR << " " << trackMom << std::endl;
139 #endif
140  std::vector<DetId> vdets = spr::matrixHCALIds(coreDet, geo, topology, dR, trackMom, includeHO, false);
141 #ifdef EDM_ML_DEBUG
142  if (debug)
143  spr::debugHcalDets(0, vdets);
144 #endif
145  spr::cGenSimInfo(vdets, trkItr, trackIds, false, info, debug);
146  }
147 
148  void hGenSimInfo(const DetId& coreDet,
149  reco::GenParticleCollection::const_iterator trkItr,
150  std::vector<spr::propagatedGenParticleID>& trackIds,
151  const HcalTopology* topology,
152  int ieta,
153  int iphi,
154  genSimInfo& info,
155  bool includeHO,
156  bool debug) {
157 #ifdef EDM_ML_DEBUG
158  if (debug)
159  std::cout << "hGenSimInfo:: For track " << trkItr->momentum().R() << "/" << trkItr->momentum().eta() << "/"
160  << trkItr->momentum().phi() << " with ieta:iphi " << ieta << ":" << iphi << std::endl;
161 #endif
162  std::vector<DetId> dets;
163  dets.push_back(coreDet);
164  std::vector<DetId> vdets = spr::matrixHCALIds(dets, topology, ieta, iphi, includeHO, false);
165 #ifdef EDM_ML_DEBUG
166  if (debug)
167  spr::debugHcalDets(0, vdets);
168 #endif
169  spr::cGenSimInfo(vdets, trkItr, trackIds, false, info, debug);
170  }
171 
172  void hGenSimInfo(const DetId& coreDet,
173  reco::GenParticleCollection::const_iterator trkItr,
174  std::vector<spr::propagatedGenParticleID>& trackIds,
175  const CaloGeometry* geo,
176  const HcalTopology* topology,
177  double dR,
178  const GlobalVector& trackMom,
180  bool includeHO,
181  bool debug) {
182 #ifdef EDM_ML_DEBUG
183  if (debug)
184  std::cout << "hGenSimInfo:: For track " << trkItr->momentum().R() << "/" << trkItr->momentum().eta() << "/"
185  << trkItr->momentum().phi() << " with dR,tMom " << dR << " " << trackMom << std::endl;
186 #endif
187  std::vector<DetId> vdets = spr::matrixHCALIds(coreDet, geo, topology, dR, trackMom, includeHO, false);
188 #ifdef EDM_ML_DEBUG
189  if (debug)
190  spr::debugHcalDets(0, vdets);
191 #endif
192  spr::cGenSimInfo(vdets, trkItr, trackIds, false, info, debug);
193  }
194 
195  void cGenSimInfo(std::vector<DetId>& vdets,
196  HepMC::GenEvent::particle_const_iterator trkItr,
197  std::vector<spr::propagatedGenTrackID>& trackIds,
198  bool ifECAL,
200  bool debug) {
201  info.maxNearP = -1.0;
202  info.cHadronEne = info.nHadronEne = info.eleEne = info.muEne = info.photonEne = 0.0;
203  info.isChargedIso = true;
204  for (int i = 0; i < 3; ++i)
205  info.cHadronEne_[i] = 0.0;
206  for (unsigned int i = 0; i < trackIds.size(); ++i) {
207  HepMC::GenEvent::particle_const_iterator trkItr2 = trackIds[i].trkItr;
208  // avoid the track under consideration
209  if ((trkItr2 != trkItr) && trackIds[i].ok) {
210  int charge = trackIds[i].charge;
211  int pdgid = trackIds[i].pdgId;
212  double p = (*trkItr2)->momentum().rho();
213  bool isolat = false;
214  if (ifECAL) {
215  const DetId anyCell = trackIds[i].detIdECAL;
216  isolat = spr::chargeIsolation(anyCell, vdets);
217  } else {
218  const DetId anyCell = trackIds[i].detIdHCAL;
219  isolat = spr::chargeIsolation(anyCell, vdets);
220  }
221  if (!isolat)
223  }
224  }
225 #ifdef EDM_ML_DEBUG
226  if (debug) {
227  std::cout << "Isolation variables: isChargedIso :" << info.isChargedIso << " maxNearP " << info.maxNearP
228  << " Energy e/mu/g/ch/nh " << info.eleEne << "," << info.muEne << "," << info.photonEne << ","
229  << info.cHadronEne << "," << info.nHadronEne << " charge " << info.cHadronEne_[0] << ","
230  << info.cHadronEne_[1] << "," << info.cHadronEne_[2] << std::endl;
231  }
232 #endif
233  }
234 
235  void cGenSimInfo(std::vector<DetId>& vdets,
236  reco::GenParticleCollection::const_iterator trkItr,
237  std::vector<spr::propagatedGenParticleID>& trackIds,
238  bool ifECAL,
240  bool debug) {
241  info.maxNearP = -1.0;
242  info.cHadronEne = info.nHadronEne = info.eleEne = info.muEne = info.photonEne = 0.0;
243  info.isChargedIso = true;
244  for (int i = 0; i < 3; ++i)
245  info.cHadronEne_[i] = 0.0;
246  for (unsigned int i = 0; i < trackIds.size(); ++i) {
247  reco::GenParticleCollection::const_iterator trkItr2 = trackIds[i].trkItr;
248  // avoid the track under consideration
249  if ((trkItr2 != trkItr) && trackIds[i].ok) {
250  int charge = trackIds[i].charge;
251  int pdgid = trackIds[i].pdgId;
252  double p = trkItr2->momentum().R();
253  bool isolat = false;
254  if (ifECAL) {
255  const DetId anyCell = trackIds[i].detIdECAL;
256  isolat = spr::chargeIsolation(anyCell, vdets);
257  } else {
258  const DetId anyCell = trackIds[i].detIdHCAL;
259  isolat = spr::chargeIsolation(anyCell, vdets);
260  }
261  if (!isolat)
263  }
264  }
265 
266 #ifdef EDM_ML_DEBUG
267  if (debug) {
268  std::cout << "Isolation variables: isChargedIso :" << info.isChargedIso << " maxNearP " << info.maxNearP
269  << " Energy e/mu/g/ch/nh " << info.eleEne << "," << info.muEne << "," << info.photonEne << ","
270  << info.cHadronEne << "," << info.nHadronEne << " charge " << info.cHadronEne_[0] << ","
271  << info.cHadronEne_[1] << "," << info.cHadronEne_[2] << std::endl;
272  }
273 #endif
274  }
275 
276  void cGenSimInfo(int charge, int pdgid, double p, spr::genSimInfo& info, bool) {
277  if (pdgid == 22)
278  info.photonEne += p;
279  else if (pdgid == 11)
280  info.eleEne += p;
281  else if (pdgid == 13)
282  info.muEne += p;
283  else if (std::abs(charge) > 0) {
284  info.isChargedIso = false;
285  info.cHadronEne += p;
286  if (p > 1.0)
287  info.cHadronEne_[0] += p;
288  if (p > 2.0)
289  info.cHadronEne_[1] += p;
290  if (p > 3.0)
291  info.cHadronEne_[2] += p;
292  if (info.maxNearP < p)
293  info.maxNearP = p;
294  } else if (std::abs(charge) == 0) {
295  info.nHadronEne += p;
296  }
297  }
298 } // namespace spr
Vector3DBase
Definition: Vector3DBase.h:8
mps_fire.i
i
Definition: mps_fire.py:428
spr
Definition: CaloConstants.h:6
GenSimInfo.h
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HcalTopology
Definition: HcalTopology.h:26
DebugInfo.h
spr::debugEcalDets
void debugEcalDets(unsigned int, const DetId &, bool)
Definition: DebugInfo.cc:11
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
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
CaloTopology
Definition: CaloTopology.h:19
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
ChargeIsolation.h
MatrixECALDetIds.h
spr::hGenSimInfo
void hGenSimInfo(const DetId &coreDet, HepMC::GenEvent::particle_const_iterator trkItr, std::vector< spr::propagatedGenTrackID > &trackIds, const HcalTopology *topology, int ieta, int iphi, spr::genSimInfo &info, bool includeHO=false, bool debug=false)
Definition: GenSimInfo.cc:101
MatrixHCALDetIds.h
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
spr::chargeIsolation
bool chargeIsolation(const DetId anyCell, std::vector< DetId > &vdets)
Definition: ChargeIsolation.cc:213
spr::eGenSimInfo
void eGenSimInfo(const DetId &coreDet, HepMC::GenEvent::particle_const_iterator trkItr, std::vector< spr::propagatedGenTrackID > &trackIds, const CaloGeometry *geo, const CaloTopology *caloTopology, int ieta, int iphi, spr::genSimInfo &info, bool debug=false)
Definition: GenSimInfo.cc:13
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
spr::cGenSimInfo
void cGenSimInfo(std::vector< DetId > &vdets, HepMC::GenEvent::particle_const_iterator trkItr, std::vector< spr::propagatedGenTrackID > &trackIds, bool ifECAL, spr::genSimInfo &info, bool debug=false)
Definition: GenSimInfo.cc:195
spr::genSimInfo
Definition: GenSimInfo.h:37
cms::cuda::for
for(int i=first, nt=offsets[nh];i< nt;i+=gridDim.x *blockDim.x)
Definition: HistoContainer.h:15
spr::debugHcalDets
void debugHcalDets(unsigned int, std::vector< DetId > &)
Definition: DebugInfo.cc:39
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HGC3DClusterGenMatchSelector_cfi.dR
dR
Definition: HGC3DClusterGenMatchSelector_cfi.py:7
EgammaValidation_cff.pdgid
pdgid
Definition: EgammaValidation_cff.py:29