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
cscdqm::AddressMask::chamber
bool chamber
Definition: CSCDQM_Detector.h:72
cscdqm::Detector::NextAddress
const bool NextAddress(unsigned int &i, const Address *&adr, const Address &mask) const
Address iterator by mask.
Definition: CSCDQM_Detector.cc:337
cscdqm::Address::operator==
const bool operator==(const Address &a) const
Definition: CSCDQM_Detector.h:93
mps_fire.i
i
Definition: mps_fire.py:428
cscdqm::PartitionMapIterator
PartitionMap::iterator PartitionMapIterator
Definition: CSCDQM_Detector.h:163
cscdqm::Detector::NumberOfChambers
const unsigned int NumberOfChambers(const unsigned int station, const unsigned int ring) const
Returns the number of chambers for the given station and ring.
Definition: CSCDQM_Detector.cc:215
cscdqm::Address::side
unsigned int side
Definition: CSCDQM_Detector.h:83
cscdqm::Address::layer
unsigned int layer
Definition: CSCDQM_Detector.h:87
cscdqm::Detector::Detector
Detector(const unsigned int p_partitions_x=0, const unsigned int p_partitions_y=0)
Constructor.
Definition: CSCDQM_Detector.cc:33
cscdqm::Detector::NumberOfChamberHVs
const unsigned int NumberOfChamberHVs(const unsigned int station, const unsigned int ring) const
Returns the number of HVs per Chamber on given Station/Ring.
Definition: CSCDQM_Detector.cc:271
relativeConstraints.station
station
Definition: relativeConstraints.py:67
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
CSCDQM_Utility.h
cscdqm::AddressBox
Area covered by Address in eta/phy space.
Definition: CSCDQM_Detector.h:151
cscdqm::AddressBox::adr
Address adr
Definition: CSCDQM_Detector.h:152
cscdqm::AddressBox::ymax
float ymax
Definition: CSCDQM_Detector.h:156
cscdqm::Detector::RMinHV
const float RMinHV(const int station, const int ring, const int n_hv) const
Get R min parameter (used in address eta/phi calculation)
Definition: CSCDQM_Detector.cc:464
N_ELEMENTS
#define N_ELEMENTS
Definition: CSCDQM_Detector.h:54
cscdqm::Detector::GlobalChamberIndex
unsigned int GlobalChamberIndex(unsigned int side, unsigned int station, unsigned int ring, unsigned int chamber) const
Return global chamber index on his geometric location.
Definition: CSCDQM_Detector.cc:147
cscdqm::Detector::Eta
const float Eta(const float r, const float z) const
Definition: CSCDQM_Detector.cc:391
cscdqm::Detector::NextAddressBoxByPartition
const bool NextAddressBoxByPartition(unsigned int &i, const unsigned int px, const unsigned int py, AddressBox *&box)
Address box iterator by partition.
Definition: CSCDQM_Detector.cc:374
PVValHelper::eta
Definition: PVValidationHelpers.h:70
cscdqm::Detector::NumberOfRings
const unsigned int NumberOfRings(const unsigned int station) const
Returns the number of rings for the given station.
Definition: CSCDQM_Detector.cc:197
cscdqm::Detector::NextAddressBox
const bool NextAddressBox(unsigned int &i, const AddressBox *&box, const Address &mask) const
Address box iterator by mask.
Definition: CSCDQM_Detector.cc:355
cscdqm::Address::station
unsigned int station
Definition: CSCDQM_Detector.h:84
cscdqm::Detector::station_area
float station_area[4]
Definition: CSCDQM_Detector.h:210
cscdqm::PartitionMap
std::map< const unsigned int, std::vector< unsigned int > > PartitionMap
Definition: CSCDQM_Detector.h:160
a
double a
Definition: hdecay.h:119
cscdqm::AddressBox::xmax
float xmax
Definition: CSCDQM_Detector.h:154
cscdqm
Definition: CSCDQM_DCSBase.h:29
cscdqm::Address::mask
AddressMask mask
Definition: CSCDQM_Detector.h:91
cscdqm::Address::name
const std::string name() const
Get the full name of the address prefixed with CSC_. It is being used by summaryReportContent variabl...
Definition: CSCDQM_Detector.h:120
cscdqm::Address::cfeb
unsigned int cfeb
Definition: CSCDQM_Detector.h:88
cscdqm::AddressBox::ymin
float ymin
Definition: CSCDQM_Detector.h:155
cscdqm::Detector::PhiToY
const float PhiToY(const float phi) const
Transform phi coordinate to local canvas coordinate.
Definition: CSCDQM_Detector.cc:422
cscdqm::Detector::NumberOfChamberCFEBs
const unsigned int NumberOfChamberCFEBs(const unsigned int station, const unsigned int ring) const
Returns the number of CFEBs per Chamber on given Station/Ring.
Definition: CSCDQM_Detector.cc:243
cscdqm::Detector::PrintAddress
void PrintAddress(const Address &adr) const
Prints address for debugging.
Definition: CSCDQM_Detector.cc:298
cscdqm::AddressMask::cfeb
bool cfeb
Definition: CSCDQM_Detector.h:74
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cscdqm::AddressMask::side
bool side
Definition: CSCDQM_Detector.h:69
alignCSCRings.r
r
Definition: alignCSCRings.py:93
cscdqm::AddressMask::station
bool station
Definition: CSCDQM_Detector.h:70
cscdqm::Address
Structure to store detector addresses of any granularity: from whole detector to the single HV elemen...
Definition: CSCDQM_Detector.h:82
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
cscdqm::AddressMask::ring
bool ring
Definition: CSCDQM_Detector.h:71
cscdqm::AddressMask::layer
bool layer
Definition: CSCDQM_Detector.h:73
cscdqm::Address::hv
unsigned int hv
Definition: CSCDQM_Detector.h:89
cscdqm::Address::chamber
unsigned int chamber
Definition: CSCDQM_Detector.h:86
cscdqm::Detector::partitions
PartitionMap partitions
Definition: CSCDQM_Detector.h:219
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
N_STATIONS
#define N_STATIONS
Definition: CSCDQM_Detector.h:43
cscdqm::Detector::RMaxHV
const float RMaxHV(const int station, const int ring, const int n_hv) const
Get R max parameter (used in address eta/phi calculation)
Definition: CSCDQM_Detector.cc:542
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
cscdqm::Detector::partitions_y
unsigned int partitions_y
Definition: CSCDQM_Detector.h:216
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
cscdqm::Detector::AddressFromString
const bool AddressFromString(const std::string &str_address, Address &adr) const
Construct address from string.
Definition: CSCDQM_Detector.cc:658
cscdqm::AddressMask::hv
bool hv
Definition: CSCDQM_Detector.h:75
cscdqm::Address::ring
unsigned int ring
Definition: CSCDQM_Detector.h:85
cscdqm::AddressMask
Mask of the address which is used to switch on and off appropriate Address fields.
Definition: CSCDQM_Detector.h:68
cscdqm::Detector
Detector geometry and addressing related imformation and routines.
Definition: CSCDQM_Detector.h:169
cscdqm::Detector::Area
const float Area(const unsigned int station) const
Calculate station area in eta/phi space.
Definition: CSCDQM_Detector.cc:132
cscdqm::Detector::Z
const float Z(const int station, const int ring) const
Get Z parameter (used in address eta/phi calculation)
Definition: CSCDQM_Detector.cc:438
cscdqm::Address::operator<<
friend std::ostream & operator<<(std::ostream &out, const Address &adr)
Definition: CSCDQM_Detector.h:111
cscdqm::Detector::partitions_x
unsigned int partitions_x
Definition: CSCDQM_Detector.h:213
cscdqm::Detector::boxes
AddressBox boxes[9540]
Definition: CSCDQM_Detector.h:207
cscdqm::Detector::PhiMinCFEB
const float PhiMinCFEB(const int station, const int ring, const int chamber, const int cfeb) const
Get Min phi boundary for particular CFEB.
Definition: CSCDQM_Detector.cc:621
cscdqm::AddressBox::xmin
float xmin
Definition: CSCDQM_Detector.h:153
cscdqm::Detector::EtaToX
const float EtaToX(const float eta) const
Transform eta coordinate to local canvas coordinate.
Definition: CSCDQM_Detector.cc:407
cscdqm::Detector::PhiMaxCFEB
const float PhiMaxCFEB(const int station, const int ring, const int chamber, const int cfeb) const
Get Max phi boundary for particular CFEB.
Definition: CSCDQM_Detector.cc:641