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 25 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 56 of file Isolation.h.

◆ reliso_thresh_t

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

Definition at line 57 of file Isolation.h.

Constructor & Destructor Documentation

◆ Isolation() [1/2]

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

Definition at line 60 of file Isolation.h.

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

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

◆ ~Isolation()

Phase2L1GMT::Isolation::~Isolation ( )
inline

Definition at line 76 of file Isolation.h.

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

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

◆ Isolation() [2/2]

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

Definition at line 83 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 199 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().

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

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

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

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

Referenced by isolation_allmu_alltrk().

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

◆ SetAbsIsolationBits()

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

Definition at line 101 of file Isolation.h.

References absiso_thrL, absiso_thrM, absiso_thrT, and verbose_.

Referenced by isolation_allmu_alltrk().

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

◆ SetRelIsolationBits()

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

Definition at line 116 of file Isolation.h.

References reliso_thrL, reliso_thrM, reliso_thrT, and verbose_.

Referenced by isolation_allmu_alltrk().

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

Member Data Documentation

◆ absiso_thrL

int Phase2L1GMT::Isolation::absiso_thrL
private

Definition at line 46 of file Isolation.h.

Referenced by SetAbsIsolationBits().

◆ absiso_thrM

int Phase2L1GMT::Isolation::absiso_thrM
private

Definition at line 47 of file Isolation.h.

Referenced by SetAbsIsolationBits().

◆ absiso_thrT

int Phase2L1GMT::Isolation::absiso_thrT
private

Definition at line 48 of file Isolation.h.

Referenced by SetAbsIsolationBits().

◆ c_iso_dangle_max

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

Definition at line 41 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 42 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 43 of file Isolation.h.

Referenced by compute_trk_iso().

◆ dumpForHLS_

bool Phase2L1GMT::Isolation::dumpForHLS_
private

Definition at line 53 of file Isolation.h.

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

◆ dumpOutput

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

Definition at line 54 of file Isolation.h.

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

◆ reliso_thrL

double Phase2L1GMT::Isolation::reliso_thrL
private

Definition at line 49 of file Isolation.h.

Referenced by SetRelIsolationBits().

◆ reliso_thrM

double Phase2L1GMT::Isolation::reliso_thrM
private

Definition at line 50 of file Isolation.h.

Referenced by SetRelIsolationBits().

◆ reliso_thrT

double Phase2L1GMT::Isolation::reliso_thrT
private

Definition at line 51 of file Isolation.h.

Referenced by SetRelIsolationBits().

◆ verbose_

bool Phase2L1GMT::Isolation::verbose_
private