00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "otsdaq-core/MonicelliInterface/Geometry.h"
00011 #include "otsdaq-core/MonicelliInterface/MessageTools.h"
00012
00013 using namespace monicelli;
00014
00015 ClassImp(Geometry)
00016
00017
00018 Geometry::Geometry (void) :
00019 calibrationDone_(false)
00020 {
00021
00022 }
00023
00024
00025 Geometry::~Geometry(void)
00026 {
00027
00028 this->clear();
00029
00030 }
00031
00032
00033 void Geometry::setGeometryFileName(std::string fileName)
00034 {
00035 geometryFileName_ = fileName;
00036 }
00037
00038
00039 bool Geometry::compare_zPosition(std::string first, std::string second)
00040 {
00041 if ( this->getDetector(first)->getZPositionTotal() < this->getDetector(second)->getZPositionTotal() )
00042 return true;
00043 else
00044 return false;
00045 }
00046
00047
00048 Detector * Geometry::addDetector(std::string plaqID, bool isDUT)
00049 {
00050 if( detectorsMap_.find( plaqID ) == detectorsMap_.end() )
00051 {
00052 detectorsMap_[ plaqID ] = new Detector(plaqID, isDUT);
00053 if( isDUT ) dutNumbers_++ ;
00054 }
00055 else STDLINE("Warning: Detector: " + plaqID + " was already added!!",ACRed);
00056
00057 return detectorsMap_[ plaqID ];
00058 }
00059
00060
00061 Detector * Geometry::getDetector (std::string plaqID)
00062 {
00063 if( detectorsMap_.find( plaqID ) == detectorsMap_.end() )
00064 {
00065
00066 return NULL ;
00067 }
00068 else return detectorsMap_[plaqID];
00069 }
00070
00071
00072 Detector * Geometry::getDetector(int station , int plaq)
00073 {
00074 std::stringstream ss_;
00075 ss_.str("");
00076 ss_ << "Station: " << station << " - " << "Plaq: " << plaq;
00077 return this->getDetector(ss_.str());
00078 }
00079
00080
00081 std::string Geometry::getDetectorID(int station , int plaq)
00082 {
00083 std::stringstream ss_;
00084 ss_.str("");
00085 ss_ << "Station: " << station << " - " << "Plaq: " << plaq;
00086 return ss_.str();
00087 }
00088
00089
00090 unsigned int Geometry::getMaxRowsNum(void)
00091 {
00092 unsigned int maxRowsNum=0;
00093 for (detectorsMapDef::iterator it=detectorsMap_.begin(); it!=detectorsMap_.end(); ++it)
00094 {
00095 if ( (*it).second->getNumberOfRows() > maxRowsNum ) maxRowsNum = (*it).second->getNumberOfRows();
00096 }
00097 return maxRowsNum;
00098 }
00099
00100
00101 unsigned int Geometry::getMaxColsNum(void)
00102 {
00103 unsigned int maxColsNum=0;
00104 for (detectorsMapDef::iterator it=detectorsMap_.begin(); it!=detectorsMap_.end(); ++it)
00105 {
00106 if ( (*it).second->getNumberOfCols() > maxColsNum ) maxColsNum = (*it).second->getNumberOfCols();
00107 }
00108 return maxColsNum;
00109 }
00110
00111
00112 double Geometry::getMaxDetectorsLength(void)
00113 {
00114 double maxDetectorsLength=0;
00115 for (detectorsMapDef::iterator it=detectorsMap_.begin(); it!=detectorsMap_.end(); ++it)
00116 {
00117 if ( (*it).second->getDetectorLengthX() > maxDetectorsLength ) maxDetectorsLength = (*it).second->getDetectorLengthX();
00118 if ( (*it).second->getDetectorLengthY() > maxDetectorsLength ) maxDetectorsLength = (*it).second->getDetectorLengthY();
00119 }
00120 return maxDetectorsLength;
00121 }
00122
00123
00124 unsigned int Geometry::getDetectorsNumber(bool excludeDUT)
00125 {
00126 if (!excludeDUT) return detectorsMap_.size() ;
00127 else return (detectorsMap_.size()-dutNumbers_ );
00128 }
00129
00130
00131 std::vector<Detector*> Geometry::getDUTs(void )
00132 {
00133 std::vector<Detector*> DUTs;
00134 for (detectorsMapDef::iterator it=detectorsMap_.begin(); it!=detectorsMap_.end(); ++it)
00135 {
00136 if( (*it).second->isDUT() ) DUTs.push_back( (*it).second );
00137 }
00138 return DUTs;
00139 }
00140
00141
00142 void Geometry::dump(void)
00143 {
00144 for (detectorsMapDef::iterator it=detectorsMap_.begin(); it!=detectorsMap_.end(); ++it)
00145 {
00146 STDLINE(it->first,ACRed);
00147 it->second->dump();
00148 }
00149 }