//////////////////////////////////////////////////////////////////////////// // File: L2STTCluster.cpp // // Purpose: Definition of Silicon Track Trigger cluster // // Created: 19-MAY-1999 Silvia Tentindo-Repond // // // // $Revision: 1.10 $ // // Updated: 18-June-1999 STR added physical address for cluster position // // (and silicon geometry stuff) // // 24-Nov-99 STR added _X,_Y,_Z to class Cluster // // 1-Dec-99 STR use TranslationMgr to get x y z // // 3-17-00 STR bool UseMap=false used to not use translation map // 25-May-00 STR from JDH atan2 in phi method // 12-Jun-00 STR more from JDH atan2 /////////////////////////////////////////////////////////////////////////// // Include files #include #include #include #include "l2stt_util/L2STTCluster.hpp" // SMT Address #include "smtutil/StripAddress.hpp" #include "smtutil/StripFEAddress.hpp" #include "smtutil/SmtAddressTranslation.hpp" #include "smtutil/SmtFEAddress.hpp" #include "tsim_l2stt/TranslationMgr.hpp" #include "tsim_l2stt/StripRPHI.hpp" // silicon geometry stuff #include "d0om/d0_Ref.hpp" #include "geometry_system/components/CartesianCoordinate.hpp" #include #include "geometry_system/components/CartesianCoordinate.hpp" #include "silicon_geometry/base/SiGeometer.hpp" #include "silicon_geometry/base/SiBaseGeometry.hpp" #include "silicon_geometry/base/SiBarrel.hpp" #include "silicon_geometry/base/SiLayer.hpp" #include "silicon_geometry/channel/SiChannelGeometer.hpp" #include "silicon_geometry/channel/SiStrips.hpp" #include "silicon_geometry/utils/smt_build_default.hpp" #include "silicon_geometry/utils/smt_build_default.hpp" // Global definitions using namespace dgs; //bool SmtAddressTranslation::_UseMap=false; StripRPHI rphiAddr = StripRPHI(); // Constructors/Destructors L2STTCluster::L2STTCluster(): _serial_number(-1) {} int L2STTCluster::_next_serial_number = 1; // Note: Here strip is really the Svx Channel L2STTCluster::L2STTCluster(int number, int offset, int size, int pulse_height, int chan, int chip, int HDI, int sequencer, int crate) : _number(number) , _offset(offset) , _size(size) , _pulse_height(pulse_height) , _chan(chan) , _chip(chip) , _HDI(HDI) , _sequencer(sequencer) , _crate(crate) { // Set the serial number _serial_number = _next_serial_number++; if( _next_serial_number > (1<<(8*sizeof(int)-3)) ) _next_serial_number = 1; // convert MCHid to Physical address (Barrel, Layer,Ladder) int modid,chid; SmtFEAddress converter; _address = converter.Encoder(crate,sequencer,HDI,chip,chan); converter.Decoder(_address,modid,chid); StripFEAddress stripFEAddr = StripFEAddress(modid,chid); StripAddress stripAddr; bool UseMap=false; SmtAddressTranslation addrTranslation(UseMap); bool ok = addrTranslation.translator(stripFEAddr,stripAddr); _barrel = stripAddr.Barrel(); _layer = stripAddr.Layer(); _ladder = stripAddr.Ladder(); _view = stripAddr.View(); // Use TranslationNgr to get x y z ok = TranslationMgr::translator(stripFEAddr,rphiAddr); _x = rphiAddr.get_Stripx(); _y = rphiAddr.get_Stripy(); _z = rphiAddr.get_Stripz(); } int L2STTCluster::reset_serial_number() { int old = _next_serial_number; _next_serial_number = 1; return old; } // Print out // Note: This operator doesn't really have to be a fiend of L2STTCluster // because we could have used the public methods of instances of // that class. ///////////////////////////////////////////////////////////////////////// std::ostream& operator << (std::ostream &os, const L2STTCluster &o) { using std::setw; using std::endl; os << "L2STTCLuster" << setw(10) << o._number << endl; os << " " << setw(12) << "Address" << setw(10) << o._address << endl; os << " " << setw(12) << "Channel" << setw(10) << o._chan << endl; os << " " << setw(12) << "offset" << setw(10) << o._offset << endl; os << " " << setw(12) << "size" << setw(10) << o._size << endl; os << " " << setw(12) << "pulse_height" << setw(10) << o._pulse_height << endl; os << " " << setw(12) << "Chip" << setw(10) << o._chip << endl; os << " " << setw(12) << "HDI" << setw(10) << o._HDI << endl; os << " " << setw(12) << "Sequencer" << setw(10) << o._sequencer << endl; os << " " << setw(12) << "Crate" << setw(10) << o._crate << endl; os << " " << setw(12) << "Barrel" << setw(10) << o._barrel << endl; os << " " << setw(12) << "Layer" << setw(10) << o._layer << endl; os << " " << setw(12) << "Ladder" << setw(10) << o._ladder << endl; os << " " << setw(12) << "View" << setw(10) << o._view << endl; os << " " << setw(12) << "x" << setw(10) << o._x << endl; os << " " << setw(12) << "y" << setw(10) << o._y << endl; os << " " << setw(12) << "z" << setw(10) << o._z << endl; return os; } double L2STTCluster::r() const { return sqrt(_x*_x + _y*_y); } double L2STTCluster::phi() const { double phi; double pi = acos(-1.0); const float eps = 1.0e-30; phi = atan2(_y,_x+eps);// JDH atan replaced by atan2 if(phi < 0)phi=phi+2*pi; return phi; } int L2STTCluster::barrel() const { return _barrel; } int L2STTCluster::layer() const { return _layer; } int L2STTCluster::ladder() const { return _ladder; }