CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
Phase2L1GMT::Isolation Class Reference

#include <Isolation.h>

Inheritance diagram for Phase2L1GMT::Isolation:
Phase2L1GMT::TopoAlgo

Public Member Functions

unsigned compute_trk_iso (l1t::TrackerMuon &in_mu, ConvertedTTTrack &in_trk)
 
 Isolation (const edm::ParameterSet &iConfig)
 
 Isolation (const Isolation &cpy)
 
void isolation_allmu_alltrk (std::vector< l1t::TrackerMuon > &trkMus, std::vector< ConvertedTTTrack > &convertedTracks)
 
 ~Isolation ()
 
- Public Member Functions inherited from Phase2L1GMT::TopoAlgo
int deltaEta (const int eta1, const int eta2)
 
int deltaPhi (int phi1, int phi2)
 
int deltaZ0 (const int Z01, const int Z02)
 
void DumpInputs ()
 
void load (std::vector< l1t::TrackerMuon > &trkMus, std::vector< ConvertedTTTrack > &convertedTracks)
 
 TopoAlgo ()
 
 TopoAlgo (const TopoAlgo &cpy)
 
 ~TopoAlgo ()
 

Private Types

typedef ap_ufixed< 9, 9, AP_TRN, AP_SAT > iso_accum_t
 
typedef ap_ufixed< 9, 0 > reliso_thresh_t
 

Private Member Functions

void DumpOutputs (std::vector< l1t::TrackerMuon > &trkMus)
 
int OverlapRemoval (unsigned &ovrl, std::vector< unsigned > &overlaps)
 
int SetAbsIsolationBits (int accum)
 
int SetRelIsolationBits (int accum, int mupt)
 

Private Attributes

int absiso_thrL
 
int absiso_thrM
 
int absiso_thrT
 
bool dumpForHLS_
 
std::ofstream dumpOutput
 
double reliso_thrL
 
double reliso_thrM
 
double reliso_thrT
 
bool verbose_
 

Static Private Attributes

static const int c_iso_dangle_max = 260
 
static const int c_iso_dz_max = 17
 
static const int c_iso_pt_min = 120
 

Additional Inherited Members

- Protected Attributes inherited from Phase2L1GMT::TopoAlgo
std::vector< ConvertedTTTrack > * convertedTracks
 
std::ofstream dumpInput
 
std::vector< l1t::TrackerMuon > * trkMus
 

Detailed Description

Definition at line 24 of file Isolation.h.

Member Typedef Documentation

◆ iso_accum_t

typedef ap_ufixed<9, 9, AP_TRN, AP_SAT> Phase2L1GMT::Isolation::iso_accum_t
private

Definition at line 55 of file Isolation.h.

◆ reliso_thresh_t

typedef ap_ufixed<9, 0> Phase2L1GMT::Isolation::reliso_thresh_t
private

Definition at line 56 of file Isolation.h.

Constructor & Destructor Documentation

◆ Isolation() [1/2]

Phase2L1GMT::Isolation::Isolation ( const edm::ParameterSet iConfig)
inline

Definition at line 59 of file Isolation.h.

References dumpForHLS_, Phase2L1GMT::TopoAlgo::dumpInput, dumpOutput, and MillePedeFileConverter_cfg::out.

