-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
avoid redundant computations in StripCPE #14344
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,14 +10,15 @@ | |
#include "CondFormats/SiStripObjects/interface/SiStripBackPlaneCorrection.h" | ||
#include "CondFormats/SiStripObjects/interface/SiStripConfObject.h" | ||
#include "CondFormats/SiStripObjects/interface/SiStripLatency.h" | ||
#include <ext/hash_map> | ||
|
||
class StripTopology; | ||
|
||
class StripCPE : public StripClusterParameterEstimator | ||
{ | ||
public: | ||
using StripClusterParameterEstimator::localParameters; | ||
|
||
StripClusterParameterEstimator::LocalValues localParameters( const SiStripCluster& cl, const GeomDetUnit&) const; | ||
StripClusterParameterEstimator::LocalValues localParameters( const SiStripCluster& cl, const GeomDetUnit&) const override; | ||
|
||
StripCPE( edm::ParameterSet & conf, | ||
const MagneticField&, | ||
|
@@ -28,6 +29,45 @@ class StripCPE : public StripClusterParameterEstimator | |
const SiStripLatency&); | ||
LocalVector driftDirection(const StripGeomDetUnit* det) const; | ||
|
||
struct Param { | ||
Param() : topology(nullptr) {} | ||
StripTopology const * topology; | ||
LocalVector drift; | ||
float thickness, invThickness,pitch_rel_err2, maxLength; | ||
int nstrips; | ||
float backplanecorrection; | ||
SiStripDetId::ModuleGeometry moduleGeom; | ||
float coveredStrips(const LocalVector&, const LocalPoint&) const; | ||
}; | ||
|
||
|
||
struct AlgoParam { | ||
Param const & p; const LocalTrajectoryParameters & ltp; | ||
SiStripDetId::SubDetector loc; float afullProjection; float corr; | ||
}; | ||
|
||
|
||
virtual StripClusterParameterEstimator::LocalValues | ||
localParameters( const SiStripCluster& cl, AlgoParam const & ap) const { | ||
return std::make_pair(LocalPoint(), LocalError()); | ||
} | ||
|
||
AlgoParam getAlgoParam(const GeomDetUnit& det, const LocalTrajectoryParameters & ltp) const { | ||
|
||
StripCPE::Param const & p = param(det); | ||
SiStripDetId::SubDetector loc = SiStripDetId( det.geographicalId() ).subDetector(); | ||
|
||
LocalVector track = ltp.momentum(); | ||
track *= -p.thickness/track.z(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this division safe? Could There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. was like this before. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @VinInn: I was thinking of #14306, which is not related to the code in this PR, but fixes a bug with a bad TrajectoryStateOnSurface. I have a faint recollection of seeing similar issues previously. How many paths through the code lead to line 61 above? If you have an idea of how to find them all, we could check that the proper validation is being done in advance. But I would prefer bullet-proof code that never has a possibility to propagate NANs and nonsense values. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to have a more in depth discussion about "FPE" and NaN particularly in the context of vectorization and the future move to vector hardware. We cannot afford to protect each single operation. The current accepted wisdom is to let NaN to propagate and trap it at very high level. Maybe we need to invite an expert and give us a lecture on how one manage this type of issues in HPC. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On 5/6/16 8:44 AM, Vincenzo Innocente wrote:
"A very high level" better be the output of the module or at worst The problem is more complex for utility/tools which are used in many places.
Do you have a name in mind?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very High level is before storing in the event. In any case this code was like this before, so this is not the place to argue about it. We need to investigate. Somebody from Intel or NVidia or a supercomputing center... |
||
|
||
const float fullProjection = p.coveredStrips( track+p.drift, ltp.position()); | ||
|
||
auto const corr = - 0.5f*(1.f-p.backplanecorrection) * fullProjection | ||
+ 0.5f*p.coveredStrips(track, ltp.position()); | ||
|
||
return AlgoParam{p,ltp,loc,std::abs(fullProjection),corr}; | ||
} | ||
|
||
protected: | ||
|
||
const bool peakMode_; | ||
|
@@ -38,16 +78,6 @@ class StripCPE : public StripClusterParameterEstimator | |
std::vector<float> xtalk1; | ||
std::vector<float> xtalk2; | ||
|
||
struct Param { | ||
Param() : topology(nullptr) {} | ||
StripTopology const * topology; | ||
LocalVector drift; | ||
float thickness, invThickness,pitch_rel_err2, maxLength; | ||
int nstrips; | ||
float backplanecorrection; | ||
SiStripDetId::ModuleGeometry moduleGeom; | ||
float coveredStrips(const LocalVector&, const LocalPoint&) const; | ||
}; | ||
Param const & param(const GeomDetUnit& det) const { | ||
return m_Params[det.index()-m_off]; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not
ci - container().begin();
? That would seem to me to be easier for a person to understand.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you have to use
front
becauseconst_iterator
in this class is a pointer and not astd::vector<...>::const_iterator
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to make sure I am using pointers and not iterators.
it is consistent to the implementation few lines above