Skip to content

Commit

Permalink
Merge pull request cms-sw#7 from jbsauvan/myemuldevel-branch
Browse files Browse the repository at this point in the history
Add first version of the stage 2 clustering algo
  • Loading branch information
mulhearn committed Mar 13, 2014
2 parents 0415828 + 84a9a98 commit e1b0e5d
Show file tree
Hide file tree
Showing 8 changed files with 453 additions and 20 deletions.
23 changes: 15 additions & 8 deletions DataFormats/L1TCalorimeter/interface/CaloCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ namespace l1t {
enum ClusterFlag{
PASS_THRES_SEED = 0,
PASS_FILTER_CLUSTER = 1,
PASS_FILTER_NW = 2,
PASS_FILTER_N = 3,
PASS_FILTER_NE = 4,
PASS_FILTER_E = 5,
PASS_FILTER_SE = 7,
PASS_FILTER_S = 8,
PASS_FILTER_SW = 9,
PASS_FILTER_W = 10,
TRIM_NW = 2,
TRIM_N = 3,
TRIM_NE = 4,
TRIM_E = 5,
TRIM_SE = 7,
TRIM_S = 8,
TRIM_SW = 9,
TRIM_W = 10,
TRIM_LEFT = 11,
TRIM_RIGHT = 12,
EXT_UP = 13,
Expand All @@ -36,8 +36,12 @@ namespace l1t {
~CaloCluster();

void setClusterFlag(ClusterFlag flag, bool val=true);
void setHwSeedPt(int pt);
void setHOverE(int hOverE);

bool checkClusterFlag(ClusterFlag flag) const;
bool isValid() const;
int hwSeedPt() const;
int fgEta() const;
int fgPhi() const;
int hOverE() const;
Expand All @@ -46,6 +50,9 @@ namespace l1t {
// Summary of clustering outcomes
int m_clusterFlags; // see ClusterFlag bits (15 bits, will evolve)

// Energies
int m_hwSeedPt;

// fine grained position
int m_fgEta; // 2 bits (to be defined in agreement with GT inputs)
int m_fgPhi; // 2 bits (to be defined in agreement with GT inputs)
Expand Down
20 changes: 20 additions & 0 deletions DataFormats/L1TCalorimeter/src/CaloCluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,31 @@ void l1t::CaloCluster::setClusterFlag(ClusterFlag flag, bool val)
}
};

void l1t::CaloCluster::setHwSeedPt(int pt)
{
m_hwSeedPt = pt;
}

void l1t::CaloCluster::setHOverE(int hOverE)
{
m_hOverE = hOverE;
}

bool l1t::CaloCluster::checkClusterFlag(ClusterFlag flag) const
{
return (m_clusterFlags & (0x1<<flag));
};

bool l1t::CaloCluster::isValid() const
{
return ( checkClusterFlag(PASS_THRES_SEED) && checkClusterFlag(PASS_FILTER_CLUSTER) );
}

int l1t::CaloCluster::hwSeedPt() const
{
return m_hwSeedPt;
}

int l1t::CaloCluster::fgEta() const
{
return m_fgEta;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,24 @@ namespace l1t {
// Imp1 is for v1 and v2
class CaloStage2ClusterAlgorithmFirmwareImp1 : public CaloStage2ClusterAlgorithm {
public:
CaloStage2ClusterAlgorithmFirmwareImp1(CaloParams* params);
enum ClusterInput{
E = 0,
H = 1,
EH = 2
};

CaloStage2ClusterAlgorithmFirmwareImp1(CaloParams* params, ClusterInput clusterInput);
virtual ~CaloStage2ClusterAlgorithmFirmwareImp1();
virtual void processEvent(const std::vector<l1t::CaloTower> & towers,
std::vector<l1t::CaloCluster> & clusters);
private:
void clustering(const std::vector<l1t::CaloTower> & towers, std::vector<l1t::CaloCluster> & clusters);
void filtering(const std::vector<l1t::CaloTower> & towers, std::vector<l1t::CaloCluster> & clusters);
void sharing(const std::vector<l1t::CaloTower> & towers, std::vector<l1t::CaloCluster> & clusters);
void refining(const std::vector<l1t::CaloTower> & towers, std::vector<l1t::CaloCluster> & clusters);

// parameters
ClusterInput m_clusterInput;
int m_seedThreshold;
int m_clusterThreshold;
CaloParams* params_;
Expand Down
5 changes: 4 additions & 1 deletion L1Trigger/L1TCalorimeter/interface/CaloTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define L1Trigger_L1TCommon_CaloTools_h

#include "DataFormats/L1TCalorimeter/interface/CaloTower.h"
#include "DataFormats/L1TCalorimeter/interface/CaloCluster.h"

namespace l1t {

Expand All @@ -29,7 +30,8 @@ namespace l1t {

enum SubDet{ECAL=0x1,HCAL=0x2,CALO=0x3}; //CALO is a short cut for ECAL|HCAL

static const l1t::CaloTower& getTower(const std::vector<l1t::CaloTower>& towers,int iEta,int iPhi);
static const l1t::CaloTower& getTower(const std::vector<l1t::CaloTower>& towers,int iEta,int iPhi);
static const l1t::CaloCluster& getCluster(const std::vector<l1t::CaloCluster>& clusters,int iEta,int iPhi);

//returns a hash suitable for indexing a vector (note does not check for validity yet of iEta,iPhi)
static size_t caloTowerHash(int iEta,int iPhi);
Expand All @@ -48,6 +50,7 @@ namespace l1t {

private:
static const l1t::CaloTower nullTower_; //to return when we need to return a tower which was not found/invalid rather than throwing an exception
static const l1t::CaloCluster nullCluster_; //to return when we need to return a tower which was not found/invalid rather than throwing an exception
};

}
Expand Down
13 changes: 12 additions & 1 deletion L1Trigger/L1TCalorimeter/src/CaloTools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
#include "L1Trigger/L1TCalorimeter/interface/CaloStage2Nav.h"

const l1t::CaloTower l1t::CaloTools::nullTower_;
const l1t::CaloCluster l1t::CaloTools::nullCluster_;

//currently implimented as a brute force search but this will hopefully change in the future
//currently implemented as a brute force search but this will hopefully change in the future
//with standarising the layout of std::vector<l1t::CaloTower>
const l1t::CaloTower& l1t::CaloTools::getTower(const std::vector<l1t::CaloTower>& towers,int iEta,int iPhi)
{
Expand All @@ -15,6 +16,16 @@ const l1t::CaloTower& l1t::CaloTools::getTower(const std::vector<l1t::CaloTower>
return nullTower_;
}

const l1t::CaloCluster& l1t::CaloTools::getCluster(const std::vector<l1t::CaloCluster>& clusters,int iEta,int iPhi)
{
for(size_t clusterNr=0;clusterNr<clusters.size();clusterNr++){
if(clusters[clusterNr].hwEta()==iEta && clusters[clusterNr].hwPhi()==iPhi) return clusters[clusterNr];
}
return nullCluster_;
}



//this implimentation has not all the necessary info yet, we need to check the exact HF numbering
//(iEta=-28,iPhi=1)=index 0 to (iEta=28,iPhi=72)=index 28*72*2-1
//HF then runs after that so -32,1 = 28*72*2
Expand Down
Loading

0 comments on commit e1b0e5d

Please sign in to comment.