1 #ifndef __JDETECTOR__JDETECTORTOOLKIT__
2 #define __JDETECTOR__JDETECTORTOOLKIT__
33 namespace JDETECTOR {}
34 namespace JPP {
using namespace JDETECTOR; }
77 for (JDetector::const_iterator i = detector.begin(); i != detector.end(); ++i) {
78 for (JDetector::const_iterator j = detector.begin(); j != i; ++j) {
79 if (i->getDistance(*j) > dmax) {
80 dmax = i->getDistance(*j);
97 const double phi = atan2(dir.
getDY(), dir.
getDZ())*(180.0/
PI);
116 return asin(-dir.
getDX())*(180.0/
PI);
132 const JCylinder3D cylinder(detector.begin(), detector.end());
144 const double WorldBoxHeight = 2200.;
147 const double Crust_Z_size = WorldBoxHeight/2;
149 const double Crust_Z_position= -WorldBoxHeight/4;
152 out<<
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<gdml xmlns:gdml=\"http://cern.ch/2001/Schemas/GDML\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"/afs/cern.ch/sw/geant4/releases/share/geant4.9.5/source/persistency/gdml/schema/gdml.xsd\">\n\n\n";
154 out<<
"<rotation name=\"identity\"/>\n<position name=\"zero\"/>\n";
157 for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
162 out<<
"<position name=\"PosString"<<module->getString()<<
"_Dom"<<module->getID()<<
"\" unit=\"m\" x=\""<<module->
getX()<<
"\" y=\""<<module->getY()<<
"\" z=\""<<module->getZ()<<
"\"/>\n";
164 for (JModule::const_iterator pmt = module->begin(); pmt != module->end(); ++pmt) {
169 out<<
"<position name=\"CathodPosition"<<pmt->getID()<<
"_"<<module->getID()<<
"\" unit=\"m\" x=\""<<vec.
getX()<<
"\" y=\""<<vec.
getY()<<
"\" z=\""<<vec.
getZ()<<
"\"/>\n";
170 out<<
"<rotation name=\"CathodRotation"<<pmt->getID()<<
"_"<<module->getID()<<
"\" unit=\"deg\" x=\""<<
GetXrotationG4(*pmt)<<
"\" y=\""<<
GetYrotationG4(*pmt)<<
"\" z=\"0.000000\"/>\n";
171 out<<
"<constant name=\"CathodID_"<<PMTs_NO<<
"\" value=\""<<pmt->getID()<<
"\"/>\n";
177 out<<
"<position name=\"OMShift\" unit=\"m\" x=\"0\" y=\"0\" z=\"0.0392\"/>\n";
179 out<<
"<!-- end of DU position definitions -->\n<position name=\"CrustPosition\" unit=\"m\" x=\"0\" y=\"0\" z=\""<<Crust_Z_position<<
"\"/>\n";
182 out<<
"<materials>\n";
183 out<<
"</materials>\n";
185 out<<
" <box name=\"WorldBox\" lunit=\"m\" x=\"2200\" y=\"2200\" z=\"2200\"/>\n";
186 out<<
" <box name=\"CrustBox\" lunit=\"m\" x=\"2200\" y=\"2200\" z=\""<<Crust_Z_size<<
"\"/>\n";
187 out<<
" <box name=\"StoreyBox\" lunit=\"m\" x=\"0.6\" y=\"0.6\" z=\"0.6\"/>\n";
188 out<<
" <sphere name=\"OMSphere\" lunit=\"cm\" aunit=\"deg\" rmin=\"0.0\" rmax=\"21.6\" startphi=\"0.0\" deltaphi=\"360.0\" starttheta=\"0.0\" deltatheta=\"180.0\"/>\n";
189 out<<
" <tube name=\"CathodTube\" lunit=\"cm\" aunit=\"deg\" rmin=\"0.0\" rmax=\"4.7462\" z=\"0.5\" startphi=\"0.0\" deltaphi=\"360.0\"/>\n";
190 out<<
"</solids>\n\n\n";
192 out<<
"<structure>\n";
193 out<<
" <volume name=\"CathodVolume\">\n";
194 out<<
" <materialref ref=\"Cathod\"/>\n";
195 out<<
" <solidref ref=\"CathodTube\"/>\n";
198 out<<
"<!-- OMVolume(s) construction -->\n";
200 for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
202 out<<
" <volume name=\"OMVolume"<<module->getID()<<
"\">\n";
203 out<<
" <materialref ref=\"Water\"/>\n";
204 out<<
" <solidref ref=\"OMSphere\"/>\n";
206 for (JModule::const_iterator pmt = module->begin(); pmt != module->end(); ++pmt) {
208 out<<
" <volumeref ref=\"CathodVolume\"/>\n";
209 out<<
" <positionref ref=\"CathodPosition"<<pmt->getID()<<
"_"<<module->getID()<<
"\"/>\n";
210 out<<
" <rotationref ref=\"CathodRotation"<<pmt->getID()<<
"_"<<module->getID()<<
"\"/>\n";
211 out<<
" </physvol>\n";
217 out<<
"<!-- StoreyVolume(s) construction -->\n";
219 for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
220 out<<
" <volume name=\"StoreyVolume"<<module->getID()<<
"\">\n";
221 out<<
" <materialref ref=\"Water\"/>\n";
222 out<<
" <solidref ref=\"StoreyBox\"/>\n";
224 out<<
" <volumeref ref=\"OMVolume"<<module->getID()<<
"\"/>\n";
225 out<<
" <positionref ref=\"OMShift\"/>\n";
227 out<<
" <rotationref ref=\"identity\"/>\n";
228 out<<
" </physvol>\n";
232 out<<
"<!-- Crust Volume construction-->\n";
233 out<<
"<volume name=\"CrustVolume\">\n";
234 out<<
" <materialref ref=\"Crust\"/>\n";
235 out<<
" <solidref ref=\"CrustBox\"/>\n";
238 out<<
"<!-- World Volume construction-->\n";
239 out<<
"<volume name=\"WorldVolume\">\n";
240 out<<
" <materialref ref=\"Water\"/>\n";
241 out<<
" <solidref ref=\"WorldBox\"/>\n";
244 out<<
" <volumeref ref=\"CrustVolume\"/>\n";
245 out<<
" <positionref ref=\"CrustPosition\"/>\n";
246 out<<
" <rotationref ref=\"identity\"/>\n";
247 out<<
" </physvol>\n";
249 for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
251 out<<
" <volumeref ref=\"StoreyVolume"<<module->getID()<<
"\"/>\n";
252 out<<
" <positionref ref=\"PosString"<< module->getString() <<
"_Dom"<< module->getID() <<
"\"/>\n";
254 out<<
" <rotationref ref=\"identity\"/>\n";
255 out<<
" </physvol>\n";
260 out<<
"</structure>\n";
261 out<<
"<setup name=\"Default\" version=\"1.0\">\n";
262 out<<
"<world ref=\"WorldVolume\"/>\n";
309 if (!module.empty()) {
313 for (JModule::const_iterator pmt = module.begin(); pmt != module.end(); ++pmt) {
317 time_range.include(
putTime(timeRange.getLowerLimit(), calibration));
318 time_range.include(
putTime(timeRange.getUpperLimit(), calibration));
338 return module.size();
350 int number_of_pmts = 0;
352 for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
356 return number_of_pmts;
370 for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
371 buffer.insert(module->getString());
374 return buffer.size();
388 for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
389 buffer.insert(module->getString());
406 for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
407 buffer.insert(module->getFloor());
410 return buffer.size();
424 for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
425 buffer.insert(module->getID());
428 return buffer.size();
453 ifstream in(file_name.c_str());
463 detector.swap(buffer);
479 ifstream in(file_name.c_str());
535 std::ofstream out(file_name.c_str());
551 std::ofstream out(file_name.c_str());
583 module.resize(memo.size());
644 if (module.empty()) {
648 const double R = 0.5;
650 const double st = sin(0.75*
PI);
651 const double ct = cos(0.75*
PI);
653 for (
int i = 0; i != 3; ++i) {
655 const double phi = (2.0*
PI*i) / 3.0;
656 const double cp = cos(phi);
657 const double sp = sin(phi);
675 os <<
"DU" << setfill(
'0') << setw(3) << location.
getString();
676 os <<
"F" << setfill(
'0') << setw(2) << location.
getFloor();
Exception for opening of file.
double GetYrotationG4(const JVersor3D dir)
Get rotation over Y axis in Geant4 coordinate system.
Wrapper class around STL string class.
Data structure for a composite optical module.
Logical location of module.
int getNumberOfStrings(const JDetector &detector)
Get number of strings.
const JCalibration & getCalibration() const
Get calibration.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
std::set< int > getStringIDs(const JDetector &detector)
Get list of strings IDs.
virtual JWriter & write(JWriter &out) const
Write to output.
int getNumberOfPMTs(const JModule &module)
Get number of PMTs.
virtual JReader & read(JReader &in)
Read from input.
Data structure for PMT calibration.
Data structure for detector geometry and calibration.
Data structure for position fit.
bool endsWith(const std::string &suffix) const
Test if this string ends with the specified suffix.
JTimeRange getTimeRange(const Evt &event)
Get time range (i.e.
Monte Carlo detector (i.e.
int getFloor() const
Get floor number.
int getString() const
Get string number.
Lookup table for PMT addresses in optical module.
double putTime(const T &t1, const JCalibration &cal)
Get de-calibrated time.
JVector3D & sub(const JVector3D &vector)
Subtract vector.
double getMaximalDistance(const JDetector &detector)
Get maximal distance between modules in detector.
Data structure for vector in three dimensions.
double getDY() const
Get y direction.
double getDX() const
Get x direction.
void setLocation(const JModuleLocation &location)
Set location.
Data structure for PMT geometry and calibration.
int getNumberOfFloors(const JDetector &detector)
Get number of floors.
double getY() const
Get y position.
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
double getMaximalTime(const JDetector &detector)
Get maximal time between modules in detector following causality.
static const char *const KM3NET_DETECTOR_FILE_FORMAT
KM3NeT standard ASCII format.
std::string getModuleLabel(const JModuleLocation &location)
Get module label (DU-floor) for JMonitor applications.
static const char *const ZIPPED_DETECTOR_FILE_FORMAT
zipped KM3NeT standard ASCII format
Linear fit of JFIT::JPoint3D.
static const char *const GENDET_DETECTOR_FILE_FORMAT
File name extensions.
static const char *const BINARY_DETECTOR_FILE_FORMAT
JIO binary file format.
void setID(const int id)
Set identifier.
double getX() const
Get x position.
void store(const JString &file_name, const JDetector &detector)
Store detector to output file.
Data structure for normalised vector in three dimensions.
void read_gdml(std::istream &, const JDetector &)
Binary buffered file output.
int getNumberOfModules(const JDetector &detector)
Get number of modules.
Linear fit of crossing point (position) between axes (objects with position and direction).
double GetXrotationG4(const JVersor3D dir)
Get rotation over X axis in Geant4 coordinate system.
static const char *const GDML_DETECTOR_FILE_FORMAT
KM3Sim input format.
double getZ() const
Get z position.
Binary buffered file input.
bool has(const int index) const
Test whether index is available.
double getDZ() const
Get z direction.
const JModule & getModule(const JDetector &detector, const JModuleLocation &location)
find module with a given string and floor number
Logical location of module.
void write_gdml(std::ostream &out, const JDetector &detector)
Writes KM3Sim GDML input file from detector.