Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
Update PEC classes to most recent versions
Browse files Browse the repository at this point in the history
This accounts for the changes introduced in commits [1-2].
[1] andrey-popov/PEC-tuples@e24209f
[2] andrey-popov/PEC-tuples@82b2814
  • Loading branch information
andrey-popov committed May 18, 2019
1 parent 336639c commit 1b296ae
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 17 deletions.
23 changes: 18 additions & 5 deletions src/PECReader/GeneratorInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ void pec::GeneratorInfo::Reset()
{
processId = 0;
nominalWeight = 0;
altWeights.clear();
altLheWeights.clear();
altPsWeights.clear();
pdfId = 0;
pdfX[0] = pdfX[1] = 0;
pdfQScale = 0;
Expand All @@ -36,9 +37,15 @@ void pec::GeneratorInfo::SetNominalWeight(float weight)
}


void pec::GeneratorInfo::AddAltWeight(float weight)
void pec::GeneratorInfo::AddAltLheWeight(float weight)
{
altWeights.emplace_back(weight);
altLheWeights.emplace_back(weight);
}


void pec::GeneratorInfo::AddAltPsWeight(float weight)
{
altPsWeights.emplace_back(weight);
}


Expand Down Expand Up @@ -118,9 +125,15 @@ float pec::GeneratorInfo::NominalWeight() const
}


std::vector<Float_t> const &pec::GeneratorInfo::AltWeights() const
std::vector<Float_t> const &pec::GeneratorInfo::AltLheWeights() const
{
return altLheWeights;
}


std::vector<Float_t> const &pec::GeneratorInfo::AltPsWeights() const
{
return altWeights;
return altPsWeights;
}


Expand Down
21 changes: 15 additions & 6 deletions src/PECReader/GeneratorInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ class GeneratorInfo
/// Sets the nominal generator-level weight
void SetNominalWeight(float weight);

/// Adds an alternative generator-level event weight to the end of the collection
void AddAltWeight(float weight);
/// Adds an alternative LHE event weight to the end of the collection
void AddAltLheWeight(float weight);

/// Adds an alternative PS event weight to the end of the collection
void AddAltPsWeight(float weight);

/**
* \brief Sets momentum fraction carried by an initial parton
Expand Down Expand Up @@ -83,8 +86,11 @@ class GeneratorInfo
/// Returns the nominal generator-level weight
float NominalWeight() const;

/// Returns alternative weights
std::vector<Float_t> const &AltWeights() const;
/// Returns alternative LHE weights
std::vector<Float_t> const &AltLheWeights() const;

/// Returns alternative PS weights
std::vector<Float_t> const &AltPsWeights() const;

/**
* \brief Returns momentum fraction carried by an initial parton
Expand All @@ -111,8 +117,11 @@ class GeneratorInfo
/// Nominal generator-level weight
Float_t nominalWeight;

/// Alternative generator-level weights
std::vector<Float_t> altWeights;
/// Alternative LHE weights
std::vector<Float_t> altLheWeights;

/// Alternative PS weights
std::vector<Float_t> altPsWeights;

/// Momenta fractions carried by initial-state partons
Float_t pdfX[2];
Expand Down
12 changes: 7 additions & 5 deletions src/PECReader/PECGeneratorReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ void PECGeneratorReader::BeginRun(Dataset const &dataset)

ROOTLock::Lock();
if (not readAltWeights)
tree->SetBranchStatus("altWeights", false);
tree->SetBranchStatus("altLheWeights", false);

tree->SetBranchStatus("altPsWeights", false);

tree->SetBranchAddress("generator", &bfGeneratorP);
ROOTLock::Unlock();
Expand All @@ -78,16 +80,16 @@ double PECGeneratorReader::GetAltWeight(unsigned index) const
throw std::logic_error(message.str());
}

if (index >= bfGeneratorP->AltWeights().size())
if (index >= bfGeneratorP->AltLheWeights().size())
{
std::ostringstream message;
message << "PECGeneratorReader[\"" << GetName() <<
"\"]::GetAltWeight: Weight with index " << index << " is requested, but only " <<
bfGeneratorP->AltWeights().size() << " weights are available.";
bfGeneratorP->AltLheWeights().size() << " weights are available.";
throw std::logic_error(message.str());
}

return bfGeneratorP->AltWeights()[index];
return bfGeneratorP->AltLheWeights()[index];
}


Expand All @@ -102,7 +104,7 @@ unsigned PECGeneratorReader::GetNumAltWeights() const
if (not readAltWeights)
return 0;
else
return bfGeneratorP->AltWeights().size();
return bfGeneratorP->AltLheWeights().size();
}


Expand Down
1 change: 1 addition & 0 deletions src/PECReader/PECPileUpReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ void PECPileUpReader::BeginRun(Dataset const &)
TTree *tree = inputDataPlugin->ExposeTree(treeName);
ROOTLock::Lock();
tree->SetBranchStatus("inTimeNumPU", false);
tree->SetBranchStatus("maxPtHat", false);
tree->SetBranchAddress("puInfo", &bfPileUpInfoP);
ROOTLock::Unlock();
}
Expand Down
16 changes: 15 additions & 1 deletion src/PECReader/PileUpInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ pec::PileUpInfo::PileUpInfo() noexcept:
numPV(0),
rho(0), rhoCentral(0),
trueNumPU(0),
inTimeNumPU(0)
inTimeNumPU(0),
maxPtHat(0)
{}


Expand All @@ -16,6 +17,7 @@ void pec::PileUpInfo::Reset()
rhoCentral = 0;
trueNumPU = 0;
inTimeNumPU = 0;
maxPtHat = 0;
}


Expand Down Expand Up @@ -49,6 +51,12 @@ void pec::PileUpInfo::SetInTimePU(unsigned n)
}


void pec::PileUpInfo::SetMaxPtHat(float maxPtHat_)
{
maxPtHat = maxPtHat_;
}


unsigned pec::PileUpInfo::NumPV() const
{
return numPV;
Expand Down Expand Up @@ -77,3 +85,9 @@ unsigned pec::PileUpInfo::InTimePU() const
{
return inTimeNumPU;
}


float pec::PileUpInfo::MaxPtHat() const
{
return maxPtHat;
}
18 changes: 18 additions & 0 deletions src/PECReader/PileUpInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ class PileUpInfo
*/
void SetInTimePU(unsigned n);

/**
* \brief Sets the largest ptHat of pile-up interactions in the nominal bunch crossing
*
* The method must be used for simulation only. If an event contains no pileup interactions,
* set the value to zero.
*/
void SetMaxPtHat(float maxPtHat);

/// Returns the number of good reconstructed primary vertices
unsigned NumPV() const;

Expand All @@ -73,6 +81,13 @@ class PileUpInfo
*/
unsigned InTimePU() const;

/**
* \brief Returns the largest ptHat of pile-up interactions in the nominal bunch crossing
*
* Returns a zero in case of real data.
*/
float MaxPtHat() const;

private:
/// Number of good reconstructed primary vertices
UChar_t numPV;
Expand All @@ -93,5 +108,8 @@ class PileUpInfo
* Zero in case of real data.
*/
UChar_t inTimeNumPU;

/// Largest ptHat of admixed in-time pileup interactions
Float_t maxPtHat;
};
} // end of namespace pec

0 comments on commit 1b296ae

Please sign in to comment.