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  unsigned int side;
84  unsigned int station;
85  unsigned int ring;
86  unsigned int chamber;
87  unsigned int layer;
88  unsigned int cfeb;
89  unsigned int hv;
90 
92 
93  const bool operator==(const Address& a) const {
94  if (mask.side == a.mask.side && mask.side == true && side != a.side)
95  return false;
96  if (mask.station == a.mask.station && mask.station == true && station != a.station)
97  return false;
98  if (mask.ring == a.mask.ring && mask.ring == true && ring != a.ring)
99  return false;
100  if (mask.chamber == a.mask.chamber && mask.chamber == true && chamber != a.chamber)
101  return false;
102  if (mask.layer == a.mask.layer && mask.layer == true && layer != a.layer)
103  return false;
104  if (mask.cfeb == a.mask.cfeb && mask.cfeb == true && cfeb != a.cfeb)
105  return false;
106  if (mask.hv == a.mask.hv && mask.hv == true && hv != a.hv)
107  return false;
108  return true;
109  };
110 
111  friend std::ostream& operator<<(std::ostream& out, const Address& adr) {
112  out << adr.name();
113  return out;
114  }
115 
120  const std::string name() const {
121  std::ostringstream oss;
122  oss << "CSC";
123  if (mask.side) {
124  oss << "_Side" << (side == 1 ? "Plus" : "Minus");
125  if (mask.station) {
126  oss << "_Station" << std::setfill('0') << std::setw(2) << station;
127  if (mask.ring) {
128  oss << "_Ring" << std::setfill('0') << std::setw(2) << ring;
129  if (mask.chamber) {
130  oss << "_Chamber" << std::setfill('0') << std::setw(2) << chamber;
131  if (mask.layer) {
132  oss << "_Layer" << std::setfill('0') << std::setw(2) << layer;
133  if (mask.cfeb) {
134  oss << "_CFEB" << std::setfill('0') << std::setw(2) << cfeb;
135  if (mask.hv) {
136  oss << "_HV" << std::setfill('0') << std::setw(2) << hv;
137  }
138  }
139  }
140  }
141  }
142  }
143  }
144  return oss.str();
145  }
146  };
147 
151  struct AddressBox {
153  float xmin;
154  float xmax;
155  float ymin;
156  float ymax;
157  };
158 
160  typedef std::map<const unsigned int, std::vector<unsigned int> > PartitionMap;
161 
163  typedef PartitionMap::iterator PartitionMapIterator;
164 
169  class Detector {
170  public:
171  Detector(const unsigned int p_partitions_x = 0, const unsigned int p_partitions_y = 0);
172 
173  const bool NextAddress(unsigned int& i, const Address*& adr, const Address& mask) const;
174  const bool NextAddressBox(unsigned int& i, const AddressBox*& box, const Address& mask) const;
175  //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);
176  const bool NextAddressBoxByPartition(unsigned int& i,
177  const unsigned int px,
178  const unsigned int py,
179  AddressBox*& box);
180 
181  const float Area(const unsigned int station) const;
182  const float Area(const Address& adr) const;
183 
184  void PrintAddress(const Address& adr) const;
185  const bool AddressFromString(const std::string& str_address, Address& adr) const;
186 
187  const unsigned int NumberOfRings(const unsigned int station) const;
188  const unsigned int NumberOfChambers(const unsigned int station, const unsigned int ring) const;
189  const unsigned int NumberOfChamberCFEBs(const unsigned int station, const unsigned int ring) const;
190  const unsigned int NumberOfChamberHVs(const unsigned int station, const unsigned int ring) const;
191  unsigned int GlobalChamberIndex(unsigned int side,
192  unsigned int station,
193  unsigned int ring,
194  unsigned int chamber) const;
195 
196  private:
197  const float Eta(const float r, const float z) const;
198  const float EtaToX(const float eta) const;
199  const float PhiToY(const float phi) const;
200  const float Z(const int station, const int ring) const;
201  const float RMinHV(const int station, const int ring, const int n_hv) const;
202  const float RMaxHV(const int station, const int ring, const int n_hv) const;
203  const float PhiMinCFEB(const int station, const int ring, const int chamber, const int cfeb) const;
204  const float PhiMaxCFEB(const int station, const int ring, const int chamber, const int cfeb) const;
205 
208 
211 
213  unsigned int partitions_x;
214 
216  unsigned int partitions_y;
217 
220  };
221 
222 } // namespace cscdqm
223 
224 #endif
const bool NextAddressBox(unsigned int &i, const AddressBox *&box, const Address &mask) const
Address box iterator by mask.
PartitionMap partitions
Detector geometry and addressing related imformation and routines.
unsigned int partitions_y
unsigned int layer
PartitionMap::iterator PartitionMapIterator
unsigned int GlobalChamberIndex(unsigned int side, unsigned int station, unsigned int ring, unsigned int chamber) const
Return global chamber index on his geometric location.
friend std::ostream & operator<<(std::ostream &out, const Address &adr)
unsigned int partitions_x
const float EtaToX(const float eta) const
Transform eta coordinate to local canvas coordinate.
const float PhiMaxCFEB(const int station, const int ring, const int chamber, const int cfeb) const
Get Max phi boundary for particular CFEB.
Area covered by Address in eta/phy space.
std::map< const unsigned int, std::vector< unsigned int > > PartitionMap
const bool operator==(const Address &a) const
Detector(const unsigned int p_partitions_x=0, const unsigned int p_partitions_y=0)
Constructor.
Mask of the address which is used to switch on and off appropriate Address fields.
const bool NextAddressBoxByPartition(unsigned int &i, const unsigned int px, const unsigned int py, AddressBox *&box)
Address box iterator by partition.
constexpr uint32_t mask
Definition: gpuClustering.h:24
const float Area(const unsigned int station) const
Calculate station area in eta/phi space.
unsigned int cfeb
const float Z(const int station, const int ring) const
Get Z parameter (used in address eta/phi calculation)
const float PhiToY(const float phi) const
Transform phi coordinate to local canvas coordinate.
const unsigned int NumberOfChamberCFEBs(const unsigned int station, const unsigned int ring) const
Returns the number of CFEBs per Chamber on given Station/Ring.
unsigned int chamber
#define N_ELEMENTS
unsigned int hv
const unsigned int NumberOfRings(const unsigned int station) const
Returns the number of rings for the given station.
unsigned int station
#define N_STATIONS
const float RMaxHV(const int station, const int ring, const int n_hv) const
Get R max parameter (used in address eta/phi calculation)
const float RMinHV(const int station, const int ring, const int n_hv) const
Get R min parameter (used in address eta/phi calculation)
const bool AddressFromString(const std::string &str_address, Address &adr) const
Construct address from string.
const unsigned int NumberOfChambers(const unsigned int station, const unsigned int ring) const
Returns the number of chambers for the given station and ring.
const std::string name() const
Get the full name of the address prefixed with CSC_. It is being used by summaryReportContent variabl...
const float PhiMinCFEB(const int station, const int ring, const int chamber, const int cfeb) const
Get Min phi boundary for particular CFEB.
const bool NextAddress(unsigned int &i, const Address *&adr, const Address &mask) const
Address iterator by mask.
double a
Definition: hdecay.h:119
AddressMask mask
void PrintAddress(const Address &adr) const
Prints address for debugging.
AddressBox boxes[9540]
unsigned int side
Structure to store detector addresses of any granularity: from whole detector to the single HV elemen...
const float Eta(const float r, const float z) const
unsigned int ring
const unsigned int NumberOfChamberHVs(const unsigned int station, const unsigned int ring) const
Returns the number of HVs per Chamber on given Station/Ring.