CMS 3D CMS Logo

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