Changes between Version 20 and Version 21 of CodingRules


Ignore:
Timestamp:
11/29/13 10:30:21 (11 years ago)
Author:
tbretz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CodingRules

    v20 v21  
    112112
    113113
     114== ROOT ==
     115
     116Root is sometimes a bit tricky... here are a few coding rules or hints.
     117
     1180. Try to avoid using global pointers (gRandom is an exception)
     1190. *same* is TGraphs is done by omitting the A (A means *with axis*)
     1200. Try to avoid pointers, use objects, except if you add them to a root list.
     1210. Histograms are usually automatically written to open files (it is switched of in the MARS code, but be carefull). Avoid that by removing the histogram from everything after creation: {{{hist.SetDirectory(0)}}}
     1220. Make sure that all objects are properly deleted. E.g. when drawing something with DrawClone like {{{g=graph.DrawClone("AP")}}}, make sure you set the kCanDelete bit with {{{g->SetBit(kCanDelete)}}}. When you draw something with DrawCopy this is done automatically.
     1230. Sometimes graphs are not where they ought to be (usually when you use DrawClone). In this case, add a {{{gROOT->SetSelectedPad(0)}}} before you cd() into the pad you want the graph to appear. Alternatively you can create the Clone() first and add the clone to the pad with {{{gPad->GetListOfPrimitives(clone, draw_options)}}}
     124
     125
     126=== FACT camera display ===
     127
     128{{{#!C++
     129
     130// Create a FACT camera with
     131MGeomCamFACT geom;
     132
     133// Create a display with
     134MHCamera h(geom);
     135
     136// Set value of pixel 0 with
     137h.SetBinContent(1); // (note the +1!)
     138
     139// Enable the display of the pixel with
     140h.SetUsed(0)
     141
     142// Or enable the the display of all pixels with
     143h.SetAllUsed()
     144
     145// Draw display
     146h.DrawCopy();
     147}}}
     148
     149
     150=== Reading a display ===
     151
     152{{{#!C++
     153TFile file("filename.root");
     154if (file.IsZombie())
     155   return;
     156
     157MStatusArray arr;
     158if (arr.Read()<=0)
     159   return;
     160
     161TWhatever *ptr = arr.FindObjectInCanvas("CanvasName", "TWhatever", "ObjectName");
     162if (!ptr)
     163   return;
     164}}}
    114165
    115166
    116167
    117 
    118