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