CMS 3D CMS Logo

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

#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
 
virtual float unscale_pt (const float pt, const int mode=15) const
 
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 17 of file PtAssignmentEngine.h.

Member Typedef Documentation

Definition at line 22 of file PtAssignmentEngine.h.

Constructor & Destructor Documentation

PtAssignmentEngine::PtAssignmentEngine ( )
explicit

Definition at line 10 of file PtAssignmentEngine.cc.

References forests_, ptlut_reader_, and ptLUTVersion_.

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

Definition at line 19 of file PtAssignmentEngine.cc.

19  {
20 
21 }

Member Function Documentation

const PtAssignmentEngineAux & PtAssignmentEngine::aux ( ) const

Definition at line 109 of file PtAssignmentEngine.cc.

References instance.

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

109  {
110  static const PtAssignmentEngineAux instance;
111  return instance;
112 }
static PFTauRenderPlugin instance
virtual address_t PtAssignmentEngine::calculate_address ( const EMTFTrack track) const
inlinevirtual

Reimplemented in PtAssignmentEngine2016, and PtAssignmentEngine2017.

Definition at line 44 of file PtAssignmentEngine.h.

References calculate_pt(), calculate_pt_lut(), and HiIsolationCommonParameters_cff::track.

Referenced by PtAssignment::process().

44 { return 0; }
float PtAssignmentEngine::calculate_pt ( const address_t address) const
virtual

Definition at line 122 of file PtAssignmentEngine.cc.

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

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

122  {
123  float pt = 0.;
124 
125  if (readPtLUTFile_) {
126  pt = calculate_pt_lut(address);
127  } else {
128  pt = calculate_pt_xml(address);
129  }
130 
131  return pt;
132 }
virtual float calculate_pt_xml(const address_t &address) const
virtual float calculate_pt_lut(const address_t &address) const
float PtAssignmentEngine::calculate_pt ( const EMTFTrack track) const
virtual

Definition at line 134 of file PtAssignmentEngine.cc.

References calculate_pt_xml(), and EnergyCorrector::pt.

134  {
135  float pt = 0.;
136 
137  pt = calculate_pt_xml(track);
138 
139  return pt;
140 }
virtual float calculate_pt_xml(const address_t &address) const
float PtAssignmentEngine::calculate_pt_lut ( const address_t address) const
virtual

Definition at line 142 of file PtAssignmentEngine.cc.

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

Referenced by calculate_address(), and calculate_pt().

142  {
143  // LUT outputs 'gmt_pt', so need to convert back to 'xmlpt'
144  int gmt_pt = ptlut_reader_.lookup(address);
145  float pt = aux().getPtFromGMTPt(gmt_pt);
146  float xmlpt = pt;
147  xmlpt *= unscale_pt(pt);
148 
149  return xmlpt;
150 }
const PtAssignmentEngineAux & aux() const
virtual float unscale_pt(const float pt, const int mode=15) const
float getPtFromGMTPt(int gmt_pt) const
content_t lookup(const address_t &address) const
Definition: PtLUTReader.cc:67
virtual float PtAssignmentEngine::calculate_pt_xml ( const address_t address) const
inlinevirtual

Reimplemented in PtAssignmentEngine2016, and PtAssignmentEngine2017.

Definition at line 50 of file PtAssignmentEngine.h.

Referenced by calculate_pt().

50 { return 0.; }
virtual float PtAssignmentEngine::calculate_pt_xml ( const EMTFTrack track) const
inlinevirtual

Reimplemented in PtAssignmentEngine2016, and PtAssignmentEngine2017.

Definition at line 51 of file PtAssignmentEngine.h.

51 { return 0.; }
void PtAssignmentEngine::configure ( int  verbose,
bool  readPtLUTFile,
bool  fixMode15HighPt,
bool  bug9BitDPhi,
bool  bugMode7CLCT,
bool  bugNegPt 
)

Definition at line 83 of file PtAssignmentEngine.cc.

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

Referenced by PtAssignment::configure(), and get_pt_lut_version().

87  {
88  verbose_ = verbose;
89 
90  readPtLUTFile_ = readPtLUTFile;
91  fixMode15HighPt_ = fixMode15HighPt;
92  bug9BitDPhi_ = bug9BitDPhi;
93  bugMode7CLCT_ = bugMode7CLCT;
94  bugNegPt_ = bugNegPt;
95 
97 }
bool verbose
void PtAssignmentEngine::configure_details ( )

Definition at line 99 of file PtAssignmentEngine.cc.

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

Referenced by configure(), and get_pt_lut_version().

99  {
100  if (readPtLUTFile_) {
101  std::stringstream ss;
102  // Hardcoded - this 2 GB LUT file does not exist in CMSSW
103  ss << "/afs/cern.ch/work/a/abrinke1/public/EMTF/PtAssign2017/LUTs/2017_06_07/LUT_v07_07June17.dat";
104  std::string lut_full_path = ss.str();
105  ptlut_reader_.read(lut_full_path);
106  }
107 }
void read(const std::string &lut_full_path)
Definition: PtLUTReader.cc:21
int PtAssignmentEngine::get_pt_lut_version ( ) const
inline
const std::vector<int>& PtAssignmentEngine::getAllowedModes ( void  ) const
inline

Definition at line 27 of file PtAssignmentEngine.h.

References allowedModes_.

Referenced by L1TMuonEndCapForestESProducer::produce().

27 { return allowedModes_; }
std::vector< int > allowedModes_
const std::array<emtf::Forest, 16>& PtAssignmentEngine::getForests ( void  ) const
inline

