QwAnalysis
QwDumpGeant4Geometry.cc File Reference
#include <sys/time.h>
#include "QwLog.h"
#include "QwOptions.h"
#include "QwOptionsTracking.h"
#include "QwParameterFile.h"
#include "QwEventBuffer.h"
#include "QwSubsystemArrayTracking.h"
#include "QwSciFiDetector.h"
#include "QwDriftChamberHDC.h"
#include "QwDriftChamberVDC.h"
#include "QwTriggerScintillator.h"
#include "QwMainDetector.h"
#include "QwScanner.h"
#include "QwRaster.h"
+ Include dependency graph for QwDumpGeant4Geometry.cc:

Go to the source code of this file.

Functions

Int_t main (Int_t argc, Char_t *argv[])
 

Function Documentation

Int_t main ( Int_t  argc,
Char_t *  argv[] 
)

First, fill the search paths for the parameter files; this sets a static variable within the QwParameterFile class which will be used by all instances. The "scratch" directory should be first.

Then, we set the command line arguments and the configuration filename, and we define the options that can be used in them (using QwOptions).

false: do not try to add a configuration file with the program name

Define the command line options

Setup screen and file logging

Create the event buffer

Fail when run cannot be found

Set the current event number for parameter file lookup

Load the tracking detectors from file

Get detector geometry

Definition at line 23 of file QwDumpGeant4Geometry.cc.

References QwParameterFile::AppendToSearchPath(), DefineOptionsTracking(), QwLog::endl(), getenv_safe_string(), QwEventBuffer::GetRunNumber(), gQwLog, gQwOptions, QwGeometry::in(), kPackage1, kRegionID2, kRegionID3, kRegionIDTrig, QwOptions::ListConfigFiles(), QwEventBuffer::OpenNextStream(), QwEventBuffer::ProcessOptions(), QwLog::ProcessOptions(), QwMessage, QwOptions::SetCommandLine(), and QwParameterFile::SetCurrentRunNumber().

