// SimpleCFTDetectorSimulator.cpp #include "SimpleCFTDetectorSimulator.h" #include #include "SimpleCFTDetector.h" #include "trflayer/LayerSimGeneric.h" #include "trfcyl/PropCyl.h" #include "trfcyl/LayerCylinder.h" #include "trfcyl/BSurfCylinder.h" #include "trfcyl/HitCylPhiGenerator.h" #include "trfcyl/HitCylPhiZGenerator.h" #include "trfutil/RandomSeed.h" using std::string; using namespace trf; //********************************************************************** // Constructor. SimpleCFTDetectorSimulator:: SimpleCFTDetectorSimulator(const DetectorPtr& pdet) : DetectorSimulator(pdet) { // Measurement error. double dx = 0.01; // 0.01 cm = 100 um // stereo slope (dphi/dz in rad/cm) double stereo_angle = 0.001; // Propagator. PropagatorPtr pprop( new PropCyl(ObjDoublePtr(new ObjDouble(2.0)))); // Fetch the list of layers. Detector::LayerNameList names = pdet->get_layer_names(); // Loop over layers. Detector::LayerNameList::const_iterator iname; int icnt = 0; for ( iname=names.begin(); iname!=names.end(); ++iname ) { Detector::LayerName name = *iname; assert( pdet->is_assigned(name) ); LayerPtr plyr = pdet->get_layer_pointer(name); Layer& lyr = *plyr; // Choose stereo angle based on name. string type = name.substr(0,2); int len = name.length(); StereoAngle stereo = UNDEFINED; if ( name.find("CFTX") < len ) stereo = ZERO; if ( name.find("CFTU") < len ) stereo = POSITIVE; if ( name.find("CFTV") < len ) stereo = NEGATIVE; // If the name does not begin with CFTX, CFTU or CFTV, this is not // a scifi layer. Go to the next layer. if ( stereo == UNDEFINED ) continue; // Check the layer type and cast. assert( lyr.get_type() == LayerCylinder::get_static_type() ); LayerCylinder& lcy = (LayerCylinder&) lyr; // Extract the surface and radius and calculate dphi. const SurfCylinder& scy = dynamic_cast( *lcy.get_surface() ); double r = scy.get_radius(); double dphi = dx/r; // Construct the hit generator. LayerSimGeneric::HitGeneratorPtr pgen; double angle = stereo_angle; switch ( stereo ) { case ZERO: pgen = new HitCylPhiGenerator( scy, dx/r, RandomSeed(icnt) ); break; case NEGATIVE: // Note fall through to POSITIVE. angle = -angle; case POSITIVE: pgen = new HitCylPhiZGenerator( scy, angle, dphi, RandomSeed(icnt) ); } // Construct the layer simulator. DetectorSimulator::LayerSimulatorPtr plsim( new LayerSimGeneric(plyr, pgen, pprop) ); // Add the layer simulator to the detector simulator. add_layer_simulator(name, plsim); ++icnt; } // end loop over layers } //********************************************************************** // Destructor. SimpleCFTDetectorSimulator::~SimpleCFTDetectorSimulator() { } //**********************************************************************