Skip to content

Commit

Permalink
Merge pull request #187 from jbsauvan/cleaning
Browse files Browse the repository at this point in the history
Cleaning
  • Loading branch information
jbsauvan authored Feb 28, 2018
2 parents 1edf95b + a881c1d commit 99cea22
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 96 deletions.
2 changes: 1 addition & 1 deletion DataFormats/L1THGCal/interface/HGCalTower.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace l1t {
int hwEtHad()const;
int hwEtRatio()const;

const HGCalTower& operator+=(const HGCalTower tower);
HGCalTower& operator+=(const HGCalTower& tower);

private:

Expand Down
6 changes: 3 additions & 3 deletions DataFormats/L1THGCal/interface/HGCalTowerMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace l1t {

public:

HGCalTowerMap(): nEtaBins_(0), nPhiBins_(0), layer_(0) {}
HGCalTowerMap(): nEtaBins_(0), nPhiBins_(0), layer_(0) {}

HGCalTowerMap( int nEtaBins, int nPhiBins );

Expand All @@ -30,13 +30,13 @@ namespace l1t {
int nPhiBins() const { return nPhiBins_; }
const vector<double>& etaBins() const { return etaBins_; }
const vector<double>& phiBins() const { return phiBins_; }
const l1t::HGCalTower& tower(int iEta, int iPhi) { return towerMap_[bin_id(iEta,iPhi)]; }
const l1t::HGCalTower& tower(int iEta, int iPhi) const { return towerMap_.at(bin_id(iEta,iPhi)); }

int iEta(const double eta) const;
int iPhi(const double phi) const;
int layer() const { return layer_;}

const HGCalTowerMap& operator+=(HGCalTowerMap map);
HGCalTowerMap& operator+=(const HGCalTowerMap& map);
void addTower(int iEta, int iPhi, const l1t::HGCalTower& tower) { towerMap_[bin_id(iEta,iPhi)] += tower; }

private:
Expand Down
2 changes: 1 addition & 1 deletion DataFormats/L1THGCal/src/HGCalTower.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ int HGCalTower::hwEtRatio()const



const HGCalTower& HGCalTower::operator+=(const HGCalTower tower){
HGCalTower& HGCalTower::operator+=(const HGCalTower& tower){

if(this->hwEta()!= tower.hwEta() || this->hwPhi()!= tower.hwPhi()){
throw edm::Exception(edm::errors::StdException, "StdException")
Expand Down
2 changes: 1 addition & 1 deletion DataFormats/L1THGCal/src/HGCalTowerMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ int HGCalTowerMap::iPhi(const double phi) const
}


const HGCalTowerMap& HGCalTowerMap::operator+=(HGCalTowerMap map){
HGCalTowerMap& HGCalTowerMap::operator+=(const HGCalTowerMap& map){

if(etaBins_!=map.etaBins() || phiBins_!=map.phiBins()){
throw edm::Exception(edm::errors::StdException, "StdException")
Expand Down
2 changes: 1 addition & 1 deletion L1Trigger/L1THGCal/interface/HGCalTriggerTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class HGCalTriggerTools {
unsigned fhLayers_;
unsigned bhLayers_;
unsigned totalLayers_;
};
};


#endif
178 changes: 89 additions & 89 deletions L1Trigger/L1THGCal/src/be_algorithms/HGCalMulticlusteringImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,97 +149,97 @@ void HGCalMulticlusteringImpl::clusterizeDBSCAN( const std::vector<edm::Ptr<l1t:
const HGCalTriggerGeometryBase & triggerGeometry)
{

std::vector<l1t::HGCalMulticluster> multiclustersTmp;
l1t::HGCalMulticluster mcluTmp;
std::vector<bool> visited(clustersPtrs.size(),false);
std::vector<bool> merged (clustersPtrs.size(),false);
std::vector<std::pair<unsigned int,double>> rankedList;
rankedList.reserve(clustersPtrs.size());
std::vector<std::vector<unsigned int>> neighborList;
neighborList.reserve(clustersPtrs.size());

int iclu = 0, imclu = 0, neighNo;
double dist = 0.;

for(std::vector<edm::Ptr<l1t::HGCalCluster>>::const_iterator clu = clustersPtrs.begin(); clu != clustersPtrs.end(); ++clu, ++iclu){
dist = (*clu)->centreProj().mag()*HGCalDetId((*clu)->detId()).zside();
rankedList.push_back(std::make_pair(iclu,dist));
}
iclu = 0;
std::sort(rankedList.begin(), rankedList.end(), [](auto &left, auto &right) {
return left.second < right.second;
});

for(const auto& cluRanked: rankedList){
std::vector<unsigned int> neighbors;

if(!visited.at(iclu)){
visited.at(iclu) = true;
findNeighbor(rankedList, iclu, clustersPtrs, neighbors);
neighborList.push_back(std::move(neighbors));

if(neighborList.at(iclu).size() >= minNDbscan_) {
multiclustersTmp.emplace_back( clustersPtrs[cluRanked.first] );
merged.at(iclu) = true;
/* dynamic range loop: range-based loop syntax cannot be employed */
for(unsigned int neighInd = 0; neighInd < neighborList.at(iclu).size(); neighInd++){
neighNo = neighborList.at(iclu).at(neighInd);
/* This condition also ensures merging of clusters visited by other clusters but not merged. */
if(!merged.at(neighNo) ){
merged.at(neighNo) = true;
multiclustersTmp.at(imclu).addConstituent( clustersPtrs[rankedList.at(neighNo).first] );

if(!visited.at(neighNo)){
visited.at(neighNo) = true;
std::vector<unsigned int> secNeighbors;
findNeighbor(rankedList, neighNo,clustersPtrs, secNeighbors);

if(secNeighbors.size() >= minNDbscan_){
neighborList.at(iclu).insert(neighborList.at(iclu).end(), secNeighbors.begin(), secNeighbors.end());
}
std::vector<l1t::HGCalMulticluster> multiclustersTmp;
l1t::HGCalMulticluster mcluTmp;
std::vector<bool> visited(clustersPtrs.size(),false);
std::vector<bool> merged (clustersPtrs.size(),false);
std::vector<std::pair<unsigned int,double>> rankedList;
rankedList.reserve(clustersPtrs.size());
std::vector<std::vector<unsigned int>> neighborList;
neighborList.reserve(clustersPtrs.size());

int iclu = 0, imclu = 0, neighNo;
double dist = 0.;

for(std::vector<edm::Ptr<l1t::HGCalCluster>>::const_iterator clu = clustersPtrs.begin(); clu != clustersPtrs.end(); ++clu, ++iclu){
dist = (*clu)->centreProj().mag()*HGCalDetId((*clu)->detId()).zside();
rankedList.push_back(std::make_pair(iclu,dist));
}
iclu = 0;
std::sort(rankedList.begin(), rankedList.end(), [](auto &left, auto &right) {
return left.second < right.second;
});

for(const auto& cluRanked: rankedList){
std::vector<unsigned int> neighbors;

if(!visited.at(iclu)){
visited.at(iclu) = true;
findNeighbor(rankedList, iclu, clustersPtrs, neighbors);
neighborList.push_back(std::move(neighbors));

if(neighborList.at(iclu).size() >= minNDbscan_) {
multiclustersTmp.emplace_back( clustersPtrs[cluRanked.first] );
merged.at(iclu) = true;
/* dynamic range loop: range-based loop syntax cannot be employed */
for(unsigned int neighInd = 0; neighInd < neighborList.at(iclu).size(); neighInd++){
neighNo = neighborList.at(iclu).at(neighInd);
/* This condition also ensures merging of clusters visited by other clusters but not merged. */
if(!merged.at(neighNo) ){
merged.at(neighNo) = true;
multiclustersTmp.at(imclu).addConstituent( clustersPtrs[rankedList.at(neighNo).first] );

if(!visited.at(neighNo)){
visited.at(neighNo) = true;
std::vector<unsigned int> secNeighbors;
findNeighbor(rankedList, neighNo,clustersPtrs, secNeighbors);

if(secNeighbors.size() >= minNDbscan_){
neighborList.at(iclu).insert(neighborList.at(iclu).end(), secNeighbors.begin(), secNeighbors.end());
}
}
}
}
imclu++;
}
}
}
imclu++;
}
else neighborList.push_back(std::move(neighbors));
iclu++;
}
else neighborList.push_back(std::move(neighbors));
iclu++;
}
/* making the collection of multiclusters */
for( unsigned i(0); i<multiclustersTmp.size(); ++i ){

// compute the eta, phi observables for multicluster starting from its barycenter x,y,z position + pT as scalar sum of pT of constituents
double sumPt=0.;

const std::vector<edm::Ptr<l1t::HGCalCluster>> &pertinentClu = multiclustersTmp.at(i).constituents();
for( std::vector<edm::Ptr<l1t::HGCalCluster>>::const_iterator it_clu=pertinentClu.begin(); it_clu<pertinentClu.end(); it_clu++) sumPt +=(*it_clu)->pt();

math::PtEtaPhiMLorentzVector multiclusterP4( sumPt,
multiclustersTmp.at(i).centre().eta(),
multiclustersTmp.at(i).centre().phi(),
0. );
multiclustersTmp.at(i).setP4( multiclusterP4 );


if( multiclustersTmp.at(i).pt() > ptC3dThreshold_ ){

//compute shower shape
multiclustersTmp.at(i).showerLength(shape_.showerLength(multiclustersTmp.at(i)));
multiclustersTmp.at(i).coreShowerLength(shape_.coreShowerLength(multiclustersTmp.at(i), triggerGeometry));
multiclustersTmp.at(i).firstLayer(shape_.firstLayer(multiclustersTmp.at(i)));
multiclustersTmp.at(i).maxLayer(shape_.maxLayer(multiclustersTmp.at(i)));
multiclustersTmp.at(i).sigmaEtaEtaTot(shape_.sigmaEtaEtaTot(multiclustersTmp.at(i)));
multiclustersTmp.at(i).sigmaEtaEtaMax(shape_.sigmaEtaEtaMax(multiclustersTmp.at(i)));
multiclustersTmp.at(i).sigmaPhiPhiTot(shape_.sigmaPhiPhiTot(multiclustersTmp.at(i)));
multiclustersTmp.at(i).sigmaPhiPhiMax(shape_.sigmaPhiPhiMax(multiclustersTmp.at(i)));
multiclustersTmp.at(i).sigmaZZ(shape_.sigmaZZ(multiclustersTmp.at(i)));
multiclustersTmp.at(i).sigmaRRTot(shape_.sigmaRRTot(multiclustersTmp.at(i)));
multiclustersTmp.at(i).sigmaRRMax(shape_.sigmaRRMax(multiclustersTmp.at(i)));
multiclustersTmp.at(i).sigmaRRMean(shape_.sigmaRRMean(multiclustersTmp.at(i)));
multiclustersTmp.at(i).eMax(shape_.eMax(multiclustersTmp.at(i)));

multiclusters.push_back( 0, multiclustersTmp.at(i));
/* making the collection of multiclusters */
for( unsigned i(0); i<multiclustersTmp.size(); ++i ){

// compute the eta, phi observables for multicluster starting from its barycenter x,y,z position + pT as scalar sum of pT of constituents
double sumPt=0.;

const std::vector<edm::Ptr<l1t::HGCalCluster>> &pertinentClu = multiclustersTmp.at(i).constituents();
for( std::vector<edm::Ptr<l1t::HGCalCluster>>::const_iterator it_clu=pertinentClu.begin(); it_clu<pertinentClu.end(); it_clu++) sumPt +=(*it_clu)->pt();

math::PtEtaPhiMLorentzVector multiclusterP4( sumPt,
multiclustersTmp.at(i).centre().eta(),
multiclustersTmp.at(i).centre().phi(),
0. );
multiclustersTmp.at(i).setP4( multiclusterP4 );


if( multiclustersTmp.at(i).pt() > ptC3dThreshold_ ){

//compute shower shape
multiclustersTmp.at(i).showerLength(shape_.showerLength(multiclustersTmp.at(i)));
multiclustersTmp.at(i).coreShowerLength(shape_.coreShowerLength(multiclustersTmp.at(i), triggerGeometry));
multiclustersTmp.at(i).firstLayer(shape_.firstLayer(multiclustersTmp.at(i)));
multiclustersTmp.at(i).maxLayer(shape_.maxLayer(multiclustersTmp.at(i)));
multiclustersTmp.at(i).sigmaEtaEtaTot(shape_.sigmaEtaEtaTot(multiclustersTmp.at(i)));
multiclustersTmp.at(i).sigmaEtaEtaMax(shape_.sigmaEtaEtaMax(multiclustersTmp.at(i)));
multiclustersTmp.at(i).sigmaPhiPhiTot(shape_.sigmaPhiPhiTot(multiclustersTmp.at(i)));
multiclustersTmp.at(i).sigmaPhiPhiMax(shape_.sigmaPhiPhiMax(multiclustersTmp.at(i)));
multiclustersTmp.at(i).sigmaZZ(shape_.sigmaZZ(multiclustersTmp.at(i)));
multiclustersTmp.at(i).sigmaRRTot(shape_.sigmaRRTot(multiclustersTmp.at(i)));
multiclustersTmp.at(i).sigmaRRMax(shape_.sigmaRRMax(multiclustersTmp.at(i)));
multiclustersTmp.at(i).sigmaRRMean(shape_.sigmaRRMean(multiclustersTmp.at(i)));
multiclustersTmp.at(i).eMax(shape_.eMax(multiclustersTmp.at(i)));

multiclusters.push_back( 0, multiclustersTmp.at(i));
}
}
}
}

0 comments on commit 99cea22

Please sign in to comment.