Skip to content
This repository has been archived by the owner on Jan 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #32 from usarica/newVH
Browse files Browse the repository at this point in the history
v2.1.2
  • Loading branch information
usarica authored Dec 14, 2017
2 parents 465174c + db98707 commit 14d02de
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 133 deletions.
3 changes: 3 additions & 0 deletions MELA/interface/MELACandidate.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class MELACandidate : public MELAParticle{
const std::vector<MELAParticle*>& getAssociatedJets()const;
const std::vector<MELATopCandidate*>& getAssociatedTops()const;

std::vector<MELAParticle*> getAssociatedSortedVs();
std::vector<MELAParticle*> getAssociatedSortedVs()const;

void getRelatedParticles(std::vector<MELAParticle*>& particles);

TLorentzVector getAlternativeVMomentum(int index)const;
Expand Down
4 changes: 3 additions & 1 deletion MELA/interface/MELAParticle.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class MELAParticle{
std::vector<MELAParticle*>& getDaughters(){ return daughters; }
const std::vector<MELAParticle*>& getMothers()const{ return mothers; }
const std::vector<MELAParticle*>& getDaughters()const{ return daughters; }
bool hasMother(MELAParticle const* part) const;
bool hasDaughter(MELAParticle const* part) const;

double charge()const;
double m()const{ return p4.M(); }
Expand All @@ -84,7 +86,7 @@ class MELAParticle{
MELAParticle& operator+=(const TLorentzVector& mom){ p4 += mom; return *this; }

// Helper functions
static bool checkParticleExists(MELAParticle* myParticle, std::vector<MELAParticle*>& particleArray);
static bool checkParticleExists(MELAParticle const* myParticle, std::vector<MELAParticle*> const& particleArray);
};


Expand Down
26 changes: 26 additions & 0 deletions MELA/src/MELACandidate.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <iterator>
#include <algorithm>
#include <utility>
#include "MELACandidate.h"
Expand Down Expand Up @@ -190,6 +191,31 @@ const std::vector<MELAParticle*>& MELACandidate::getAssociatedPhotons()const{ re
const std::vector<MELAParticle*>& MELACandidate::getAssociatedJets()const{ return associatedJets; }
const std::vector<MELATopCandidate*>& MELACandidate::getAssociatedTops()const{ return associatedTops; }

std::vector<MELAParticle*> MELACandidate::getAssociatedSortedVs(){
std::vector<MELAParticle*> res;
std::vector<MELAParticle*>::iterator itBegin;
std::vector<MELAParticle*>::iterator itEnd=sortedVs.end();
for (std::vector<MELAParticle*>::iterator it=sortedVs.begin(); it!=itEnd; it++){
bool doSkip=false;
for (auto const& dau:sortedDaughters){ if ((*it)->hasDaughter(dau)){ doSkip=true; break; } }
if (!doSkip){ itBegin=it; break; }
}
std::copy(itBegin, itEnd, std::back_inserter(res));
return res;
}
std::vector<MELAParticle*> MELACandidate::getAssociatedSortedVs()const{
std::vector<MELAParticle*> res;
std::vector<MELAParticle*>::const_iterator itBegin;
std::vector<MELAParticle*>::const_iterator itEnd=sortedVs.cend();
for (std::vector<MELAParticle*>::const_iterator it=sortedVs.cbegin(); it!=itEnd; it++){
bool doSkip=false;
for (auto const& dau:sortedDaughters){ if ((*it)->hasDaughter(dau)){ doSkip=true; break; } }
if (!doSkip){ itBegin=it; break; }
}
std::copy(itBegin, itEnd, std::back_inserter(res));
return res;
}

void MELACandidate::sortDaughtersInitial(){
bool beginWithIdPair = (
selfDecayMode==TVar::CandidateDecay_ZZ
Expand Down
7 changes: 5 additions & 2 deletions MELA/src/MELAParticle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ void MELAParticle::getRelatedParticles(std::vector<MELAParticle*>& particles){
if (!checkParticleExists(this, particles)) particles.push_back(this);
}

bool MELAParticle::hasMother(MELAParticle const* part) const{ return MELAParticle::checkParticleExists(part, mothers); }
bool MELAParticle::hasDaughter(MELAParticle const* part) const{ return MELAParticle::checkParticleExists(part, daughters); }

double MELAParticle::charge()const{
double cpos=0;
if (isAWBoson(id) || abs(id)==37 || abs(id)==2212 || abs(id)==211 || abs(id)==321 || abs(id)==411 || abs(id)==521) cpos = 1.;
Expand All @@ -107,7 +110,7 @@ void MELAParticle::boost(const TVector3& vec, bool boostAll){
<< std::endl;
}

bool MELAParticle::checkParticleExists(MELAParticle* myParticle, std::vector<MELAParticle*>& particleArray){
for (auto& part : particleArray){ if (part==myParticle) return true; }
bool MELAParticle::checkParticleExists(MELAParticle const* myParticle, std::vector<MELAParticle*> const& particleArray){
for (MELAParticle* const& part : particleArray){ if (part==myParticle) return true; }
return false;
}
36 changes: 21 additions & 15 deletions MELA/src/Mela.cc
Original file line number Diff line number Diff line change
Expand Up @@ -952,13 +952,15 @@ void Mela::computeP(
}
if (myVerbosity_>=TVar::DEBUG){ // Summarize the integrated particles
MELAout << "Mela::computeP: hs, Phi1 are now " << hs_val << " " << phi1_val << endl;
for (unsigned int idau=0; idau<daughters.size(); idau++){
unsigned int idau=1;
for (SimpleParticle_t const& tmpPart:daughters){
MELAout << "Dau " << idau << " "
<< "id=" << daughters.at(idau).first << " "
<< "x=" << daughters.at(idau).second.X() << " "
<< "y=" << daughters.at(idau).second.Y() << " "
<< "z=" << daughters.at(idau).second.Z() << " "
<< "t=" << daughters.at(idau).second.T() << endl;
<< "id=" << tmpPart.first << " "
<< "x=" << tmpPart.second.X() << " "
<< "y=" << tmpPart.second.Y() << " "
<< "z=" << tmpPart.second.Z() << " "
<< "t=" << tmpPart.second.T() << endl;
idau++;
}
}
vector<MELAParticle*> partList_tmp;
Expand All @@ -977,8 +979,8 @@ void Mela::computeP(
// calculate the ME
ZZME->computeXS(temp_prob);
// Delete the temporary particles
for (unsigned int ic=0; ic<candList_tmp.size(); ic++){ if (candList_tmp.at(ic)!=0) delete candList_tmp.at(ic); } // Only one candidate should really be here
for (unsigned int ip=0; ip<partList_tmp.size(); ip++){ if (partList_tmp.at(ip)!=0) delete partList_tmp.at(ip); }
for (MELACandidate* tmpPart:candList_tmp) delete tmpPart; // Only one candidate should really be here
for (MELAParticle* tmpPart:partList_tmp) delete tmpPart;
setCurrentCandidate(melaCand);
prob += temp_prob;
}
Expand Down Expand Up @@ -1220,13 +1222,17 @@ void Mela::computeProdP(
higgs=melaCand->p4;
if (myProduction_ == TVar::JJQCD || myProduction_ == TVar::JJVBF){
int njets=0;
for (int ip=0; ip<melaCand->getNAssociatedJets(); ip++){
if (melaCand->getAssociatedJet(ip)->passSelection){
njets++;
if (njets==1){
firstJetIndex = ip;
jet1 = melaCand->getAssociatedJet(ip)->p4;
{
int ip=0;
for (MELAParticle* tmpPart:melaCand->getAssociatedJets()){
if (tmpPart->passSelection){
njets++;
if (njets==1){
firstJetIndex = ip;
jet1 = tmpPart->p4;
}
}
ip++;
}
}
if (njets==1){
Expand Down Expand Up @@ -2563,7 +2569,7 @@ MelaPConstant* Mela::getPConstantHandle(
}
if (!inserted) trysqrts.push_back(val);
}
for (auto& dsqrts : trysqrts){
for (auto& dsqrts:trysqrts){
TString strsqrts = Form("%s_%.0f%s", relpath.Data(), dsqrts, "TeV");
cfile_fullpath = path;
cfile_fullpath.append(strsqrts.Data());
Expand Down
15 changes: 3 additions & 12 deletions MELA/src/TEvtProb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -340,22 +340,13 @@ void TEvtProb::ResetInputEvent(){

// Clear bookkeeping objects
// Clean MELACandidates first since they contain all other objects
for (unsigned int p=0; p<candList.size(); p++){
MELACandidate* tmpCand = (MELACandidate*)candList.at(p);
if (tmpCand!=0) delete tmpCand;
}
for (MELACandidate* tmpPart:candList) delete tmpPart;
candList.clear();
// Clean MELATopCandidates next since they contain MELAParticles
for (unsigned int p=0; p<topCandList.size(); p++){
MELATopCandidate* tmpCand = (MELATopCandidate*)topCandList.at(p);
if (tmpCand!=0) delete tmpCand;
}
for (MELATopCandidate* tmpPart:topCandList) delete tmpPart;
topCandList.clear();
// Clean all remaining MELAPArticles
for (unsigned int p=0; p<particleList.size(); p++){
MELAParticle* tmpPart = (MELAParticle*)particleList.at(p);
if (tmpPart!=0) delete tmpPart;
}
for (MELAParticle* tmpPart:particleList) delete tmpPart;
particleList.clear();
}

Expand Down
Loading

0 comments on commit 14d02de

Please sign in to comment.