/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/src/geometry/Chip.cpp

Go to the documentation of this file.
00001 /* @version $Revision: 1751 $ * @modifiedby $Author: lcdet $ * @lastmodified $Date: 2012-05-30 17:01:35 +0200 (Wed, 30 May 2012) $ */
00002 
00003 #include "geometry/Dif.hh"
00004 #include "geometry/Chip.hh"
00005 #include "geometry/Channel.hh"
00006 #include "geometry/Chamber.hh"
00007 #include "geometry/Board.hh"
00008 #include "tools/MicroException.hh"
00009 #include "tools/Log.hh"
00010 
00011 using namespace std;
00012 
00013 
00014 Chip::Chip(const Board& _board, const i32 aCol, const i32 aRow, const ui32 aNbColumns,const ui32 aNbRows ,const i32 aId ,const ui32 aSerialNumber)
00015 :board(_board), id(aId), serialNum(aSerialNumber),  row(aRow), column(aCol), nbRows(aNbRows), nbColumns(aNbColumns), bypassed(false), configured(false)
00016 {
00017     gain = 0;
00018     type = 0;
00019     const Dif* dif = _board.getDif();
00020            unsigned int difId = 0;
00021            if ( dif != NULL) difId = dif->getId();
00022            const Chamber& cham = _board.getChamber();
00023 
00024                 chipSoftId.SetValue(cham.getId(), difId,_board.getId(), id);
00025     FILE_LOG(logDEBUG1) << "Chip id["<< id << "], serial number["<< serialNum <<"]" << endl;
00026 
00027 
00028 }
00029 //--------------------------//
00030 std::ostream& operator <<(std::ostream& out, const Chip* x) {
00031   return(x->operator <<(out));
00032 };
00033 //--------------------------//
00034 std::ostream& operator <<(std::ostream& out, const Chip& x) {
00035   return(x.operator <<(out));
00036 };
00037 
00038 //--------------------------//
00039 std::ostream& Chip::operator <<(std::ostream& out) const {
00040   out << "      " << "Chip id " << id << ", Chip serialNum " << serialNum << ", position [x/y] @[" << getX() << ", " << getY() << "], "
00041       << "[col/row]=>["<< column << "/" << row << "], "
00042       << "[Xlength/Ylength]=>["<< getXLength() << "/" << getYLength() << "], "
00043       << channels.size() << " channels" 
00044       << "bypassed[" << this->bypassed << "]" << endl;
00045   
00046   return(out);
00047 };
00048 
00049 //--------------------------//
00050 Chip::Chip(const Chip& x) : board(x.board) {
00051   *this = x;
00052 }
00053 
00054 //--------------------------//
00055 Chip& Chip::operator = (const Chip& x) {
00056   id = x.id;
00057   column = x.column, row = x.row;
00058   nbColumns = x.nbColumns, nbRows = x.nbRows;
00059   channels = x.channels;
00060         const Dif* dif = board.getDif();
00061         unsigned int difId = 0;
00062         if ( dif != NULL) difId = dif->getId();
00063         const Chamber& cham = board.getChamber();
00064 
00065         chipSoftId.SetValue(cham.getId(), difId,board.getId(), id);
00066   gain  = x.gain;
00067 }
00068 
00069 //--------------------------//
00070 Chip::~Chip() {
00071   for (map<i32, Channel *>::const_iterator it = channels.begin(); it != channels.end(); ++it)
00072   {
00073       FILE_LOG(logDEBUG1) << "Chip destructeur delete it->second"<< endl;
00074       delete (it->second);
00075   }
00076 }
00077 
00078 //--------------------------//
00079 Channel &Chip::getChannelById(const i32 channelId)
00080 {
00081   std::map<i32, Channel *>::const_iterator it = channels.find(channelId);
00082   if (it == channels.end())
00083     throw MicroException("Chip.getChannelById : no Channel found for this id and this chamber ");
00084 
00085   //FILE_LOG(logDEBUG) << "----Channel Id " << channelId << " found" << endl;
00086   return(*(it->second));
00087 };
00088 
00089 //-------------------------------------------//
00090 const float Chip::getX() const
00091 {
00092 
00093   float result = 0.;
00094   if ( board.getChamber().getZrotation() == 90 )
00095   {
00096     result = getYRelative() + board.getYRelative();
00097   }
00098   else if ( board.getChamber().getZrotation() == -90 )
00099   {
00100     result = - (getYRelative() + board.getYRelative());
00101   }
00102   else
00103   {
00104     result = getXRelative() + board.getXRelative();
00105   }
00106 
00107   if ( board.getChamber().getYrotation() )
00108   {
00109     result = - result;
00110   }
00111 
00112   return result + board.getChamber().getX() ;
00113 
00114 }
00115 
00116 //-------------------------------------------//
00117 const float Chip::getXRelative() const
00118 {
00119   float result = - ( board.getXLength() / 2. ) + ( row * this->getXLength() )  + ( this->getXLength() / 2. );
00120 
00121   return result;
00122 }
00123 
00124 
00125 //-------------------------------------------//
00126 const float Chip::getY() const
00127 {
00128 
00129   float result = 0.;
00130   if ( board.getChamber().getZrotation() == 90 )
00131   {
00132     result = -(getXRelative() + board.getXRelative());
00133  }
00134   else if ( board.getChamber().getZrotation() == -90 )
00135   {
00136     result = (getXRelative() + board.getXRelative());
00137  }
00138   else {
00139     result =  getYRelative() + board.getYRelative(); 
00140   }
00141   if ( board.getChamber().getXrotation() )
00142   {
00143     result = - result;
00144   }
00145   return result + board.getChamber().getY();
00146 
00147 }
00148 
00149 //-------------------------------------------//
00150 const float Chip::getYRelative() const
00151 {
00152   float result = 0.;
00153   result = - ( board.getYLength() / 2. ) + ( column * this->getYLength() )  + ( this->getYLength() / 2. );
00154 
00155   return result;
00156 
00157 }
00158 
00159 //-------------------------------------------//
00160 const float Chip::getLeftBottomX() const
00161 {
00162   if ( board.getChamber().getZrotation() == 90 || board.getChamber().getZrotation() == -90) return ( getX() - getYLength() / 2.);
00163    return ( getX() - getXLength() / 2.);
00164 }
00165 
00166 //-------------------------------------------//
00167 const float Chip::getLeftBottomY() const
00168 {
00169   if ( board.getChamber().getZrotation() == 90 || board.getChamber().getZrotation() == -90) return ( getY() - getXLength() / 2.);
00170    return ( getY() - getYLength() / 2.);
00171 }
00172 
00173 //-------------------------------------------//
00174 const float Chip::getRightUpperX() const
00175 {
00176   if ( board.getChamber().getZrotation() == 90 || board.getChamber().getZrotation() == -90) return ( getX() + getYLength() / 2.);
00177    return ( getX() + getXLength() / 2.);
00178 }
00179 
00180 //-------------------------------------------//
00181 const float Chip::getRightUpperY() const
00182 {
00183   if ( board.getChamber().getZrotation() == 90|| board.getChamber().getZrotation() == -90 ) return ( getY() + getXLength() / 2.);
00184    return ( getY() + getYLength() / 2.);
00185 }
00186 
00187 
00188 
00189 //-------------------------------------------//
00190 const float  Chip::getXLength() const
00191 {
00192   if (channels.size()) {
00193     const Channel&  ch = *(channels.begin()->second);
00194     return (nbRows * ch.getXLength())  + ( nbRows-1)  * getXGap() ;
00195   }
00196   return(0);
00197 }
00198 //-------------------------------------------//
00199 const float  Chip::getYLength() const
00200 {
00201   if (channels.size()) {
00202     const Channel&  ch = *(channels.begin()->second);
00203     return (nbColumns *  ch.getYLength()) + (nbColumns-1) * getYGap() ;
00204   }
00205   return(0);
00206 }
00207 
00208 //-------------------------------------------//
00209 i32 Chip::getMinChannelId() const
00210 {
00211         i32     result = 0xffff;
00212   for (std::map<i32, Channel *>::const_iterator it = channels.begin(); it != channels.end(); ++it)
00213   {
00214     Channel* channel = it->second;
00215                 if (channel)
00216                 {
00217                                                 if ( channel->getHardId() < result) { result = channel->getHardId(); }
00218                 }
00219         }
00220                 return result;
00221 }
00222 
00223 //-------------------------------------------//
00224 i32 Chip::getMaxChannelId() const
00225 {
00226         i32     result = 0;
00227   for (std::map<i32, Channel *>::const_iterator it = channels.begin(); it != channels.end(); ++it)
00228   {
00229     Channel* channel = it->second;
00230                 if (channel)
00231                 {
00232                                                 if ( channel->getHardId() > result) { result = channel->getHardId(); }
00233                 }
00234         }
00235                 return result;
00236 }
00237 
00238 
00239 

Generated on Mon Jan 7 13:15:22 2013 for MicromegasFramework by  doxygen 1.4.7