24 {
25  /// First, fill the search paths for the parameter files; this sets a static
26  /// variable within the QwParameterFile class which will be used by
27  /// all instances.
28  /// The "scratch" directory should be first.
30  QwParameterFile::AppendToSearchPath(getenv_safe_string("QWANALYSIS") + "/Tracking/prminput");
31  QwParameterFile::AppendToSearchPath(getenv_safe_string("QWANALYSIS") + "/Analysis/prminput");
32 
33  /// Then, we set the command line arguments and the configuration filename,
34  /// and we define the options that can be used in them (using QwOptions).
35  ///
36  /// false: do not try to add a configuration file with the program name
37  gQwOptions.SetCommandLine(argc, argv, false);
39 
40  /// Define the command line options
42 
43  /// Setup screen and file logging
45 
46 
47  /// Create the event buffer
48  QwEventBuffer eventbuffer;
49  eventbuffer.ProcessOptions(gQwOptions);
50  /// Fail when run cannot be found
51  if (eventbuffer.OpenNextStream() != CODA_OK) {
52  return -1;
53  }
54  /// Set the current event number for parameter file lookup
56 
57 
58  /// Load the tracking detectors from file
59  QwSubsystemArrayTracking tracking_detectors(gQwOptions);
60  tracking_detectors.ProcessOptions(gQwOptions);
61  /// Get detector geometry
62  QwGeometry geometry = tracking_detectors.GetGeometry();
63  QwMessage << geometry << QwLog::endl;
64 
65 
66 
67  QwMessage << "Copy and paste the following lines in your QwGeant4 session or macro:" << QwLog::endl;
68  QwMessage << "--------------------" << QwLog::endl;
69 
70  // Trigger scintillator
71  QwGeometry trigscint = geometry.in(kPackage1).in(kRegionIDTrig);
72  if (trigscint.size() > 0) {
73  QwMessage << "# Trigger Scintillator" << QwLog::endl;
74  QwMessage << "/TriggerScintillator/SetCenterPositionInX "
75  << trigscint.front()->GetXPosition()
76  << " cm" << QwLog::endl;
77  QwMessage << "/TriggerScintillator/SetCenterPositionInY "
78  << trigscint.front()->GetYPosition()
79  << " cm" << QwLog::endl;
80  QwMessage << "/TriggerScintillator/SetCenterPositionInZ "
81  << trigscint.front()->GetZPosition()
82  << " cm" << QwLog::endl;
83  QwMessage << "/TriggerScintillator/SetTiltingAngle "
84  << trigscint.front()->GetDetectorRollInDeg()
85  << " degree" << QwLog::endl;
87  }
88 
89 
90  // HDC
91  QwGeometry hdc = geometry.in(kPackage1).in(kRegionID2);
92  if (hdc.size() > 0) {
93  QwMessage << "# Horizontal Drift Chamber" << QwLog::endl;
94 
95  QwMessage << "/HDC/SetFrontCenterPositionInX "
96  << (hdc.at(3)->GetXPosition() + hdc.at(2)->GetXPosition()) / 2.0
97  << " cm" << QwLog::endl;
98  QwMessage << "/HDC/SetFrontCenterPositionInY "
99  << (hdc.at(3)->GetYPosition() + hdc.at(2)->GetYPosition()) / 2.0
100  << " cm" << QwLog::endl;
101  QwMessage << "/HDC/SetFrontCenterPositionInZ "
102  << (hdc.at(3)->GetZPosition() + hdc.at(2)->GetZPosition()) / 2.0
103  << " cm" << QwLog::endl;
105 
106  QwMessage << "/HDC/SetBackCenterPositionInX "
107  << (hdc.at(10)->GetXPosition() + hdc.at(9)->GetXPosition()) / 2.0
108  << " cm" << QwLog::endl;
109  QwMessage << "/HDC/SetBackCenterPositionInY "
110  << (hdc.at(10)->GetYPosition() + hdc.at(9)->GetYPosition()) / 2.0
111  << " cm" << QwLog::endl;
112  QwMessage << "/HDC/SetBackCenterPositionInZ "
113  << (hdc.at(10)->GetZPosition() + hdc.at(9)->GetZPosition()) / 2.0
114  << " cm" << QwLog::endl;
116  }
117 
118 
119  // VDC
120  QwGeometry vdc = geometry.in(kPackage1).in(kRegionID3);
121  if (vdc.size() > 0) {
122  QwMessage << "# Vertical Drift Chamber" << QwLog::endl;
123 
124  QwMessage << "/VDC/SetFrontCenterPositionInX "
125  << (vdc.at(1)->GetXPosition() + vdc.at(0)->GetXPosition()) / 2.0
126  << " cm" << QwLog::endl;
127  QwMessage << "/VDC/SetFrontCenterPositionInY "
128  << (vdc.at(1)->GetYPosition() + vdc.at(0)->GetYPosition()) / 2.0
129  << " cm" << QwLog::endl;
130  QwMessage << "/VDC/SetFrontCenterPositionInZ "
131  << (vdc.at(1)->GetZPosition() + vdc.at(0)->GetZPosition()) / 2.0
132  << " cm" << QwLog::endl;
133  QwMessage << "/VDC/DriftCell/SetWireAngleFront "
134  << vdc.at(1)->GetElementAngleInDeg()
135  << " degree" << QwLog::endl;
137 
138  QwMessage << "/VDC/SetBackCenterPositionInX "
139  << (vdc.at(3)->GetXPosition() + vdc.at(2)->GetXPosition()) / 2.0
140  << " cm" << QwLog::endl;
141  QwMessage << "/VDC/SetBackCenterPositionInY "
142  << (vdc.at(3)->GetYPosition() + vdc.at(2)->GetYPosition()) / 2.0
143  << " cm" << QwLog::endl;
144  QwMessage << "/VDC/SetBackCenterPositionInZ "
145  << (vdc.at(3)->GetZPosition() + vdc.at(2)->GetZPosition()) / 2.0
146  << " cm" << QwLog::endl;
147  QwMessage << "/VDC/DriftCell/SetWireAngleBack "
148  << vdc.at(3)->GetElementAngleInDeg()
149  << " degree" << QwLog::endl;
151  }
152 
153  QwMessage << "--------------------" << QwLog::endl;
154 }
#define QwMessage
Predefined log drain for regular messages.
Definition: QwLog.h:50
static void AppendToSearchPath(const TString &searchdir)
Add a directory to the search path.
const QwGeometry in(const EQwRegionID &r) const
Get detectors in given region.
Definition: QwGeometry.h:92
void ProcessOptions(QwOptions &options)
Sets internal flags based on the QwOptions.
Int_t OpenNextStream()
Opens the event stream (file or ET) based on the internal flags.
static void SetCurrentRunNumber(const UInt_t runnumber)
Set the current run number for looking up the appropriate parameter file.
QwOptions gQwOptions
Definition: QwOptions.cc:27
void ProcessOptions(QwOptions *options)
Process class options for QwOptions.
Definition: QwLog.cc:108
void ListConfigFiles()
List the configuration files.
Definition: QwOptions.h:214
Int_t GetRunNumber() const
Return CODA file run number.
Definition: QwEventBuffer.h:80
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
const std::string getenv_safe_string(const char *name)
Definition: QwOptions.h:37
Collection of QwDetectorInfo pointers that specifies an experimental geometry.
Definition: QwGeometry.h:27
void DefineOptionsTracking(QwOptions &options)
QwLog gQwLog
Definition: QwLog.cc:22
void SetCommandLine(int argc, char *argv[], bool default_config_file=true)
Set the command line arguments.
Definition: QwOptions.cc:112

+ Here is the call graph for this function: