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, int ptLUTVersion, bool readPtLUTFile, bool fixMode15HighPt, bool bug9BitDPhi, bool bugMode7CLCT, bool bugNegPt)
 
void configure_details ()
 
const std::vector< int > & getAllowedModes (void) const
 
const std::array< emtf::Forest, 16 > & getForests (void) const
 
void load (const L1TMuonEndCapForest *payload)
 
 PtAssignmentEngine ()
 
void read (const std::string &xml_dir)
 
int readPtLUTFile ()
 
virtual float scale_pt (const float pt, const int mode=15) const
 
void set_ptLUTVersion (int ptLUTVersion)
 
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 8 of file PtAssignmentEngine.cc.

References forests_, and ptlut_reader_.

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

Definition at line 16 of file PtAssignmentEngine.cc.

16  {
17 
18 }

Member Function Documentation

const PtAssignmentEngineAux & PtAssignmentEngine::aux ( ) const

Definition at line 107 of file PtAssignmentEngine.cc.

References instance.

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

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

Reimplemented in PtAssignmentEngine2016, and PtAssignmentEngine2017.

Definition at line 42 of file PtAssignmentEngine.h.

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

Referenced by PtAssignment::process().

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

Definition at line 120 of file PtAssignmentEngine.cc.

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

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

120  {
121  float pt = 0.;
122 
123  if (readPtLUTFile_) {
124  pt = calculate_pt_lut(address);
125  } else {
126  pt = calculate_pt_xml(address);
127  }
128 
129  return pt;
130 }
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 132 of file PtAssignmentEngine.cc.

References calculate_pt_xml(), and EnergyCorrector::pt.

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

Definition at line 140 of file PtAssignmentEngine.cc.

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

Referenced by calculate_address(), and calculate_pt().

140  {
141  // LUT outputs 'gmt_pt', so need to convert back to 'xmlpt'
142  int gmt_pt = ptlut_reader_.lookup(address);
143  float pt = aux().getPtFromGMTPt(gmt_pt);
144  float xmlpt = pt;
145  xmlpt *= unscale_pt(pt);
146 
147  return xmlpt;
148 }
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 48 of file PtAssignmentEngine.h.

Referenced by calculate_pt().

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

Reimplemented in PtAssignmentEngine2016, and PtAssignmentEngine2017.

Definition at line 49 of file PtAssignmentEngine.h.

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

Definition at line 97 of file PtAssignmentEngine.cc.

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

Referenced by configure(), and getAllowedModes().

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

Definition at line 44 of file PtAssignmentEngine.cc.

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

Referenced by TrackFinder::process().

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

Definition at line 23 of file PtAssignmentEngine.cc.

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

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

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

Definition at line 51 of file PtAssignmentEngine.h.

References readPtLUTFile_.

Referenced by configure(), and getAllowedModes().

51 { return readPtLUTFile_; }
float PtAssignmentEngine::scale_pt ( const float  pt,
const int  mode = 15 
) const
virtual

Reimplemented in PtAssignmentEngine2016, and PtAssignmentEngine2017.

Definition at line 112 of file PtAssignmentEngine.cc.

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

112  {
113  return scale_pt(pt, mode);
114 }
virtual float scale_pt(const float pt, const int mode=15) const
void PtAssignmentEngine::set_ptLUTVersion ( int  ptLUTVersion)
inline

Definition at line 52 of file PtAssignmentEngine.h.

References ptLUTVersion_.

Referenced by TrackFinder::process().

52 { ptLUTVersion_ = ptLUTVersion; }
float PtAssignmentEngine::unscale_pt ( const float  pt,
const int  mode = 15 
) const
virtual

Reimplemented in PtAssignmentEngine2016, and PtAssignmentEngine2017.

Definition at line 116 of file PtAssignmentEngine.cc.

Referenced by calculate_pt_lut(), and getAllowedModes().

116  {
117  return unscale_pt(pt, mode);
118 }
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 63 of file PtAssignmentEngine.h.

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

bool PtAssignmentEngine::bugMode7CLCT_
protected

Definition at line 63 of file PtAssignmentEngine.h.

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

bool PtAssignmentEngine::bugNegPt_
protected

Definition at line 63 of file PtAssignmentEngine.h.

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

bool PtAssignmentEngine::fixMode15HighPt_
protected

Definition at line 62 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 57 of file PtAssignmentEngine.h.

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

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

Definition at line 62 of file PtAssignmentEngine.h.

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

int PtAssignmentEngine::verbose_
protected

Definition at line 59 of file PtAssignmentEngine.h.

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