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, HepMC::GenEvent::particle_const_iterator trkItr, std::vector<spr::propagatedGenTrackID>& trackIds, const CaloGeometry* geo, const CaloTopology* caloTopology, int ieta, int iphi, genSimInfo & info, bool debug) {
14 
15 #ifdef EDM_ML_DEBUG
16  if (debug) std::cout << "eGenSimInfo:: For track " << (*trkItr)->momentum().rho() << "/" << (*trkItr)->momentum().eta() << "/" << (*trkItr)->momentum().phi() << " with ieta:iphi " << ieta << ":" << iphi << std::endl;
17 #endif
18  std::vector<DetId> vdets = spr::matrixECALIds(coreDet, ieta, iphi, geo, caloTopology, false);
19 #ifdef EDM_ML_DEBUG
20  if (debug) spr::debugEcalDets(0, vdets);
21 #endif
22  spr::cGenSimInfo(vdets, trkItr, trackIds, true, info, debug);
23  }
24 
25  void eGenSimInfo(const DetId& coreDet, HepMC::GenEvent::particle_const_iterator trkItr, std::vector<spr::propagatedGenTrackID>& trackIds, const CaloGeometry* geo, const CaloTopology* caloTopology, double dR, const GlobalVector& trackMom, spr::genSimInfo & info, bool debug) {
26 
27 #ifdef EDM_ML_DEBUG
28  if (debug) std::cout << "eGenSimInfo:: For track " << (*trkItr)->momentum().rho() << "/" << (*trkItr)->momentum().eta() << "/" << (*trkItr)->momentum().phi() << " with dR,tMom " << dR << " " << trackMom << std::endl;
29 #endif
30  std::vector<DetId> vdets = spr::matrixECALIds(coreDet, dR, trackMom, geo, caloTopology, false);
31 #ifdef EDM_ML_DEBUG
32  if (debug) spr::debugEcalDets(0, vdets);
33 #endif
34  spr::cGenSimInfo(vdets, trkItr, trackIds, true, info, debug);
35  }
36 
37  void eGenSimInfo(const DetId& coreDet, reco::GenParticleCollection::const_iterator trkItr, std::vector<spr::propagatedGenParticleID>& trackIds, const CaloGeometry* geo, const CaloTopology* caloTopology, int ieta, int iphi, genSimInfo & info, bool debug) {
38 
39 #ifdef EDM_ML_DEBUG
40  if (debug) std::cout << "eGenSimInfo:: For track " << trkItr->momentum().R() << "/" << trkItr->momentum().eta() << "/" << trkItr->momentum().phi() << " with ieta:iphi " << ieta << ":" << iphi << std::endl;
41 #endif
42  std::vector<DetId> vdets = spr::matrixECALIds(coreDet, ieta, iphi, geo, caloTopology, false);
43 #ifdef EDM_ML_DEBUG
44  if (debug) spr::debugEcalDets(0, vdets);
45 #endif
46  spr::cGenSimInfo(vdets, trkItr, trackIds, true, info, debug);
47  }
48 
49  void eGenSimInfo(const DetId& coreDet, reco::GenParticleCollection::const_iterator trkItr, std::vector<spr::propagatedGenParticleID>& trackIds, const CaloGeometry* geo, const CaloTopology* caloTopology, double dR, const GlobalVector& trackMom, spr::genSimInfo & info, bool debug) {
50 
51 #ifdef EDM_ML_DEBUG
52  if (debug) std::cout << "eGenSimInfo:: For track " << trkItr->momentum().R() << "/" << trkItr->momentum().eta() << "/" << trkItr->momentum().phi() << " with dR,tMom " << dR << " " << trackMom << std::endl;
53 #endif
54  std::vector<DetId> vdets = spr::matrixECALIds(coreDet, dR, trackMom, geo, caloTopology, false);
55 #ifdef EDM_ML_DEBUG
56  if (debug) spr::debugEcalDets(0, vdets);
57 #endif
58  spr::cGenSimInfo(vdets, trkItr, trackIds, true, info, debug);
59  }
60 
61  void hGenSimInfo(const DetId& coreDet, HepMC::GenEvent::particle_const_iterator trkItr, std::vector<spr::propagatedGenTrackID>& trackIds, const HcalTopology* topology, int ieta, int iphi, genSimInfo & info, bool includeHO, bool debug) {
62 
63 #ifdef EDM_ML_DEBUG
64  if (debug) std::cout << "hGenSimInfo:: For track " << (*trkItr)->momentum().rho() << "/" << (*trkItr)->momentum().eta() << "/" << (*trkItr)->momentum().phi() << " with ieta:iphi " << ieta << ":" << iphi << std::endl;
65 #endif
66  std::vector<DetId> dets;
67  dets.push_back(coreDet);
68  std::vector<DetId> vdets = spr::matrixHCALIds(dets, topology, ieta, iphi, includeHO, false);
69 #ifdef EDM_ML_DEBUG
70  if (debug) spr::debugHcalDets(0, vdets);
71 #endif
72  spr::cGenSimInfo(vdets, trkItr, trackIds, false, info, debug);
73  }
74 
75  void hGenSimInfo(const DetId& coreDet, HepMC::GenEvent::particle_const_iterator trkItr, std::vector<spr::propagatedGenTrackID>& trackIds, const CaloGeometry* geo, const HcalTopology* topology, double dR, const GlobalVector& trackMom, spr::genSimInfo & info, bool includeHO, bool debug) {
76 
77 #ifdef EDM_ML_DEBUG
78  if (debug) std::cout << "hGenSimInfo:: For track " << (*trkItr)->momentum().rho() << "/" << (*trkItr)->momentum().eta() << "/" << (*trkItr)->momentum().phi() << " with dR,tMom " << dR << " " << trackMom << std::endl;
79 #endif
80  std::vector<DetId> vdets = spr::matrixHCALIds(coreDet, geo, topology, dR, trackMom, includeHO, false);
81 #ifdef EDM_ML_DEBUG
82  if (debug) spr::debugHcalDets(0, vdets);
83 #endif
84  spr::cGenSimInfo(vdets, trkItr, trackIds, false, info, debug);
85  }
86 
87  void hGenSimInfo(const DetId& coreDet, reco::GenParticleCollection::const_iterator trkItr, std::vector<spr::propagatedGenParticleID>& trackIds, const HcalTopology* topology, int ieta, int iphi, genSimInfo & info, bool includeHO, bool debug) {
88 
89 #ifdef EDM_ML_DEBUG
90  if (debug) std::cout << "hGenSimInfo:: For track " << trkItr->momentum().R() << "/" << trkItr->momentum().eta() << "/" << trkItr->momentum().phi() << " with ieta:iphi " << ieta << ":" << iphi << std::endl;
91 #endif
92  std::vector<DetId> dets;
93  dets.push_back(coreDet);
94  std::vector<DetId> vdets = spr::matrixHCALIds(dets, topology, ieta, iphi, includeHO, false);
95 #ifdef EDM_ML_DEBUG
96  if (debug) spr::debugHcalDets(0, vdets);
97 #endif
98  spr::cGenSimInfo(vdets, trkItr, trackIds, false, info, debug);
99  }
100 
101  void hGenSimInfo(const DetId& coreDet, reco::GenParticleCollection::const_iterator trkItr, std::vector<spr::propagatedGenParticleID>& trackIds, const CaloGeometry* geo, const HcalTopology* topology, double dR, const GlobalVector& trackMom, spr::genSimInfo & info, bool includeHO, bool debug) {
102 
103 #ifdef EDM_ML_DEBUG
104  if (debug) std::cout << "hGenSimInfo:: For track " << trkItr->momentum().R() << "/" << trkItr->momentum().eta() << "/" << trkItr->momentum().phi() << " with dR,tMom " << dR << " " << trackMom << std::endl;
105 #endif
106  std::vector<DetId> vdets = spr::matrixHCALIds(coreDet, geo, topology, dR, trackMom, includeHO, false);
107 #ifdef EDM_ML_DEBUG
108  if (debug) spr::debugHcalDets(0, vdets);
109 #endif
110  spr::cGenSimInfo(vdets, trkItr, trackIds, false, info, debug);
111  }
112 
113  void cGenSimInfo(std::vector<DetId>& vdets, HepMC::GenEvent::particle_const_iterator trkItr, std::vector<spr::propagatedGenTrackID>& trackIds, bool ifECAL, spr::genSimInfo & info, bool debug) {
114 
115  info.maxNearP=-1.0;
116  info.cHadronEne=info.nHadronEne=info.eleEne=info.muEne=info.photonEne=0.0;
117  info.isChargedIso=true;
118  for (int i=0; i<3; ++i) info.cHadronEne_[i]=0.0;
119  for (unsigned int i=0; i<trackIds.size(); ++i) {
120  HepMC::GenEvent::particle_const_iterator trkItr2 = trackIds[i].trkItr;
121  // avoid the track under consideration
122  if ( (trkItr2 != trkItr) && trackIds[i].ok) {
123  int charge = trackIds[i].charge;
124  int pdgid = trackIds[i].pdgId;
125  double p = (*trkItr2)->momentum().rho();
126  bool isolat= false;
127  if (ifECAL) {
128  const DetId anyCell = trackIds[i].detIdECAL;
129  isolat = spr::chargeIsolation(anyCell,vdets);
130  } else {
131  const DetId anyCell = trackIds[i].detIdHCAL;
132  isolat = spr::chargeIsolation(anyCell,vdets);
133  }
134  if (!isolat) spr::cGenSimInfo(charge, pdgid, p, info, debug);
135  }
136  }
137 #ifdef EDM_ML_DEBUG
138  if (debug) {
139  std::cout << "Isolation variables: isChargedIso :" << info.isChargedIso
140  << " maxNearP " << info.maxNearP << " Energy e/mu/g/ch/nh "
141  << info.eleEne << "," << info.muEne << "," << info.photonEne
142  << "," << info.cHadronEne << "," << info.nHadronEne
143  << " charge " << info.cHadronEne_[0] << ","
144  << info.cHadronEne_[1] << "," << info.cHadronEne_[2]
145  << std::endl;
146  }
147 #endif
148  }
149 
150  void cGenSimInfo(std::vector<DetId>& vdets, reco::GenParticleCollection::const_iterator trkItr, std::vector<spr::propagatedGenParticleID>& trackIds, bool ifECAL, spr::genSimInfo & info, bool debug) {
151 
152  info.maxNearP=-1.0;
153  info.cHadronEne=info.nHadronEne=info.eleEne=info.muEne=info.photonEne=0.0;
154  info.isChargedIso=true;
155  for (int i=0; i<3; ++i) info.cHadronEne_[i]=0.0;
156  for (unsigned int i=0; i<trackIds.size(); ++i) {
157  reco::GenParticleCollection::const_iterator trkItr2 = trackIds[i].trkItr;
158  // avoid the track under consideration
159  if ( (trkItr2 != trkItr) && trackIds[i].ok) {
160  int charge = trackIds[i].charge;
161  int pdgid = trackIds[i].pdgId;
162  double p = trkItr2->momentum().R();
163  bool isolat= false;
164  if (ifECAL) {
165  const DetId anyCell = trackIds[i].detIdECAL;
166  isolat = spr::chargeIsolation(anyCell,vdets);
167  } else {
168  const DetId anyCell = trackIds[i].detIdHCAL;
169  isolat = spr::chargeIsolation(anyCell,vdets);
170  }
171  if (!isolat) spr::cGenSimInfo(charge, pdgid, p, info, debug);
172  }
173  }
174 
175 #ifdef EDM_ML_DEBUG
176  if (debug) {
177  std::cout << "Isolation variables: isChargedIso :" << info.isChargedIso
178  << " maxNearP " << info.maxNearP << " Energy e/mu/g/ch/nh "
179  << info.eleEne << "," << info.muEne << "," << info.photonEne
180  << "," << info.cHadronEne << "," << info.nHadronEne
181  << " charge " << info.cHadronEne_[0] << ","
182  << info.cHadronEne_[1] << "," << info.cHadronEne_[2]
183  << std::endl;
184  }
185 #endif
186  }
187 
188  void cGenSimInfo(int charge, int pdgid, double p, spr::genSimInfo& info,
189  bool ) {
190 
191  if (pdgid==22 ) info.photonEne += p;
192  else if (pdgid==11) info.eleEne += p;
193  else if (pdgid==13) info.muEne += p;
194  else if (std::abs(charge)>0) {
195  info.isChargedIso = false;
196  info.cHadronEne += p;
197  if (p>1.0) info.cHadronEne_[0] += p;
198  if (p>2.0) info.cHadronEne_[1] += p;
199  if (p>3.0) info.cHadronEne_[2] += p;
200  if (info.maxNearP<p) info.maxNearP=p;
201  } else if (std::abs(charge)==0) {
202  info.nHadronEne += p;
203  }
204  }
205 }
static const TGPicture * info(bool iBackgroundIsBlack)
void debugEcalDets(unsigned int, const DetId &, bool)
Definition: DebugInfo.cc:11
double cHadronEne_[3]
Definition: GenSimInfo.h:47
double photonEne
Definition: GenSimInfo.h:45
CaloTopology const * topology(0)
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)
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:113
void debugHcalDets(unsigned int, std::vector< DetId > &)
Definition: DebugInfo.cc:42
double cHadronEne
Definition: GenSimInfo.h:45
double nHadronEne
Definition: GenSimInfo.h:45
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:13
Definition: DetId.h:18
#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:61
double maxNearP
Definition: GenSimInfo.h:44