00001
00002
00003 #include "geometry/Detector.hh"
00004 #include "geometry/Chamber.hh"
00005 #include "geometry/GassiplexChamber1.hh"
00006 #include "geometry/GassiplexChamber4.hh"
00007 #include "geometry/GassiplexStripChamber1.hh"
00008 #include "geometry/Hardroc1Chamber.hh"
00009 #include "geometry/Hardroc2Chamber1.hh"
00010 #include "geometry/Hardroc2Chamber2.hh"
00011 #include "geometry/Hardroc2Chamber6.hh"
00012 #include "geometry/Hardroc2IPNLChamber6.hh"
00013 #include "geometry/MicrorocChamber1.hh"
00014 #include "geometry/MicrorocChamber6.hh"
00015 #include "geometry/MicrorocTestChamber.hh"
00016 #include "geometry/MetreCarreChamber.hh"
00017 #include "geometry/DiracChamber1.hh"
00018 #include "geometry/Board.hh"
00019 #include "geometry/Hardroc1Board.hh"
00020 #include "geometry/Hardroc2Board.hh"
00021 #include "geometry/MicrorocBoard.hh"
00022 #include "geometry/DiracBoard.hh"
00023 #include "geometry/Dif.hh"
00024 #include "geometry/Chip.hh"
00025 #include "geometry/GassiplexChip.hh"
00026 #include "geometry/Hardroc1Chip.hh"
00027 #include "geometry/Hardroc2Chip.hh"
00028 #include "geometry/DiracChip.hh"
00029 #include "tools/SteerDesc.hh"
00030
00031 #include "tools/MicroException.hh"
00032 #include "tools/Log.hh"
00033 #include <iostream>
00034
00035 using namespace std;
00036
00037 std::ostream& operator << (std::ostream& out, const Detector& x) {
00038 return(x.operator <<(out));
00039 }
00040
00041
00042 Detector::Detector()
00043 :monDev(0)
00044 {
00045
00046 }
00047
00048
00049 Detector::~Detector()
00050 {
00051
00052 for (ChamberMap_t::const_iterator it = chambers.begin(); it != chambers.end(); ++it) {
00053 delete (it->second);
00054 }
00055
00056 }
00057
00058
00059 std::ostream& Detector::operator << (std::ostream& out) const {
00060 out << description << endl ;
00061 for (ChamberMap_t::const_iterator it = chambers.begin(); it != chambers.end(); ++it) {
00062 out << *(it->second);
00063 }
00064 return(out);
00065 }
00066
00067
00068 bool Detector::addChamber(Chamber* aChamber)
00069 {
00070 if (!aChamber)
00071 return false;
00072
00073 chambers.insert(make_pair(aChamber->getId(), aChamber));
00074 return true;
00075 }
00076
00077
00078 Chamber& Detector::getChamberById(const i32 _id) const
00079 {
00080 ChamberMap_t::const_iterator result = chambers.find(_id);
00081 if (result != chambers.end())
00082 {
00083 return *(result->second);
00084 }
00085 throw MicroException("No Chamber correspond for this detector and this id.");
00086 }
00087
00088
00089 Dif& Detector::getDifById(const i32 _id) const
00090 {
00091 const ChamberMap_t &chambers = getChambers();
00092 for (ChamberMap_t::const_iterator it = chambers.begin(); it != chambers.end(); ++it) {
00093 Chamber& chamber = *(it->second);
00094 DifMap_t difs = chamber.getDifs();
00095 DifMap_t::iterator difIt = difs.find(_id);
00096 if (difIt != difs.end())
00097 return(*difIt->second);
00098 }
00099 throw MicroException("No Dif correspond for this detector and this id.");
00100 }
00101
00102
00103 unsigned int Detector::getNumberOfGaziplex96(void) const
00104 {
00105 unsigned int result = 0;
00106
00107 ChamberMap_t::const_iterator iter = chambers.begin();
00108
00109 for ( iter = chambers.begin(); iter != chambers.end() ; iter++ )
00110 {
00111
00112
00113
00114
00115
00116
00117
00118 if ( iter->second->getType().find("GASSIPLEX") != string::npos )
00119 {
00120 result = result + iter->second->getNumberOfBoards();
00121 }
00122 }
00123 return result;
00124 }
00125
00126
00127 int Detector::build(const SteerDesc& sd) {
00128
00129
00130 int nbChamber = 0;
00131
00132 monDev = sd.monitoringDif;
00133
00134 for (int index = 0 ; index < sd.chambers.size(); index++)
00135 {
00136 int brow = 0;
00137 const chamber_info_t& chamberInfo = sd.chambers[index];
00138
00139
00140
00141 ui32 unit = 1;
00142 if ( chamberInfo.unit.compare("m")==0 ) { unit = 1000000 ;}
00143 else if ( chamberInfo.unit.compare("dm")==0 ) { unit = 100000 ;}
00144 else if ( chamberInfo.unit.compare("cm")==0 ) { unit = 10000 ;}
00145 else if ( chamberInfo.unit.compare("mm")==0 ) { unit = 1000 ;}
00146 else if ( chamberInfo.unit.compare("um")==0 ) { unit = 1 ;}
00147
00148 float xPos = chamberInfo.xPos * unit;
00149 float yPos = chamberInfo.yPos * unit;
00150 float zPos = chamberInfo.zPos * unit;
00151 bool xRotation = chamberInfo.xRotation;
00152 bool yRotation = chamberInfo.yRotation;
00153 i16 zRotation = chamberInfo.zRotation;
00154 bool stripHorizontal = chamberInfo.stripHorizontal;
00155
00156
00157 std::vector<DifInfo_t>difs;
00158 std::vector<BoardInfo_t>boards;
00159 std::vector<ChipInfo_t>chips;
00160
00161
00162 sd.fillDifByChamberId(difs,chamberInfo.id);
00163 sd.fillBoardByChamberId(boards,chamberInfo.id);
00164 sd.fillChipByChamberId(chips,chamberInfo.id);
00165
00166 FILE_LOG(logDEBUG1)<< "Detector.build : chamber " << chamberInfo.id << " ,chamberInfo.xPos: " << xPos
00167 << "um ,chamberInfo.yPos: " << yPos
00168 << "um ,chamberInfo.zPos: " << zPos
00169 << "um ,chamberInfo.stripHorizontal: " << chamberInfo.stripHorizontal << endl;
00170 if ( !chamberInfo.type.compare(GASSIPLEXCHAMBER1))
00171 {
00172 GassiplexChamber1 *chamber = new GassiplexChamber1(xPos, yPos, zPos, xRotation, yRotation, zRotation, 1, 1, chamberInfo.id);
00173 if ( chamber->isValid()) {
00174 addChamber(chamber);
00175 nbChamber++;
00176 }
00177 }
00178
00179 else if ( !chamberInfo.type.compare(GASSIPLEXCHAMBER4))
00180 {
00181 GassiplexChamber4 *chamber = new GassiplexChamber4(xPos, yPos, zPos, xRotation,yRotation, zRotation,2, 2, chamberInfo.id);
00182 if ( chamber->isValid()) {
00183 addChamber(chamber);
00184 nbChamber++;
00185 }
00186
00187 }
00188
00189 else if ( !chamberInfo.type.compare(GASSIPLEXSTRIPCHAMBER1))
00190 {
00191 GassiplexStripChamber1 *chamber = new GassiplexStripChamber1(xPos, yPos, zPos, xRotation,yRotation, zRotation,1, 1, chamberInfo.id,chamberInfo.stripHorizontal);
00192 if ( chamber->isValid()) {
00193 addChamber(chamber);
00194 nbChamber++;
00195 }
00196
00197 }
00198
00199
00200 else if ( !chamberInfo.type.compare(HARDROC1CHAMBER))
00201
00202
00203
00204
00205 {
00206 Hardroc1Chamber *chamber = new Hardroc1Chamber(xPos, yPos, zPos, xRotation,yRotation, zRotation, chamberInfo.id,difs,boards,chips);
00207 if ( chamber->isValid()) {
00208 addChamber(chamber);
00209 nbChamber++;
00210 }
00211 }
00212
00213
00214
00215
00216
00217 else if ( !chamberInfo.type.compare(HARDROC2CHAMBER1))
00218 {
00219 Hardroc2Chamber1 *chamber = new Hardroc2Chamber1(xPos, yPos, zPos, xRotation,yRotation, zRotation, chamberInfo.id,difs,boards,chips);
00220 if ( chamber->isValid()) {
00221 addChamber(chamber);
00222 nbChamber++;
00223 }
00224 }
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234 else if ( !chamberInfo.type.compare(HARDROC2CHAMBER2))
00235 {
00236 Hardroc2Chamber2 *chamber = new Hardroc2Chamber2(xPos, yPos, zPos, xRotation,yRotation, zRotation, chamberInfo.id,difs,boards,chips);
00237 if ( chamber->isValid()) {
00238 addChamber(chamber);
00239 nbChamber++;
00240 }
00241 }
00242
00243
00244
00245
00246
00247 else if ( !chamberInfo.type.compare(HARDROC2CHAMBER6))
00248 {
00249 Hardroc2Chamber6 *chamber = new Hardroc2Chamber6(xPos, yPos, zPos, xRotation,yRotation, zRotation, chamberInfo.id,difs,boards,chips);
00250 if ( chamber->isValid()) {
00251 addChamber(chamber);
00252 nbChamber++;
00253 }
00254 }
00255
00256
00257
00258
00259
00260 else if ( !chamberInfo.type.compare(HARDROC2IPNLCHAMBER6))
00261 {
00262 Hardroc2IPNLChamber6 *chamber = new Hardroc2IPNLChamber6(xPos, yPos, zPos, xRotation,yRotation, zRotation, chamberInfo.id,difs,boards,chips);
00263 if ( chamber->isValid()) {
00264 addChamber(chamber);
00265 nbChamber++;
00266 }
00267 }
00268
00269
00270
00271
00272
00273 else if ( !chamberInfo.type.compare(METRECARRECHAMBER))
00274 {
00275 MetreCarreChamber *chamber = new MetreCarreChamber(xPos, yPos, zPos, xRotation,yRotation, zRotation, chamberInfo.id,difs,boards,chips);
00276 if ( chamber->isValid()) {
00277 addChamber(chamber);
00278 nbChamber++;
00279 }
00280 }
00281
00282
00283
00284
00285
00286
00287 else if ( !chamberInfo.type.compare(MICROROCCHAMBER1))
00288 {
00289 MicrorocChamber1 *chamber = new MicrorocChamber1(xPos, yPos, zPos, xRotation,yRotation, zRotation, chamberInfo.id,difs,boards,chips);
00290 if ( chamber->isValid()) {
00291 addChamber(chamber);
00292 nbChamber++;
00293 }
00294 }
00295
00296
00297
00298
00299 else if ( !chamberInfo.type.compare(MICROROCCHAMBER6))
00300 {
00301 MicrorocChamber6 *chamber = new MicrorocChamber6(xPos, yPos, zPos, xRotation,yRotation, zRotation, chamberInfo.id,difs,boards,chips);
00302 if ( chamber->isValid()) {
00303 addChamber(chamber);
00304 nbChamber++;
00305 }
00306 }
00307
00308
00309
00310
00311
00312 else if ( !chamberInfo.type.compare(MICROROCTESTCHAMBER))
00313 {
00314 MicrorocTestChamber *chamber = new MicrorocTestChamber(xPos, yPos, zPos, xRotation,yRotation, zRotation, chamberInfo.id,difs,boards,chips);
00315 if ( chamber->isValid()) {
00316 addChamber(chamber);
00317 nbChamber++;
00318 }
00319 }
00320 else if ( !chamberInfo.type.compare(DIRACCHAMBER1))
00321 {
00322 DiracChamber1 *chamber = new DiracChamber1(xPos, yPos, zPos, xRotation,yRotation, zRotation, chamberInfo.id,difs,boards,chips);
00323 if ( chamber->isValid()) {
00324 addChamber(chamber);
00325 nbChamber++;
00326 }
00327 }
00328 }
00329
00330
00331 return nbChamber;
00332 }
00333