Dear ROOTers,
when debugging software, I often come across the issue, that I'd like to make extensive use of histograms to understand some problem in detail, however I'd like to be able to turn off these histograms (because of memory and speed issues) when the same code is used in production.
The obvious solution is to write code along the lines of:
TH3D *h1;
if (debug)
h1 = new TH3D(...);
else
h1 = NULL;
...
if (debug1)
h1->Fill(...);
if (debug2)
h2->Fill(...);
if (debug3)
h3->Fill(...);
...
However, this impairs the readability of the code, especially when large numbers of histograms and different levels of debugging are used.
To my mind, there would be a simple way to improve this. Adding to the top of the THxx::Fill() methods
if (!this) return;
would allow much cleaner code:
h1->Fill(...); h2->Fill(...); h3->Fill(...);
What do you think? Would you accept a patch?
Cheers,
Thiemo
-- +-----------------------------------+--------------------------+Received on Mon Jun 27 2011 - 15:18:54 CEST
| Dipl.-Phys. Thiemo Nagel | |
| Technische Universitaet Muenchen | Room PH1 3276 |
| Physik-Department E18 | |
| James-Franck-Strasse | Phone +49 89 289-12379 |
| D-85747 Garching | Fax +49 89 289-12570 |
+-----------------------------------+--------------------------+
This archive was generated by hypermail 2.2.0 : Mon Jun 27 2011 - 23:50:01 CEST