CMS 3D CMS Logo

CSCDQM_Detector.h
Go to the documentation of this file.
1 /*
2  * =====================================================================================
3  *
4  * Filename: CSCDQM_Detector.h
5  *
6  * Description: CSC detector functions.
7  *
8  * Version: 1.0
9  * Created: 05/19/2008 10:52:21 AM
10  * Revision: none
11  * Compiler: gcc
12  *
13  * Author: Valdas Rapsevicius (VR), Valdas.Rapsevicius@cern.ch
14  * Company: CERN, CH
15  *
16  * =====================================================================================
17  */
18 
19 #ifndef CSCDQM_Detector_H
20 #define CSCDQM_Detector_H
21 
22 #include <cmath>
23 #include <cfloat>
24 #include <map>
25 #include <vector>
26 #include <iostream>
27 #include <sstream>
28 #include <iomanip>
29 
30 #ifdef CSC_RENDER_PLUGIN
31 #include "CSCDQM_Utility.h"
32 #else
33 #include "CSCDQM_Utility.h"
34 #endif
35 
36 namespace cscdqm {
37 
42 #define N_SIDES 2
43 #define N_STATIONS 4
44 #define N_RINGS 3
45 #define N_CHAMBERS 36
46 #define N_LAYERS 6
47 #define N_CFEBS 5
48 #define N_HVS 5
49 
51 #define ADDR_SIZE 7
52 
54 #define N_ELEMENTS 9540
55 //(7740 + 1800)
56 
61 #define PARTITION_INDEX(x,y) (x * partitions_y + y)
62 #define PARTITION_STEP_X (5.0 / partitions_x)
63 #define PARTITION_STEP_Y ((2.0 * 3.14159) / partitions_y)
64 
68 struct AddressMask {
69  bool side;
70  bool station;
71  bool ring;
72  bool chamber;
73  bool layer;
74  bool cfeb;
75  bool hv;
76 };
77 
82 struct Address {
83 
84  unsigned int side;
85  unsigned int station;
86  unsigned int ring;
87  unsigned int chamber;
88  unsigned int layer;
89  unsigned int cfeb;
90  unsigned int hv;
91 
93 
94  const bool operator== (const Address& a) const {
95  if (mask.side == a.mask.side && mask.side == true && side != a.side) return false;
96  if (mask.station == a.mask.station && mask.station == true && station != a.station) return false;
97  if (mask.ring == a.mask.ring && mask.ring == true && ring != a.ring) return false;
98  if (mask.chamber == a.mask.chamber && mask.chamber == true && chamber != a.chamber) return false;
99  if (mask.layer == a.mask.layer && mask.layer == true && layer != a.layer) return false;
100  if (mask.cfeb == a.mask.cfeb && mask.cfeb == true && cfeb != a.cfeb) return false;
101  if (mask.hv == a.mask.hv && mask.hv == true && hv != a.hv) return false;
102  return true;
103  };
104 
105  const Address* operator= (const Address& a) {
106  mask.side = a.mask.side;
107  side = a.side;
108  mask.station = a.mask.station;
109  station = a.station;
110  mask.ring = a.mask.ring;
111  ring = a.ring;
112  mask.chamber = a.mask.chamber;
113  chamber = a.chamber;
114  mask.layer = a.mask.layer;
115  layer = a.layer;
116  mask.cfeb = a.mask.cfeb;
117  cfeb = a.cfeb;
118  mask.hv = a.mask.hv;
119  hv = a.hv;
120  return this;
121  };
122 
123  friend std::ostream& operator<<(std::ostream& out, const Address& adr) {
124  out << adr.name();
125  return out;
126  }
127 
132  const std::string name() const {
133  std::ostringstream oss;
134  oss << "CSC";
135  if (mask.side) {
136  oss << "_Side" << (side == 1 ? "Plus" : "Minus");
137  if (mask.station) {
138  oss << "_Station" << std::setfill('0') << std::setw(2) << station;
139  if (mask.ring) {
140  oss << "_Ring" << std::setfill('0') << std::setw(2) << ring;
141  if (mask.chamber) {
142  oss << "_Chamber" << std::setfill('0') << std::setw(2) << chamber;
143  if (mask.layer) {
144  oss << "_Layer" << std::setfill('0') << std::setw(2) << layer;
145  if (mask.cfeb) {
146  oss << "_CFEB" << std::setfill('0') << std::setw(2) << cfeb;
147  if (mask.hv) {
148  oss << "_HV" << std::setfill('0') << std::setw(2) << hv;
149  }
150  }
151  }
152  }
153  }
154  }
155  }
156  return oss.str();
157  }
158 
159 };
160 
164 struct AddressBox {
166  float xmin;
167  float xmax;
168  float ymin;
169  float ymax;
170 };
171 
172 
174 typedef std::map<const unsigned int, std::vector<unsigned int> > PartitionMap;
175 
177 typedef PartitionMap::iterator PartitionMapIterator;
178 
183 class Detector {
184 
185  public:
186 
187  Detector(const unsigned int p_partitions_x = 0, const unsigned int p_partitions_y = 0);
188 
189  const bool NextAddress(unsigned int& i, const Address*& adr, const Address& mask) const;
190  const bool NextAddressBox(unsigned int& i, const AddressBox*& box, const Address& mask) const;
191  //const bool NextAddressBoxByPartition(unsigned int& i, unsigned int& px, unsigned int& py, const AddressBox*& box, const Address& mask, const float xmin, const float xmax, const float ymin, const float ymax);
192  const bool NextAddressBoxByPartition (unsigned int& i, const unsigned int px, const unsigned int py, AddressBox*& box);
193 
194  const float Area(const unsigned int station) const;
195  const float Area(const Address& adr) const;
196 
197  void PrintAddress(const Address& adr) const;
198  const bool AddressFromString(const std::string& str_address, Address& adr) const;
199 
200  const unsigned int NumberOfRings(const unsigned int station) const;
201  const unsigned int NumberOfChambers(const unsigned int station, const unsigned int ring) const;
202  const unsigned int NumberOfChamberCFEBs(const unsigned int station, const unsigned int ring) const;
203  const unsigned int NumberOfChamberHVs(const unsigned int station, const unsigned int ring) const;
204  unsigned int GlobalChamberIndex(unsigned int side, unsigned int station, unsigned int ring, unsigned int chamber) const;
205 
206  private:
207 
208  const float Eta(const float r, const float z) const;
209  const float EtaToX(const float eta) const;
210  const float PhiToY(const float phi) const;
211  const float Z(const int station, const int ring) const;
212  const float RMinHV(const int station, const int ring, const int n_hv) const;
213  const float RMaxHV(const int station, const int ring, const int n_hv) const;
214  const float PhiMinCFEB(const int station, const int ring, const int chamber, const int cfeb) const;
215  const float PhiMaxCFEB(const int station, const int ring, const int chamber, const int cfeb) const;
216 
219 
221  float station_area[N_STATIONS];
222 
224  unsigned int partitions_x;
225 
227  unsigned int partitions_y;
228 
230  PartitionMap partitions;
231 
232 };
233 
234 }
235 
236 #endif
PartitionMap partitions
Detector geometry and addressing related imformation and routines.
unsigned int partitions_y
unsigned int layer
PartitionMap::iterator PartitionMapIterator
friend std::ostream & operator<<(std::ostream &out, const Address &adr)
unsigned int partitions_x
Area covered by Address in eta/phy space.
std::map< const unsigned int, std::vector< unsigned int > > PartitionMap
Mask of the address which is used to switch on and off appropriate Address fields.
unsigned int cfeb
bool operator==(const QGLikelihoodParameters &lhs, const QGLikelihoodCategory &rhs)
Test if parameters are compatible with category.
unsigned int chamber
#define N_ELEMENTS
unsigned int hv
unsigned int station
const std::string name() const
Get the full name of the address prefixed with CSC_. It is being used by summaryReportContent variabl...
#define N_STATIONS
double a
Definition: hdecay.h:121
AddressMask mask
unsigned int side
Structure to store detector addresses of any granularity: from whole detector to the single HV elemen...
unsigned int ring