Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[12_0_X] backport : HF SimHits timing fix #34799

Merged
merged 1 commit into from
Aug 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Geometry/HcalSimData/python/HFParameters_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
ProbMax = cms.double(1.0),
CFibre = cms.double(0.5),
OnlyLong = cms.bool(True),
IgnoreTimeShift = cms.bool(False)
EqualizeTimeShift = cms.bool(False)
)

##
Expand All @@ -34,4 +34,4 @@
##
from Configuration.Eras.Modifier_run3_HFSL_cff import run3_HFSL
run3_HFSL.toModify( HFLibraryFileBlock, FileName = 'SimG4CMS/Calo/data/HFShowerLibrary_run3_v5.root', FileVersion = 1 )
run3_HFSL.toModify( HFShowerBlock, IgnoreTimeShift = True )
run3_HFSL.toModify( HFShowerBlock, EqualizeTimeShift = True )
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@
readoutFrameSize = cms.int32(10),
binOfMaximum = cms.int32(6)
),
hf1 = dict( samplingFactor = 0.35,
timePhase = -6.0
hf1 = dict( samplingFactor = 0.36,
timePhase = 9.0
),
hf2 = dict( samplingFactor = 0.35,
timePhase = -7.0
hf2 = dict( samplingFactor = 0.36,
timePhase = 8.0
)
)

Expand Down
2 changes: 1 addition & 1 deletion SimG4CMS/Calo/interface/HFShower.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class HFShower {

int chkFibre_;
bool applyFidCut_;
bool ignoreTimeShift_;
bool equalizeTimeShift_;
double probMax_;
std::vector<double> gpar_;
};
Expand Down
2 changes: 1 addition & 1 deletion SimG4CMS/Calo/interface/HFShowerLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class HFShowerLibrary {
std::vector<double> pmom;

int fileVersion_;
bool ignoreTimeShift_;
bool equalizeTimeShift_;
double probMax, backProb;
double dphi, rMin, rMax;
std::vector<double> gpar;
Expand Down
2 changes: 1 addition & 1 deletion SimG4CMS/Calo/interface/HFShowerParam.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class HFShowerParam {
std::unique_ptr<HFGflash> gflash_;
bool fillHisto_;
double pePerGeV_, edMin_, ref_index_, aperture_, attLMeanInv_;
bool trackEM_, ignoreTimeShift_, onlyLong_, applyFidCut_, parametrizeLast_;
bool trackEM_, equalizeTimeShift_, onlyLong_, applyFidCut_, parametrizeLast_;
G4int emPDG_, epPDG_, gammaPDG_;
std::vector<double> gpar_;
TH1F *em_long_1_, *em_lateral_1_, *em_long_2_, *em_lateral_2_;
Expand Down
11 changes: 6 additions & 5 deletions SimG4CMS/Calo/src/HFShower.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ HFShower::HFShower(const std::string &name,
edm::ParameterSet m_HF = p.getParameter<edm::ParameterSet>("HFShower");
applyFidCut_ = m_HF.getParameter<bool>("ApplyFiducialCut");
edm::ParameterSet m_HF2 = m_HF.getParameter<edm::ParameterSet>("HFShowerBlock");
ignoreTimeShift_ = m_HF2.getParameter<bool>("IgnoreTimeShift");
equalizeTimeShift_ = m_HF2.getParameter<bool>("EqualizeTimeShift");
probMax_ = m_HF2.getParameter<double>("ProbMax");

edm::LogVerbatim("HFShower") << "HFShower:: Maximum probability cut off " << probMax_ << " Check flag " << chkFibre_
<< " ignoreTimeShift " << ignoreTimeShift_;
<< " EqualizeTimeShift " << equalizeTimeShift_;

cherenkov_ = std::make_unique<HFCherenkov>(m_HF);
fibre_ = std::make_unique<HFFibre>(name, hcalConstant_, hps, p);
Expand Down Expand Up @@ -114,7 +114,8 @@ std::vector<HFShower::Hit> HFShower::getHits(const G4Step *aStep, double weight)
double zCoor = localPos.z();
double zFibre = (0.5 * gpar_[1] - zCoor - translation.z());
double tSlice = (aStep->GetPostStepPoint()->GetGlobalTime());
double time = (ignoreTimeShift_) ? 0 : fibre_->tShift(localPos, depth, chkFibre_);
double time =
(equalizeTimeShift_) ? (fibre_->tShift(localPos, depth, -1)) : (fibre_->tShift(localPos, depth, chkFibre_));

#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HFShower") << "HFShower::getHits: in " << name << " Z " << zCoor << "(" << globalPos.z() << ") "
Expand Down Expand Up @@ -221,7 +222,7 @@ std::vector<HFShower::Hit> HFShower::getHits(const G4Step *aStep, bool forLibrar
double tSlice = (aStep->GetPostStepPoint()->GetGlobalTime());

#ifdef EDM_ML_DEBUG
double time = (ignoreTimeShift_) ? 0 : fibre_->tShift(localPos, depth, chkFibre_);
double time = (equalizeTimeShift_) ? 0 : fibre_->tShift(localPos, depth, chkFibre_);
edm::LogVerbatim("HFShower") << "HFShower::getHits: in " << name << " Z " << zCoor << "(" << globalPos.z() << ") "
<< zFibre << " Trans " << translation << " Time " << tSlice << " " << time
<< "\n Direction " << momentumDir << " Local " << localMom;
Expand Down Expand Up @@ -325,7 +326,7 @@ std::vector<HFShower::Hit> HFShower::getHits(const G4Step *aStep, bool forLibrar
double zCoor = localPos.z();
double zFibre = (0.5 * gpar_[1] - zCoor - translation.z());
double tSlice = (aStep->GetPostStepPoint()->GetGlobalTime());
double time = (ignoreTimeShift_) ? 0 : fibre_->tShift(localPos, depth, chkFibre_);
double time = (equalizeTimeShift_) ? 0 : fibre_->tShift(localPos, depth, chkFibre_);

#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HFShower") << "HFShower::getHits(SL): in " << name << " Z " << zCoor << "(" << globalPos.z() << ") "
Expand Down
9 changes: 5 additions & 4 deletions SimG4CMS/Calo/src/HFShowerLibrary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ HFShowerLibrary::HFShowerLibrary(const std::string& name,
edm::ParameterSet m_HF =
(p.getParameter<edm::ParameterSet>("HFShower")).getParameter<edm::ParameterSet>("HFShowerBlock");
probMax = m_HF.getParameter<double>("ProbMax");
ignoreTimeShift_ = m_HF.getParameter<bool>("IgnoreTimeShift");
equalizeTimeShift_ = m_HF.getParameter<bool>("EqualizeTimeShift");

edm::ParameterSet m_HS =
(p.getParameter<edm::ParameterSet>("HFShowerLibrary")).getParameter<edm::ParameterSet>("HFLibraryFileBlock");
Expand Down Expand Up @@ -113,7 +113,7 @@ HFShowerLibrary::HFShowerLibrary(const std::string& name,
<< " entries\n HFShowerLibrary::No packing information - Assume x, y, z are not in "
"packed form\n Maximum probability cut off "
<< probMax << " Back propagation of light probability " << backProb
<< " Flag for ignoring Time Shift " << ignoreTimeShift_;
<< " Flag for equalizing Time Shift for different eta " << equalizeTimeShift_;

fibre_ = std::make_unique<HFFibre>(name, hcalConstant_, hps, p);
photo = new HFShowerPhotonCollection;
Expand Down Expand Up @@ -298,11 +298,12 @@ std::vector<HFShowerLibrary::Hit> HFShowerLibrary::fillHits(const G4ThreeVector&
#endif
if (rInside(r) && r1 <= exp(-p * zv) && r2 <= probMax * weight && dfir > gpar[5] && zz >= gpar[4] &&
zz <= gpar[4] + gpar[1] && r3 <= backProb && (depth != 2 || zz >= gpar[4] + gpar[0])) {
double tdiff = (ignoreTimeShift_) ? 0 : (fibre_->tShift(lpos, depth, 1));
double tdiff = (equalizeTimeShift_) ? (fibre_->tShift(lpos, depth, -1)) : (fibre_->tShift(lpos, depth, 1));
oneHit.position = pos;
oneHit.depth = depth;
oneHit.time = (tSlice + (pe[i].t()) + tdiff);
hit.push_back(oneHit);

#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HFShower") << "HFShowerLibrary: Final Hit " << nHit << " position " << (hit[nHit].position)
<< " Depth " << (hit[nHit].depth) << " Time " << tSlice << ":" << pe[i].t() << ":"
Expand All @@ -318,7 +319,7 @@ std::vector<HFShowerLibrary::Hit> HFShowerLibrary::fillHits(const G4ThreeVector&
r1 = G4UniformRand();
r2 = G4UniformRand();
if (rInside(r) && r1 <= exp(-p * zv) && r2 <= probMax && dfir > gpar[5]) {
double tdiff = (ignoreTimeShift_) ? 0 : (fibre_->tShift(lpos, 2, 1));
double tdiff = (equalizeTimeShift_) ? (fibre_->tShift(lpos, 2, -1)) : (fibre_->tShift(lpos, 2, 1));
oneHit.position = pos;
oneHit.depth = 2;
oneHit.time = (tSlice + (pe[i].t()) + tdiff);
Expand Down
12 changes: 7 additions & 5 deletions SimG4CMS/Calo/src/HFShowerParam.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ HFShowerParam::HFShowerParam(const std::string& name,
bool useShowerLibrary = m_HF.getParameter<bool>("UseShowerLibrary");
bool useGflash = m_HF.getParameter<bool>("UseHFGflash");
edMin_ = m_HF.getParameter<double>("EminLibrary");
ignoreTimeShift_ = m_HF2.getParameter<bool>("IgnoreTimeShift");
equalizeTimeShift_ = m_HF2.getParameter<bool>("EqualizeTimeShift");
onlyLong_ = m_HF2.getParameter<bool>("OnlyLong");
ref_index_ = m_HF.getParameter<double>("RefIndex");
double lambdaMean = m_HF.getParameter<double>("LambdaMean");
Expand All @@ -52,7 +52,7 @@ HFShowerParam::HFShowerParam(const std::string& name,
<< ", ref. index of fibre " << ref_index_ << ", Track EM Flag " << trackEM_ << ", edMin "
<< edMin_ << " GeV, use of Short fibre info in"
<< " shower library set to " << !(onlyLong_)
<< " ignore flag for time shift in fire is set to " << ignoreTimeShift_
<< " equalize flag for time shift in fibre is set to " << equalizeTimeShift_
<< ", use of parametrization for last part set to " << parametrizeLast_
<< ", Mean lambda " << lambdaMean << ", aperture (cutoff) " << aperture_
<< ", Application of Fiducial Cut " << applyFidCut_;
Expand Down Expand Up @@ -266,7 +266,8 @@ std::vector<HFShowerParam::Hit> HFShowerParam::getHits(const G4Step* aStep, doub
<< "HFShowerParam:Extra exclusion " << r2 << ">" << weight << " " << (r2 > weight);
#endif
if (r2 < weight) {
double time = (ignoreTimeShift_) ? 0 : fibre_->tShift(localPoint, depth, 0);
double time = (equalizeTimeShift_) ? (fibre_->tShift(localPoint, depth, -1))
: (fibre_->tShift(localPoint, depth, 0));

hit.position = hitSL[i].position;
hit.depth = depth;
Expand Down Expand Up @@ -302,7 +303,8 @@ std::vector<HFShowerParam::Hit> HFShowerParam::getHits(const G4Step* aStep, doub
path = "Rest";
edep *= pePerGeV_;
double tSlice = (aStep->GetPostStepPoint()->GetGlobalTime());
double time = (ignoreTimeShift_) ? 0 : fibre_->tShift(localPoint, 1, 0); // remaining part
double time = (equalizeTimeShift_) ? (fibre_->tShift(localPoint, 1, -1))
: (fibre_->tShift(localPoint, 1, 0)); // remaining part
bool ok = true;
if (applyFidCut_) { // @@ For showerlibrary no z-cut for Short (no z)
int npmt = HFFibreFiducial::PMTNumber(hitPoint);
Expand All @@ -328,7 +330,7 @@ std::vector<HFShowerParam::Hit> HFShowerParam::getHits(const G4Step* aStep, doub
}
#endif
if (zz >= gpar_[0]) {
time = (ignoreTimeShift_) ? 0 : fibre_->tShift(localPoint, 2, 0);
time = (equalizeTimeShift_) ? (fibre_->tShift(localPoint, 2, -1)) : (fibre_->tShift(localPoint, 2, 0));
hit.depth = 2;
hit.time = tSlice + time;
hits.push_back(hit);
Expand Down