Opened 12 years ago
Closed 12 years ago
#49 closed Task (fixed)
math related suggestions
Reported by: | Pavel Demin | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | Delphes code | Version: | |
Keywords: | Cc: |
Description (last modified by )
Looking at the Delphes code, I've noticed a couple of things that could be improved:
- Most of the underlying libraries operate with double precision numbers. However in Delphes, some variables are single precision. Should not we switch to double for all variables?
- There are at least 13 calls to something like
sqrt(pow(x,2), pow(y,2))
. As most of them are inside loops, it would be better to replace them withhypot(x, y)
. Here is a command to find corresponding lines:grep -r "sqrt( *pow" trunk/* | grep c:
- A strange pi constant is defined as 3.14159265358979312 in
interface/D_Constants.h
and inUtilities/Fastjet/plugins/CDFCones/interface/CalTower.hh
. Normally, it should be 3.14159265358979323846. Moreover M_PI is already defined inmath.h
, pi and twopi are defined inUtilities/CLHEP/Units/PhysicalConstants.h
. It would be better to use definitions fromPhysicalConstants.h
.
Change History (9)
comment:1 by , 12 years ago
Description: | modified (diff) |
---|
comment:2 by , 12 years ago
Description: | modified (diff) |
---|
comment:3 by , 12 years ago
Description: | modified (diff) |
---|
comment:4 by , 12 years ago
comment:5 by , 12 years ago
Nice work !
I think binetaphi is very badly written. in:
https://server06.fynu.ucl.ac.be/projects/delphes/browser/trunk/src/SmearUtil.cc#L1536
We see that a loop is used to see in which phi region the particle falls. As all regions have equal phi size, i suggest we get it directly as:
int((pi+phi)/dphi)*dphi + dphi/2.
or something like that.
I think we have to keep the eta loop as all cells can have different eta size.
comment:6 by , 12 years ago
Looking at the at the calorimeter related code it occurred to me that we could use a 2D histogram TH2D
with variable bin sizes. Then filling the towers will become:
towers.Fill(eta, phi, E)
Or at least we should use TMath::BinarySearch
when filling calorimeter towers.
comment:7 by , 12 years ago
Looks like it would be possible to eliminate 90% of DeltaR/DeltaPhi
calls buy storing initial number of tracks associated with a tower. This could be done via PseudoJet::set_user_index
method. Then number of tracks within a jet can be calculated as a sum of all _user_indexes from all jet's constituents.
comment:8 by , 12 years ago
in the same binetaphi function, the last line computing the phi is wrong, it should be corrected in the rewrite of the function.
comment:9 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
These issues are fixed in Delphes 3.
I've run Delphes through a profiler and it found some hot spots:
BinEtaPhi
andDeltaR
are fromsrc/SmearUtil.cc
.DeltaR
is easy to optimize:DeltaPhi
sqrt(pow...
with hypotHere are profiler results ater the modification:
I'll check if anything could be done with
BinEtaPhi
.