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

Go to the documentation of this file.
00001 /* @version $Revision: 1759 $ * @modifiedby $Author: jacquem $ * @lastmodified $Date: 2012-06-04 16:49:12 +0200 (Mon, 04 Jun 2012) $ */
00002 
00003 #include "geometry/Channel.hh"
00004 #include "geometry/Chip.hh"
00005 #include "geometry/Board.hh"
00006 #include "geometry/Dif.hh"
00007 #include "geometry/Chamber.hh"
00008 #include "event/ChannelHit.hh"
00009 
00010 #include <iostream>
00011 #include "tools/Log.hh"
00012 
00013 using namespace std;
00014 
00015 //-------------------------------------------//
00016 std::ostream& operator <<(std::ostream& out, const Channel& x) {
00017   out << "        " << x.description << " id " << x.hardId
00018       << ", position [x/y/z] @[" << x.getX() << ", " << x.getY() << ", " << x.getZ() << "], "
00019       << "[col/row]=>["<< x.column << "/" << x.row << "]";
00020   return(out);
00021 } // operator <<
00022 
00023 //--------------- Constructeur -------------//
00024 Channel::Channel(const Chip& _chip, const std::string aDesc, const i32 aColumn, const i32 aRow, const i32 aHardId)
00025   :chip(_chip), description(aDesc), column(aColumn), row(aRow), hardId(aHardId)
00026 {
00027   enable = true;
00028   stimulate = false;
00029 
00030         const Chip&  chip = this->getChip() ;
00031         const Board& board = chip.getBoard() ;
00032         const Dif* dif = board.getDif();
00033                 unsigned int difId = 0;
00034          if ( dif != NULL) difId = dif->getId();
00035         const Chamber& cham = this->getChamber();
00036         channelSoftId.SetValue(cham.getId(), difId, board.getId(),chip.getId(),getHardId(),getRow(),getColumn());
00037 //  FILE_LOG(logDEBUG) << "------Channel constructor. " << endl;
00038 }
00039 
00040 //--------------- Constructeur de copie -------------//
00041 // Obligatoire pour l utisation de cette classe dans un std::vector container
00042 //
00043 //
00044 Channel::Channel(const Channel &source) : chip(source.chip)
00045 {
00046   //FILE_LOG(logDEBUG) << "-- Channel copy constructor" << endl;
00047   *this = source;  // appel de l operateur =
00048 }
00049 
00050 //--------------- operateur de copie -------------//
00051 // Obligatoire pour l utisation de cette classe dans un std::vector container
00052 //
00053 Channel& Channel::operator = (const Channel &source)
00054 {
00055   //FILE_LOG(logDEBUG) << "--Channel operator de copie"<< endl;
00056   hardId = source.hardId;
00057   description = source.description;
00058   column = source.column;
00059   row = source.row;
00060   enable = source.enable;
00061   stimulate = source.stimulate;
00062   pedestal_offset  = source.pedestal_offset;
00063   return *this;
00064 }
00065 
00066 //--------------- Destructeur -------------//
00067 Channel::~Channel()
00068 {
00069   FILE_LOG(logDEBUG1) << "------Channel destructeur:" <<  this->getHardId() << " in chip["  << this->getChip().getId() << endl;
00070 }
00071 
00072 //-------------------------------------------//
00073 const Chamber& Channel::getChamber() const
00074 {
00075   return(chip.getBoard().getChamber());
00076 };
00077 
00078 
00079 //-------------------------------------------//
00080 const float Channel::getX() const
00081 
00082 {
00083   float result = 0.;
00084   if ( getChamber().getZrotation() == 90 )
00085   {
00086     result = getYRelative() +chip.getYRelative()  + chip.getBoard().getYRelative();
00087   }
00088   else if ( getChamber().getZrotation() == -90 )
00089   {
00090     result = -(getYRelative() +chip.getYRelative()  + chip.getBoard().getYRelative());
00091   }
00092   else
00093   {
00094     result = getXRelative() + chip.getXRelative() + chip.getBoard().getXRelative();
00095   }
00096 
00097   if ( getChamber().getYrotation() )
00098   {
00099     result = - result;
00100   }
00101 
00102   return result + getChamber().getX() ;
00103 
00104 
00105 }
00106 //-------------------------------------------//
00107 const float Channel::getXRelative() const
00108 {
00109 
00110   float result = -( chip.getXLength() / 2. ) + ( row * this->getXLength() )  + ( this->getXLength() / 2. );
00111 
00112   return result;
00113 }
00114 //-------------------------------------------//
00115 
00116 const float Channel::getY() const
00117 {
00118 
00119   float result = 0.;
00120   if ( getChamber().getZrotation() == 90 )
00121   {
00122     result = -(getXRelative() + chip.getXRelative() +  chip.getBoard().getXRelative());
00123  }
00124   else if ( getChamber().getZrotation() == -90 )
00125   {
00126     result = (getXRelative() + chip.getXRelative() +  chip.getBoard().getXRelative());
00127  }
00128   else {
00129     result =  getYRelative() +  chip.getYRelative() + chip.getBoard().getYRelative();
00130   }
00131   if ( getChamber().getXrotation() )
00132   {
00133     result = - result;
00134   }
00135   return result + getChamber().getY();
00136 
00137 
00138 
00139 }
00140 //-------------------------------------------//
00141 const float Channel::getYRelative() const
00142 {
00143   float result = 0.;
00144 
00145 
00146   result = - ( chip.getYLength() / 2. ) + ( column * this->getYLength() )  + ( this->getYLength() / 2. );
00147 
00148 
00149   return result ;
00150 }
00151 //-------------------------------------------//
00152 
00153 float Channel::getZ() const
00154 {
00155   return getChamber().getZ();
00156 }
00157 
00158 //-------------------------------------------//
00159 const float Channel::getLeftBottomX() const
00160 {
00161   if ( chip.getBoard().getChamber().getZrotation() == 90 || chip.getBoard().getChamber().getZrotation() == -90) return ( getX() - getYLength() / 2.);
00162    return ( getX() - getXLength() / 2.);
00163 }
00164 
00165 //-------------------------------------------//
00166 const float Channel::getLeftBottomY() const
00167 {
00168   if ( chip.getBoard().getChamber().getZrotation() == 90 || chip.getBoard().getChamber().getZrotation() == -90) return ( getY() - getXLength() / 2.);
00169    return ( getY() - getYLength() / 2.);
00170 }
00171 
00172 //-------------------------------------------//
00173 const float Channel::getRightUpperX() const
00174 {
00175   if ( chip.getBoard().getChamber().getZrotation() == 90 || chip.getBoard().getChamber().getZrotation() == -90) return ( getX() + getYLength() / 2.);
00176    return ( getX() + getXLength() / 2.);
00177 }
00178 
00179 //-------------------------------------------//
00180 const float Channel::getRightUpperY() const
00181 {
00182   if ( chip.getBoard().getChamber().getZrotation() == 90 || chip.getBoard().getChamber().getZrotation() == -90) return ( getY() + getXLength() / 2.);
00183    return ( getY() + getYLength() / 2.);
00184 }
00185 
00186 
00187 //-------------------------------------------//
00188 void Channel::print() const
00189 {
00190   cout << *this << endl;
00191 }
00192 
00193 
00194 //-------------------------------------------//
00195   const ui16 Channel::getColInChamberRelative() const  // along side Y axis in this franework, without rotation
00196   {
00197     const Board& board = chip.getBoard();
00198     ui16 chipCol =  ( board.getColumn() * board.getNbColumns() ) + chip.getColumn();
00199     return chipCol * chip.getNbColumns() + getColumn();
00200   }
00201 //-------------------------------------------//
00202   const ui16 Channel::getRowInChamberRelative() const  // along side X axis in this franework, without rotation
00203   {
00204     const Board& board = chip.getBoard();
00205     ui16 chipRow =  ( board.getRow() * board.getNbRows() ) + chip.getRow();
00206     return chipRow * chip.getNbRows() + getRow();
00207   }
00208 
00209 //-------------------------------------------//
00210   const ui16 Channel::getColInChamber() const  // along side Y axis in this franework, with rotation
00211   {
00212     ui16 result = 0;
00213     const Board& board = chip.getBoard();
00214     const Chamber& chamber = board.getChamber();
00215     if ( chamber.getZrotation() == 90 )
00216     {
00217       ui16 nbTotalRow = chamber.getNbRows() * board.getNbRows() *  chip.getNbRows();
00218       result =  nbTotalRow - (getRowInChamberRelative()+1);     
00219     }
00220     else if ( chamber.getZrotation() == -90 )
00221     {
00222       result =  getRowInChamberRelative();
00223     }
00224     else // no roration
00225     {
00226       result =  getColInChamberRelative();
00227     }
00228 
00229     if (  chamber.getXrotation() == true )
00230     {
00231       ui16 nbTotalCol = chamber.getNbColumns() * board.getNbColumns() *  chip.getNbColumns();
00232       result = nbTotalCol - (result+1);
00233     }
00234 
00235     return result;
00236     
00237   }
00238 //-------------------------------------------//
00239   const ui16 Channel::getRowInChamber() const  // along side Y axis in this franework, with rotation
00240   {
00241     ui16 result = 0;
00242     const Board& board = chip.getBoard();
00243     const Chamber& chamber = board.getChamber();
00244     if ( chamber.getZrotation() == 90 )
00245     {
00246       result =  getColInChamberRelative();
00247     }
00248     else if ( chamber.getZrotation() == -90 )
00249     {
00250       ui16 nbTotalCol = chamber.getNbColumns() * board.getNbColumns() *  chip.getNbColumns();
00251       result =  nbTotalCol - (getColInChamberRelative()+1);
00252     }
00253     else
00254     {
00255       result =  getRowInChamberRelative() ;
00256     }
00257     if (  chamber.getYrotation() == true )
00258     {
00259       ui16 nbTotalRow = chamber.getNbRows() * board.getNbRows() *  chip.getNbRows();
00260       result = nbTotalRow - (result+1);
00261     }
00262     return result;
00263   }
00264 

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