CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Attributes
PtAssignmentEngine Class Referenceabstract

#include <PtAssignmentEngine.h>

Inheritance diagram for PtAssignmentEngine:
PtAssignmentEngine2016 PtAssignmentEngine2017

Public Types

typedef uint64_t address_t
 

Public Member Functions

const PtAssignmentEngineAuxaux () const
 
virtual address_t calculate_address (const EMTFTrack &track) const
 
virtual float calculate_pt (const address_t &address) const
 
virtual float calculate_pt (const EMTFTrack &track) const
 
virtual float calculate_pt_lut (const address_t &address) const
 
virtual float calculate_pt_xml (const address_t &address) const
 
virtual float calculate_pt_xml (const EMTFTrack &track) const
 
void configure (int verbose, bool readPtLUTFile, bool fixMode15HighPt, bool bug9BitDPhi, bool bugMode7CLCT, bool bugNegPt)
 
void configure_details ()
 
int get_pt_lut_version () const
 
const std::vector< int > & getAllowedModes (void) const
 
const std::array< emtf::Forest, 16 > & getForests (void) const
 
void load (int pt_lut_version, const L1TMuonEndCapForest *payload)
 
 PtAssignmentEngine ()
 
void read (int pt_lut_version, const std::string &xml_dir)
 
virtual float scale_pt (const float pt, const int mode=15) const =0
 
virtual float unscale_pt (const float pt, const int mode=15) const =0
 
virtual ~PtAssignmentEngine ()
 

Protected Attributes

std::vector< int > allowedModes_
 
bool bug9BitDPhi_
 
bool bugMode7CLCT_
 
bool bugNegPt_
 
bool fixMode15HighPt_
 
std::array< emtf::Forest, 16 > forests_
 
PtLUTReader ptlut_reader_
 
int ptLUTVersion_
 
bool readPtLUTFile_
 
int verbose_
 

Detailed Description

Definition at line 16 of file PtAssignmentEngine.h.

Member Typedef Documentation

◆ address_t

Definition at line 21 of file PtAssignmentEngine.h.

Constructor & Destructor Documentation

◆ PtAssignmentEngine()

PtAssignmentEngine::PtAssignmentEngine ( )
explicit

Definition at line 6 of file PtAssignmentEngine.cc.

7  : allowedModes_({3, 5, 9, 6, 10, 12, 7, 11, 13, 14, 15}), forests_(), ptlut_reader_(), ptLUTVersion_(0xFFFFFFFF) {}
std::array< emtf::Forest, 16 > forests_
std::vector< int > allowedModes_

◆ ~PtAssignmentEngine()

PtAssignmentEngine::~PtAssignmentEngine ( )
virtual

Definition at line 9 of file PtAssignmentEngine.cc.

9 {}

Member Function Documentation

◆ aux()

const PtAssignmentEngineAux & PtAssignmentEngine::aux ( ) const

Definition at line 95 of file PtAssignmentEngine.cc.

References instance.

Referenced by PtAssignment::aux(), and calculate_pt_lut().

95  {
96  static const PtAssignmentEngineAux instance;
97  return instance;
98 }
static PFTauRenderPlugin instance

◆ calculate_address()

virtual address_t PtAssignmentEngine::calculate_address ( const EMTFTrack track) const
inlinevirtual

Reimplemented in PtAssignmentEngine2016, and PtAssignmentEngine2017.

Definition at line 40 of file PtAssignmentEngine.h.

Referenced by PtAssignment::process().

40 { return 0; }

◆ calculate_pt() [1/2]

float PtAssignmentEngine::calculate_pt ( const address_t address) const
virtual

Definition at line 100 of file PtAssignmentEngine.cc.

References calculate_pt_lut(), calculate_pt_xml(), DiDispStaMuonMonitor_cfi::pt, and readPtLUTFile_.

Referenced by PtAssignment::process().

100  {
101  float pt = 0.;
102 
103  if (readPtLUTFile_) {
104  pt = calculate_pt_lut(address);
105  } else {
106  pt = calculate_pt_xml(address);
107  }
108 
109  return pt;
110 }
virtual float calculate_pt_lut(const address_t &address) const
virtual float calculate_pt_xml(const address_t &address) const

◆ calculate_pt() [2/2]

float PtAssignmentEngine::calculate_pt ( const EMTFTrack track) const
virtual

Definition at line 112 of file PtAssignmentEngine.cc.

References calculate_pt_xml(), DiDispStaMuonMonitor_cfi::pt, and HLT_2022v15_cff::track.

112  {
113  float pt = 0.;
114 
116 
117  return pt;
118 }
virtual float calculate_pt_xml(const address_t &address) const

◆ calculate_pt_lut()

float PtAssignmentEngine::calculate_pt_lut ( const address_t address) const
virtual

Definition at line 120 of file PtAssignmentEngine.cc.

References aux(), PtAssignmentEngineAux::getPtFromGMTPt(), PtLUTReader::lookup(), DiDispStaMuonMonitor_cfi::pt, ptlut_reader_, and unscale_pt().

Referenced by calculate_pt().

120  {
121  // LUT outputs 'gmt_pt', so need to convert back to 'xmlpt'
122  int gmt_pt = ptlut_reader_.lookup(address);
123  float pt = aux().getPtFromGMTPt(gmt_pt);
124  float xmlpt = pt;
125  xmlpt *= unscale_pt(pt);
126 
127  return xmlpt;
128 }
float getPtFromGMTPt(int gmt_pt) const
content_t lookup(const address_t &address) const
Definition: PtLUTReader.cc:60
virtual float unscale_pt(const float pt, const int mode=15) const =0
const PtAssignmentEngineAux & aux() const

◆ calculate_pt_xml() [1/2]

virtual float PtAssignmentEngine::calculate_pt_xml ( const address_t address) const
inlinevirtual

Reimplemented in PtAssignmentEngine2016, and PtAssignmentEngine2017.

Definition at line 46 of file PtAssignmentEngine.h.

Referenced by calculate_pt().

46 { return 0.; }

◆ calculate_pt_xml() [2/2]

virtual float PtAssignmentEngine::calculate_pt_xml ( const EMTFTrack track) const
inlinevirtual

Reimplemented in PtAssignmentEngine2016, and PtAssignmentEngine2017.

Definition at line 47 of file PtAssignmentEngine.h.

47 { return 0.; }

◆ configure()

void PtAssignmentEngine::configure ( int  verbose,
bool  readPtLUTFile,
bool  fixMode15HighPt,
bool  bug9BitDPhi,
bool  bugMode7CLCT,
bool  bugNegPt 
)

Definition at line 72 of file PtAssignmentEngine.cc.

References bug9BitDPhi_, bugMode7CLCT_, bugNegPt_, configure_details(), fixMode15HighPt_, readPtLUTFile_, verbose, and verbose_.

Referenced by PtAssignment::configure().

73  {
74  verbose_ = verbose;
75 
76  readPtLUTFile_ = readPtLUTFile;
77  fixMode15HighPt_ = fixMode15HighPt;
78  bug9BitDPhi_ = bug9BitDPhi;
79  bugMode7CLCT_ = bugMode7CLCT;
80  bugNegPt_ = bugNegPt;
81 
83 }
bool verbose

◆ configure_details()

void PtAssignmentEngine::configure_details ( )

Definition at line 85 of file PtAssignmentEngine.cc.

References ptlut_reader_, PtLUTReader::read(), readPtLUTFile_, contentValuesCheck::ss, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by configure().

85  {
86  if (readPtLUTFile_) {
87  std::stringstream ss;
88  // Hardcoded - this 2 GB LUT file does not exist in CMSSW
89  ss << "/afs/cern.ch/work/a/abrinke1/public/EMTF/PtAssign2017/LUTs/2017_06_07/LUT_v07_07June17.dat";
90  std::string lut_full_path = ss.str();
91  ptlut_reader_.read(lut_full_path);
92  }
93 }
void read(const std::string &lut_full_path)
Definition: PtLUTReader.cc:13

◆ get_pt_lut_version()

int PtAssignmentEngine::get_pt_lut_version ( ) const
inline

Definition at line 28 of file PtAssignmentEngine.h.

References ptLUTVersion_.

Referenced by TrackFinder::process(), and PtAssignment::process().

28 { return ptLUTVersion_; }

◆ getAllowedModes()

const std::vector<int>& PtAssignmentEngine::getAllowedModes ( void  ) const
inline

Definition at line 26 of file PtAssignmentEngine.h.

References allowedModes_.

Referenced by L1TMuonEndCapForestESProducer::produce().

26 { return allowedModes_; }
std::vector< int > allowedModes_

◆ getForests()

const std::array<emtf::Forest, 16>& PtAssignmentEngine::getForests ( void  ) const
inline

Definition at line 25 of file PtAssignmentEngine.h.

References forests_.

Referenced by L1TMuonEndCapForestESProducer::produce().

25 { return forests_; }
std::array< emtf::Forest, 16 > forests_

◆ load()

void PtAssignmentEngine::load ( int  pt_lut_version,
const L1TMuonEndCapForest payload 
)

Definition at line 34 of file PtAssignmentEngine.cc.

References allowedModes_, emtf_assert, forests_, mps_fire::i, ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, jetsAK4_Puppi_cff::payload, and ptLUTVersion_.

34  {
35  if (ptLUTVersion_ == pt_lut_version)
36  return;
37  ptLUTVersion_ = pt_lut_version;
38 
39  edm::LogInfo("L1T") << "EMTF using pt_lut_ver: " << pt_lut_version;
40 
41  for (unsigned i = 0; i < allowedModes_.size(); ++i) {
42  int mode = allowedModes_.at(i);
43 
44  L1TMuonEndCapForest::DForestMap::const_iterator index =
45  payload->forest_map_.find(mode); // associates mode to index
46  if (index == payload->forest_map_.end())
47  continue;
48 
49  forests_.at(mode).loadFromCondPayload(payload->forest_coll_[index->second]);
50 
51  double boostWeight_ = payload->forest_map_.find(mode + 16)->second / 1000000.;
52  // std::cout << "Loaded forest for mode " << mode << " with boostWeight_ = " << boostWeight_ << std::endl;
53  // std::cout << " * ptLUTVersion_ = " << ptLUTVersion_ << std::endl;
54  forests_.at(mode).getTree(0)->setBoostWeight(boostWeight_);
55 
56  emtf_assert(boostWeight_ == 0 || ptLUTVersion_ >= 6); // Check that XMLs and pT LUT version are consistent
57 
58  // Will catch user trying to run with Global Tag settings on 2017 data, rather than fakeEmtfParams. - AWB 08.06.17
59 
60  // // Code below can be used to save out trees in XML format
61  // for (int t = 0; t < 64; t++) {
62  // emtf::Tree* tree = forests_.at(mode).getTree(t);
63  // std::stringstream ss;
64  // ss << mode << "/" << t << ".xml";
65  // tree->saveToXML( ss.str().c_str() );
66  // }
67  }
68 
69  return;
70 }
Log< level::Info, false > LogInfo
std::array< emtf::Forest, 16 > forests_
#define emtf_assert(expr)
Definition: DebugTools.h:18
std::vector< int > allowedModes_

◆ read()

void PtAssignmentEngine::read ( int  pt_lut_version,
const std::string &  xml_dir 
)

Definition at line 14 of file PtAssignmentEngine.cc.

References allowedModes_, gather_cfg::cout, forests_, mps_fire::i, ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, contentValuesCheck::ss, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by edmIntegrityCheck.PublishToFileSystem::get(), and L1TMuonEndCapForestESProducer::produce().

14  {
15  std::string xml_dir_full = "L1Trigger/L1TMuonEndCap/data/pt_xmls/" + xml_dir;
16  unsigned xml_nTrees = 64; // 2016 XMLs
17  if (pt_lut_version >= 6)
18  xml_nTrees = 400; // First 2017 XMLs
19 
20  std::cout << "EMTF emulator: attempting to read " << xml_nTrees << " pT LUT XMLs from local directory" << std::endl;
21  std::cout << xml_dir_full << std::endl;
22  std::cout << "Non-standard operation; if it fails, now you know why" << std::endl;
23 
24  for (unsigned i = 0; i < allowedModes_.size(); ++i) {
25  int mode = allowedModes_.at(i); // For 2016, maps to "mode_inv"
26  std::stringstream ss;
27  ss << xml_dir_full << "/" << mode;
28  forests_.at(mode).loadForestFromXML(ss.str().c_str(), xml_nTrees);
29  }
30 
31  return;
32 }
std::array< emtf::Forest, 16 > forests_
std::vector< int > allowedModes_

◆ scale_pt()

virtual float PtAssignmentEngine::scale_pt ( const float  pt,
const int  mode = 15 
) const
pure virtual

◆ unscale_pt()

virtual float PtAssignmentEngine::unscale_pt ( const float  pt,
const int  mode = 15 
) const
pure virtual

Member Data Documentation

◆ allowedModes_

std::vector<int> PtAssignmentEngine::allowedModes_
protected

◆ bug9BitDPhi_

bool PtAssignmentEngine::bug9BitDPhi_
protected

Definition at line 58 of file PtAssignmentEngine.h.

Referenced by PtAssignmentEngine2016::calculate_address(), and configure().

◆ bugMode7CLCT_

bool PtAssignmentEngine::bugMode7CLCT_
protected

Definition at line 58 of file PtAssignmentEngine.h.

Referenced by PtAssignmentEngine2016::calculate_pt_xml(), and configure().

◆ bugNegPt_

bool PtAssignmentEngine::bugNegPt_
protected

Definition at line 58 of file PtAssignmentEngine.h.

Referenced by PtAssignmentEngine2016::calculate_pt_xml(), and configure().

◆ fixMode15HighPt_

bool PtAssignmentEngine::fixMode15HighPt_
protected

Definition at line 57 of file PtAssignmentEngine.h.

Referenced by PtAssignmentEngine2016::calculate_pt_xml(), and configure().

◆ forests_

std::array<emtf::Forest, 16> PtAssignmentEngine::forests_
protected

◆ ptlut_reader_

PtLUTReader PtAssignmentEngine::ptlut_reader_
protected

Definition at line 52 of file PtAssignmentEngine.h.

Referenced by calculate_pt_lut(), and configure_details().

◆ ptLUTVersion_

int PtAssignmentEngine::ptLUTVersion_
protected

◆ readPtLUTFile_

bool PtAssignmentEngine::readPtLUTFile_
protected

Definition at line 57 of file PtAssignmentEngine.h.

Referenced by calculate_pt(), configure(), and configure_details().

◆ verbose_

int PtAssignmentEngine::verbose_
protected

Definition at line 54 of file PtAssignmentEngine.h.

Referenced by PtAssignmentEngine2016::calculate_pt_xml(), and configure().