diff --git a/CMakeLists.txt b/CMakeLists.txt index e8187f099e1fa81c68a956649df59ec50306c14b..d08174b98b65b98bb334865b943e902167e3d05f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,10 @@ if(DD4HEP_USE_XERCESC) find_package(XercesC) endif() +INCLUDE(CTest) +ENABLE_TESTING() + + #---Packages------------------------------------------------------------------------ add_subdirectory(DDCore) if(DD4HEP_WITH_GEANT4) @@ -26,6 +30,7 @@ add_subdirectory(DDExamples/CLICSiDDisplay) add_subdirectory(DDExamples/ILDExDet) add_subdirectory(DDExamples/ILDExDisplay) add_subdirectory(DDExamples/ILDExReco) +add_subdirectory(DDExamples/ILDExTest) if(DD4HEP_WITH_GEANT4) #add_subdirectory(DDExamples/CLICSiDSimu) # add_subdirectory(DDExamples/ILDExSimu) diff --git a/DDExamples/ILDExReco/CMakeLists.txt b/DDExamples/ILDExReco/CMakeLists.txt index 4e1e6b60b19a9442e31dd391e5403352c77c5027..c882324d2005d94fad8ad9ecd78e2854e2379ab2 100644 --- a/DDExamples/ILDExReco/CMakeLists.txt +++ b/DDExamples/ILDExReco/CMakeLists.txt @@ -6,14 +6,14 @@ include_directories( ${CMAKE_SOURCE_DIR}/DDCore/include ${ROOT_INCLUDE_DIR}) add_executable(ILDExReco ILDExReco.cpp src/GearTPC.cpp) -add_executable(TestTPCPrototype TestTPCPrototype.cpp src/GearTPC.cpp) +add_executable(RecoTPCPrototype RecoTPCPrototype.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) 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(TestTPCPrototype DD4hepCore ILDEx ${ROOT_LIBRARIES}) +target_link_libraries(RecoTPCPrototype 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/TestTPCPrototype.cpp b/DDExamples/ILDExReco/RecoTPCPrototype.cpp similarity index 100% rename from DDExamples/ILDExReco/TestTPCPrototype.cpp rename to DDExamples/ILDExReco/RecoTPCPrototype.cpp diff --git a/DDExamples/ILDExReco/include/GearTPC.h b/DDExamples/ILDExReco/include/GearTPC.h index 8c5f80eaf103f7440e4167416e4556e39551504f..ae40938cd46b7944c10bce9478049cd352e7eb97 100644 --- a/DDExamples/ILDExReco/include/GearTPC.h +++ b/DDExamples/ILDExReco/include/GearTPC.h @@ -5,6 +5,9 @@ // // Author : M.Frank, A. Muennich // +// Interface to answer all user questions to a TPC. +// Reproducing the functionality of TPCParameters in GEAR +// //==================================================================== #ifndef GEARTPC_H #define GEARTPC_H diff --git a/DDExamples/ILDExTest/CMakeLists.txt b/DDExamples/ILDExTest/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..94c76046aa7f7c2a9820ab20f691d954ad641102 --- /dev/null +++ b/DDExamples/ILDExTest/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 2.8.3 FATAL_ERROR) + +include_directories( ${CMAKE_SOURCE_DIR}/DDCore/include + ${CMAKE_SOURCE_DIR}/DDExamples/ILDExDet/include + ${CMAKE_SOURCE_DIR}/DDExamples/ILDExReco/include + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${ROOT_INCLUDE_DIR}) + +add_executable(TestILDTPC TestILDTPC.cpp ${CMAKE_SOURCE_DIR}/DDExamples/ILDExReco/src/GearTPC.cpp) +add_executable(TestTPCPrototype TestTPCPrototype.cpp ${CMAKE_SOURCE_DIR}/DDExamples/ILDExReco/src/GearTPC.cpp) + +target_link_libraries(TestILDTPC DD4hepCore ILDEx ${ROOT_LIBRARIES}) +target_link_libraries(TestTPCPrototype DD4hepCore ILDEx ${ROOT_LIBRARIES}) + + +ADD_TEST(TestILDTPC TestILDTPC file:${CMAKE_SOURCE_DIR}/DDExamples/ILDExTest/ILDExTPC.xml) +ADD_TEST(TestILDTPC_Output grep PASSED ${CMAKE_CURRENT_BINARY_DIR}/testOutput_TestILCTPC.txt) +ADD_TEST(TestTPCPrototype TestTPCPrototype file:${CMAKE_SOURCE_DIR}/DDExamples/ILDExTest/TPCPrototype.xml) +ADD_TEST(TestTPCPrototype_Output grep PASSED ${CMAKE_CURRENT_BINARY_DIR}/testOutput_TestTPCPrototype.txt) + \ No newline at end of file diff --git a/DDExamples/ILDExTest/ILDExTPC.xml b/DDExamples/ILDExTest/ILDExTPC.xml new file mode 100644 index 0000000000000000000000000000000000000000..23c410375502c9a02c3b751840407d03166d5ac2 --- /dev/null +++ b/DDExamples/ILDExTest/ILDExTPC.xml @@ -0,0 +1,146 @@ +<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="ild_TPC" + title="example TPC for ILD" + author="Astrid Muennich" + status="development" + version="$Id: compact.xml,v 1.3 2010/12/02 16:34:00 grefe Exp $"> + <comment>The compact format for the CLIC Silicon Detector used for the conceptual design report</comment> + </info> + + <includes> + <gdmlFile ref="elements.xml"/> + <gdmlFile ref="materials.xml"/> + </includes> + + <define> + <constant name="world_side" value="10*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="2500*mm"/> + <constant name="TPC_outer_radius" value="1800*mm"/> + <constant name="TPC_inner_radius" value="350*mm"/> + <constant name="TPC_inner_thickness" value="2*mm"/> + <constant name="TPC_outer_thickness" value="3*mm"/> + <constant name="TPC_endcap_thickness" value="3*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="ILDExTPC" vis="TPCVis" id="3"> + <tubs rmin="TPC_inner_radius" rmax="TPC_outer_radius" zhalf="TPC_zhalf"/> + + <material name="Air"/> + + <detector name="TPC_InnerWall" type="TubeSegment" reflect="false" vis="TPCSupportVis" id="2"> + <material name="Carbon"/> + <tubs rmin="TPC_inner_radius" rmax="TPC_inner_radius+TPC_inner_thickness" zhalf="TPC_zhalf"/> + <position x="0" y="0" z="0"/> + <rotation x="0" y="0" z="0"/> + </detector> + + <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="0" y="0" z="0"/> + <rotation x="0" y="0" z="0"/> + </detector> + + <detector name="TPC_EndPlate" type="TubeSegment" reflect="true" vis="TPCEndPlateVis" id="0"> + <material name="Carbon" /> + <tubs rmin="TPC_inner_radius+TPC_inner_thickness" rmax="TPC_outer_radius-TPC_outer_thickness" zhalf="0.5*TPC_endcap_thickness"/> + <position x="0" y="0" z="TPC_zhalf-0.5*TPC_endcap_thickness"/> + <rotation x="0" y="0" z="0"/> + + <modules name="TPC_Module" vis="TPCModuleVis"> + <row type ="TubeSegment" moduleHeight="210" rowPitch="100" modulePitch="35" pads="PadLayout0" nModules="5" RowID="0"/> + <row type ="TubeSegment" moduleHeight="210" rowPitch="100" modulePitch="35" pads="PadLayout1" nModules="9" RowID="1"/> + <row type ="TubeSegment" moduleHeight="210" rowPitch="100" modulePitch="35" pads="PadLayout2" nModules="13" RowID="2"/> + <row type ="TubeSegment" moduleHeight="210" rowPitch="100" modulePitch="35" pads="PadLayout3" nModules="16" RowID="3"/> + <row type ="TubeSegment" moduleHeight="210" rowPitch="100" modulePitch="35" pads="PadLayout4" nModules="20" RowID="4"/> + </modules> + </detector> + + + <detector name="TPC_GasVolume" type="TubeSegment" reflect="false" vis="TPCGasVis" id="4"> + <material name="Argon"/> + <tubs rmin="TPC_inner_radius+TPC_inner_thickness" rmax="TPC_outer_radius-TPC_outer_thickness" zhalf="TPC_zhalf-TPC_endcap_thickness"/> + <position x="0" y="0" z="0"/> + <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="0" 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> + <readout name="PadLayout1"> + <segmentation type="ProjectiveCylinder" phiBins="667" thetaBins="21"/> + <id>system:7</id> + </readout> + <readout name="PadLayout2"> + <segmentation type="ProjectiveCylinder" phiBins="692" thetaBins="21"/> + <id>system:8</id> + </readout> + <readout name="PadLayout3"> + <segmentation type="ProjectiveCylinder" phiBins="707" thetaBins="21"/> + <id>system:8</id> + </readout> + <readout name="PadLayout4"> + <segmentation type="ProjectiveCylinder" phiBins="717" thetaBins="21"/> + <id>system:8</id> + </readout> + <readout name="PadLayout5"> + <segmentation type="ProjectiveCylinder" phiBins="724" thetaBins="21"/> + <id>system:8</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/ILDExTest/TPCPrototype.xml b/DDExamples/ILDExTest/TPCPrototype.xml new file mode 100644 index 0000000000000000000000000000000000000000..0faca095b02ee2628438e4095b2693953fc093f0 --- /dev/null +++ b/DDExamples/ILDExTest/TPCPrototype.xml @@ -0,0 +1,117 @@ +<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="proto_TPC" + title="example TPC Prototype" + 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="10*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="500*mm"/> + <constant name="TPC_outer_radius" value="500*mm"/> + <constant name="TPC_inner_radius" value="0*mm"/> + <constant name="TPC_outer_thickness" value="3*mm"/> + <constant name="TPC_endcap_thickness" value="3*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="TPCPrototype" 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="0" 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="0" y="0" z="2*TPC_zhalf-0.5*TPC_endcap_thickness"/> + <rotation x="0" y="0" z="0"/> + + <modules name="TPC_Module" vis="TPCModuleVis"> + <row type ="Box" modulePosX="-15*cm" modulePosY="20*cm" moduleHeight="15*cm" moduleWidth="10*cm" modulePitch="10*cm" pads="PadLayout0" nModules="3" RowID="0"/> + <row type ="Box" modulePosX="-15*cm" modulePosY="0" moduleHeight="15*cm" moduleWidth="10*cm" modulePitch="10*cm" pads="PadLayout0" nModules="3" RowID="1"/> + <row type ="Box" modulePosX="-15*cm" modulePosY="-20*cm" moduleHeight="15*cm" moduleWidth="10*cm" modulePitch="10*cm" pads="PadLayout0" nModules="3" RowID="2"/> + </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-TPC_endcap_thickness"/> + <position x="0" 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="0" y="0" z="0"/> + <rotation x="0" y="0" z="0"/> + </detector> + </detector> + + </detectors> + + <readouts> + <readout name="PadLayout0"> + <segmentation type="CartesianGridXY" gridSizeX="2*mm" gridSizeY="6*mm"/> + <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/ILDExTest/TestILDTPC.cpp b/DDExamples/ILDExTest/TestILDTPC.cpp new file mode 100644 index 0000000000000000000000000000000000000000..be4f54e09d93a2197b021e1402f2a9f76f21f574 --- /dev/null +++ b/DDExamples/ILDExTest/TestILDTPC.cpp @@ -0,0 +1,227 @@ + +//==================================================================== +// Test application for TPC functionality +//-------------------------------------------------------------------- +// +// Author : A.Muennich +// +// +//==================================================================== + +#include "DD4hep/LCDD.h" +#include <iostream> +#include <fstream> +#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]); + + ofstream myfile; + myfile.open ("testOutput_TestILCTPC.txt"); + + //based on the reference value precision input + double myPrecision=1e-3; + int failures=0; + GearTPC tpc(lcdd.detector("TPC")); + if(fabs(tpc.getInnerRadius() - 350) > myPrecision ) + { + myfile << "FAILED tpc.getInnerRadius(): 350!=" <<tpc.getInnerRadius()<<endl; + failures++; + } + if(fabs( tpc.getOuterRadius() - 1800 )> myPrecision ) + { + myfile << "FAILED tpc.getOuterRadius(): 1800!="<<tpc.getOuterRadius()<< endl; + failures++; + } + if( fabs( tpc.getMaxDriftLength() -2497 )> myPrecision) + { + myfile << "FAILED tpc.getMaxDriftLength(): 2497!=" << tpc.getMaxDriftLength()<<endl; + failures++; + } + if(fabs(tpc.getEndPlateThickness(0) - 1.5) > myPrecision) + { + myfile << "FAILED tpc.getEndPlateThickness(0): 1.5!=" <<tpc.getEndPlateThickness(0)<<endl; + failures++; + } + if(fabs(tpc.getEndPlateZPosition(0)-2498.5)> myPrecision) + { + myfile << "FAILED tpc.getEndPlateZPosition(0): 2498.5!="<<tpc.getEndPlateZPosition(0)<<endl; + failures++; + } + if(fabs(tpc.getEndPlateThickness(1)-1.5)> myPrecision) + { + myfile << "FAILED tpc.getEndPlateThickness(1): 1.5!=" <<tpc.getEndPlateThickness(1)<<endl; + failures++; + } + if(fabs(tpc.getEndPlateZPosition(1)-(-2498.5)) > myPrecision) + { + myfile << "FAILED tpc.getEndPlateZPosition(1): -2498.5!="<<tpc.getEndPlateZPosition(1)<<endl; + failures++; + } + std::vector<TPCModule> mymods=tpc.getModules(0); + if(fabs(mymods.size()-63)> myPrecision) + { + myfile << "FAILED mymods.size(): 63!="<<mymods.size()<< endl; + failures++; + } + if(fabs(tpc.getNModules(1)-63)> myPrecision) + { + myfile << "FAILED tpc.getNModules(1): 63!= "<<tpc.getNModules(1)<< endl; + failures++; + } + int npads=0; + for(int p=0;p<mymods.size();p++) + npads+=tpc.getModule(p,0).getNPads(); + if(fabs(npads-918456)> myPrecision) + { + myfile << "FAILED npads: 918456!=" <<npads<< endl; + failures++; + } + if( fabs(tpc.getModule(2,0).id()-2)> myPrecision) + { + myfile << "FAILED tpc.getModule(2,0).id(): 2!="<< tpc.getModule(2,0).id()<<endl; + failures++; + } + if(fabs(tpc.isInsideModule(500,900,0)-1)> myPrecision) + { + myfile << "FAILED tpc.isInsideModule(500,900,0): 1!="<<tpc.isInsideModule(500,900,0)<<endl; + failures++; + } + if(fabs(tpc.getNearestModule(500,900,0).getID()-16)> myPrecision) + { + myfile << "FAILED tpc.getNearestModule(500,900,0).getID(): 16!="<<tpc.getNearestModule(500,900,0).getID()<<endl; + failures++; + } + if(fabs(tpc.getNearestModule(800,0,0).getID()-8)> myPrecision) + { + myfile << "FAILED tpc.getNearestModule(800,0,0).getID(): 8!="<<tpc.getNearestModule(800,0,0).getID()<<endl; + failures++; + } + + TPCModule mymod=tpc.getModule(10,1); + if(fabs(mymod.getID()-10)> myPrecision) + { + myfile << "FAILED mymod.getID(): 10!="<<mymod.getID()<<endl; + failures++; + } + if(mymod.getPadType()!="projective_cylinder") + { + myfile << "FAILED mymod.getPadType(): projective_cylinder!="<<mymod.getPadType()<<endl; + failures++; + } + if(fabs(mymod.getNPads()-14007)> myPrecision) + { + myfile << "FAILED mymod.getNPads(): 14007!="<<mymod.getNPads()<<endl; + failures++; + } + if(fabs(mymod.getNRows()-21)> myPrecision) + { + myfile << "FAILED mymod.getNRows(): 21!="<<mymod.getNRows()<<endl; + failures++; + } + if(fabs(mymod.getNPadsInRow(0)-667)> myPrecision) + { + myfile << "FAILED mymod.getNPadsInRow(0): 667!="<<mymod.getNPadsInRow(0)<<endl; + failures++; + } + if(fabs( mymod.getRowHeight(0)-10)> myPrecision) + { + myfile << "FAILED mymod.getRowHeight(0): 10!="<<mymod.getRowHeight(0)<<endl; + failures++; + } + if(fabs(mymod.getPadPitch(1)-0.652499)> myPrecision) + { + myfile << "FAILED mymod.getPadPitch(1): 0.652499!="<<mymod.getPadPitch(1)<<endl; + failures++; + } + if(fabs(mymod.getRowNumber(15)-0)> myPrecision) + { + myfile << "FAILED mymod.getRowNumber(15): 0!="<<mymod.getRowNumber(15)<<endl; + failures++; + } + if( fabs(mymod.getPadNumber(15)-15)> myPrecision) + { + myfile << "FAILED mymod.getPadNumber(15): 15!="<<mymod.getPadNumber(15)<<endl; + failures++; + } + if( fabs(mymod.getPadIndex(1,5)-672)> myPrecision) + { + myfile << "FAILED mymod.getPadIndex(1,5): 672!="<<mymod.getPadIndex(1,5)<<endl; + failures++; + } + if(fabs(tpc.getModule(0,0).getRightNeighbour(0)-1)> myPrecision) + { + myfile << "FAILED tpc.getModule(0,0).getRightNeighbour(0): 1!="<<tpc.getModule(0,0).getRightNeighbour(0)<<endl; + failures++; + } + if(fabs(tpc.getModule(0,0).getLeftNeighbour(3)-2)> myPrecision) + { + myfile << "FAILED tpc.getModule(0,0).getLeftNeighbour(3): 2!="<<tpc.getModule(0,0).getLeftNeighbour(3)<<endl; + failures++; + } + + std::vector<double> center1=tpc.getModule(0,0).getPadCenter(10); + if(fabs(center1[0]-406.515) > myPrecision || fabs(center1[1]-19.8558) > myPrecision) + { + myfile <<"FAILED tpc.getModule(0,0).getPadCenter(10) 406.515 19.8558 != "<<center1[0]<<" "<<center1[1]<<endl; + failures++; + } + std::vector<double> center2=tpc.getModule(1,0).getPadCenter(10); + if(fabs(center2[0]-106.736)> myPrecision || fabs(center2[1]-392.755)> myPrecision) + { + myfile <<"FAILED tpc.getModule(1,0).getPadCenter(10) 106.736 392.755 != "<<center2[0]<<" "<<center2[1]<<endl; + failures++; + } + std::vector<double> center1a=tpc.getModule(0,1).getPadCenter(10); + if(fabs(center1a[0]-(-406.515)) > myPrecision || fabs(center1a[1]-19.8558) > myPrecision) + { + myfile <<"FAILED tpc.getModule(0,1).getPadCenter(10) -406.515 19.8558 != "<<center1a[0]<<" "<<center1a[1]<<endl; + failures++; + } + std::vector<double> center2a=tpc.getModule(1,1).getPadCenter(10); + if(fabs(center2a[0]-(-106.736))> myPrecision || fabs(center2a[1]-392.755) > myPrecision) + { + myfile <<"FAILED tpc.getModule(1,1).getPadCenter(10) -106.736 392.755 != "<<center2a[0]<<" "<<center2a[1]<<endl; + failures++; + } + + if(fabs(tpc.getModule(0,0).getNearestPad(tpc.getModule(0,0).getPadCenter(10)[0],tpc.getModule(0,0).getPadCenter(10)[1]) -10)> myPrecision) + { + myfile<<"FAILED tpc.getModule(0,0).getNearestPad(): 10!=" <<tpc.getModule(0,0).getNearestPad(tpc.getModule(0,0).getPadCenter(10)[0],tpc.getModule(0,0).getPadCenter(10)[1])<<endl; + failures++; + } + if(fabs(tpc.getModule(0,0).getNearestPad(tpc.getModule(0,0).getPadCenter(0)[0],tpc.getModule(0,0).getPadCenter(0)[1]) -0)> myPrecision) + { + myfile<<"FAILED tpc.getModule(0,0).getNearestPad(): 0!=" <<tpc.getModule(0,0).getNearestPad(tpc.getModule(0,0).getPadCenter(0)[0],tpc.getModule(0,0).getPadCenter(0)[1])<<endl; + failures++; + } +if(fabs(tpc.getModule(0,0).getNearestPad(tpc.getModule(0,0).getPadCenter(5)[0],tpc.getModule(0,0).getPadCenter(5)[1]) -5)> myPrecision) + { + myfile<<"FAILED tpc.getModule(0,0).getNearestPad(): 5!=" <<tpc.getModule(0,0).getNearestPad(tpc.getModule(0,0).getPadCenter(5)[0],tpc.getModule(0,0).getPadCenter(5)[1])<<endl; + failures++; + } + if(fabs(tpc.getModule(0,0).getNearestPad(tpc.getModule(0,0).getPadCenter(120)[0],tpc.getModule(0,0).getPadCenter(120)[1]) -120)> myPrecision) + { + myfile<<"FAILED tpc.getModule(0,0).getNearestPad(): 120!=" <<tpc.getModule(0,0).getNearestPad(tpc.getModule(0,0).getPadCenter(120)[0],tpc.getModule(0,0).getPadCenter(120)[1])<<endl; + } + + if(!failures) + myfile<<"ALL PASSED"<<endl; + + myfile.close(); + + return 0; +} diff --git a/DDExamples/ILDExTest/TestTPCPrototype.cpp b/DDExamples/ILDExTest/TestTPCPrototype.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4b834122a56efcb55a2c12c89a68f3aacc13c981 --- /dev/null +++ b/DDExamples/ILDExTest/TestTPCPrototype.cpp @@ -0,0 +1,198 @@ +// +// pymain.cpp +// +// +// Created by Pere Mato on 20/1/12. +// Copyright 2012 __MyCompanyName__. All rights reserved. +// +//==================================================================== +// Test application for TPC functionality +//-------------------------------------------------------------------- +// +// Author : A.Muennich +// +// +//==================================================================== + +#include "DD4hep/LCDD.h" +#include <iostream> +#include <fstream> +#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]); + + ofstream myfile; + myfile.open ("testOutput_TestTPCPrototype.txt"); + + //based on the reference value precision input + double myPrecision=1e-3; + int failures=0; + + GearTPC tpc(lcdd.detector("TPC")); + if(fabs(tpc.getOuterRadius()-500)>myPrecision) + { + myfile<<"FAILED tpc.getOuterRadius(): 500!="<<tpc.getOuterRadius()<<endl; + failures++; + } + if(fabs(tpc.getMaxDriftLength()-497)>myPrecision) + { + myfile<<"FAILED tpc.getMaxDriftLength(): 497!="<<tpc.getMaxDriftLength()<<endl; + failures++; + } + if(fabs(tpc.getEndPlateThickness(0)-1.5)>myPrecision) + { + myfile<<"FAILED tpc.getEndPlateThickness(0): 1.5!="<<tpc.getEndPlateThickness(0)<<endl; + failures++; + } + if(fabs(tpc.getEndPlateZPosition(0)-998.5)>myPrecision) + { + myfile<<"FAILED tpc.getEndPlateZPosition(0): 998.5 !="<<tpc.getEndPlateZPosition(0)<<endl; + failures++; + } + + std::vector<TPCModule> mymods=tpc.getModules(0); + if(fabs(mymods.size()-9)>myPrecision) + { + myfile<<"FAILED mymods.size(); 9!="<<mymods.size()<< endl; + failures++; + } + int npads=0; + for(int p=0;p<mymods.size();p++) + npads+=tpc.getModule(p,0).getNPads(); + if(fabs(npads-11250)>myPrecision) + { + myfile<<"FAILED npads: 11250!=" <<npads<< endl; + failures++; + } + if(fabs(tpc.isInsideModule(-150,0,0)-1)>myPrecision) + { + myfile<<"FAILED tpc.isInsideModule: 1!="<<tpc.isInsideModule(-150,0,0)<<endl; + failures++; + } + if(fabs(tpc.getNearestModule(-150,0,0).getID()-3)>myPrecision) + { + myfile<<"FAILED tpc.getNearestModule(-150,0,0).getID(): 3!="<<tpc.getNearestModule(-150,0,0).getID()<<endl; + failures++; + } + if(fabs(tpc.getNearestModule(800,0,0).getID()-2)>myPrecision) + { + myfile<<"FAILED tpc.getNearestModule(800,0,0).getID(): 2!=" <<tpc.getNearestModule(800,0,0).getID()<<endl; + failures++; + } + + + TPCModule mymod=tpc.getModule(4,0); + if(fabs(mymod.getID()-4)>myPrecision) + { + myfile<<"FAILED mymod.getID(): 4!=" <<mymod.getID()<<endl; + failures++; + } + if(mymod.getPadType()!="cartesian_grid_xy") + { + myfile<<"FAILED mymod.getPadType(): cartesian_grid_xy!=" <<mymod.getPadType()<<endl; + failures++; + } + if(fabs(mymod.getNPads()-1250)>myPrecision) + { + myfile<<"FAILED mymod.getNPads(): 1250!="<<mymod.getNPads()<<endl; + failures++; + } + if(fabs(mymod.getNRows()-25)>myPrecision) + { + myfile<<"FAILED mymod.getNRows(): 25!="<<mymod.getNRows()<<endl; + failures++; + } + if(fabs(mymod.getNPadsInRow(0)-50)>myPrecision) + { + myfile<<"FAILED mymod.getNPadsInRow(0): 50!="<<mymod.getNPadsInRow(0)<<endl; + failures++; + } + if(fabs(mymod.getRowHeight(0)-6)>myPrecision) + { + myfile<<"FAILED mymod.getRowHeight(0): 6!="<<mymod.getRowHeight(0)<<endl; + failures++; + } + if(fabs(mymod.getPadPitch(1)-2)>myPrecision) + { + myfile<<"FAILED mymod.getPadPitch(1): 2!="<<mymod.getPadPitch(1)<<endl; + failures++; + } + if(fabs(mymod.getRowNumber(15)-0)>myPrecision) + { + myfile<<"FAILED mymod.getRowNumber(15): 0!=" <<mymod.getRowNumber(15)<<endl; + failures++; + } + if(fabs(mymod.getPadNumber(15)-15)>myPrecision) + { + myfile<<"FAILED mymod.getPadNumber(15): 15!=" <<mymod.getPadNumber(15)<<endl; + failures++; + } + if(fabs(mymod.getPadIndex(1,5)-55)>myPrecision) + { + myfile<<"FAILED mymod.getPadIndex(1,5): 55!=" <<mymod.getPadIndex(1,5)<<endl; + failures++; + } + if(fabs(tpc.getModule(0,0).getRightNeighbour(0)-1)>myPrecision) + { + myfile<<"FAILED tpc.getModule(0,0).getRightNeighbour(0): 1!="<<tpc.getModule(0,0).getRightNeighbour(0)<<endl; + failures++; + } + if(fabs(tpc.getModule(0,0).getLeftNeighbour(3)-2)>myPrecision) + { + myfile<<"FAILED tpc.getModule(0,0).getLeftNeighbour(3): 2!="<<tpc.getModule(0,0).getLeftNeighbour(3)<<endl; + failures++; + } + std::vector<double> center1=tpc.getModule(0,0).getPadCenter(10); + if(fabs(center1[0]-179)>myPrecision && fabs(center1[1]-128)>myPrecision) + { + myfile<<"FAILED tpc.getModule(0,0).getPadCenter(10): -179 128!= " <<center1[0]<<" "<<center1[1]<<endl; + failures++; + } + std::vector<double> center2=tpc.getModule(8,0).getPadCenter(10); + if(fabs(center2[0]-121)>myPrecision && fabs(center2[1]-272)>myPrecision) + { + myfile<<"FAILED tpc.getModule(8,0).getPadCenter(10): 121 -272!= " <<center2[0]<<" "<<center2[1]<<endl; + failures++; + } + if(fabs(tpc.getModule(0,0).getNearestPad(tpc.getModule(0,0).getPadCenter(10)[0],tpc.getModule(0,0).getPadCenter(10)[1])-10) >myPrecision) + { + myfile<<"FAILED tpc.getModule(0,0).getNearestPad(): 10!=" <<tpc.getModule(0,0).getNearestPad(tpc.getModule(0,0).getPadCenter(10)[0],tpc.getModule(0,0).getPadCenter(10)[1])<<endl; + failures++; + } + if(fabs(tpc.getModule(0,0).getNearestPad(tpc.getModule(0,0).getPadCenter(0)[0],tpc.getModule(0,0).getPadCenter(0)[1])) >myPrecision) + { + myfile<<"FAILED tpc.getModule(0,0).getNearestPad(): 0!=" <<tpc.getModule(0,0).getNearestPad(tpc.getModule(0,0).getPadCenter(0)[0],tpc.getModule(0,0).getPadCenter(0)[1])<<endl; + failures++; + } + if(fabs(tpc.getModule(0,0).getNearestPad(tpc.getModule(0,0).getPadCenter(5)[0],tpc.getModule(0,0).getPadCenter(5)[1]) -5)>myPrecision) + { + myfile<<"FAILED tpc.getModule(0,0).getNearestPad(): 5!=" <<tpc.getModule(0,0).getNearestPad(tpc.getModule(0,0).getPadCenter(5)[0],tpc.getModule(0,0).getPadCenter(5)[1])<<endl; + failures++; + } + if(fabs(tpc.getModule(0,0).getNearestPad(tpc.getModule(0,0).getPadCenter(120)[0],tpc.getModule(0,0).getPadCenter(120)[1])-120) >myPrecision) + { + myfile<<"FAILED tpc.getModule(0,0).getNearestPad(): 120!=" <<tpc.getModule(0,0).getNearestPad(tpc.getModule(0,0).getPadCenter(120)[0],tpc.getModule(0,0).getPadCenter(120)[1])<<endl; + failures++; + } + + if(!failures) + myfile<<"ALL PASSED"<<endl; + + myfile.close(); + + return 0; +} diff --git a/DDExamples/ILDExTest/elements.xml b/DDExamples/ILDExTest/elements.xml new file mode 120000 index 0000000000000000000000000000000000000000..06397c3f5d23b5e3a84f0eac90208b0bbdf550ab --- /dev/null +++ b/DDExamples/ILDExTest/elements.xml @@ -0,0 +1 @@ +../ILDExDet/compact/elements.xml \ No newline at end of file diff --git a/DDExamples/ILDExTest/materials.xml b/DDExamples/ILDExTest/materials.xml new file mode 120000 index 0000000000000000000000000000000000000000..01a54e8d12d31c0692226b7f2dddae5e12e71ce2 --- /dev/null +++ b/DDExamples/ILDExTest/materials.xml @@ -0,0 +1 @@ +../ILDExDet/compact/materials.xml \ No newline at end of file diff --git a/DDExamples/ILDExTest/reference_TestILDTPC.txt b/DDExamples/ILDExTest/reference_TestILDTPC.txt new file mode 100644 index 0000000000000000000000000000000000000000..b6913e4869135e6d6ebe4e811a7ce4124d7b6cb8 --- /dev/null +++ b/DDExamples/ILDExTest/reference_TestILDTPC.txt @@ -0,0 +1,37 @@ +Gear TPC functionality: +-----> Inner Radius: 350 +-----> Outer Radius: 1800 +-----> DriftLength: 2497 +-----> EndplateThickness 0: 1.5 +-----> EndplateZPosition 0: 2498.5 +-----> EndplateThickness 1: 1.5 +-----> EndplateZPosition 1: -2498.5 +-----> NModules EP0: 63 +-----> NModules EP1: 63 +-----> NPads EP1: 918456 +-----> Module 2 EP 0 ID: 2 +-----> Inside Module (500,900): 1 +-----> Nearest Module (500,900) ->16: 16 +-----> Nearest Module (800,0): 8 +TPC Module functionality: +-----> Module 10 EP 1 ID: 10 +-----> Module 10 Pads: projective_cylinder +-----> Module 10 NPads: 14007 +-----> Module 10 pad rows: 21 +-----> Module 10 pads in rows: 667 +-----> Module 10 row height: 10 +-----> Module 10 pad pitch: 0.652499 +-----> Module 10 row number pad 15: 0 +-----> Module 10 pad number pad 15: 15 +-----> Module 10 pad index (1,5): 672 +-----> RightNeighbour of 0: 1 +-----> LeftNeighbour of 3: 2 +-----> Center of mod0/pad10 EP0: 406.515 19.8558 +-----> Center of mod1/pad10 EP0: 106.736 392.755 +-----> Center of mod0/pad10 EP1: -406.515 19.8558 +-----> Center of mod1/pad10 EP1: -106.736 392.755 +-----> Nearest Pad 10: 10 +-----> Nearest Pad 0: 0 +-----> Nearest Pad 5: 5 +-----> Nearest Pad 20: 20 +-----> Exception test: OutsideGeometryException: getRowNumber: Requested pad not on module querried! diff --git a/DDExamples/ILDExTest/reference_TestTPCPrototype.txt b/DDExamples/ILDExTest/reference_TestTPCPrototype.txt new file mode 100644 index 0000000000000000000000000000000000000000..41f5c01f5bf2dc7257735e10f947cdb9d93e13e5 --- /dev/null +++ b/DDExamples/ILDExTest/reference_TestTPCPrototype.txt @@ -0,0 +1,30 @@ +Gear TPC functionality: +-----> Outer Radius: 500 +-----> DriftLength: 497 +-----> EndplateThickness 0: 1.5 +-----> EndplateZPosition 0: 998.5 +-----> Exception test: OutsideGeometryException: TPC endplate not found! +-----> NModules EP0: 9 +-----> NPads EP0: 11250 +-----> Inside Module (-150,0): 1 +-----> Nearest Module (-150,0): 3 +-----> Nearest Module (800,0): 2 +TPC Module functionality: +-----> Module 4 EP 0 ID: 4 +-----> Module 4 Pads: cartesian_grid_xy +-----> Module 4 NPads: 1250 +-----> Module 4 pad rows: 25 +-----> Module 4 pads in row: 50 +-----> Module 4 row height: 6 +-----> Module 4 pad pitch: 2 +-----> Module 4 row number pad 15: 0 +-----> Module 4 pad number pad 15: 15 +-----> Module 4 pad index (1,5): 55 +-----> RightNeighbour of 0: 1 +-----> LeftNeighbour of 3: 2 +-----> Center of mod0/pad10 EP0: -179 128 +-----> Center of mod9/pad10 EP0: 121 -272 +-----> Nearest Pad 10: 10 +-----> Nearest Pad 0: 0 +-----> Nearest Pad 5: 5 +-----> Nearest Pad 120: 120