Skip to content

Commit

Permalink
Merge pull request #35111 from kbunkow/from-CMSSW_12_1_X_KB_v1
Browse files Browse the repository at this point in the history
new package L1Trigger/L1TMuonOverlapPhase1 (new version of the L1 Trigger Overlap Muon Track Finder (OMTF) emulator)
  • Loading branch information
cmsbuild committed Oct 5, 2021
2 parents 8e25e38 + b8d8a96 commit ffe0bbf
Show file tree
Hide file tree
Showing 100 changed files with 13,358 additions and 4 deletions.
18 changes: 17 additions & 1 deletion CondFormats/L1TObjects/interface/L1TMuonOverlapParams.h
Expand Up @@ -98,7 +98,8 @@ class L1TMuonOverlapParams {
GENERAL = 5,
SECTORS_START = 6,
SECTORS_END = 7,
NUM_OMTFPARAMNODES = 8
DIST_PHI_SHIFT = 8,
NUM_OMTFPARAMNODES = 9
};

// General configuration parameters indexes
Expand Down Expand Up @@ -205,6 +206,17 @@ class L1TMuonOverlapParams {
const l1t::LUT *pdfLUT() const { return &pnodes_[PDF].LUT_; }
const l1t::LUT *meanDistPhiLUT() const { return &pnodes_[MEANDISTPHI].LUT_; }

/**
* return nullptr if the DistPhiShiftLUT is not available in the given L1TMuonOverlapParamsRcd,
* which is the case for the fwVersion <= 0x6
*/
const l1t::LUT *distPhiShiftLUT() const {
if (pnodes_.size() >= (DIST_PHI_SHIFT + 1))
return &pnodes_[DIST_PHI_SHIFT].LUT_;
else
return nullptr;
}

void setChargeLUT(const l1t::LUT &lut) {
pnodes_[CHARGE].type_ = "LUT";
pnodes_[CHARGE].LUT_ = lut;
Expand All @@ -225,6 +237,10 @@ class L1TMuonOverlapParams {
pnodes_[MEANDISTPHI].type_ = "LUT";
pnodes_[MEANDISTPHI].LUT_ = lut;
}
void setDistPhiShiftLUT(const l1t::LUT &lut) {
pnodes_[DIST_PHI_SHIFT].type_ = "LUT";
pnodes_[DIST_PHI_SHIFT].LUT_ = lut;
}

private:
///Version of firmware configuration
Expand Down
6 changes: 4 additions & 2 deletions DQM/L1TMonitor/python/L1TStage2Emulator_cff.py
Expand Up @@ -42,12 +42,14 @@
)

# OMTF
from L1Trigger.L1TMuonOverlap.simOmtfDigis_cfi import *
from L1Trigger.L1TMuonOverlapPhase1.simOmtfDigis_cfi import *
valOmtfDigis = simOmtfDigis.clone(
srcDTPh = "omtfStage2Digis",
srcDTTh = "omtfStage2Digis",
srcCSC = "omtfStage2Digis",
srcRPC = "omtfStage2Digis"
srcRPC = "omtfStage2Digis",
bxMin = -3,
bxMax = 4
)

# GEM TPG
Expand Down
2 changes: 1 addition & 1 deletion L1Trigger/L1TMuon/python/simDigis_cff.py
Expand Up @@ -80,7 +80,7 @@
from L1Trigger.L1TMuonBarrel.simKBmtfDigis_cfi import *
from L1Trigger.L1TMuonEndCap.simEmtfDigis_cfi import *
from L1Trigger.L1TMuonEndCap.simEmtfShowers_cfi import *
from L1Trigger.L1TMuonOverlap.simOmtfDigis_cfi import *
from L1Trigger.L1TMuonOverlapPhase1.simOmtfDigis_cfi import *
from L1Trigger.L1TMuon.simGmtCaloSumDigis_cfi import *
from L1Trigger.L1TMuon.simGmtStage2Digis_cfi import *
from Configuration.Eras.Modifier_stage2L1Trigger_cff import stage2L1Trigger
Expand Down
7 changes: 7 additions & 0 deletions L1Trigger/L1TMuonOverlapPhase1/.gitignore
@@ -0,0 +1,7 @@
/.cproject
/.project
/.pydevproject
/.settings
/test/*.xml
/test/*.root
/test/*.txt
45 changes: 45 additions & 0 deletions L1Trigger/L1TMuonOverlapPhase1/BuildFile.xml
@@ -0,0 +1,45 @@
<export>
<lib name="1"/>
<use name="DataFormats/L1TMuon"/>
<use name="L1Trigger/RPCTrigger"/>
<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>

<flags ADD_SUBDIR="1"/>

<use name="xerces-c"/>
<use name="root"/>
<use name="roofit"/>

<!-- <use lib=boost_timer /> -->
<lib name="boost_timer" />

<use name="L1Trigger/RPCTrigger"/>
<use name="L1Trigger/DTUtilities"/>
<use name="L1Trigger/L1TMuon" />

<use name="DataFormats/L1TMuon"/>
<use name="DataFormats/L1DTTrackFinder"/>

<use name="Geometry/Records"/>
<use name="Geometry/DTGeometry"/>
<use name="Geometry/CSCGeometry"/>
<use name="Geometry/RPCGeometry"/>

<use name="SimDataFormats/DigiSimLinks"/>
<use name="SimDataFormats/Vertex"/>
<use name="SimDataFormats/TrackingAnalysis"/>

<use name="PhysicsTools/UtilAlgos"/>
<use name="FWCore/ServiceRegistry"/>

<use name="TrackingTools/Records" />
<use name="TrackingTools/TrajectoryState" />
<use name="TrackingTools/GeomPropagators" />

59 changes: 59 additions & 0 deletions L1Trigger/L1TMuonOverlapPhase1/interface/AlgoMuonBase.h
@@ -0,0 +1,59 @@
/*
* AlgoMuonBase.h
*
* Created on: Mar 1, 2019
* Author: Karol Bunkowski kbunkow@cern.ch
*/

#ifndef L1T_OmtfP1_ALGOMUONBASE_H_
#define L1T_OmtfP1_ALGOMUONBASE_H_

#include "L1Trigger/L1TMuonOverlapPhase1/interface/ProcConfigurationBase.h"
#include "L1Trigger/L1TMuonOverlapPhase1/interface/MuonStub.h"
#include "L1Trigger/L1TMuonOverlapPhase1/interface/StubResult.h"
#include "boost/dynamic_bitset.hpp"

class AlgoMuonBase {
public:
AlgoMuonBase(){};

AlgoMuonBase(const ProcConfigurationBase* config);
virtual ~AlgoMuonBase();

virtual int getEtaHw() const = 0;

virtual bool isValid() const = 0;

virtual unsigned int getFiredLayerCnt() const {
unsigned int count = 0;
for (auto& firedLayerBits : firedLayerBitsInBx) {
count += firedLayerBits.count();
}
return count;
}

virtual unsigned int getFiredLayerCnt(int bx) const { return firedLayerBitsInBx.at(bx).count(); }

boost::dynamic_bitset<> getFiredLayerBits()
const { //TODO make it virtual, and change the return type in in the AlgoMuon to dynamic_bitset<>
boost::dynamic_bitset<> firedLayerBitsSum(firedLayerBitsInBx[0].size());
for (auto& firedLayerBits : firedLayerBitsInBx) {
firedLayerBitsSum |= firedLayerBits;
}
return firedLayerBitsSum;
}

virtual bool isLayerFired(unsigned int iLayer, unsigned int bx) const { return firedLayerBitsInBx.at(bx)[iLayer]; }

virtual double getPdfSum() const = 0;

virtual const StubResult& getStubResult(unsigned int iLayer) const = 0;

virtual const StubResults& getStubResults() const = 0;

protected:
///bits representing fired logicLayers (including bending layers),
std::vector<boost::dynamic_bitset<> > firedLayerBitsInBx;
};

#endif /* L1T_OmtfP1_ALGOMUONBASE_H_ */
119 changes: 119 additions & 0 deletions L1Trigger/L1TMuonOverlapPhase1/interface/AngleConverterBase.h
@@ -0,0 +1,119 @@
#ifndef L1T_OmtfP1_ANGLECONVERTER_H
#define L1T_OmtfP1_ANGLECONVERTER_H

#include "L1Trigger/L1TMuonOverlapPhase1/interface/ProcConfigurationBase.h"

#include "FWCore/Framework/interface/ESHandle.h"
#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
#include "DataFormats/L1TMuon/interface/RegionalMuonCandFwd.h"
#include "Geometry/Records/interface/MuonGeometryRecord.h"
#include "FWCore/Framework/interface/ESWatcher.h"

#include <memory>

namespace edm {
class EventSetup;
}

class RPCGeometry;
class CSCGeometry;
class CSCLayer;
class DTGeometry;

class L1MuDTChambPhDigi;
class L1MuDTChambThDigi;
class L1MuDTChambThContainer;
class CSCCorrelatedLCTDigi;
class RPCDigi;

class DTChamberId;
class CSCDetId;
class RPCDetId;

struct EtaValue {
int eta = 0;
///error of the eta measurement
int etaSigma = 0;
int quality = 0;

int bx = 0;
int timing = 0; //sub-bx timing, should be already in scale common for all muon subsystems
};

struct MuonGeometryTokens {
edm::ESGetToken<RPCGeometry, MuonGeometryRecord> rpcGeometryEsToken;
edm::ESGetToken<CSCGeometry, MuonGeometryRecord> cscGeometryEsToken;
edm::ESGetToken<DTGeometry, MuonGeometryRecord> dtGeometryEsToken;
};

class AngleConverterBase {
public:
AngleConverterBase();
virtual ~AngleConverterBase();

///Update the Geometry with current Event Setup
virtual void checkAndUpdateGeometry(const edm::EventSetup&,
const ProcConfigurationBase* config,
const MuonGeometryTokens& muonGeometryTokens);

/// get phi of DT,CSC and RPC azimutal angle digi in processor scale, used by OMTF algorithm.
/// in case of wrong phi returns OMTFConfiguration::instance()->nPhiBins
/// phiZero - desired phi where the scale should start, should be in the desired scale, use getProcessorPhiZero to obtain it
virtual int getProcessorPhi(int phiZero, l1t::tftype part, int dtScNum, int dtPhi) const;

virtual int getProcessorPhi(int phiZero,
l1t::tftype part,
const CSCDetId& csc,
const CSCCorrelatedLCTDigi& digi) const;

virtual int getProcessorPhi(unsigned int iProcessor,
l1t::tftype part,
const RPCDetId& rollId,
const unsigned int& digi) const;
virtual int getProcessorPhi(int phiZero,
l1t::tftype part,
const RPCDetId& rollId,
const unsigned int& digi1,
const unsigned int& digi2) const;

///returns the eta position of the DT chamber
///(n.b. in the DT phi and eta segments are independent)
virtual EtaValue getGlobalEtaDt(const DTChamberId& detId) const;

//adds the eta segments from the thetaDigi to etaSegments
virtual void getGlobalEta(const L1MuDTChambThDigi& thetaDigi, std::vector<EtaValue>& etaSegments) const;
virtual std::vector<EtaValue> getGlobalEta(const L1MuDTChambThContainer* dtThDigis, int bxFrom, int bxTo) const;

///Convert local eta coordinate to global digital microGMT scale.
virtual EtaValue getGlobalEta(const CSCDetId& detId, const CSCCorrelatedLCTDigi& aDigi) const;

///returns the eta position of the CSC chamber
virtual EtaValue getGlobalEtaCsc(const CSCDetId& detId) const;

///Convert local eta coordinate to global digital microGMT scale.
///EtaValue::etaSigma is half of the strip
virtual EtaValue getGlobalEta(unsigned int rawid, const unsigned int& aDigi) const;

float cscChamberEtaSize(const CSCDetId& id) const;

protected:
///Check orientation of strips in given CSC chamber
virtual bool isCSCCounterClockwise(const CSCLayer* layer) const;

///Find BTI group
virtual const int findBTIgroup(const L1MuDTChambPhDigi& aDigi, const L1MuDTChambThContainer* dtThDigis);

// pointers to the current geometry records
unsigned long long _geom_cache_id = 0;
edm::ESHandle<RPCGeometry> _georpc;
edm::ESHandle<CSCGeometry> _geocsc;
edm::ESHandle<DTGeometry> _geodt;

edm::ESWatcher<MuonGeometryRecord> muonGeometryRecordWatcher;

const ProcConfigurationBase* config = nullptr;
///Number of phi bins along 2Pi.
unsigned int nPhiBins = 0;
};

#endif
68 changes: 68 additions & 0 deletions L1Trigger/L1TMuonOverlapPhase1/interface/MuonStub.h
@@ -0,0 +1,68 @@
/*
* MuonStub.h
*
* Created on: Dec 21, 2018
* Author: kbunkow
*
* MuonStub - data structure for algorithm input
*/

#ifndef L1T_OmtfP1_MUONSTUB_H_
#define L1T_OmtfP1_MUONSTUB_H_

#include <vector>
#include <memory>

struct MuonStub {
public:
enum Type {
EMPTY,
DT_PHI,
DT_THETA,
DT_PHI_ETA,
DT_HIT,
RPC,
CSC_PHI,
CSC_ETA,
CSC_PHI_ETA,
BARREL_SUPER_SEG,
};

MuonStub();

MuonStub(int phiHw, int phiBHw) : phiHw(phiHw), phiBHw(phiBHw){};

virtual ~MuonStub();

Type type = EMPTY;

int phiHw = 0;
int phiBHw = 0;

static const int EMTPY_PHI = 0xffffff;

int etaHw = 0;
int etaSigmaHw = 0; ///error of the eta measurement
int qualityHw = 0;

int bx = 0;
int timing = 0;

//used to address LUTs
unsigned int logicLayer = 0;

//int roll = 0; //TODO remove

int detId = 0;

friend std::ostream& operator<<(std::ostream& out, const MuonStub& stub);
};

typedef std::vector<MuonStub> MuonStubs1D;
typedef std::vector<MuonStubs1D> MuonStubs2D;

typedef std::shared_ptr<const MuonStub> MuonStubPtr;
typedef std::vector<MuonStubPtr> MuonStubPtrs1D;
typedef std::vector<MuonStubPtrs1D> MuonStubPtrs2D;

#endif /* L1T_OmtfP1_MUONSTUB_H_ */

0 comments on commit ffe0bbf

Please sign in to comment.