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  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:307
std::ofstream dumpOutput
Definition: Isolation.h:54

◆ ~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:54

◆ 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:39
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 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 std::atomic<int> nevto = 0;
86  auto evto = nevto++;
87  for (unsigned int i = 0; i < trkMus.size(); ++i) {
88  auto mu = trkMus.at(i);
89  if (mu.hwPt() != 0) {
90  double convertphi = mu.hwPhi() * LSBphi;
91  if (convertphi > M_PI) {
92  convertphi -= 2 * M_PI;
93  }
94  dumpOutput << evto << " " << i << " " << mu.hwPt() * LSBpt << " " << mu.hwEta() * LSBeta << " " << convertphi
95  << " " << mu.hwZ0() * LSBGTz0 << " " << mu.hwIso() << endl;
96  }
97  }
98  }
const float LSBphi
Definition: Constants.h:93
const float LSBGTz0
Definition: Constants.h:96
const float LSBpt
Definition: Constants.h:92
#define M_PI
const float LSBeta
Definition: Constants.h:94
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 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, submitPVValidationJobs::t, groupFilesInBlocks::temp, Phase2L1GMT::TopoAlgo::trkMus, and verbose_.

140  {
142  if (dumpForHLS_) {
143  DumpInputs();
144  }
145 
146  static std::atomic<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  std::vector<unsigned> overlaps;
154  for (auto t : convertedTracks) {
155  unsigned ovrl = compute_trk_iso(mu, t);
156  if (ovrl != 0) {
157  accum += OverlapRemoval(ovrl, overlaps) * t.pt();
158  }
159  }
160 
161  // Accumation without fixed bit width
162  mu.setHwIsoSum(accum);
163 
164  // Accumation with fixed bit width
165  // Bit shifts with 3 bits with LSB of 0.25GeV
166  iso_accum_t temp(accum);
167  mu.setHwIsoSumAp(temp.to_int() >> 3);
168 
169  //Disable isolation bit, sending isolation sumPT to GT
170  //iso_ |= SetAbsIsolationBits(accum);
171  //iso_ |= SetRelIsolationBits(accum, mu.hwPt());
172 
173  //mu.setHwIso(iso_);
174  }
175 
176  if (dumpForHLS_) {
178  }
179  }
void DumpOutputs(std::vector< l1t::TrackerMuon > &trkMus)
Definition: Isolation.h:84
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: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, genparticles_cff::iso, and verbose_.

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 genparticles_cff::iso, reliso_thrL, reliso_thrM, reliso_thrT, and verbose_.

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: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