Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-03-13 08:20:26

0001 #include "DD4hep/DDTest.h"
0002 #include <exception>
0003 #include <iostream>
0004 #include <assert.h>
0005 #include <cmath>
0006 
0007 #include "DDSegmentation/BitFieldCoder.h"
0008 
0009 using namespace std;
0010 using namespace dd4hep;
0011 using namespace DDSegmentation;
0012 
0013 //=============================================================================
0014 int main(int /* argc */, char** /* argv */ ){
0015   // this should be the first line in your test
0016   DDTest test( "bitfield64" );
0017  
0018   try{
0019     
0020     // ----- write your tests in here -------------------------------------
0021 
0022     test.log( "test bitfieldcoder" );
0023 
0024 
0025     // initialize with a string that uses all 64 bits :
0026     const BitFieldCoder bf("system:5,side:-2,layer:9,module:8,sensor:8,x:32:-16,y:-16" ) ;
0027 
0028     // set some 'random' values to bf2 
0029     CellID field = 0  ;
0030     
0031     bf.set( field, "layer",  373 );
0032     bf.set( field, "module", 254 );
0033     bf.set( field, "sensor", 202 );
0034     bf.set( field, "side",   1 );
0035     bf.set( field, "system", 30 );
0036     bf.set( field, "x",      -310 );
0037     bf.set( field, "y",      -16710 );
0038 
0039 
0040     test(  field , CellID(0xbebafecacafebabeUL)  , " same value 0xbebafecacafebabeUL from individual initialization " ); 
0041 
0042 
0043     // make a copy for testing the access
0044     const BitFieldCoder bf2 = bf ;
0045 
0046     test( bf2.get( field, "layer") ,  373 , " acces field value: layer" );
0047     test( bf2.get( field, "module"),  254 , " acces field value: module" );
0048     test( bf2.get( field, "sensor"),  202 , " acces field value: sensor" );
0049     test( bf2.get( field, "side"),    1   , " acces field value: side" );
0050     test( bf2.get( field, "system"),  30  , " acces field value: system" );
0051     test( bf2.get( field, "x"),      -310 , " acces field value: x" );
0052     test( bf2.get( field, "y"),    -16710 , " acces field value: y" );
0053 
0054 
0055 
0056 
0057     test( bf2.get( field, bf2.index( "layer")) ,  373 , " acces field value: layer" );
0058     test( bf2.get( field, bf2.index( "module")),  254 , " acces field value: module" );
0059     test( bf2.get( field, bf2.index( "sensor")),  202 , " acces field value: sensor" );
0060     test( bf2.get( field, bf2.index( "side")),    1   , " acces field value: side" );
0061     test( bf2.get( field, bf2.index( "system")),  30  , " acces field value: system" );
0062     test( bf2.get( field, bf2.index( "x")),      -310 , " acces field value: x" );
0063     test( bf2.get( field, bf2.index( "y")),    -16710 , " acces field value: y" );
0064 
0065 
0066     // --------------------------------------------------------------------
0067 
0068 
0069   } catch( exception &e ){
0070     //} catch( ... ){
0071 
0072     test.log( e.what() );
0073     test.error( "exception occurred" );
0074   }
0075 
0076   return 0;
0077 }
0078 
0079 //=============================================================================