2 #include "gearimpl/Util.h"
3 #include "gearxml/GearXML.h"
4 #include "gear/GearMgr.h"
6 #include "gear/VXDParameters.h"
9 #include "gearcga/CGAGearDistanceProperties.h"
10 #include "gearcga/CGAGearPointProperties.h"
25 #include "AIDA/AIDA.h"
26 using namespace AIDA ;
31 using namespace gear ;
47 void gear_unexpected(){
53 }
catch( std::exception& e) {
55 std::cout <<
" A runtime error has occured : "
58 <<
" the program will have to be terminated - sorry." << std::endl ;
67 IAnalysisFactory * myaida ;
68 ITreeFactory * mytreefactory ;
70 IHistogramFactory * myhistofactory ;
71 ITupleFactory * mytuplefactory ;
83 int main(
int argc,
char**argv){
86 std::set_unexpected( gear_unexpected ) ;
87 std::set_terminate( gear_unexpected ) ;
90 std::cout <<
" testgear: Testprogram for vertex detecto in gear. " << std::endl
91 <<
" usage: testgear input.xml " << std::endl ;
95 std::string fileName( argv[1] ) ;
99 GearMgr* gearMgr = gearXML.createGearMgr() ;
102 std::cout <<
" testVTXgear - instantiated GearMgr from file " << fileName
109 std::cout <<
" VXD parameters : " << std::endl
117 std::string storeName(
"vxdCheckPlot.root");
119 myaida = AIDA_createAnalysisFactory() ;
121 mytreefactory = myaida->createTreeFactory() ;
123 mytree = mytreefactory->create(storeName,
"root",
false,
true,
"none") ;
126 myhistofactory = myaida->createHistogramFactory( *mytree ) ;
127 mytuplefactory = myaida->createTupleFactory( *mytree ) ;
134 createCheckPlots( vp ) ;
138 std::cout <<
" Compile with GEAR_USE_AIDA==1 to get some histograms ! "
166 testVXDDist( p0, vxdParams ) ;
167 testVXDDist( p1, vxdParams ) ;
168 testVXDDist( p2, vxdParams ) ;
169 testVXDDist( p3, vxdParams ) ;
170 testVXDDist( p4, vxdParams ) ;
173 testAllVXDPoint( vxdParams ) ;
183 double testStart = -65 ;
184 double testEnd = 65 ;
185 double testStep = .05 ;
191 int skipDist = 1000 ;
194 double testDetailStart = 2 ;
195 double testDetailEnd = 18 ;
196 double testDetailStep = 0.005 ;
198 float myStatusP = 0, myStatusL = 0;
199 int nLadder = 0 , nSensitive = 0 ;
202 std::string mapName =
"vxdMap" ;
203 std::string mapTitle =
"Map of the VTX" ;
204 std::vector<std::string> columnNames ;
205 std::vector<std::string> columnTypes ;
207 columnNames.push_back(
"x" ) ; columnTypes.push_back(
"double" ) ;
208 columnNames.push_back(
"y" ) ; columnTypes.push_back(
"double" ) ;
209 columnNames.push_back(
"z" ) ; columnTypes.push_back(
"double" ) ;
210 columnNames.push_back(
"sensitive" ) ; columnTypes.push_back(
"bool" ) ;
212 ITuple *vxdMap = mytuplefactory->create( mapName , mapTitle , columnNames , columnTypes ) ;
215 mapName =
"vxdDetailMap" ;
216 mapTitle =
"Detailed Map of part of the VTX" ;
218 ITuple *vxdDetailMap = mytuplefactory->create( mapName , mapTitle , columnNames , columnTypes ) ;
221 mapName =
"vxdPointsOnSurface" ;
222 mapTitle =
"Map of Points On Surface" ;
224 ITuple *vxdSurfaceMap = mytuplefactory->create( mapName , mapTitle , columnNames , columnTypes ) ;
227 mapName =
"vxdIntersectionPoints" ;
228 mapTitle =
"Map of Intersection Points" ;
230 ITuple *vxdIntersectionMap = mytuplefactory->create( mapName , mapTitle , columnNames , columnTypes ) ;
233 IHistogram1D *distanceHisto = myhistofactory->createHistogram1D(
"distance",
234 100, 0, 0.00000000000001 ) ;
237 int nPoints = int( (testEnd-testStart)*(testEnd-testStart)*(zEnd-zStart)
238 / ( testStep * testStep * zStep )
239 + (testDetailEnd-testDetailStart)*(testDetailEnd-testDetailStart)*(zEnd-zStart)
240 / (testDetailStep * testDetailStep * zStep ) ) ;
242 std::cout <<
"Testing " << nPoints <<
" Points to AIDA" << std::endl ;
249 for (
double x = testStart ; x < testEnd ; x += testStep ) {
252 float curStatus = (x - testStart) / (testEnd - testStart) * 50 ;
253 if ( curStatus > ( myStatusP + 0.25 ) ) {
254 myStatusP = curStatus ;
255 std::cout <<
"." << std::flush ;
257 if ( curStatus > ( myStatusL + 10 ) ) {
258 myStatusL = curStatus ;
259 std::cout << floor(myStatusL) <<
"% finished" << std::endl ;
264 for (
double y=testStart ; y < testEnd ; y += testStep ) {
267 for (
double z = zStart ; z < zEnd ; z += zStep ) {
273 if( isPoint ) nLadder ++;
274 if( isSensitive ) nSensitive ++;
276 if( isPoint || isSensitive ) {
279 vxdMap->fill( 0 , p[0] ) ;
280 vxdMap->fill( 1 , p[1] ) ;
281 vxdMap->fill( 2 , p[2] ) ;
282 vxdMap->fill( 3 , isSensitive ) ;
287 if( skipped >= skipDist ) {
291 Vector3D np ( p[0] + v[0] , p[1] + v[1] , p[2] + v[2] ) ;
294 Vector3D nps ( p[0] + v[0] , p[1] + v[1] , p[2] + v[2] ) ;
296 vxdSurfaceMap->fill( 0 , np[0] ) ;
297 vxdSurfaceMap->fill( 1 , np[1] ) ;
298 vxdSurfaceMap->fill( 2 , np[2] ) ;
299 vxdSurfaceMap->fill( 3 ,
false ) ;
300 vxdSurfaceMap->addRow() ;
302 vxdSurfaceMap->fill( 0 , nps[0] ) ;
303 vxdSurfaceMap->fill( 1 , nps[1] ) ;
304 vxdSurfaceMap->fill( 2 , nps[2] ) ;
305 vxdSurfaceMap->fill( 3 ,
true ) ;
306 vxdSurfaceMap->addRow() ;
310 distanceHisto->fill( sqrt( v[0]*v[0] + v[1]*v[1] + v[2]*v[2] ) ) ;
327 for (
double x = testDetailStart ; x < testDetailEnd ; x += testDetailStep ) {
330 float curStatus = (x - testDetailStart) / (testDetailEnd - testDetailStart) * 50 + 50 ;
331 if ( curStatus > ( myStatusP + 0.25 ) ) {
332 myStatusP = curStatus ;
333 std::cout <<
"." << std::flush ;
335 if ( curStatus > ( myStatusL + 10 ) ) {
336 myStatusL = curStatus ;
337 std::cout << floor(myStatusL) <<
"% finished" << std::endl ;
342 for (
double y=testDetailStart ; y < testDetailEnd ; y += testDetailStep ) {
345 for (
double z = zStart ; z < zEnd ; z += zStep ) {
351 if( isPoint ) nLadder ++;
352 if( isSensitive ) nSensitive ++;
354 if( isPoint || isSensitive ) {
357 vxdDetailMap->fill( 0 , p[0] ) ;
358 vxdDetailMap->fill( 1 , p[1] ) ;
359 vxdDetailMap->fill( 2 , p[2] ) ;
360 vxdDetailMap->fill( 3 , isSensitive ) ;
361 vxdDetailMap->addRow() ;
372 std::cout <<
"Testing intersection " << std::flush ;
379 for(
double phi=-M_PI ; phi < M_PI ; phi += (M_PI/180) ) {
380 lineVec =
Vector3D ( sin(phi) , cos(phi) , 0 ) ;
383 vxdIntersectionMap->fill( 0, iPoint0[0] ) ;
384 vxdIntersectionMap->fill( 1, iPoint0[1] ) ;
385 vxdIntersectionMap->fill( 2, iPoint0[2] ) ;
386 vxdIntersectionMap->fill( 3,
false ) ;
387 vxdIntersectionMap->addRow() ;
388 vxdIntersectionMap->fill( 0, iPoint1[0] ) ;
389 vxdIntersectionMap->fill( 1, iPoint1[1] ) ;
390 vxdIntersectionMap->fill( 2, iPoint1[2] ) ;
391 vxdIntersectionMap->fill( 3,
false ) ;
392 vxdIntersectionMap->addRow() ;
397 std::cout <<
"\ntotal tested points: " << nPoints <<
"\n"
398 <<
" in ladder: " << nLadder <<
" (" << nLadder/nPoints*100 <<
") \n"
399 <<
" in sensitive: " << nSensitive <<
" (" << nSensitive/nPoints*100 <<
")\n"
400 <<
"Points finished " << std::endl ;
414 std::cout << p[0] <<
" " << p[1] <<
" "<< p[2] ;
418 std::cout << p[0] <<
" " << p[1] <<
" "<< p[2] <<
" inside";
421 std::cout << std::endl ;
429 std::cout <<
"\nPoint (" << p[0] <<
"," << p[1] <<
"," << p[2] <<
") "
430 <<
"\ndistance Vector " << v << std::endl;
442 std::cout <<
" distance to ladder : " << v2.
r() << std::endl ;
480 double testStart = -65 ;
481 double testEnd = 65 ;
482 double testStep = 0.05 ;
487 float myStatusP = 0, myStatusL = 0;
488 int nLadder = 0 , nSensitive = 0 ;
490 std::ofstream myfile;
491 const char *fileName =
"./gearVXDTest.txt" ;
492 myfile.open (fileName, std::ios::out | std::ios::trunc );
499 std::string mapName =
"vxdMap" ;
500 std::string mapTitle =
"Map of the VTX" ;
501 std::vector<std::string> columnNames ;
502 std::vector<std::string> columnTypes ;
504 columnNames.push_back(
"x" ) ; columnTypes.push_back(
"double" ) ;
505 columnNames.push_back(
"y" ) ; columnTypes.push_back(
"double" ) ;
506 columnNames.push_back(
"z" ) ; columnTypes.push_back(
"double" ) ;
507 columnNames.push_back(
"sensitive" ) ; columnTypes.push_back(
"bool" ) ;
509 ITuple *ladderMap = mytuplefactory->create( mapName , mapTitle , columnNames , columnTypes ) ;
514 int nPoints = int( (testEnd-testStart)*(testEnd-testStart)*(zEnd-zStart)
515 / ( testStep * testStep * zStep ) ) ;
516 std::cout <<
"Testing " << nPoints <<
" Points to AIDA" << std::endl ;
519 for (
double x=testStart ; x < testEnd ; x += testStep ) {
522 float curStatus = (x - testStart) / (testEnd - testStart) * 100 ;
523 if ( curStatus > ( myStatusP + 0.25 ) ) {
524 myStatusP = curStatus ;
525 std::cout <<
"." << std::flush ;
527 if ( curStatus > ( myStatusL + 10 ) ) {
528 myStatusL = curStatus ;
529 std::cout << floor(myStatusL) <<
"% finished" << std::endl ;
533 for (
double y=testStart ; y < testEnd ; y += testStep ) {
536 for (
double z = zStart ; z < zEnd ; z += zStep ) {
542 if( isPoint ) nLadder ++;
543 if( isSensitive ) nSensitive ++;
545 if( isPoint || isSensitive ) {
546 myfile << p[0] <<
" " << p[1] <<
" "<< p[2] <<
" " << isSensitive <<
"\n" ;
549 ladderMap->fill( 0 , p[0] ) ;
550 ladderMap->fill( 1 , p[1] ) ;
551 ladderMap->fill( 2 , p[2] ) ;
552 ladderMap->fill( 3 , isSensitive ) ;
553 ladderMap->addRow() ;
563 std::cout <<
"\ntotal tested points: " << nPoints <<
"\n"
564 <<
" in ladder: " << nLadder <<
" (" << nLadder/nPoints*100 <<
") \n"
565 <<
" in sensitive: " << nSensitive <<
" (" << nSensitive/nPoints*100 <<
")\n"
566 <<
"Points finished " << std::endl ;
573 double testStart = -65 ;
574 double testEnd = 65 ;
575 double testStep = 1 ;
576 double zStart = -120 ;
580 float myStatusP = 0, myStatusL = 0;
582 std::ofstream myfile, myHisto;
583 const char *fileName =
"./gearVXDTest_out.txt" ;
584 const char *histoName =
"./gearVXDTest_Histogram.txt" ;
585 myfile.open (fileName, std::ios::out | std::ios::trunc );
586 myHisto.open( histoName, std::ios::out | std::ios::trunc ) ;
588 int nPoints = int ( (testEnd-testStart)*(testEnd-testStart)*(zEnd-zStart)
589 / ( testStep * testStep * zStep ) ) ;
590 std::cout <<
"Testing " << nPoints <<
" Points to file : " << fileName <<std::endl ;
593 for (
double x=testStart ; x < testEnd ; x += testStep ) {
596 float curStatus = (x - testStart) / (testEnd - testStart) * 100 ;
597 if ( curStatus > ( myStatusP + 0.25 ) ) {
598 myStatusP = curStatus ;
599 std::cout <<
"." << std::flush ;
601 if ( curStatus > ( myStatusL + 10 ) ) {
602 myStatusL = curStatus ;
603 std::cout << floor(myStatusL) <<
"% finished" << std::endl ;
607 for (
double y=testStart ; y < testEnd ; y += testStep ) {
610 for (
double z = zStart ; z < zEnd ; z += zStep ) {
614 Vector3D np ( p[0] + nv[0] , p[1] + nv[1] , p[2] + nv[2] ) ;
620 myHisto << sqrt( nv2[0]*nv2[0] + nv2[1]*nv2[1] + nv2[2]*nv2[2] ) <<
"\n" ;
621 myfile << np[0] <<
" " << np[1] <<
" "<< np[2] << 0 <<
"\n" ;
631 std::cout <<
"Points finished " << std::endl ;
virtual bool isPointInSensitive(Vector3D p, SensorID *sensorID=0) const =0
returns wheter a point is inside a sensitive volume- if sensorID != 0 the sensorID is returned in cas...
Geometry properties of a vertex detector needed for reconstruction code.
virtual const ZPlanarParameters & getVXDParameters() const =0
Get the VXD parameters.
virtual bool isPointInLadder(Vector3D p) const =0
returns whether a point is inside a ladder
Implementation of GEAR using XML.
Simple three dimensional vector providing the components for cartesian, cylindrical and spherical coo...
virtual Vector3D distanceToNearestLadder(Vector3D p) const =0
returns vector from point to nearest ladder
virtual Vector3D intersectionLadder(Vector3D p, Vector3D v) const =0
returns the first point where a given straight line (parameters point p and direction v) crosses a la...
double r() const
Spherical r/magnitude.
Abstract interface for a manager class that returns the Gear classes for the relevant subdetectors...
virtual Vector3D distanceToNearestSensitive(Vector3D p) const =0
returns vector from point to nearest sensitive volume