00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef CSCDQM_Detector_H
00020 #define CSCDQM_Detector_H
00021
00022 #include <math.h>
00023 #include <float.h>
00024 #include <map>
00025 #include <vector>
00026 #include <iostream>
00027 #include <sstream>
00028 #include <iomanip>
00029
00030 #include "DQM/CSCMonitorModule/interface/CSCDQM_Utility.h"
00031
00032 namespace cscdqm {
00033
00034 #define N_SIDES 2
00035 #define N_STATIONS 4
00036 #define N_RINGS 3
00037 #define N_CHAMBERS 36
00038 #define N_LAYERS 6
00039 #define N_CFEBS 5
00040 #define N_HVS 5
00041
00042 #define ADDR_SIZE 7
00043
00044 #define N_ELEMENTS 7740
00045
00046 #define PARTITION_INDEX(x,y) (x * partitions_y + y)
00047 #define PARTITION_STEP_X (5.0 / partitions_x)
00048 #define PARTITION_STEP_Y ((2.0 * 3.14159) / partitions_y)
00049
00050
00051
00052
00056 typedef struct AddressMask {
00057 bool side;
00058 bool station;
00059 bool ring;
00060 bool chamber;
00061 bool layer;
00062 bool cfeb;
00063 bool hv;
00064 };
00065
00070 typedef struct Address {
00071
00072 unsigned int side;
00073 unsigned int station;
00074 unsigned int ring;
00075 unsigned int chamber;
00076 unsigned int layer;
00077 unsigned int cfeb;
00078 unsigned int hv;
00079
00080 AddressMask mask;
00081
00082 const bool operator== (const Address& a) const {
00083 if (mask.side == a.mask.side && mask.side == true && side != a.side) return false;
00084 if (mask.station == a.mask.station && mask.station == true && station != a.station) return false;
00085 if (mask.ring == a.mask.ring && mask.ring == true && ring != a.ring) return false;
00086 if (mask.chamber == a.mask.chamber && mask.chamber == true && chamber != a.chamber) return false;
00087 if (mask.layer == a.mask.layer && mask.layer == true && layer != a.layer) return false;
00088 if (mask.cfeb == a.mask.cfeb && mask.cfeb == true && cfeb != a.cfeb) return false;
00089 if (mask.hv == a.mask.hv && mask.hv == true && hv != a.hv) return false;
00090 return true;
00091 };
00092
00093 const Address* operator= (const Address& a) {
00094 mask.side = a.mask.side;
00095 side = a.side;
00096 mask.station = a.mask.station;
00097 station = a.station;
00098 mask.ring = a.mask.ring;
00099 ring = a.ring;
00100 mask.chamber = a.mask.chamber;
00101 chamber = a.chamber;
00102 mask.layer = a.mask.layer;
00103 layer = a.layer;
00104 mask.cfeb = a.mask.cfeb;
00105 cfeb = a.cfeb;
00106 mask.hv = a.mask.hv;
00107 hv = a.hv;
00108 return this;
00109 };
00110
00111 };
00112
00116 typedef struct AddressBox {
00117 Address adr;
00118 float xmin;
00119 float xmax;
00120 float ymin;
00121 float ymax;
00122 };
00123
00127 struct AddressBoxStationPartition {
00128 unsigned int from[2];
00129 unsigned int to[2];
00130 };
00131
00132 typedef std::map<const unsigned int, std::vector<unsigned int> > PartitionMap;
00133 typedef PartitionMap::iterator PartitionMapIterator;
00134
00139 class Detector {
00140
00141 public:
00142
00143 Detector(const unsigned int p_partitions_x = 0, const unsigned int p_partitions_y = 0);
00144
00145 const bool NextAddress(unsigned int& i, const Address*& adr, const Address& mask) const;
00146 const bool NextAddressBox(unsigned int& i, const AddressBox*& box, const Address& mask) const;
00147
00148 const bool NextAddressBoxByPartition (unsigned int& i, const unsigned int px, const unsigned int py, AddressBox*& box);
00149
00150 const float Area(const unsigned int station) const;
00151 const float Area(const Address& adr) const;
00152
00153 void PrintAddress(const Address& adr) const;
00154 const std::string AddressName(const Address& adr) const;
00155 const bool AddressFromString(const std::string str_address, Address& adr) const;
00156
00157 const unsigned int NumberOfRings(const unsigned int station) const;
00158 const unsigned int NumberOfChambers(const unsigned int station, const unsigned int ring) const;
00159 const unsigned int NumberOfChamberCFEBs(const unsigned int station, const unsigned int ring) const;
00160 const unsigned int NumberOfChamberHVs(const unsigned int station, const unsigned int ring) const;
00161
00162 private:
00163
00164 const float Eta(const float r, const float z) const;
00165 const float EtaToX(const float eta) const;
00166 const float PhiToY(const float phi) const;
00167 const float Z(const int station, const int ring) const;
00168 const float RMinHV(const int station, const int ring, const int n_hv) const;
00169 const float RMaxHV(const int station, const int ring, const int n_hv) const;
00170 const float PhiMinCFEB(const int station, const int ring, const int chamber, const int cfeb) const;
00171 const float PhiMaxCFEB(const int station, const int ring, const int chamber, const int cfeb) const;
00172
00173 AddressBox boxes[N_ELEMENTS];
00174 float station_area[N_STATIONS];
00175
00176 unsigned int partitions_x;
00177 unsigned int partitions_y;
00178 unsigned int partitions_offset;
00179
00180
00181 PartitionMap partitions;
00182 AddressBoxStationPartition station_partitions[N_STATIONS];
00183
00184 };
00185
00186 }
00187
00188 #endif