forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
3,955 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/.cproject | ||
/.project | ||
/.pydevproject | ||
/.settings | ||
/test/*.xml | ||
/test/*.root | ||
/test/*.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<export> | ||
<lib name="1"/> | ||
<use name="DataFormats/L1TMuon"/> | ||
<use name="DataFormats/L1TMuon"/> | ||
<use name="Geometry/Records"/> | ||
<use name="Geometry/DTGeometry"/> | ||
<use name="Geometry/CSCGeometry"/> | ||
<use name="Geometry/RPCGeometry"/> | ||
<use name="root"/> | ||
<use name="xerces-c"/> | ||
</export> | ||
|
||
<use name="xerces-c"/> | ||
<use name="root"/> | ||
<use name="roofit"/> | ||
|
||
<!-- <use lib=boost_timer /> --> | ||
<lib name="boost_timer" /> | ||
|
||
<use name="DataFormats/L1TMuon"/> | ||
|
||
<use name="Geometry/Records"/> | ||
<use name="Geometry/DTGeometry"/> | ||
<use name="Geometry/CSCGeometry"/> | ||
<use name="Geometry/RPCGeometry"/> | ||
|
||
<use name="L1Trigger/DTUtilities"/> | ||
<use name="L1Trigger/L1TMuonOverlapPhase1"/> | ||
|
||
<use name="PhysicsTools/UtilAlgos"/> | ||
<use name="FWCore/ServiceRegistry"/> |
116 changes: 116 additions & 0 deletions
116
L1Trigger/L1TMuonOverlapPhase2/interface/InputMakerPhase2.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
/* | ||
* InputMakerPhase2.h | ||
* | ||
* Created on: May 20, 2020 | ||
* Author: kbunkow | ||
*/ | ||
|
||
#ifndef INTERFACE_INPUTMAKERPHASE2_H_ | ||
#define INTERFACE_INPUTMAKERPHASE2_H_ | ||
|
||
#include "DataFormats/Common/interface/Handle.h" | ||
#include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambThContainer.h" | ||
#include "DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTPhContainer.h" | ||
#include "DataFormats/L1TMuon/interface/RegionalMuonCandFwd.h" | ||
#include "DataFormats/MuonDetId/interface/DTChamberId.h" | ||
#include "FWCore/Utilities/interface/EDGetToken.h" | ||
|
||
#include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFConfiguration.h" | ||
#include "L1Trigger/L1TMuonOverlapPhase1/interface/MuonStub.h" | ||
#include "L1Trigger/L1TMuonOverlapPhase1/interface/MuonStubMakerBase.h" | ||
#include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFinputMaker.h" | ||
#include "L1Trigger/L1TMuonOverlapPhase2/interface/OmtfPhase2AngleConverter.h" | ||
|
||
class DtPhase2DigiToStubsConverter : public DigiToStubsConverterBase { | ||
public: | ||
DtPhase2DigiToStubsConverter(edm::EDGetTokenT<L1Phase2MuDTPhContainer> inputTokenDtPh, | ||
edm::EDGetTokenT<L1MuDTChambThContainer> inputTokenDtTh) | ||
: inputTokenDtPh(inputTokenDtPh), inputTokenDtTh(inputTokenDtTh){}; | ||
|
||
~DtPhase2DigiToStubsConverter() override{}; | ||
|
||
//virtual void initialize(const edm::ParameterSet& edmCfg, const edm::EventSetup& es, const ProcConfigurationBase* procConf) {}; | ||
|
||
void loadDigis(const edm::Event& event) override; | ||
|
||
void makeStubs(MuonStubPtrs2D& muonStubsInLayers, | ||
unsigned int iProcessor, | ||
l1t::tftype procTyp, | ||
int bxFrom, | ||
int bxTo, | ||
std::vector<std::unique_ptr<IOMTFEmulationObserver> >& observers) override; | ||
|
||
//dtThDigis is provided as argument, because in the OMTF implementation the phi and eta digis are merged (even thought it is artificial) | ||
virtual void addDTphiDigi(MuonStubPtrs2D& muonStubsInLayers, | ||
const L1Phase2MuDTPhDigi& digi, | ||
const L1MuDTChambThContainer* dtThDigis, | ||
unsigned int iProcessor, | ||
l1t::tftype procTyp) = 0; | ||
|
||
virtual void addDTetaStubs(MuonStubPtrs2D& muonStubsInLayers, | ||
const L1MuDTChambThDigi& thetaDigi, | ||
unsigned int iProcessor, | ||
l1t::tftype procTyp) = 0; | ||
|
||
virtual bool acceptDigi(const DTChamberId& dTChamberId, unsigned int iProcessor, l1t::tftype procType) { | ||
return true; | ||
} | ||
|
||
protected: | ||
bool mergePhiAndTheta = true; | ||
|
||
edm::EDGetTokenT<L1Phase2MuDTPhContainer> inputTokenDtPh; | ||
edm::EDGetTokenT<L1MuDTChambThContainer> inputTokenDtTh; | ||
|
||
edm::Handle<L1Phase2MuDTPhContainer> dtPhDigis; | ||
edm::Handle<L1MuDTChambThContainer> dtThDigis; | ||
}; | ||
|
||
class DtPhase2DigiToStubsConverterOmtf : public DtPhase2DigiToStubsConverter { | ||
public: | ||
DtPhase2DigiToStubsConverterOmtf(const OMTFConfiguration* config, | ||
const OmtfAngleConverter* angleConverter, | ||
edm::EDGetTokenT<L1Phase2MuDTPhContainer> inputTokenDtPh, | ||
edm::EDGetTokenT<L1MuDTChambThContainer> inputTokenDtTh) | ||
: DtPhase2DigiToStubsConverter(inputTokenDtPh, inputTokenDtTh), config(config), angleConverter(angleConverter){}; | ||
|
||
~DtPhase2DigiToStubsConverterOmtf() override{}; | ||
|
||
//dtThDigis is provided as argument, because in the OMTF implementation the phi and eta digis are merged (even thought it is artificial) | ||
void addDTphiDigi(MuonStubPtrs2D& muonStubsInLayers, | ||
const L1Phase2MuDTPhDigi& digi, | ||
const L1MuDTChambThContainer* dtThDigis, | ||
unsigned int iProcessor, | ||
l1t::tftype procTyp) override; | ||
|
||
void addDTetaStubs(MuonStubPtrs2D& muonStubsInLayers, | ||
const L1MuDTChambThDigi& thetaDigi, | ||
unsigned int iProcessor, | ||
l1t::tftype procTyp) override; | ||
|
||
bool acceptDigi(const DTChamberId& dTChamberId, unsigned int iProcessor, l1t::tftype procType) override; | ||
|
||
private: | ||
const OMTFConfiguration* config = nullptr; | ||
const OmtfAngleConverter* angleConverter = nullptr; | ||
}; | ||
|
||
class InputMakerPhase2 : public OMTFinputMaker { | ||
public: | ||
InputMakerPhase2(const edm::ParameterSet& edmParameterSet, | ||
MuStubsInputTokens& muStubsInputTokens, | ||
edm::EDGetTokenT<L1Phase2MuDTPhContainer> inputTokenDTPhPhase2, | ||
const OMTFConfiguration* config, | ||
std::unique_ptr<OmtfAngleConverter> angleConverter); | ||
|
||
~InputMakerPhase2() override; | ||
|
||
//the phi and eta digis are merged (even thought it is artificial) | ||
virtual void addDTphiDigi(MuonStubPtrs2D& muonStubsInLayers, | ||
const L1Phase2MuDTPhDigi& digi, | ||
const L1Phase2MuDTPhContainer* dtThDigis, | ||
unsigned int iProcessor, | ||
l1t::tftype procTyp) {} | ||
}; | ||
|
||
#endif /* INTERFACE_INPUTMAKERPHASE2_H_ */ |
69 changes: 69 additions & 0 deletions
69
L1Trigger/L1TMuonOverlapPhase2/interface/LutNetworkFixedPointCommon.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* LutNetworkCommon.h | ||
* | ||
* Created on: Jan 13, 2023 | ||
* Author: kbunkow | ||
*/ | ||
|
||
#ifndef INTERFACE_LUTNETWORKFIXEDPOINTCOMMON_H_ | ||
#define INTERFACE_LUTNETWORKFIXEDPOINTCOMMON_H_ | ||
|
||
#include <ap_fixed.h> | ||
#include <ap_int.h> | ||
#include <array> | ||
#include <vector> | ||
#include <limits> | ||
|
||
#include <boost/property_tree/ptree.hpp> | ||
|
||
namespace lutNN { | ||
|
||
template <int W, int I> | ||
const ap_ufixed<W, I> max_ap_ufixed() { | ||
static_assert(I < 64, "this max_ap_ufixed works only for I < 64"); | ||
return ap_ufixed<W, I, AP_RND, AP_SAT>(std::numeric_limits<uint64_t>::max()); | ||
//AP_SAT Saturate the value to the maximum value in case of overflow | ||
} | ||
|
||
template <int W, int I> | ||
const ap_fixed<W, I> max_ap_fixed() { | ||
static_assert(I < 64, "this max_ap_ufixed works only for I < 64"); | ||
return ap_fixed<W, I, AP_RND, AP_SAT>(std::numeric_limits<uint64_t>::max()); | ||
//AP_SAT Saturate the value to the maximum value in case of overflow | ||
} | ||
|
||
#define PUT_VAR(tree, keyPath, var) tree.put((keyPath) + "." + #var, (var)); | ||
|
||
#define CHECK_VAR(tree, keyPath, var) \ | ||
if ((var) != tree.get<int>((keyPath) + "." + #var)) \ | ||
throw std::runtime_error((keyPath) + "." + #var + " has different value in the file then given"); | ||
|
||
/*template<typename arrayType> | ||
void saveLut(boost::property_tree::ptree& tree, std::string keyPath, const arrayType& lut) { | ||
std::ostringstream ostr; | ||
for(auto& a : lut) { | ||
ostr<<std::hex<<a.bits_to_uint64()<<", "; | ||
} | ||
tree.put(keyPath + ".lutArray." + , ostr.str()); | ||
}*/ | ||
|
||
class LutNetworkFixedPointRegressionBase { | ||
public: | ||
virtual ~LutNetworkFixedPointRegressionBase(){}; | ||
|
||
virtual void save(const std::string& filename) = 0; | ||
virtual void load(const std::string& filename) = 0; | ||
|
||
/* template <typename InputType> | ||
void run(std::vector<InputType>& inputs, InputType noHitVal, std::vector<double>& nnResult) = 0;*/ | ||
|
||
virtual void run(std::vector<float>& inputs, float noHitVal, std::vector<double>& nnResult) = 0; | ||
|
||
//pt in the hardware scale, ptGeV = (ptHw -1) / 2 | ||
virtual int getCalibratedHwPt() = 0; | ||
}; | ||
|
||
} // namespace lutNN | ||
|
||
#endif /* INTERFACE_LUTNETWORKFIXEDPOINTCOMMON_H_ */ |
Oops, something went wrong.