forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
TPC code discussions
sawenzel edited this page Nov 22, 2016
·
1 revision
- write small functions inline in header
- description: The problem is that the compiler cannot inline small functions even from within the same file, if they are part of the (visible) interface of Digitizer
- one could also consider not making some functions part of interface (and not make them link-visible)
- do not return
vector<T>from functions (returnvector<T> &or modify a vector passed by reference to a function) - do not allocate new
vector<T>containers at each step - favour reusing/reseting containers over deleting/recreating
- avoid divisions by constants (often better to define inverse constant and multiply)
- avoid dynamic casting when reading from a TClonesArray (we should make this better by introducing a strongly typed TClonesArray extension)
- use
constkeyword wherever possible- variable that do not change
- functions which do not change member variables
- invariant arguments
-
note that const functions require the
constkeyword after the function:foo() const;
-
note that const functions require the
- consistently use C++11 range based iteration (much less code):
for(auto &hit : mHits)
- avoid division by constants (or constant member variables) in favour of multiplications with cached inverses
- We need to address the question of storage in
std::vector-
std::vector<Hits*>might be very bad (looses all the good stuff of TClonesArray) and leads to many small memory allocations -
std::vector<Hits>might be ok if we use emplace_back and move semantics
-
- does mixing
Float_tandDouble_tmake sense? (example:getTimefunction- this is potentially bad for vectorization
-
getPadResponsedoes not seem to be doing anything with its arguments