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