Commit 142b2485 authored by Whitney Armstrong's avatar Whitney Armstrong
Browse files

Merge branch 'tooling'

parents b3eeb38a c57bf2ee
......@@ -19,5 +19,4 @@ compile:
# - make -j4
job2:
script: "ls -lrth"
......@@ -10,7 +10,24 @@ dd4hep_package (${a_lib_name} MAJOR 0 MINOR 0 PATCH 1
INCLUDE_DIRS include
)
dd4hep_add_plugin(${a_lib_name} SOURCES src/*.cpp)
dd4hep_add_plugin(${a_lib_name}
SOURCES src/*.cpp
NOINSTALL
)
target_compile_features(${a_lib_name}
PUBLIC cxx_auto_type
PUBLIC cxx_trailing_return_types
PRIVATE cxx_variadic_templates
PRIVATE cxx_std_14
)
install(TARGETS ${a_lib_name}
EXPORT NPDetTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
#-----------------------------------------------------------------------------------
install(DIRECTORY compact/
......
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
###################
# CLHEP
set (CLHEP_CONFIG_DEBUG 1)
find_package(CLHEP REQUIRED)
# CLHEP_INCLUDE_DIRS - include directories for CLHEP
# CLHEP_DEFINITIONS - compile definitions needed to use CLHEP
# CLHEP_LIBRARIES - libraries to link against
include_directories(${CLHEP_INCLUDE_DIRS})
add_definitions(${CLHEP_DEFINITIONS})
link_directories(${CLHEP_LIBRARY_DIR})
#link_libraries(CLHEP) # ${ClasDigi_LIBRARIES}
#message(" CLHEP_DEFINITIONS = ${CLHEP_DEFINITIONS} " )
#set(C12SIM_LINK_LIBRARIES ${C12SIM_LINK_LIBRARIES} ${CLHEP_LIBRARIES})
###################
# ClasDigi
find_package(ClasDigi REQUIRED)
include(${ClasDigi_USE_FILE})
#add_definitions()
include_directories(${ClasDigi_INCLUDE_DIRS})
#R1_points2set(C12SIM_LINK_LIBRARIES ${C12SIM_LINK_LIBRARIES} ${ClasDigi_LIBRARIES})
link_directories(${ClasDigi_LIBRARY_DIR})
link_libraries(ClasGeo CLHEP) # ${ClasDigi_LIBRARIES}
FIND_PACKAGE(DD4hep REQUIRED COMPONENTS DDRec DDG4)
if( DD4hep_CMAKE_FILES_PATH )
include ( ${DD4hep_CMAKE_FILES_PATH}/DD4hep.cmake )
else()
include ( ${DD4hep_DIR}/cmake/DD4hep.cmake )
endif()
# see https://rix0r.nl/blog/2015/08/13/cmake-guide/
# Must use GNUInstallDirs to install libraries into correct
# locations on all platforms.
include(GNUInstallDirs)
#-----------------------------------------------------------------------------------
SET(a_lib_name clas12 )
set(ALIB clas12)
dd4hep_configure_output()
dd4hep_package (${a_lib_name} MAJOR 0 MINOR 0 PATCH 1
USES [ROOT REQUIRED COMPONENTS Geom GenVector ClasGeo]
[DD4hep REQUIRED COMPONENTS DDCore DDRec]
OPTIONAL XERCESC
INCLUDE_DIRS include )
dd4hep_package(${ALIB} MAJOR ${NPDet_VERSION_MAJOR} MINOR ${NPDet_VERSION_MINOR} PATCH ${NPDet_VERSION_PATCH}
USES [ROOT REQUIRED COMPONENTS Geom GenVector]
[DD4hep REQUIRED COMPONENTS DDCore DDRec]
OPTIONAL XERCESC
INCLUDE_DIRS include
NOINSTALL
)
#-----------------------------------------------------------------------------------
dd4hep_add_plugin(${a_lib_name} SOURCES src/*.cpp)
#dd4hep_install_dir(compact DESTINATION ${DD4hep_DIR}/examples/ClientTests)
#-----------------------------------------------------------------------------------
dd4hep_add_plugin(${ALIB}
SOURCES
src/ALERTRecoilChamber.cpp
src/ALERTRecoilChamber_geo.cpp
src/DCGeometry.cxx
src/DCWire.cxx
src/GeoUtil.cxx
src/RCGeometry.cxx
src/RCWire.cxx
src/RHGeometry.cxx
src/StandInGeometryCLAS12_geo.cpp
NOINSTALL
)
target_compile_features(${ALIB}
PUBLIC cxx_auto_type
PUBLIC cxx_trailing_return_types
PRIVATE cxx_variadic_templates
PRIVATE cxx_std_14
)
install(DIRECTORY compact/ DESTINATION share/${PROJECT_NAME}/${a_lib_name}
FILES_MATCHING PATTERN "*.xml")
install(TARGETS ${ALIB}
EXPORT NPDetTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
#dd4hep_configure_scripts(JLEIC DEFAULT_SETUP)
#-----------------------------------------------------------------------------------
#set(digi_headers
# trackers/include/SimpleSiTrackerDigi.h
# )
#
#set(digi_source
# trackers/src/SimpleSiTrackerDigi.cpp
# )
#
#add_library(GenDigi SHARED ${digi_source})
#
#target_include_directories(GenDigi PUBLIC
# PRIVATE trackers/include
# PRIVATE calorimeters/include
# )
#
#target_compile_features(GenDigi
# PUBLIC cxx_auto_type
# PUBLIC cxx_trailing_return_types
# PRIVATE cxx_variadic_templates
# )
## For list of compile_features
## https://cmake.org/cmake/help/v3.9/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html#prop_gbl:CMAKE_CXX_KNOWN_FEATURES
#
#target_link_libraries(GenDigi PUBLIC ROOT::MathCore)
#
#install(TARGETS GenDigi
# EXPORT NPDetTargets
# LIBRARY DESTINATION lib
# ARCHIVE DESTINATION lib
# RUNTIME DESTINATION bin
# INCLUDES DESTINATION include
# )
#
#install(FILES ${digi_headers} DESTINATION include/GenDigi)
#set(exename recon_test)
#message("DD4hep_LIBRARIES : ${DD4hep_LIBRARIES}")
#add_executable(${exename} src/${exename}.cxx)
#target_link_libraries(${exename} ${DD4hep_LIBRARIES} ${DD4hep_DDREC_LIBRARY} )
#install(TARGETS ${exename}
# # IMPORTANT: Add the bar executable to the "export-set"
# EXPORT ${PROJECT_NAME}Targets
# RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin)
......@@ -14,8 +14,8 @@ class ALERTRecoilChamber {
ALERTRecoilChamber();
~ALERTRecoilChamber();
std::array<std::array<DD4hep::Geometry::BooleanSolid*, 4 >, 8> fWireVolume_solid;
std::array<std::array<DD4hep::Geometry::Volume, 4 >, 8> fWireVolume_log;
std::array<std::array<dd4hep::BooleanSolid*, 4 >, 8> fWireVolume_solid;
std::array<std::array<dd4hep::Volume, 4 >, 8> fWireVolume_log;
//std::array<std::array<VPhysicalVolume*,4 >, 8> fWireVolume_phys;
//std::array<std::array<RotationMatrix* ,4 >, 8> fWireVolume_rot;
......@@ -39,10 +39,10 @@ class ALERTRecoilChamber {
double spanningAngleOfTheWire ;//= 360.*deg;
double DeltaP ;//= 2.0*mm; // *desired* wire separation around the circumference.
DD4hep::Geometry::BooleanSolid* BuildWireSolid(int layer, int subcell);
dd4hep::BooleanSolid* BuildWireSolid(int layer, int subcell);
void BuildUnitCells();
void PlaceCells(DD4hep::Geometry::Volume& mother, int layer, double z_rotation, int wire_number );
void BuildDetector(DD4hep::Geometry::Volume& mother);
void PlaceCells(dd4hep::Volume& mother, int layer, double z_rotation, int wire_number );
void BuildDetector(dd4hep::Volume& mother);
......
This diff is collapsed.
#ifndef clas12_hits_DCWire_HH
#define clas12_hits_DCWire_HH 1
#include "TNamed.h"
#include "TBrowser.h"
#include "TMath.h"
#include "CLHEP/Vector/TwoVector.h"
#include "CLHEP/Units/SystemOfUnits.h"
#include "CLHEP/Vector/Rotation.h"
#include <array>
#include <map>
#include <tuple>
#include <unordered_map>
#include "DCGeometry.h"
//______________________________________________________________________________
namespace clas12 {
namespace hits {
class DCSuperLayer {
public:
int fSector = 0;
int fRegion = 0;
int fSuperLayer = 0;
public:
DCSuperLayer() { }
DCSuperLayer(int s, int r, int sl) :
fSector(s), fRegion(r), fSuperLayer(sl) { }
DCSuperLayer(const DCSuperLayer&) = default;
DCSuperLayer(DCSuperLayer&&) = default;
DCSuperLayer& operator=(const DCSuperLayer&) = default;
DCSuperLayer& operator=(DCSuperLayer&&) = default;
virtual ~DCSuperLayer() = default;
int GlobalChannel() const { return( 6*(fSector-1) + (fSuperLayer-1) ); }
bool operator< (const DCSuperLayer& rhs) const {return( GlobalChannel() < rhs.GlobalChannel() ); }
bool operator> (const DCSuperLayer& rhs) const {return rhs < (*this);}
bool operator<=(const DCSuperLayer& rhs) const {return !((*this) > rhs);}
bool operator>=(const DCSuperLayer& rhs) const {return !((*this) < rhs);}
bool operator==(const DCSuperLayer& rhs) const {return( GlobalChannel() == rhs.GlobalChannel() ); }
bool operator!=(const DCSuperLayer& rhs) const {return !((*this) == rhs);}
ClassDef(DCSuperLayer,1)
};
//________________________________________________________________________
/*! DCWire.
Wire channel numbering convention
the smallest channel number in a layer starts
nearest the beam pipe.
Numbering starts first by completing a sector.
Each sector has 6 superlayers, and each superlayer
has 6 layers, each layer has
*/
class DCWire {
public :
int fSector;
int fRegion;
int fSuperLayer; // redundant information Region I: (1,2), Region II: (3,4) R III: (5,6)
int fLayer;
int fWire;
int fChannel; // Unique channel number
DCWire(int sec=0, int reg=0, int sl=0, int l=0, int w=0);
virtual ~DCWire();
static int GetChannel(int sector, int sl, int layer, int wire) {
int sec_ind = sector-1;
int sl_ind = sl-1;
int lay_ind = layer-1;
int wire_ind = wire-1;
const int WiresPerLayer = 112;
const int WiresPerSL = 6*112;
const int WiresPerSector = 6*6*112;
const int TotalWires = 6*6*6*112;
int res = WiresPerSector*sec_ind + WiresPerSL*sl_ind + WiresPerLayer*lay_ind + WiresPerLayer*wire_ind;
return res;
}
static int GetSector (int channel) {
//const int WiresPerLayer = 112;
//const int WiresPerSL = 6*112;
const int WiresPerSector = 6*6*112;
int sec_ind = channel/WiresPerSector;
return( sec_ind+1 );
}
static int GetSuperLayer(int channel) {
//const int WiresPerLayer = 112;
const int WiresPerSL = 6*112;
const int WiresPerSector = 6*6*112;
int sec_ind = channel/WiresPerSector;
int sec_chan = channel - sec_ind*WiresPerSector;
int sl_ind = sec_chan/WiresPerSL;
return( sl_ind+1 );
}
static int GetLayer (int channel) {
const int WiresPerLayer = 112;
const int WiresPerSL = 6*112;
const int WiresPerSector = 6*6*112;
int sec_ind = channel/WiresPerSector;
int sec_chan = channel - sec_ind*WiresPerSector;
int sl_ind = sec_chan/WiresPerSL;
int sl_chan = sec_chan - sl_ind*WiresPerSL;
int lay_ind = sl_chan/WiresPerLayer;
return( lay_ind+1 );
}
static int GetWire (int channel) {
const int WiresPerLayer = 112;
const int WiresPerSL = 6*112;
const int WiresPerSector = 6*6*112;
int sec_ind = channel/WiresPerSector;
int sec_chan = channel - sec_ind*WiresPerSector;
int sl_ind = sec_chan/WiresPerSL;
int sl_chan = sec_chan - sl_ind*WiresPerSL;
int lay_ind = sl_chan/WiresPerLayer;
int wire_ind = sl_chan - lay_ind*WiresPerLayer ;
return( wire_ind+1 );
}
static int GetRegion (int channel) {
return( GetSuperLayer(channel)/2 + 1);
}
//static std::tuple<int,int,int,int,int,int> GetWireID(int channel) {
// const int WiresPerLayer = 112;
// const int WiresPerSL = 6*112;
// const int WiresPerSector = 6*6*112;
// int sec_ind = channel/WiresPerSector;
// int sec_chan = channel - sec_ind*WiresPerSector;
// int sl_ind = sec_chan/WiresPerSL;
// int sl_chan = sec_chan - sl_ind*WiresPerSL;
// int lay_ind = sl_chan/WiresPerLayer;
// int wire_ind = sl_chan - sl_chan/WiresPerLayer ;
// return( wire_ind+1 );
//}
void Print(Option_t * opt = "") const;
//ClassDef(DCWire,4)
};
//________________________________________________________________________
}
}
#endif
#ifndef geo_clas12_GeoUtil_HH
#define geo_clas12_GeoUtil_HH 1
#include "TMath.h"
#include "Math/Vector3D.h"
namespace clas12 {
namespace geo {
using namespace ROOT::Math;
using namespace TMath;
struct XYVector {
double x = 0.0;
double y = 0.0;
double X()const {return x;}
double Y()const {return y;}
XYVector(double xx, double yy) : x(xx),y(yy){ }
XYVector& operator+=(const XYVector& v) {
x += v.x;
y += v.y;
return *this;
}
friend XYVector operator+(XYVector lhs, const XYVector& rhs ) {
lhs += rhs;
return lhs;
}
};
// rotate a two vector
XYVector ApplyRotation(const XYVector& v, double angle);
XYZVector GetIntersectionPoint(
const XYZVector x0, const XYZVector x1,
const XYZVector p0, const XYZVector norm );
//inline TVector3 Convert(const CLHEP::Hep3Vector& v0)
//{
// return(TVector3(v0.x(),v0.y(),v0.z()));
//}
}
}
#endif
#ifndef clas12_geo_RH_RCGeometry_H
#define clas12_geo_RH_RCGeometry_H
#include "TMath.h"
#include "GeoUtil.h"
#include <array>
#include <map>
#include <tuple>
#include <unordered_map>
#include "Math/Vector3D.h"
#include "Math/Rotation3D.h"
#include "Math/Transform3D.h"
#include "DDParsers/DD4hepUnits.h"
namespace clas12 {
namespace geo {
using namespace ROOT::Math;
using namespace TMath;
using namespace TMath;
using namespace dd4hep;
/*! Recoil Chamber Geometry.
Numbering conventions:
- Each "Layer" has NCells number of unit cells
- Each unit cell has 1 sense wire and 8 field wires
- Each unit cell has 4 sub-cells
Sub-cell numbering:
2_______3
\__|__/
\_|_/
1 0
- These sub cells are given the same copy number in geant4
Field wire number for cell:
4___5___6
\__|__/
3 \_|_/ 7
2 1 0
- The Field wires surrounding the wire are number going around the wire starting with the inner radius at smallest phi values
- Each unit cell has a unique "channel number" starting at 0.
- Each sub-cell trapeziod has 8 points defining it
upstream: 2_____3 downstream: 6_____7
\ / \ /
\_/ \_/
1 0 5 4
*/
class RCGeometry {
public:
double InnerRadius = 30.000*mm;
double OuterRadius = 79.995*mm;
double Length = 30.000*cm;
double DeltaR = 2.0*mm;
int NLayers = 8;
int NCellLayers = 3;
double MaxWireSep = 2.0*mm; // *desired* wire separation around the circumference.
double WireLength = Length/Cos(10.0*degree);
double StereoAngle = 10.0*degree;
double InnerGap = 1.0*mm;
double LayerGap = 1.4*mm;
std::array<int , 8> fNCells;
std::array<int , 8> fFirstChannelInLayer;
std::array<double, 8> fCellInnerRadius;
std::array<double, 8> fCellDeltaPhi;
std::array<double, 8> fCellStereoAngle;
std::array<double, 8> fCellCentralRadius;
double fNChannels;
public:
RCGeometry();
void Print();
int GetWireLayer(int channel) const ;
double GetSenseWireRadius(int channel) const ;
double GetSenseWirePhi(int channel) const ;
double GetSenseWireStereoAngle(int channel) const ;
XYZVector GetFirstCellPosition(int layer, int subcell=-1) const ;
Rotation3D GetFirstCellRotation(int layer, int subcell=-1) const ;
Transform3D GetFirstCellTransform(int layer, int subcell=-1) const ;
XYZVector GetSenseWirePerp(int channel) const ;
XYZVector GetSenseWirePosition(int channel) const ;
Rotation3D GetSenseWireRotation(int channel) const ;
Transform3D GetSenseWireTransform(int channel) const ;
XYZVector GetUpstreamSenseWirePosition(int channel) const ;
XYZVector GetDownstreamSenseWirePosition(int channel) const ;
XYZVector GetUnitSubCellPoint(int layer,int subcell, int point) const ;
std::vector<XYVector> GetSubCellTrapPoints(int layer, int subcell) ;
};
}
}
#endif
#ifndef clas12_geo_RCWire_HH
#define clas12_geo_RCWire_HH 1
#include "TNamed.h"
#include "TBrowser.h"
#include "TMath.h"
#include <array>
#include <map>
#include <tuple>
#include <unordered_map>
#include "RCGeometry.h"
//______________________________________________________________________________
namespace clas12 {
namespace geo {
class RCWire {
public :
int fLayer; // Layer number
int fWire; // Wire number in layer
int fChannel; // Unique channel number
RCWire(int l=0, int w=0);
virtual ~RCWire();
void Print(Option_t * opt = "") const;
//ClassDef(RCWire,3)
};
//________________________________________________________________________
}
}
#endif
#ifndef clas12_geo_RH_RHGeometry_H
#include "TMath.h"
#include "CLHEP/Vector/TwoVector.h"
#include "CLHEP/Units/SystemOfUnits.h"
#include "CLHEP/Vector/Rotation.h"
#include "CLHEP/Geometry/Transform3D.h"
#include "GeoUtil.h"
#include <array>
#include <map>
#include <tuple>
#include <unordered_map>
namespace clas12 {
namespace geo {
using namespace CLHEP;
using namespace TMath;
//using namespace HepGeom;
/*! Recoil Hodoscope Geometry.
*/
class RHGeometry {
public:
double ScintWrapThickness = 2.54*0.004*CLHEP::cm;
double ScintGap = 2.54*0.002*CLHEP::cm;
double ScintLength = 30.0*CLHEP::cm;
double Scint2Length = 3.0*CLHEP::cm;
double Scint1Thickness = 2.0*CLHEP::mm;
double Scint2Thickness = 50.0*CLHEP::mm;
double PhotonDetThickness = 25.4*0.00002*CLHEP::mm;
double InnerRadius = 8.0*CLHEP::cm;
double ScintDeltaTheta = 6.0*CLHEP::degree; // angle subtended by bar
int NScintZ = 10;
int NScintPhi = 60 ;
int NChannels = 600 ;
double fDeltaPhi;
double fDeltaZ;