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

Go to the documentation of this file.
00001 /* @version $Revision: 1641 $ * @modifiedby $Author: jacquem $ * @lastmodified $Date: 2012-04-10 14:55:19 +0200 (Tue, 10 Apr 2012) $ */
00002 
00003 #include "geometry/Chamber.hh"
00004 #include "geometry/Dif.hh"
00005 #include "geometry/Board.hh"
00006 #include "geometry/Chip.hh"
00007 #include "tools/MicroException.hh"
00008 #include "tools/Log.hh"
00009 
00010 using namespace std;
00011 
00012 //--------------------------//
00013 std::ostream& operator <<(std::ostream& out, const Dif *x) {
00014   return(x->operator <<(out));
00015 };
00016 //--------------------------//
00017 std::ostream& operator <<(std::ostream& out, const Dif& x) {
00018   return(x.operator <<(out));
00019 };
00020 //--------------------------//
00021 Dif::Dif(const i32 aId) : id(aId), configured(false)
00022 {
00023    low_register    = 0;        //8 bits
00024    high_register   = 0;        //8 bits
00025    before_register = 0;        //8 bits
00026    after_register  = 0;        //8 bits
00027    acqMode         = 0;        // 16 bits acquisition mod
00028    nbChips         = 0;
00029          difFirmware     = 0;
00030    difConfig       = 0;
00031          asicType        = 0;
00032          asu1Id          = 0;
00033          asu2Id          = 0;
00034 };
00035 
00036 //--------------------------//
00037 std::ostream& Dif::operator <<(std::ostream& out) const {
00038   out << "  Dif id " << id << endl;
00039   for (map<i32, Board *>::const_iterator it = boards.begin(); it != boards.end(); ++it)
00040     out << *(it->second);
00041   return(out);
00042 }; // Dif.operator <<
00043 //--------------------------//
00044 void Dif::addBoard(Board *aBoard) {
00045   if (aBoard  != NULL )
00046   {
00047       aBoard->setDif(this);
00048       boards.insert(make_pair(aBoard->getId(), aBoard));
00049   }
00050 }; // Dif.addBoard
00051 
00052 //--------------------------//
00053 const Board& Dif::getBoardById(const i32 boardId) const
00054 {
00055   std::map<i32, Board *>::const_iterator it = boards.find(boardId);
00056   if (it == boards.end())
00057     throw MicroException("Dif.getBoardById : no Board found for this id");
00058 
00059   //FILE_LOG(logDEBUG1) << "---- Dif.getBoardById(" << boardId << ") found" << endl;
00060   return(*(it->second));
00061 }; // Dif.getBoardById
00062 
00063 
00064 //--------------------------//
00065 Board &Dif::getBoardByCol(const ui16 col)const  
00066 {
00067     for ( BoardMap_t::const_iterator it = boards.begin(); it !=boards.end() ; it++ )
00068     {
00069          try 
00070          {
00071              Board& board = *(it)->second ;
00072               if ( board.getColumn() == col )
00073               {
00074                 return board;
00075               }
00076          }
00077          catch ( ... ) { }
00078     }
00079     throw MicroException(" No Board with this col for this Dif");
00080 }
00081 //--------------------------//
00082 Chip &Dif::getChipById(const i32 chipId)
00083 {
00084     for ( BoardMap_t::iterator it = boards.begin(); it !=boards.end() ; it++ )
00085     {
00086          try 
00087          {
00088              Board& board = *(it)->second ;
00089              FILE_LOG(logDEBUG1) << "board id " << board.getId() <<endl;
00090              return board.getChipById(chipId);
00091          }
00092          catch ( ... ) { }
00093     }
00094     throw MicroException(" No Chip with this id for this Dif");
00095 }
00096 //--------------------------//
00097 Chip &Dif::getChipByRowCol(const ui16 boardCol, const ui16 row, const ui16 col )
00098 {
00099          try 
00100          {
00101              Board& board = this->getBoardByCol(boardCol) ;
00102              return board.getChipByRowCol(row,col);
00103          }
00104          catch ( ... ) { }
00105     throw MicroException(" No Chip with this boardCol , row and col for this Dif");
00106 }
00107 //--------------------------//
00108 void Dif::setChipByPassed(const bool value )
00109 {
00110     for ( BoardMap_t::iterator it = boards.begin(); it !=boards.end() ; it++ )
00111     {
00112        {
00113           Board& board = *(it)->second ;
00114           ChipMap_t chips =  board.getChips();
00115           for ( ChipMap_t::iterator itc = chips.begin(); itc !=chips.end() ; itc++ )
00116           {
00117             Chip& chip = *(itc)->second;
00118             chip.setBypassed(value);
00119           }
00120        }
00121     }
00122 }
00123 
00124 void  Dif::setDifFirmware(ui16 value)
00125  { 
00126     difFirmware = value; 
00127  } 
00128 

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