60  : absiso_thrL(iConfig.getParameter<int>("AbsIsoThresholdL")),
61  absiso_thrM(iConfig.getParameter<int>("AbsIsoThresholdM")),
62  absiso_thrT(iConfig.getParameter<int>("AbsIsoThresholdT")),
63  reliso_thrL(iConfig.getParameter<double>("RelIsoThresholdL")),
64  reliso_thrM(iConfig.getParameter<double>("RelIsoThresholdM")),
65  reliso_thrT(iConfig.getParameter<double>("RelIsoThresholdT")),
66  verbose_(iConfig.getParameter<int>("verbose")),
67  dumpForHLS_(iConfig.getParameter<int>("IsodumpForHLS")) {
68  dumpForHLS_ = true;
69  if (dumpForHLS_) {
70  dumpInput.open("Isolation_Mu_Track_infolist.txt", std::ofstream::out);
71  dumpOutput.open("Isolation_Mu_Isolation.txt", std::ofstream::out);
72  }
73  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::ofstream dumpOutput
Definition: Isolation.h:53

◆ ~Isolation()

Phase2L1GMT::Isolation::~Isolation ( )
inline

Definition at line 75 of file Isolation.h.

References dumpForHLS_, Phase2L1GMT::TopoAlgo::dumpInput, and dumpOutput.

75  {
76  if (dumpForHLS_) {
77  dumpInput.close();
78  dumpOutput.close();
79  }
80  }
std::ofstream dumpOutput
Definition: Isolation.h:53

◆ Isolation() [2/2]

Phase2L1GMT::Isolation::Isolation ( const Isolation cpy)
inline

Definition at line 82 of file Isolation.h.

Member Function Documentation

◆ compute_trk_iso()

unsigned Phase2L1GMT::Isolation::compute_trk_iso ( l1t::TrackerMuon in_mu,
ConvertedTTTrack in_trk 
)
inline

Definition at line 198 of file Isolation.h.

References c_iso_dangle_max, c_iso_dz_max, c_iso_pt_min, Phase2L1GMT::TopoAlgo::deltaEta(), Phase2L1GMT::TopoAlgo::deltaPhi(), Phase2L1GMT::TopoAlgo::deltaZ0(), Phase2L1GMT::ConvertedTTTrack::eta(), l1t::L1Candidate::hwEta(), l1t::L1Candidate::hwPhi(), l1t::L1Candidate::hwPt(), l1t::TrackerMuon::hwZ0(), Phase2L1GMT::ConvertedTTTrack::phi(), Phase2L1GMT::ConvertedTTTrack::pt(), funct::true, verbose_, and Phase2L1GMT::ConvertedTTTrack::z0().

Referenced by isolation_allmu_alltrk().

198  {
199  int dphi = deltaPhi(in_mu.hwPhi(), in_trk.phi());
200  int deta = deltaEta(in_mu.hwEta(), in_trk.eta());
201  int dz0 = deltaZ0(in_mu.hwZ0(), in_trk.z0());
202 
203  bool pass_deta = (deta < c_iso_dangle_max ? true : false);
204  bool pass_dphi = (dphi < c_iso_dangle_max ? true : false);
205  bool pass_dz0 = (dz0 < c_iso_dz_max ? true : false);
206  bool pass_trkpt = (in_trk.pt() >= c_iso_pt_min ? true : false);
207  bool pass_ovrl = (deta > 0 || dphi > 0 ? true : false);
208 
209  if (verbose_) {
210  edm::LogInfo("Isolation") << " [DEBUG compute_trk_iso] : Start of debug msg for compute_trk_iso";
211  edm::LogInfo("Isolation") << " [DEBUG compute_trk_iso] : incoming muon (pt / eta / phi / z0 / isvalid)";
212  edm::LogInfo("Isolation") << " [DEBUG compute_trk_iso] : MU = " << in_mu.hwPt() << " / " << in_mu.hwEta()
213  << " / " << in_mu.hwPhi() << " / " << in_mu.hwZ0() << " / " << 1;
214  edm::LogInfo("Isolation") << " [DEBUG compute_trk_iso] : incoming track (pt / eta / phi / z0 / isvalid)";
215  edm::LogInfo("Isolation") << " [DEBUG compute_trk_iso] : TRK = " << in_trk.pt() << " / " << in_trk.eta() << " / "
216  << in_trk.phi() << " / " << in_trk.z0() << " / " << 1;
217  edm::LogInfo("Isolation") << " [DEBUG compute_trk_iso] : Delta phi : " << dphi;
218  edm::LogInfo("Isolation") << " [DEBUG compute_trk_iso] : Delta eta : " << deta;
219  edm::LogInfo("Isolation") << " [DEBUG compute_trk_iso] : Delta z0 : " << dz0;
220  edm::LogInfo("Isolation") << " [DEBUG compute_trk_iso] : pass_deta : " << pass_deta;
221  edm::LogInfo("Isolation") << " [DEBUG compute_trk_iso] : pass_dphi : " << pass_dphi;
222  edm::LogInfo("Isolation") << " [DEBUG compute_trk_iso] : pass_dz0 : " << pass_dz0;
223  edm::LogInfo("Isolation") << " [DEBUG compute_trk_iso] : pass_trkpt : " << pass_trkpt;
224  edm::LogInfo("Isolation") << " [DEBUG compute_trk_iso] : pass_ovrl : " << pass_ovrl;
225  }
226  // match conditions
227  if (pass_deta && pass_dphi && pass_dz0 && pass_trkpt && pass_ovrl) {
228  if (verbose_) {
229  edm::LogInfo("Isolation") << " [DEBUG compute_trk_iso] : THE TRACK WAS MATCHED";
230  edm::LogInfo("Isolation") << " [DEBUG compute_trk_iso] : RETURN : " << in_trk.pt();
231  }
232 
233  //return in_trk.pt();
234  // Return fixed bit output for duplication removal.
235  // dZ0(8bis) + deta(10bits)+dphi(10bits)
236  unsigned int retbits = 0;
237  retbits |= (dz0 & ((1 << 9) - 1)) << 20;
238  retbits |= (deta & ((1 << 11) - 1)) << 10;
239  retbits |= (dphi & ((1 << 11) - 1));
240  return retbits;
241  } else {
242  return 0;
243  }
244  }
const int hwZ0() const
Definition: TrackerMuon.h:37
int hwPhi() const
Definition: L1Candidate.h:37
static const int c_iso_dz_max
Definition: Isolation.h:41
static const int c_iso_pt_min
Definition: Isolation.h:42
int deltaEta(const int eta1, const int eta2)
int hwEta() const
Definition: L1Candidate.h:36
Log< level::Info, false > LogInfo
int hwPt() const
Definition: L1Candidate.h:35
static const int c_iso_dangle_max
Definition: Isolation.h:40
int deltaZ0(const int Z01, const int Z02)
int deltaPhi(int phi1, int phi2)

◆ DumpOutputs()

void Phase2L1GMT::Isolation::DumpOutputs ( std::vector< l1t::TrackerMuon > &  trkMus)
inlineprivate

Definition at line 84 of file Isolation.h.

References dumpOutput, mps_fire::i, Phase2L1GMT::LSBeta, Phase2L1GMT::LSBGTz0, Phase2L1GMT::LSBphi, Phase2L1GMT::LSBpt, M_PI, amptDefaultParameters_cff::mu, and Phase2L1GMT::TopoAlgo::trkMus.

Referenced by isolation_allmu_alltrk().

84  {
85  static int nevto = 0;
86  for (unsigned int i = 0; i < trkMus.size(); ++i) {
87  auto mu = trkMus.at(i);
88  if (mu.hwPt() != 0) {
89  double convertphi = mu.hwPhi() * LSBphi;
90  if (convertphi > M_PI) {
91  convertphi -= 2 * M_PI;
92  }
93  dumpOutput << nevto << " " << i << " " << mu.hwPt() * LSBpt << " " << mu.hwEta() * LSBeta << " " << convertphi
94  << " " << mu.hwZ0() * LSBGTz0 << " " << mu.hwIso() << endl;
95  }
96  }
97  nevto++;
98  }
const float LSBphi
Definition: Constants.h:81
const float LSBGTz0
Definition: Constants.h:83
const float LSBpt
Definition: Constants.h:80
#define M_PI
const float LSBeta
Definition: Constants.h:82
std::ofstream dumpOutput
Definition: Isolation.h:53
std::vector< l1t::TrackerMuon > * trkMus

◆ isolation_allmu_alltrk()

void Phase2L1GMT::Isolation::isolation_allmu_alltrk ( std::vector< l1t::TrackerMuon > &  trkMus,
std::vector< ConvertedTTTrack > &  convertedTracks 
)
inline

Definition at line 139 of file Isolation.h.

References compute_trk_iso(), Phase2L1GMT::TopoAlgo::convertedTracks, dumpForHLS_, Phase2L1GMT::TopoAlgo::DumpInputs(), DumpOutputs(), Phase2L1GMT::TopoAlgo::load(), amptDefaultParameters_cff::mu, OverlapRemoval(), analyzePatCleaning_cfg::overlaps, SetAbsIsolationBits(), SetRelIsolationBits(), submitPVValidationJobs::t, groupFilesInBlocks::temp, Phase2L1GMT::TopoAlgo::trkMus, and verbose_.

140  {
142  if (dumpForHLS_) {
143  DumpInputs();
144  }
145 
146  static int itest = 0;
147  if (verbose_) {
148  edm::LogInfo("Isolation") << "........ RUNNING TEST NUMBER .......... " << itest++;
149  }
150 
151  for (auto &mu : trkMus) {
152  int accum = 0;
153  int iso_ = 0;
154  std::vector<unsigned> overlaps;
155  for (auto t : convertedTracks) {
156  unsigned ovrl = compute_trk_iso(mu, t);
157  if (ovrl != 0) {
158  accum += OverlapRemoval(ovrl, overlaps) * t.pt();
159  }
160  }
161 
162  // Only 8 bit for accumation?
163  mu.setHwIsoSum(accum);
164 
165  iso_accum_t temp(accum);
166  accum = temp.to_int();
167 
168  mu.setHwIsoSumAp(accum);
169 
170  iso_ |= SetAbsIsolationBits(accum);
171  iso_ |= SetRelIsolationBits(accum, mu.hwPt());
172 
173  mu.setHwIso(iso_);
174  }
175 
176  if (dumpForHLS_) {
178  }
179  }
int SetAbsIsolationBits(int accum)
Definition: Isolation.h:100
void DumpOutputs(std::vector< l1t::TrackerMuon > &trkMus)
Definition: Isolation.h:84
int SetRelIsolationBits(int accum, int mupt)
Definition: Isolation.h:115
std::vector< ConvertedTTTrack > * convertedTracks
Log< level::Info, false > LogInfo
ap_ufixed< 9, 9, AP_TRN, AP_SAT > iso_accum_t
Definition: Isolation.h:55
std::vector< l1t::TrackerMuon > * trkMus
unsigned compute_trk_iso(l1t::TrackerMuon &in_mu, ConvertedTTTrack &in_trk)
Definition: Isolation.h:198
int OverlapRemoval(unsigned &ovrl, std::vector< unsigned > &overlaps)
Definition: Isolation.h:185
void load(std::vector< l1t::TrackerMuon > &trkMus, std::vector< ConvertedTTTrack > &convertedTracks)

◆ OverlapRemoval()

int Phase2L1GMT::Isolation::OverlapRemoval ( unsigned &  ovrl,
std::vector< unsigned > &  overlaps 
)
inlineprivate

Definition at line 185 of file Isolation.h.

References change_name::diff, mps_fire::i, and analyzePatCleaning_cfg::overlaps.

Referenced by isolation_allmu_alltrk().

185  {
186  for (auto i : overlaps) {
187  // same tracks with Phi can be off by 1 LSB
188  unsigned diff = ovrl - i;
189  if (diff <= 1 || diff == unsigned(-1)) {
190  // When Overlap, return 0 so that this track won't be consider
191  return 0;
192  }
193  }
194  overlaps.push_back(ovrl);
195  return 1;
196  } // ----- end of function Isolation::OverlapRemoval -----

◆ SetAbsIsolationBits()

int Phase2L1GMT::Isolation::SetAbsIsolationBits ( int  accum)
inlineprivate

Definition at line 100 of file Isolation.h.

References absiso_thrL, absiso_thrM, absiso_thrT, and verbose_.

Referenced by isolation_allmu_alltrk().

100  {
101  int iso = (accum <= absiso_thrT ? 3 : accum <= absiso_thrM ? 2 : accum <= absiso_thrL ? 1 : 0);
102 
103  if (verbose_) {
104  edm::LogInfo("Isolation") << " [DEBUG Isolation] : absiso_threshold L : " << absiso_thrL << " accum " << accum
105  << " bit set : " << (accum < absiso_thrL);
106  edm::LogInfo("Isolation") << " [DEBUG Isolation] : absiso_threshold M : " << absiso_thrM << " accum " << accum
107  << " bit set : " << (accum < absiso_thrM);
108  edm::LogInfo("Isolation") << " [DEBUG Isolation] : absiso_threshold T : " << absiso_thrT << " accum " << accum
109  << " bit set : " << (accum < absiso_thrT);
110  edm::LogInfo("Isolation") << " [DEBUG Isolation] : absiso : " << (iso);
111  }
112  return iso;
113  }
Log< level::Info, false > LogInfo

◆ SetRelIsolationBits()

int Phase2L1GMT::Isolation::SetRelIsolationBits ( int  accum,
int  mupt 
)
inlineprivate

Definition at line 115 of file Isolation.h.

References reliso_thrL, reliso_thrM, reliso_thrT, and verbose_.

Referenced by isolation_allmu_alltrk().

115  {
116  const static reliso_thresh_t relisoL(reliso_thrL);
117  const static reliso_thresh_t relisoM(reliso_thrM);
118  const static reliso_thresh_t relisoT(reliso_thrT);
119 
120  iso_accum_t thrL = relisoL * mupt;
121  iso_accum_t thrM = relisoM * mupt;
122  iso_accum_t thrT = relisoT * mupt;
123 
124  int iso = (accum <= thrT.to_int() ? 3 : accum <= thrM.to_int() ? 2 : accum <= thrL.to_int() ? 1 : 0);
125 
126  if (verbose_) {
127  edm::LogInfo("Isolation") << " [DEBUG Isolation] : reliso_threshold L : " << thrL << " accum " << accum
128  << " bit set : " << (accum < thrL.to_int());
129  edm::LogInfo("Isolation") << " [DEBUG Isolation] : reliso_threshold M : " << thrM << " accum " << accum
130  << " bit set : " << (accum < thrM.to_int());
131  edm::LogInfo("Isolation") << " [DEBUG Isolation] : reliso_threshold T : " << thrT << " accum " << accum
132  << " bit set : " << (accum < thrT.to_int());
133  edm::LogInfo("Isolation") << " [DEBUG Isolation] : reliso : " << (iso << 2) << " org " << iso;
134  }
135 
136  return iso << 2;
137  }
ap_ufixed< 9, 0 > reliso_thresh_t
Definition: Isolation.h:56
Log< level::Info, false > LogInfo
ap_ufixed< 9, 9, AP_TRN, AP_SAT > iso_accum_t
Definition: Isolation.h:55

Member Data Documentation

◆ absiso_thrL

int Phase2L1GMT::Isolation::absiso_thrL
private

Definition at line 45 of file Isolation.h.

Referenced by SetAbsIsolationBits().

◆ absiso_thrM

int Phase2L1GMT::Isolation::absiso_thrM
private

Definition at line 46 of file Isolation.h.

Referenced by SetAbsIsolationBits().

◆ absiso_thrT

int Phase2L1GMT::Isolation::absiso_thrT
private

Definition at line 47 of file Isolation.h.

Referenced by SetAbsIsolationBits().

◆ c_iso_dangle_max

const int Phase2L1GMT::Isolation::c_iso_dangle_max = 260
staticprivate

Definition at line 40 of file Isolation.h.

Referenced by compute_trk_iso().

◆ c_iso_dz_max

const int Phase2L1GMT::Isolation::c_iso_dz_max = 17
staticprivate

Definition at line 41 of file Isolation.h.

Referenced by compute_trk_iso().

◆ c_iso_pt_min

const int Phase2L1GMT::Isolation::c_iso_pt_min = 120
staticprivate

Definition at line 42 of file Isolation.h.

Referenced by compute_trk_iso().

◆ dumpForHLS_

bool Phase2L1GMT::Isolation::dumpForHLS_
private

Definition at line 52 of file Isolation.h.

Referenced by Isolation(), isolation_allmu_alltrk(), and ~Isolation().

◆ dumpOutput

std::ofstream Phase2L1GMT::Isolation::dumpOutput
private

Definition at line 53 of file Isolation.h.

Referenced by DumpOutputs(), Isolation(), and ~Isolation().

◆ reliso_thrL

double Phase2L1GMT::Isolation::reliso_thrL
private

Definition at line 48 of file Isolation.h.

Referenced by SetRelIsolationBits().

◆ reliso_thrM

double Phase2L1GMT::Isolation::reliso_thrM
private

Definition at line 49 of file Isolation.h.

Referenced by SetRelIsolationBits().

◆ reliso_thrT

double Phase2L1GMT::Isolation::reliso_thrT
private

Definition at line 50 of file Isolation.h.

Referenced by SetRelIsolationBits().

◆ verbose_

bool Phase2L1GMT::Isolation::verbose_
private