Skip to content

Commit

Permalink
Merge pull request cms-sw#8 from mcitron2/l1t-devel-CMSSW_7_1_0_pre2
Browse files Browse the repository at this point in the history
Added total and missing energy sums
  • Loading branch information
jimbrooke committed Mar 24, 2014
2 parents da07c3a + ab3db33 commit 8f2e028
Showing 1 changed file with 48 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


l1t::CaloStage2EtSumAlgorithmFirmwareImp1::CaloStage2EtSumAlgorithmFirmwareImp1(CaloParams* params) :
params_(params)
params_(params)
{


Expand All @@ -23,11 +23,54 @@ l1t::CaloStage2EtSumAlgorithmFirmwareImp1::~CaloStage2EtSumAlgorithmFirmwareImp1

}


void l1t::CaloStage2EtSumAlgorithmFirmwareImp1::processEvent(const std::vector<l1t::CaloTower> & towers,
std::vector<l1t::EtSum> & etsums) {


std::vector<l1t::EtSum> & etsums) {

math::XYZTLorentzVector p4;
int32_t totalEt(0);
float phiMissingEt;
int32_t missingEt;
int32_t coefficientX;
int32_t coefficientY;
int32_t ptTower;
int32_t etXComponent(0);
int32_t etYComponent(0);
int32_t intPhiMissingEt;
const float pi = acos(-1.);
float towerPhi;

for(size_t towerNr=0;towerNr<towers.size();towerNr++)
{
if (abs((towers[towerNr]).hwEta()) > 28) continue;
ptTower = (towers[towerNr]).hwPt();
towerPhi=((towers[towerNr]).hwPhi()*5.0-2.5)*pi/180.;
coefficientX = int32_t(511.*cos(towerPhi));
coefficientY = int32_t(511.*sin(towerPhi));

totalEt += ptTower;
etXComponent += coefficientX*ptTower;
etYComponent += coefficientY*ptTower;
}
phiMissingEt = -atan2(etYComponent,etXComponent);
if(phiMissingEt >= 0)
{
intPhiMissingEt = int32_t((36.*(phiMissingEt)+0.5)/pi);
}
else
{
intPhiMissingEt = int32_t((36.*(phiMissingEt+2.*pi)+0.5)/pi);
}

missingEt =int32_t(sqrt(etXComponent*etXComponent+etYComponent*etYComponent));

l1t::EtSum::EtSumType typeTotalEt = l1t::EtSum::EtSumType::kTotalEt;
l1t::EtSum::EtSumType typeMissingEt = l1t::EtSum::EtSumType::kMissingEt;

l1t::EtSum etSumTotalEt(p4,typeTotalEt,totalEt,0,0,0);
l1t::EtSum etSumMissingEt(p4,typeMissingEt,missingEt,0,intPhiMissingEt,0);

etsums.push_back(etSumTotalEt);
etsums.push_back(etSumMissingEt);

}

0 comments on commit 8f2e028

Please sign in to comment.