Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-18 08:23:38

0001 #include "L1Trigger/L1THGCal/interface/backend/HGCalMulticluster_SA.h"
0002 
0003 #include <cmath>
0004 
0005 using namespace l1thgcfirmware;
0006 
0007 HGCalMulticluster::HGCalMulticluster(const HGCalCluster& tc, float fraction) {
0008   HGCalMulticluster();
0009   addConstituent(tc, true, fraction);
0010 }
0011 
0012 void HGCalMulticluster::addConstituent(const HGCalCluster& tc, bool updateCentre, float fraction) {
0013   // If no constituents, set seedMiptPt to cluster mipPt
0014   if (constituents_.empty()) {
0015     // seedMipPt_ = cMipPt;
0016     if (!updateCentre) {
0017       centre_x_ = tc.x();
0018       centre_y_ = tc.y();
0019       centre_z_ = tc.z();
0020     }
0021   }
0022   // UpdateP4AndPosition
0023   updateP4AndPosition(tc, updateCentre, fraction);
0024 
0025   constituents_.emplace_back(tc);
0026 }
0027 
0028 void HGCalMulticluster::updateP4AndPosition(const HGCalCluster& tc, bool updateCentre, float fraction) {
0029   // Get cluster mipPt
0030   double cMipt = tc.mipPt() * fraction;
0031   double cPt = tc.pt() * fraction;
0032   if (updateCentre) {
0033     float clusterCentre_x = centre_x_ * mipPt_ + tc.x() * cMipt;
0034     float clusterCentre_y = centre_y_ * mipPt_ + tc.y() * cMipt;
0035     float clusterCentre_z = centre_z_ * mipPt_ + tc.z() * cMipt;  // Check this!
0036 
0037     if ((mipPt_ + cMipt) > 0) {
0038       clusterCentre_x /= (mipPt_ + cMipt);
0039       clusterCentre_y /= (mipPt_ + cMipt);
0040       clusterCentre_z /= (mipPt_ + cMipt);
0041     }
0042     centre_x_ = clusterCentre_x;
0043     centre_y_ = clusterCentre_y;
0044     centre_z_ = clusterCentre_z;
0045 
0046     if (centre_z_ != 0) {
0047       centreProj_x_ = centre_x_ / std::abs(centre_z_);
0048       centreProj_y_ = centre_y_ / std::abs(centre_z_);
0049       centreProj_z_ = centre_z_ / std::abs(centre_z_);
0050     }
0051   }
0052 
0053   mipPt_ += cMipt;
0054   sumPt_ += cPt;
0055 }