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_terminate( gear_unexpected ) ;
89 std::cout <<
" testgear: Testprogram for vertex detecto in gear. " << std::endl
90 <<
" usage: testgear input.xml " << std::endl ;
94 std::string fileName( argv[1] ) ;
98 GearMgr* gearMgr = gearXML.createGearMgr() ;
101 std::cout <<
" testVTXgear - instantiated GearMgr from file " << fileName
108 std::cout <<
" VXD parameters : " << std::endl
116 std::string storeName(
"vxdCheckPlot.root");
118 myaida = AIDA_createAnalysisFactory() ;
120 mytreefactory = myaida->createTreeFactory() ;
122 mytree = mytreefactory->create(storeName,
"root",
false,
true,
"none") ;
125 myhistofactory = myaida->createHistogramFactory( *mytree ) ;
126 mytuplefactory = myaida->createTupleFactory( *mytree ) ;
133 createCheckPlots( vp ) ;
137 std::cout <<
" Compile with GEAR_USE_AIDA==1 to get some histograms ! "
165 testVXDDist( p0, vxdParams ) ;
166 testVXDDist( p1, vxdParams ) ;
167 testVXDDist( p2, vxdParams ) ;
168 testVXDDist( p3, vxdParams ) ;
169 testVXDDist( p4, vxdParams ) ;
172 testAllVXDPoint( vxdParams ) ;
182 double testStart = -65 ;
183 double testEnd = 65 ;
184 double testStep = .05 ;
190 int skipDist = 1000 ;
193 double testDetailStart = 2 ;
194 double testDetailEnd = 18 ;
195 double testDetailStep = 0.005 ;
197 float myStatusP = 0, myStatusL = 0;
198 int nLadder = 0 , nSensitive = 0 ;
201 std::string mapName =
"vxdMap" ;
202 std::string mapTitle =
"Map of the VTX" ;
203 std::vector<std::string> columnNames ;
204 std::vector<std::string> columnTypes ;
206 columnNames.push_back(
"x" ) ; columnTypes.push_back(
"double" ) ;
207 columnNames.push_back(
"y" ) ; columnTypes.push_back(
"double" ) ;
208 columnNames.push_back(
"z" ) ; columnTypes.push_back(
"double" ) ;
209 columnNames.push_back(
"sensitive" ) ; columnTypes.push_back(
"bool" ) ;
211 ITuple *vxdMap = mytuplefactory->create( mapName , mapTitle , columnNames , columnTypes ) ;
214 mapName =
"vxdDetailMap" ;
215 mapTitle =
"Detailed Map of part of the VTX" ;
217 ITuple *vxdDetailMap = mytuplefactory->create( mapName , mapTitle , columnNames , columnTypes ) ;
220 mapName =
"vxdPointsOnSurface" ;
221 mapTitle =
"Map of Points On Surface" ;
223 ITuple *vxdSurfaceMap = mytuplefactory->create( mapName , mapTitle , columnNames , columnTypes ) ;
226 mapName =
"vxdIntersectionPoints" ;
227 mapTitle =
"Map of Intersection Points" ;
229 ITuple *vxdIntersectionMap = mytuplefactory->create( mapName , mapTitle , columnNames , columnTypes ) ;
232 IHistogram1D *distanceHisto = myhistofactory->createHistogram1D(
"distance",
233 100, 0, 0.00000000000001 ) ;
236 int nPoints = int( (testEnd-testStart)*(testEnd-testStart)*(zEnd-zStart)
237 / ( testStep * testStep * zStep )
238 + (testDetailEnd-testDetailStart)*(testDetailEnd-testDetailStart)*(zEnd-zStart)
239 / (testDetailStep * testDetailStep * zStep ) ) ;
241 std::cout <<
"Testing " << nPoints <<
" Points to AIDA" << std::endl ;
248 for (
double x = testStart ; x < testEnd ; x += testStep ) {
251 float curStatus = (x - testStart) / (testEnd - testStart) * 50 ;
252 if ( curStatus > ( myStatusP + 0.25 ) ) {
253 myStatusP = curStatus ;
254 std::cout <<
"." << std::flush ;
256 if ( curStatus > ( myStatusL + 10 ) ) {
257 myStatusL = curStatus ;
258 std::cout << floor(myStatusL) <<
"% finished" << std::endl ;
263 for (
double y=testStart ; y < testEnd ; y += testStep ) {
266 for (
double z = zStart ; z < zEnd ; z += zStep ) {
272 if( isPoint ) nLadder ++;
273 if( isSensitive ) nSensitive ++;
275 if( isPoint || isSensitive ) {
278 vxdMap->fill( 0 , p[0] ) ;
279 vxdMap->fill( 1 , p[1] ) ;
280 vxdMap->fill( 2 , p[2] ) ;
281 vxdMap->fill( 3 , isSensitive ) ;
286 if( skipped >= skipDist ) {
290 Vector3D np ( p[0] + v[0] , p[1] + v[1] , p[2] + v[2] ) ;
293 Vector3D nps ( p[0] + v[0] , p[1] + v[1] , p[2] + v[2] ) ;
295 vxdSurfaceMap->fill( 0 , np[0] ) ;
296 vxdSurfaceMap->fill( 1 , np[1] ) ;
297 vxdSurfaceMap->fill( 2 , np[2] ) ;
298 vxdSurfaceMap->fill( 3 ,
false ) ;
299 vxdSurfaceMap->addRow() ;
301 vxdSurfaceMap->fill( 0 , nps[0] ) ;
302 vxdSurfaceMap->fill( 1 , nps[1] ) ;
303 vxdSurfaceMap->fill( 2 , nps[2] ) ;
304 vxdSurfaceMap->fill( 3 ,
true ) ;
305 vxdSurfaceMap->addRow() ;
309 distanceHisto->fill( sqrt( v[0]*v[0] + v[1]*v[1] + v[2]*v[2] ) ) ;
326 for (
double x = testDetailStart ; x < testDetailEnd ; x += testDetailStep ) {
329 float curStatus = (x - testDetailStart) / (testDetailEnd - testDetailStart) * 50 + 50 ;
330 if ( curStatus > ( myStatusP + 0.25 ) ) {
331 myStatusP = curStatus ;
332 std::cout <<
"." << std::flush ;
334 if ( curStatus > ( myStatusL + 10 ) ) {
335 myStatusL = curStatus ;
336 std::cout << floor(myStatusL) <<
"% finished" << std::endl ;
341 for (
double y=testDetailStart ; y < testDetailEnd ; y += testDetailStep ) {
344 for (
double z = zStart ; z < zEnd ; z += zStep ) {
350 if( isPoint ) nLadder ++;
351 if( isSensitive ) nSensitive ++;
353 if( isPoint || isSensitive ) {
356 vxdDetailMap->fill( 0 , p[0] ) ;
357 vxdDetailMap->fill( 1 , p[1] ) ;
358 vxdDetailMap->fill( 2 , p[2] ) ;
359 vxdDetailMap->fill( 3 , isSensitive ) ;
360 vxdDetailMap->addRow() ;
371 std::cout <<
"Testing intersection " << std::flush ;
378 for(
double phi=-M_PI ; phi < M_PI ; phi += (M_PI/180) ) {
379 lineVec =
Vector3D ( sin(phi) , cos(phi) , 0 ) ;
382 vxdIntersectionMap->fill( 0, iPoint0[0] ) ;
383 vxdIntersectionMap->fill( 1, iPoint0[1] ) ;
384 vxdIntersectionMap->fill( 2, iPoint0[2] ) ;
385 vxdIntersectionMap->fill( 3,
false ) ;
386 vxdIntersectionMap->addRow() ;
387 vxdIntersectionMap->fill( 0, iPoint1[0] ) ;
388 vxdIntersectionMap->fill( 1, iPoint1[1] ) ;
389 vxdIntersectionMap->fill( 2, iPoint1[2] ) ;
390 vxdIntersectionMap->fill( 3,
false ) ;
391 vxdIntersectionMap->addRow() ;
396 std::cout <<
"\ntotal tested points: " << nPoints <<
"\n"
397 <<
" in ladder: " << nLadder <<
" (" << nLadder/nPoints*100 <<
") \n"
398 <<
" in sensitive: " << nSensitive <<
" (" << nSensitive/nPoints*100 <<
")\n"
399 <<
"Points finished " << std::endl ;
413 std::cout << p[0] <<
" " << p[1] <<
" "<< p[2] ;
417 std::cout << p[0] <<
" " << p[1] <<
" "<< p[2] <<
" inside";
420 std::cout << std::endl ;
428 std::cout <<
"\nPoint (" << p[0] <<
"," << p[1] <<
"," << p[2] <<
") "
429 <<
"\ndistance Vector " << v << std::endl;
441 std::cout <<
" distance to ladder : " << v2.
r() << std::endl ;
479 double testStart = -65 ;
480 double testEnd = 65 ;
481 double testStep = 0.05 ;
486 float myStatusP = 0, myStatusL = 0;
487 int nLadder = 0 , nSensitive = 0 ;
489 std::ofstream myfile;
490 const char *fileName =
"./gearVXDTest.txt" ;
491 myfile.open (fileName, std::ios::out | std::ios::trunc );
498 std::string mapName =
"vxdMap" ;
499 std::string mapTitle =
"Map of the VTX" ;
500 std::vector<std::string> columnNames ;
501 std::vector<std::string> columnTypes ;
503 columnNames.push_back(
"x" ) ; columnTypes.push_back(
"double" ) ;
504 columnNames.push_back(
"y" ) ; columnTypes.push_back(
"double" ) ;
505 columnNames.push_back(
"z" ) ; columnTypes.push_back(
"double" ) ;
506 columnNames.push_back(
"sensitive" ) ; columnTypes.push_back(
"bool" ) ;
508 ITuple *ladderMap = mytuplefactory->create( mapName , mapTitle , columnNames , columnTypes ) ;
513 int nPoints = int( (testEnd-testStart)*(testEnd-testStart)*(zEnd-zStart)
514 / ( testStep * testStep * zStep ) ) ;
515 std::cout <<
"Testing " << nPoints <<
" Points to AIDA" << std::endl ;
518 for (
double x=testStart ; x < testEnd ; x += testStep ) {
521 float curStatus = (x - testStart) / (testEnd - testStart) * 100 ;
522 if ( curStatus > ( myStatusP + 0.25 ) ) {
523 myStatusP = curStatus ;
524 std::cout <<
"." << std::flush ;
526 if ( curStatus > ( myStatusL + 10 ) ) {
527 myStatusL = curStatus ;
528 std::cout << floor(myStatusL) <<
"% finished" << std::endl ;
532 for (
double y=testStart ; y < testEnd ; y += testStep ) {
535 for (
double z = zStart ; z < zEnd ; z += zStep ) {
541 if( isPoint ) nLadder ++;
542 if( isSensitive ) nSensitive ++;
544 if( isPoint || isSensitive ) {
545 myfile << p[0] <<
" " << p[1] <<
" "<< p[2] <<
" " << isSensitive <<
"\n" ;
548 ladderMap->fill( 0 , p[0] ) ;
549 ladderMap->fill( 1 , p[1] ) ;
550 ladderMap->fill( 2 , p[2] ) ;
551 ladderMap->fill( 3 , isSensitive ) ;
552 ladderMap->addRow() ;
562 std::cout <<
"\ntotal tested points: " << nPoints <<
"\n"
563 <<
" in ladder: " << nLadder <<
" (" << nLadder/nPoints*100 <<
") \n"
564 <<
" in sensitive: " << nSensitive <<
" (" << nSensitive/nPoints*100 <<
")\n"
565 <<
"Points finished " << std::endl ;
572 double testStart = -65 ;
573 double testEnd = 65 ;
574 double testStep = 1 ;
575 double zStart = -120 ;
579 float myStatusP = 0, myStatusL = 0;
581 std::ofstream myfile, myHisto;
582 const char *fileName =
"./gearVXDTest_out.txt" ;
583 const char *histoName =
"./gearVXDTest_Histogram.txt" ;
584 myfile.open (fileName, std::ios::out | std::ios::trunc );
585 myHisto.open( histoName, std::ios::out | std::ios::trunc ) ;
587 int nPoints = int ( (testEnd-testStart)*(testEnd-testStart)*(zEnd-zStart)
588 / ( testStep * testStep * zStep ) ) ;
589 std::cout <<
"Testing " << nPoints <<
" Points to file : " << fileName <<std::endl ;
592 for (
double x=testStart ; x < testEnd ; x += testStep ) {
595 float curStatus = (x - testStart) / (testEnd - testStart) * 100 ;
596 if ( curStatus > ( myStatusP + 0.25 ) ) {
597 myStatusP = curStatus ;
598 std::cout <<
"." << std::flush ;
600 if ( curStatus > ( myStatusL + 10 ) ) {
601 myStatusL = curStatus ;
602 std::cout << floor(myStatusL) <<
"% finished" << std::endl ;
606 for (
double y=testStart ; y < testEnd ; y += testStep ) {
609 for (
double z = zStart ; z < zEnd ; z += zStep ) {
613 Vector3D np ( p[0] + nv[0] , p[1] + nv[1] , p[2] + nv[2] ) ;
619 myHisto << sqrt( nv2[0]*nv2[0] + nv2[1]*nv2[1] + nv2[2]*nv2[2] ) <<
"\n" ;
620 myfile << np[0] <<
" " << np[1] <<
" "<< np[2] << 0 <<
"\n" ;
630 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