Skip to content

TPC code discussions

sawenzel edited this page Nov 22, 2016 · 1 revision

Notes on TPC Digitization

General recommendations

  • 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 (return vector<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 const keyword wherever possible
    • variable that do not change
    • functions which do not change member variables
    • invariant arguments
      • note that const functions require the const keyword after the function: foo() const;
  • 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

Questions:

  • does mixing Float_t and Double_t make sense? (example: getTime function
    • this is potentially bad for vectorization
  • getPadResponse does not seem to be doing anything with its arguments

Clone this wiki locally