00001
00002
00003
00004
00005
00006
00007 #include "geometry/MetreCarreChamber.hh"
00008 #include "geometry/Dif.hh"
00009 #include "geometry/Hardroc2Board.hh"
00010 #include "geometry/Hardroc2Chip.hh"
00011
00012 #include "tools/Log.hh"
00013
00014 #include <iostream>
00015
00016 using namespace std;
00017
00018
00019 MetreCarreChamber::MetreCarreChamber(const float aX, const float aY, const float aZ, const bool xRotation,const bool yRotation, const i16 zRotation, const i32 id,
00020 const std::vector<DifInfo_t>& difInfos,
00021 const std::vector<BoardInfo_t>& boardInfos,
00022 const std::vector<ChipInfo_t>& chipInfos)
00023 : Chamber(aX, aY , aZ , xRotation, yRotation, zRotation, 2, 3 , id)
00024 {
00025 FILE_LOG(logDEBUG1) << "---MetreCarreChamber constructor id " << id << endl;
00026
00027 if ( difInfos.size() != 3 |
00028 boardInfos.size() != 5 |
00029 chipInfos.size() != 120)
00030 {
00031 FILE_LOG(logERROR)<< endl << "XML geometry error for chamber id[" << id << "] :MetreCarreChamber must be composed of:\n"
00032 "-[3] dif." << endl <<
00033 "-[5] board." << endl <<
00034 "-[120] chips." << endl << endl <<
00035 "-> And in your XML file:" << endl <<
00036 "[" << difInfos.size() << "] dif" << endl <<
00037 "[" << boardInfos.size() << "] board" << endl <<
00038 "[" << chipInfos.size() << "] chips" << endl;
00039 myIsValid = false;
00040 }
00041
00042 else {
00043 description = "MetreCarreChamber";
00044 type = METRECARRECHAMBER;
00045 init(id, difInfos, boardInfos, chipInfos);
00046 myIsValid = true;
00047 }
00048 }
00049
00050
00051
00052 MetreCarreChamber::~MetreCarreChamber()
00053 {
00054
00055 };
00056
00057
00058
00059 void MetreCarreChamber::init(i32 id, const std::vector<DifInfo_t>& difInfos,
00060 const std::vector<BoardInfo_t>& boardInfos,
00061 const std::vector<ChipInfo_t>& chipInfos)
00062 {
00063 int bcol = 0;
00064 int brow = 0;
00065
00066
00067 for (int difNum = 0 ; difNum < difInfos.size(); difNum++)
00068 {
00069 const DifInfo_t& difInfo = difInfos.at(difNum);
00070 if (difInfo.chamberId != this->getId())
00071 {
00072 continue;
00073 }
00074 Dif *dif = new Dif(difInfo.id);
00075
00076 for (int boardNum = 0 ; boardNum < boardInfos.size(); boardNum++)
00077 {
00078 const BoardInfo_t& boardInfo = boardInfos.at(boardNum);
00079 if (boardInfo.difId != dif->getId() || boardInfo.chamberId != this->getId())
00080 {
00081 continue;
00082 }
00083
00084 bcol= (boardNum ) % 2;
00085 Hardroc2Board *board = new Hardroc2Board(*this,bcol , brow , 6, 4, boardInfo.id);
00086
00087 this->addDif(dif);
00088 dif->addBoard(board);
00089 this->addBoard(board);
00090
00091
00092
00093 int ccol = 0;
00094 int crow = 0;
00095 for (int chipNum = 0; chipNum < chipInfos.size(); chipNum++)
00096 {
00097 const ChipInfo_t& chipInfo = chipInfos.at(chipNum);
00098 if ((chipInfo.boardId != boardInfo.id)
00099 || (chipInfo.difId != difInfo.id)
00100 || (chipInfo.chamberId != id))
00101 {
00102 continue;
00103 }
00104 FILE_LOG(logDEBUG1)<< " Detector.build : chip " << chipInfo.id << ", board " << chipInfo.boardId << endl;
00105 ccol= chipNum%6 ;
00106
00107
00108 Hardroc2Chip *chip = new Hardroc2Chip(*board, ccol, crow, chipInfo.id,chipInfo.serial);
00109 board->addChip(chip);
00110
00111 if (ccol == 5) { ++crow; }
00112 }
00113 FILE_LOG(logDEBUG1)<< " Detector.build : dif " << difInfo.id << ", chamber " << difInfo.chamberId << *this << endl;
00114
00115 if ( bcol >= 1) { brow++ ; }
00116 }
00117 }
00118 }
00119