GSI Forum
GSI Helmholtzzentrum für Schwerionenforschung

Home » R3BRoot » General Discussions » Changes to Detector Constructors for Simulations
Changes to Detector Constructors for Simulations [message #21323] Thu, 06 July 2017 20:36
Jan Mayer is currently offline  Jan Mayer
Messages: 20
Registered: August 2015
occasional visitor
From: *riken.go.jp
So with PR147 I just broke some of your macros ...
... and I'm not even sorry.

tl;dr: Instead of
R3BDetector* mydet = new R3BMyDetector("someMoreOrLessRandomName", kTRUE);
mydet->SetGeometryFileName("mydetector.geo.root");
run->AddModule(mydet);

you can just do
run->AddModule(R3BMyDetector("mydetector.geo.root"));


The new constructors look, with few exceptions, like:
R3BActar(const TString& geoFile, const TGeoTranslation& trans, const TGeoRotation& rot = TGeoRotation());
R3BActar(const TString& geoFile, const TGeoCombiTrans& combi = TGeoCombiTrans());


Which means the following is valid:
R3BActar("geofile.geo.root"); // Geometry file contains correct position
R3BActor("geofile.geo.root", {0., 0., 200.}); // Base volume is moved by 200cm in z direction
R3BActar("geofile.geo.root", {0., 0., 200.}, { "", -90., +31., 90. }); // // Translaton and Rotation. 

TGeoCombiTrans combitrans;
// ... some complicated movement here
R3BActar("geofile.geo.root", combitrans);

Note that the initializer (and thus the bracket-enclosed initializer-list) for TGeoRotation requires a string, and behaves different from before. e.g. "-90., +31., 90." is equivalent to "RotateY(31)". See changes in macros for examples and the Root Documentation of the TGeo* classes. Setters for translation & rotation are also available.

List of changes:
The main changes are in the constructors of R3BDetector, R3BModule and everything derived from that. Best point to look at is, due to its small number of changes, the dTof detector (R3BdTof.h R3BdTof.cxx).
  • There is no reason having to give the name of the detector in a specialized, derived detector class constructor. A default is provided. If this really needs to be changed, use SetName() before adding it as a module.
  • There is no reason having to specify the "active-ness" of the detector in the constructor. Default is now always true. If it really needs to be inactive, use SetActive(false) before adding it as a module.
  • The most important thing is the geometry file name. Instead of using SetGeometryFile, this is now recommended to do in the constructor.
  • Positioning of the detectors is done via TGeoCombiTrans internally anyway. By providing (constructor and setter) access to this, a lot of overly complicated code could be removed while adding a more flexible way to position detectors.
  • By using constructor delegation, a ton of duplicated code could be removed from the detector constructors. <- This might save you a ton of duplication in all your classes
  • Some code common to all detectors was pulled to the base class or removed.
  • R3BMagnet was changed to `R3BAladinMagnet´ for symmetry reasons.
  • Some macros and all tests were adapted to accommodate these changes
  • Ran clang-format on all files touched. Please always run the autoformatter on your code or at least enable automatic white space trimming in your editor (removes trailing spaces at the end of lines).


Please let me know if you find any issues.
 
Read Message
Previous Topic: CALIFA-SiTracker-GLAD geometry conflict
Next Topic: Problem with loading TVector3 in R3BRoot
Goto Forum:
  


Current Time: Thu Mar 28 12:52:50 CET 2024

Total time taken to generate the page: 0.00939 seconds