QwAnalysis
QwDumpGeant4Geometry.cc
Go to the documentation of this file.
1 // C and C++ headers
2 #include <sys/time.h>
3 
4 // Qweak headers
5 #include "QwLog.h"
6 #include "QwOptions.h"
7 #include "QwOptionsTracking.h"
8 #include "QwParameterFile.h"
9 #include "QwEventBuffer.h"
10 
11 // Qweak tracking subsystems
13 #include "QwSciFiDetector.h"
14 #include "QwDriftChamberHDC.h"
15 #include "QwDriftChamberVDC.h"
16 #include "QwTriggerScintillator.h"
17 #include "QwMainDetector.h"
18 #include "QwScanner.h"
19 #include "QwRaster.h"
20 
21 
22 // Main function
23 Int_t main(Int_t argc, Char_t* argv[])
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.
Load the options for the tracking subsystems.
static void SetCurrentRunNumber(const UInt_t runnumber)
Set the current run number for looking up the appropriate parameter file.
This is the main executable for the tracking analysis.
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
A logfile class, based on an identical class in the Hermes analyzer.
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
An options class which parses command line, config file and environment.
int main(int argc, char **argv)
Definition: QwRoot.cc:20
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