Definition at line 26 of file PtAssignmentEngine.h.

References forests_.

Referenced by L1TMuonEndCapForestESProducer::produce().

26 { return forests_; }
std::array< emtf::Forest, 16 > forests_
void PtAssignmentEngine::load ( int  pt_lut_version,
const L1TMuonEndCapForest payload 
)

Definition at line 47 of file PtAssignmentEngine.cc.

References allowedModes_, L1TMuonEndCapForest::forest_coll_, L1TMuonEndCapForest::forest_map_, forests_, mps_fire::i, ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, and ptLUTVersion_.

47  {
48  if (ptLUTVersion_ == pt_lut_version) return;
49  ptLUTVersion_ = pt_lut_version;
50 
51  edm::LogInfo("L1T") << "EMTF using pt_lut_ver: " << pt_lut_version;
52 
53  for (unsigned i = 0; i < allowedModes_.size(); ++i) {
54  int mode = allowedModes_.at(i);
55 
56  L1TMuonEndCapForest::DForestMap::const_iterator index = payload->forest_map_.find(mode); // associates mode to index
57  if (index == payload->forest_map_.end()) continue;
58 
59  forests_.at(mode).loadFromCondPayload(payload->forest_coll_[index->second]);
60 
61  double boostWeight_ = payload->forest_map_.find(mode+16)->second / 1000000.;
62  // std::cout << "Loaded forest for mode " << mode << " with boostWeight_ = " << boostWeight_ << std::endl;
63  // std::cout << " * ptLUTVersion_ = " << ptLUTVersion_ << std::endl;
64  forests_.at(mode).getTree(0)->setBoostWeight( boostWeight_ );
65 
66  if (not(boostWeight_ == 0 || ptLUTVersion_ >= 6)) // Check that XMLs and pT LUT version are consistent
67  { edm::LogError("L1T") << "boostWeight_ = " << boostWeight_ << ", ptLUTVersion_ = " << ptLUTVersion_; return; }
68  // Will catch user trying to run with Global Tag settings on 2017 data, rather than fakeEmtfParams. - AWB 08.06.17
69 
70  // // Code below can be used to save out trees in XML format
71  // for (int t = 0; t < 64; t++) {
72  // emtf::Tree* tree = forests_.at(mode).getTree(t);
73  // std::stringstream ss;
74  // ss << mode << "/" << t << ".xml";
75  // tree->saveToXML( ss.str().c_str() );
76  // }
77 
78  }
79 
80  return;
81 }
std::array< emtf::Forest, 16 > forests_
std::vector< int > allowedModes_
void PtAssignmentEngine::read ( int  pt_lut_version,
const std::string &  xml_dir 
)

Definition at line 26 of file PtAssignmentEngine.cc.

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

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

26  {
27 
28  std::string xml_dir_full = "L1Trigger/L1TMuonEndCap/data/pt_xmls/" + xml_dir;
29  unsigned xml_nTrees = 64; // 2016 XMLs
30  if (pt_lut_version >= 6)
31  xml_nTrees = 400; // First 2017 XMLs
32 
33  std::cout << "EMTF emulator: attempting to read " << xml_nTrees << " pT LUT XMLs from local directory" << std::endl;
34  std::cout << xml_dir_full << std::endl;
35  std::cout << "Non-standard operation; if it fails, now you know why" << std::endl;
36 
37  for (unsigned i = 0; i < allowedModes_.size(); ++i) {
38  int mode = allowedModes_.at(i); // For 2016, maps to "mode_inv"
39  std::stringstream ss;
40  ss << xml_dir_full << "/" << mode;
41  forests_.at(mode).loadForestFromXML(ss.str().c_str(), xml_nTrees);
42  }
43 
44  return;
45 }
std::array< emtf::Forest, 16 > forests_
std::vector< int > allowedModes_
float PtAssignmentEngine::scale_pt ( const float  pt,
const int  mode = 15 
) const
virtual

Reimplemented in PtAssignmentEngine2016, and PtAssignmentEngine2017.

Definition at line 114 of file PtAssignmentEngine.cc.

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

114  {
115  return scale_pt(pt, mode);
116 }
virtual float scale_pt(const float pt, const int mode=15) const
float PtAssignmentEngine::unscale_pt ( const float  pt,
const int  mode = 15 
) const
virtual

Reimplemented in PtAssignmentEngine2016, and PtAssignmentEngine2017.

Definition at line 118 of file PtAssignmentEngine.cc.

Referenced by calculate_pt_lut(), and get_pt_lut_version().

118  {
119  return unscale_pt(pt, mode);
120 }
virtual float unscale_pt(const float pt, const int mode=15) const

Member Data Documentation

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

Definition at line 62 of file PtAssignmentEngine.h.

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

bool PtAssignmentEngine::bugMode7CLCT_
protected

Definition at line 62 of file PtAssignmentEngine.h.

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

bool PtAssignmentEngine::bugNegPt_
protected

Definition at line 62 of file PtAssignmentEngine.h.

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

bool PtAssignmentEngine::fixMode15HighPt_
protected

Definition at line 61 of file PtAssignmentEngine.h.

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

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

Definition at line 56 of file PtAssignmentEngine.h.

Referenced by calculate_pt_lut(), configure_details(), and PtAssignmentEngine().

int PtAssignmentEngine::ptLUTVersion_
protected
bool PtAssignmentEngine::readPtLUTFile_
protected

Definition at line 61 of file PtAssignmentEngine.h.

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

int PtAssignmentEngine::verbose_
protected

Definition at line 58 of file PtAssignmentEngine.h.

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