diff --git a/DDExamples/ILDExDet/compact/LP1.xml b/DDExamples/ILDExDet/compact/LP1.xml new file mode 100644 index 0000000000000000000000000000000000000000..6952c7f0ebce0108e18a837581f663ec7b2c037b --- /dev/null +++ b/DDExamples/ILDExDet/compact/LP1.xml @@ -0,0 +1,143 @@ +<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd"> + + <info name="LP1" + title="Large TPC Prototype LP1" + author="Astrid Muennich" + status="development" + version="$Id: compact.xml,v 1.3 2010/12/02 16:34:00 grefe Exp $"> + <comment>compact discription of simple TPC prototype</comment> + </info> + + <includes> + <gdmlFile ref="elements.xml"/> + <gdmlFile ref="materials.xml"/> + <pyBuilder ref="../drivers"/> + </includes> + + <define> + <constant name="world_side" value="40*m"/> + <constant name="world_x" value="world_side/2"/> + <constant name="world_y" value="world_side/2"/> + <constant name="world_z" value="world_side/2"/> + <constant name="CrossingAngle" value="0.020"/> + + <constant name="TPC_zhalf" value="300*mm"/> + <constant name="TPC_outer_radius" value="363.35*mm"/> + <constant name="TPC_inner_radius" value="0*mm"/> + <constant name="TPC_outer_thickness" value="0*mm"/> + <constant name="TPC_endcap_thickness" value="45*mm"/> + <constant name="TPC_center_x" value="1503.615*mm"/> + + <constant name="tracking_region_radius" value="TPC_outer_radius + 1.0"/> + <constant name="tracking_region_zmax" value="TPC_zhalf + 1.0"/> + </define> + + <materials> + <material name="Graphite"> + <D value="1.7" unit="g/cm3"/> + <composite n="1" ref="C"/> + </material> + </materials> + + <limits> + <limitset name="cal_limits"> + <limit name="step_length_max" particles="*" value="5.0" unit="mm" /> + </limitset> + </limits> + + <display> + <vis name="TPCVis" alpha="1.0" r="0" g="1.0" b="0.0" showDaughters="true" visible="false"/> + <vis name="TPCEndplateVis" alpha="1.0" r="0" g="1.0" b="0.0" showDaughters="false" visible="true"/> + <vis name="TPCModuleVis" alpha="1.0" r="0" g="0.0" b="1.0" showDaughters="false" visible="true"/> + <vis name="TPCSupportVis" alpha="1.0" r="0" g="0.4" b="0.4" showDaughters="false" visible="true"/> + <vis name="TPCGasVis" alpha="0.5" r="0.7" g="0" b="0" showDaughters="false" visible="false"/> + </display> + + <detectors> + <comment>Trackers</comment> + + + <detector name="TPC" type="LP1" vis="TPCVis" id="3"> + <tubs rmin="TPC_inner_radius" rmax="TPC_outer_radius" zhalf="TPC_zhalf"/> + + <material name="Air"/> + + + <detector name="TPC_OuterWall" type="TubeSegment" reflect="false" vis="TPCSupportVis" id="3"> + <material name="Carbon" /> + <tubs rmin="TPC_outer_radius - TPC_outer_thickness" rmax="TPC_outer_radius" zhalf="TPC_zhalf"/> + <position x="1503.615" y="0" z="TPC_zhalf"/> + <rotation x="0" y="0" z="0"/> + </detector> + + <detector name="TPC_EndPlate" type="TubeSegment" reflect="false" vis="TPCEndPlateVis" id="0"> + <material name="Carbon" /> + <tubs rmin="TPC_inner_radius" rmax="TPC_outer_radius-TPC_outer_thickness" zhalf="0.5*TPC_endcap_thickness"/> + <position x="1503.615" y="0" z="2*TPC_zhalf+0.5*TPC_endcap_thickness"/> + <rotation x="0" y="0" z="0"/> + + <modules name="TPC_Module" vis="TPCModuleVis"> + <module type ="TubeSegment" rmin="1430" rmax="1600" phi0="8.387*deg" pads="PadLayout0" id="0"> + <position x="-171.615-1503.615" y="0" z="0"/> + <rotation x="0" y="0" z="- 8.3870 / 2. - 3.0"/> + </module> + <module type ="TubeSegment" rmin="1430" rmax="1600" phi0="8.387*deg" pads="PadLayout0" id="1"> + <position x="-171.615-1503.615" y="0" z="0"/> + <rotation x="0" y="0" z=" - 8.3870 / 2. + 5.39"/> + </module> + <module type ="TubeSegment" rmin="1430" rmax="1600" phi0="8.387*deg" pads="PadLayout0" id="2"> + <position x="-1503.615" y="0" z="0"/> + <rotation x="0" y="0" z=" - 8.3870 / 2. - 8.50"/> + </module> + <module type ="TubeSegment" rmin="1430" rmax="1600" phi0="8.387*deg" pads="PadLayout0" id="3"> + <position x="-1503.615" y="0" z="0"/> + <rotation x="0" y="0" z="- 8.3870 / 2. - 0.11"/> + </module> + <module type ="TubeSegment" rmin="1430" rmax="1600" phi0="8.387*deg" pads="PadLayout0" id="4"> + <position x="-1503.615" y="0" z="0"/> + <rotation x="0" y="0" z=" - 8.3870 / 2. + 8.27 "/> + </module> + <module type ="TubeSegment" rmin="1430" rmax="1600" phi0="8.387*deg" pads="PadLayout0" id="5"> + <position x="172.5-1503.615" y="0" z="0"/> + <rotation x="0" y="0" z=" - 8.3870 / 2. - 5.0"/> + </module> + <module type ="TubeSegment" rmin="1430" rmax="1600" phi0="8.387*deg" pads="PadLayout0" id="6"> + <position x="172.5-1503.615" y="" z="0"/> + <rotation x="0" y="0" z="- 8.3870 / 2. + 3.39"/> + </module> + </modules> + </detector> + + + <detector name="TPC_GasVolume" type="TubeSegment" reflect="false" vis="TPCGasVis" id="4"> + <material name="Argon"/> + <tubs rmin="TPC_inner_radius" rmax="TPC_outer_radius-TPC_outer_thickness" zhalf="TPC_zhalf"/> + <position x="1503.615" y="0" z="TPC_zhalf"/> + <rotation x="0" y="0" z="0"/> + </detector> + + <detector name="TPC_Cathode" type="TubeSegment" reflect="false" vis="TPCSupportVis" id="5"> + <material name="Argon"/> + <tubs rmin="TPC_inner_radius" rmax="TPC_outer_radius" zhalf="0.5"/> + <position x="1503.615" y="0" z="0"/> + <rotation x="0" y="0" z="0"/> + </detector> + </detector> + + </detectors> + + <readouts> + <readout name="PadLayout0"> + <segmentation type="ProjectiveCylinder" phiBins="617" thetaBins="21"/> + <id>system:6</id> + </readout> + </readouts> + + <fields> + <field type="Solenoid" name="GlobalSolenoid" inner_field="5.0" + outer_field="-1.5" zmax="SolenoidCoilOuterZ" + outer_radius="SolenoidalFieldRadius" /> + </fields> +</lccdd> diff --git a/DDExamples/ILDExDet/src/compact/LP1_geo.cpp b/DDExamples/ILDExDet/src/compact/LP1_geo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5722531e74b349ef5d2250e331a346958a4353a6 --- /dev/null +++ b/DDExamples/ILDExDet/src/compact/LP1_geo.cpp @@ -0,0 +1,113 @@ +// $Id:$ +//==================================================================== +// AIDA Detector description implementation for LCD +//-------------------------------------------------------------------- +// +// Author : A.Muennich +// +//==================================================================== + +#include "DD4hep/DetFactoryHelper.h" +#include "DD4hep/Detector.h" +#include "TPCModuleData.h" +#include "TPCModule.h" +#include "FixedPadAngleDiskLayout.h" + +using namespace std; +using namespace DD4hep; +using namespace DD4hep::Geometry; + +static Ref_t create_element(LCDD& lcdd, const xml_h& e, SensitiveDetector& sens) { + xml_det_t x_det = e; + xml_comp_t x_tube (x_det.child(_X(tubs))); + string name = x_det.nameStr(); + Material mat (lcdd.material(x_det.materialStr())); + //if data is needed do this + // Value<TNamed,TPCData>* tpcData = new Value<TNamed,TPCData>(); + // DetElement tpc(tpcData, name, x_det.typeStr()); + // tpcData->id = x_det.id(); + //else do this + DetElement tpc (name,x_det.typeStr(),x_det.id()); + Tube tpc_tub(x_tube.rmin(),x_tube.rmax(),x_tube.zhalf()); + Volume tpc_vol(name+"_envelope_volume", tpc_tub, mat); + + for(xml_coll_t c(e,_X(detector)); c; ++c) { + xml_comp_t px_det (c); + xml_comp_t px_tube (px_det.child(_X(tubs))); + xml_dim_t px_pos (px_det.child(_X(position))); + xml_dim_t px_rot (px_det.child(_X(rotation))); + xml_comp_t px_mat (px_det.child(_X(material))); + string part_nam(px_det.nameStr()); + Material part_mat(lcdd.material(px_mat.nameStr())); + DetElement part_det(part_nam,px_det.typeStr(),px_det.id()); + Tube part_tub(px_tube.rmin(),px_tube.rmax(),px_tube.zhalf()); + Volume part_vol(part_nam,part_tub,part_mat); + Position part_pos(px_pos.x(),px_pos.y(),px_pos.z()); + Rotation part_rot(px_rot.x(),px_rot.y(),px_rot.z()); + bool reflect = px_det.reflect(); + + part_vol.setVisAttributes(lcdd,px_det.visStr()); + //Endplate + if(part_det.id()== 0){ + //modules + int mdcount=0; + for(xml_coll_t m(px_det,_X(modules)); m; ++m) { + xml_comp_t modules (m); + string m_name = modules.nameStr(); + for(xml_coll_t r(modules,_X(module)); r; ++r) { + xml_comp_t mod(r); + int modID=mod.id(); + //shape of module + double rmin=mod.rmin(); + double rmax=mod.rmax(); + double DeltaPhi=mod.phi0(); + double zhalf=px_tube.zhalf(); + string m_nam=m_name+_toString(modID,"_M%d"); + Volume mr_vol(m_nam,Tube(rmin,rmax,zhalf,DeltaPhi),part_mat); + Material mr_mat(lcdd.material(px_mat.nameStr())); + Readout xml_pads(lcdd.readout(mod.padType())); + //placing modules + DetElement module(part_det,m_nam,modID); + xml_dim_t px_modpos (mod.child(_X(position))); + Position mod_pos(px_modpos.x(),px_modpos.y(),px_modpos.z()); + xml_dim_t px_modrot (mod.child(_X(rotation))); + Rotation mod_rot(px_modrot.x(),px_modrot.y(),px_modrot.z()*M_PI/180); + PlacedVolume m_phv = part_vol.placeVolume(mr_vol,mod_pos,mod_rot); + m_phv.addPhysVolID("module",modID); + module.setPlacement(m_phv); + + module.setReadout(xml_pads); + // Readout and placement must be present before adding extension, + // since they are aquired internally for optimisation reasons. (MF) + module.addExtension<PadLayout>(new FixedPadAngleDiskLayout(module)); + }//modules + }//module groups + }//endplate + + PlacedVolume part_phv = tpc_vol.placeVolume(part_vol,part_pos,part_rot); + part_phv.addPhysVolID(part_nam,px_det.id()); + part_det.setPlacement(part_phv); + tpc.add(part_det); + //now reflect it + if(reflect){ + Position r_pos(px_pos.x(),px_pos.y(),-px_pos.z()); + //Attention: rotation is given in euler angles + Rotation r_rot(M_PI,0,M_PI); + // Volume part_vol_r(lcdd,part_nam+"_negativ",part_tub,part_mat); + PlacedVolume part_phv2 = tpc_vol.placeVolume(part_vol,r_pos,r_rot); + part_phv2.addPhysVolID(part_nam+"_negativ",px_det.id()+1); + // needs a copy function for DetElement + // DetElement rdet(lcdd,part_nam+"_negativ",px_det.typeStr(),px_det.id()+1); + DetElement rdet = part_det.clone(part_nam+"_negativ",px_det.id()+1); + rdet.setPlacement(part_phv2); + tpc.add(rdet); + } + }//subdetectors + tpc_vol.setVisAttributes(lcdd, x_det.visStr()); + PlacedVolume phv = lcdd.pickMotherVolume(tpc).placeVolume(tpc_vol); + tpc.setPlacement(phv); + return tpc; +} + +//first argument is the type from the xml file +DECLARE_DETELEMENT(LP1,create_element) diff --git a/DDExamples/ILDExReco/CMakeLists.txt b/DDExamples/ILDExReco/CMakeLists.txt index c882324d2005d94fad8ad9ecd78e2854e2379ab2..8f2155a9453e694d7cf2b936ea32522f573e0894 100644 --- a/DDExamples/ILDExReco/CMakeLists.txt +++ b/DDExamples/ILDExReco/CMakeLists.txt @@ -7,6 +7,7 @@ include_directories( ${CMAKE_SOURCE_DIR}/DDCore/include add_executable(ILDExReco ILDExReco.cpp src/GearTPC.cpp) add_executable(RecoTPCPrototype RecoTPCPrototype.cpp src/GearTPC.cpp) +add_executable(RecoLP1 RecoLP1.cpp src/GearTPC.cpp) add_executable(TPCDigitisation TPCDigitisation.cpp src/GearTPC.cpp) add_executable(TPCHitReco TPCHitReco.cpp src/GearTPC.cpp) add_executable(CalculateTPCPadBinning CalculateTPCPadBinning.cpp src/GearTPC.cpp) @@ -14,6 +15,7 @@ add_executable(TPCToySimulation TPCToySimulation.cpp src/GearTPC.cpp) add_executable(TPCMaterialScan TPCMaterialScan.cpp src/GearTPC.cpp) target_link_libraries(ILDExReco DD4hepCore ILDEx ${ROOT_LIBRARIES}) target_link_libraries(RecoTPCPrototype DD4hepCore ILDEx ${ROOT_LIBRARIES}) +target_link_libraries(RecoLP1 DD4hepCore ILDEx ${ROOT_LIBRARIES}) target_link_libraries(TPCDigitisation DD4hepCore ILDEx ${ROOT_LIBRARIES}) target_link_libraries(TPCHitReco DD4hepCore ILDEx ${ROOT_LIBRARIES}) target_link_libraries(CalculateTPCPadBinning DD4hepCore ILDEx ${ROOT_LIBRARIES}) diff --git a/DDExamples/ILDExReco/RecoLP1.cpp b/DDExamples/ILDExReco/RecoLP1.cpp new file mode 100644 index 0000000000000000000000000000000000000000..41b6386bd1dda1b15e397e5bc68a83e3dd3e3ce4 --- /dev/null +++ b/DDExamples/ILDExReco/RecoLP1.cpp @@ -0,0 +1,57 @@ + +//==================================================================== +// Test application for LP1 functionality +//-------------------------------------------------------------------- +// +// Author : A.Muennich +// +// +//==================================================================== + +#include "DD4hep/LCDD.h" +#include <iostream> +#include <vector> +#include <string> +#include "GearTPC.h" +#include "TPCModuleData.h" + + +using namespace std; +using namespace DD4hep; +using namespace Geometry; + +#include "TPCModuleData.h" + + +int main(int argc,char** argv) { + + LCDD& lcdd = LCDD::getInstance(); + lcdd.fromCompact(argv[1]); + + GearTPC tpc(lcdd.detector("TPC")); + cout << "Gear TPC functionality:"<<endl; + cout << "-----> Outer Radius:\t " << tpc.getOuterRadius() << endl; + cout << "-----> DriftLength:\t " << tpc.getMaxDriftLength() << endl; + + cout << "-----> EndplateThickness 0:\t " << tpc.getEndPlateThickness(0) <<endl; + cout << "-----> EndplateZPosition 0:\t "<< tpc.getEndPlateZPosition(0)<<endl; + +// int npads=0; +// for(int p=0;p<mymods.size();p++) +// npads+=tpc.getModule(p,0).getNPads(); +// cout << "-----> NPads EP0:\t " << npads << endl; + cout << "-----> Inside Module (0,0):\t "<<tpc.isInsideModule(0,0,0)<<endl; + cout << "-----> Nearest Module (0,0):\t "<<tpc.getNearestModule(0,0,0).getID()<<endl; + cout << "TPC Module functionality:"<<endl; + + std::vector<TPCModule> mymods=tpc.getModules(0); + cout << "-----> NModules EP0:\t " << mymods.size()<< endl; + + for(int m=0;m<mymods.size();m++) + { + TPCModule mod=mymods[m]; + cout<<mod.id()<<" "<<mod.getNPads()<<endl; + } + + return 0; +} diff --git a/DDExamples/ILDExReco/src/GearTPC.cpp b/DDExamples/ILDExReco/src/GearTPC.cpp index dcaebbcca048422f1885614304810b22e7f634df..a7f2563a9ff65df36cb9a8b7d9e42cf818b7941b 100644 --- a/DDExamples/ILDExReco/src/GearTPC.cpp +++ b/DDExamples/ILDExReco/src/GearTPC.cpp @@ -44,11 +44,22 @@ namespace DD4hep { } double GearTPC::getMaxDriftLength() const { - DetElement gas = child("TPC_GasVolume"); - if(!gas.isValid()) - throw OutsideGeometryException("TPC gas volume not found!"); - Tube tube = gas.volume().solid(); - return tube->GetDz(); + //defined as distance between cathode and endplate surface + //for now assume symmetric setups, meaining if there are two endplates + //they are symmetric around the cathode + DetElement cathode = child("TPC_Cathode"); + if(!cathode.isValid()) + throw OutsideGeometryException("TPC cathode not found!"); + //positions in z + TGeoMatrix *nm=cathode.placement()->GetMatrix(); + const Double_t *trans=nm->GetTranslation(); + double z_ep=getEndPlateZPosition(0); + double z_cath=trans[2]; + //thickness in z + double th_ep=getEndPlateThickness(0); + Tube tube_cathode=cathode.volume().solid(); + double th_cath=tube_cathode->GetDz(); + return fabs(z_ep-z_cath)-(th_ep+th_cath); } double GearTPC::getEndPlateThickness(int endplate) const { diff --git a/DDExamples/ILDExTest/TestILDTPC.cpp b/DDExamples/ILDExTest/TestILDTPC.cpp index be4f54e09d93a2197b021e1402f2a9f76f21f574..60188339a1349c0fa49d1e94cf2ea9184872207f 100644 --- a/DDExamples/ILDExTest/TestILDTPC.cpp +++ b/DDExamples/ILDExTest/TestILDTPC.cpp @@ -46,9 +46,9 @@ int main(int argc,char** argv) { myfile << "FAILED tpc.getOuterRadius(): 1800!="<<tpc.getOuterRadius()<< endl; failures++; } - if( fabs( tpc.getMaxDriftLength() -2497 )> myPrecision) + if( fabs( tpc.getMaxDriftLength() -2496.5 )> myPrecision) { - myfile << "FAILED tpc.getMaxDriftLength(): 2497!=" << tpc.getMaxDriftLength()<<endl; + myfile << "FAILED tpc.getMaxDriftLength(): 2496.5!=" << tpc.getMaxDriftLength()<<endl; failures++; } if(fabs(tpc.getEndPlateThickness(0) - 1.5) > myPrecision) diff --git a/DDExamples/ILDExTest/TestTPCPrototype.cpp b/DDExamples/ILDExTest/TestTPCPrototype.cpp index 4b834122a56efcb55a2c12c89a68f3aacc13c981..dfb075a3632cc2b68a866c7bec0df6e8689b582d 100644 --- a/DDExamples/ILDExTest/TestTPCPrototype.cpp +++ b/DDExamples/ILDExTest/TestTPCPrototype.cpp @@ -48,9 +48,9 @@ int main(int argc,char** argv) { myfile<<"FAILED tpc.getOuterRadius(): 500!="<<tpc.getOuterRadius()<<endl; failures++; } - if(fabs(tpc.getMaxDriftLength()-497)>myPrecision) + if(fabs(tpc.getMaxDriftLength()-996.5)>myPrecision) { - myfile<<"FAILED tpc.getMaxDriftLength(): 497!="<<tpc.getMaxDriftLength()<<endl; + myfile<<"FAILED tpc.getMaxDriftLength(): 996.5!="<<tpc.getMaxDriftLength()<<endl; failures++; } if(fabs(tpc.getEndPlateThickness(0)-1.5)>myPrecision) diff --git a/DDExamples/ILDExTest/reference_TestILDTPC.txt b/DDExamples/ILDExTest/reference_TestILDTPC.txt index b6913e4869135e6d6ebe4e811a7ce4124d7b6cb8..dc42305de7f30e9f536472aef7ab0acadc0788c8 100644 --- a/DDExamples/ILDExTest/reference_TestILDTPC.txt +++ b/DDExamples/ILDExTest/reference_TestILDTPC.txt @@ -1,7 +1,7 @@ Gear TPC functionality: -----> Inner Radius: 350 -----> Outer Radius: 1800 ------> DriftLength: 2497 +-----> DriftLength: 2496.5 -----> EndplateThickness 0: 1.5 -----> EndplateZPosition 0: 2498.5 -----> EndplateThickness 1: 1.5 diff --git a/DDExamples/ILDExTest/reference_TestTPCPrototype.txt b/DDExamples/ILDExTest/reference_TestTPCPrototype.txt index 41f5c01f5bf2dc7257735e10f947cdb9d93e13e5..7fae1ffd56420570a431e4dab1bb30b2cedef434 100644 --- a/DDExamples/ILDExTest/reference_TestTPCPrototype.txt +++ b/DDExamples/ILDExTest/reference_TestTPCPrototype.txt @@ -1,6 +1,6 @@ Gear TPC functionality: -----> Outer Radius: 500 ------> DriftLength: 497 +-----> DriftLength: 996.5 -----> EndplateThickness 0: 1.5 -----> EndplateZPosition 0: 998.5 -----> Exception test: OutsideGeometryException: TPC endplate not found!