otsdaq  v1_01_03
 All Classes Namespaces Functions
Geometry.cxx
1 /****************************************************************************
2 ** Authors: Dario Menasce, Stefano Terzo
3 **
4 ** I.N.F.N. Milan-Bicocca
5 ** Piazza della Scienza 3, Edificio U2
6 ** Milano, 20126
7 **
8 ****************************************************************************/
9 
10 #include "otsdaq-core/MonicelliInterface/Geometry.h"
11 #include "otsdaq-core/MonicelliInterface/MessageTools.h"
12 
13 using namespace monicelli;
14 
15 ClassImp(Geometry)
16 
17 //===============================================================================
18 Geometry::Geometry (void) :
19  calibrationDone_(false)
20 {
21  //STDLINE("Empty constructor",ACWhite) ;
22 }
23 
24 //===============================================================================
25 Geometry::~Geometry(void)
26 {
27 // STDLINE("Geometry::~Geometry",ACRed);
28  this->clear();
29 // STDLINE("Geometry::~Geometry",ACGreen);
30 }
31 
32  //=============================================================================
33 void Geometry::setGeometryFileName(std::string fileName)
34 {
35  geometryFileName_ = fileName;
36 }
37 
38 //=============================================================================
39 bool Geometry::compare_zPosition(std::string first, std::string second)
40 {
41  if ( this->getDetector(first)->getZPositionTotal() < this->getDetector(second)->getZPositionTotal() )
42  return true;
43  else
44  return false;
45 }
46 
47 //===============================================================================
48 Detector * Geometry::addDetector(std::string plaqID, bool isDUT)
49 {
50  if( detectorsMap_.find( plaqID ) == detectorsMap_.end() )
51  {
52  detectorsMap_[ plaqID ] = new Detector(plaqID, isDUT);
53  if( isDUT ) dutNumbers_++ ;
54  }
55  else STDLINE("Warning: Detector: " + plaqID + " was already added!!",ACRed);
56 
57  return detectorsMap_[ plaqID ];
58 }
59 
60 //===============================================================================
61 Detector * Geometry::getDetector (std::string plaqID)
62 {
63  if( detectorsMap_.find( plaqID ) == detectorsMap_.end() )
64  {
65  //STDLINE("Warning: No detector: " + plaqID + " found",ACRed);
66  return NULL ;
67  }
68  else return detectorsMap_[plaqID];
69 }
70 
71 //===============================================================================
72 Detector * Geometry::getDetector(int station , int plaq)
73 {
74  std::stringstream ss_;
75  ss_.str("");
76  ss_ << "Station: " << station << " - " << "Plaq: " << plaq;
77  return this->getDetector(ss_.str());
78 }
79 
80 //===============================================================================
81 std::string Geometry::getDetectorID(int station , int plaq)
82 {
83  std::stringstream ss_;
84  ss_.str("");
85  ss_ << "Station: " << station << " - " << "Plaq: " << plaq;
86  return ss_.str();
87 }
88 
89 //===============================================================================
90 unsigned int Geometry::getMaxRowsNum(void)
91 {
92  unsigned int maxRowsNum=0;
93  for (detectorsMapDef::iterator it=detectorsMap_.begin(); it!=detectorsMap_.end(); ++it)
94  {
95  if ( (*it).second->getNumberOfRows() > maxRowsNum ) maxRowsNum = (*it).second->getNumberOfRows();
96  }
97  return maxRowsNum;
98 }
99 
100 //===============================================================================
101 unsigned int Geometry::getMaxColsNum(void)
102 {
103  unsigned int maxColsNum=0;
104  for (detectorsMapDef::iterator it=detectorsMap_.begin(); it!=detectorsMap_.end(); ++it)
105  {
106  if ( (*it).second->getNumberOfCols() > maxColsNum ) maxColsNum = (*it).second->getNumberOfCols();
107  }
108  return maxColsNum;
109 }
110 
111 //===============================================================================
112 double Geometry::getMaxDetectorsLength(void)
113 {
114  double maxDetectorsLength=0;
115  for (detectorsMapDef::iterator it=detectorsMap_.begin(); it!=detectorsMap_.end(); ++it)
116  {
117  if ( (*it).second->getDetectorLengthX() > maxDetectorsLength ) maxDetectorsLength = (*it).second->getDetectorLengthX();
118  if ( (*it).second->getDetectorLengthY() > maxDetectorsLength ) maxDetectorsLength = (*it).second->getDetectorLengthY();
119  }
120  return maxDetectorsLength;
121 }
122 
123 //================================================================================
124 unsigned int Geometry::getDetectorsNumber(bool excludeDUT)
125 {
126  if (!excludeDUT) return detectorsMap_.size() ;
127  else return (detectorsMap_.size()-dutNumbers_ );
128 }
129 
130 //================================================================================
131 std::vector<Detector*> Geometry::getDUTs(void )
132 {
133  std::vector<Detector*> DUTs;
134  for (detectorsMapDef::iterator it=detectorsMap_.begin(); it!=detectorsMap_.end(); ++it)
135  {
136  if( (*it).second->isDUT() ) DUTs.push_back( (*it).second );
137  }
138  return DUTs;
139 }
140 
141 //================================================================================
142 void Geometry::dump(void)
143 {
144  for (detectorsMapDef::iterator it=detectorsMap_.begin(); it!=detectorsMap_.end(); ++it)
145  {
146  STDLINE(it->first,ACRed);
147  it->second->dump();
148  }
149 }