CMS 3D CMS Logo

RPCConst.cc
Go to the documentation of this file.
1 #include <cmath>
2 #include <iostream>
3 #include <sstream>
4 #include <cstdio>
7 
8 #define m_pi 3.14159265358979
9 
10 int RPCConst::iptFromPt(const double pt) {
11  if (pt == 0.)
12  return 0;
13  if (pt < m_pts[0]) {
14  //edm::LogError("RPCTrigger")<<"** RPCConst ** iptFromPt called with illegal pt="<<pt;
15  std::string msg = "[RPCConst::iptFromPt] called with illegal pt=";
16  std::ostringstream ostr;
17  ostr << pt;
18  msg += ostr.str();
19  throw RPCException(msg);
20  return 0;
21  }
22  int ipt = RPCConst::IPT_MAX;
23  while (pt < m_pts[ipt]) {
24  ipt--;
25  };
26  return ipt;
27 }
28 
29 double RPCConst::ptFromIpt(const int ipt) {
30  if (ipt < 0 || ipt > RPCConst::IPT_MAX) {
31  //edm::LogError("RPCTrigger") <<"**RPCConst::ptFromIpt** problem with ipt: "<<ipt;
32  std::string msg = "[RPCConst::ptFromIpt] problem with ipt: ";
33  std::ostringstream ostr;
34  ostr << ipt;
35  msg += ostr.str();
36  throw RPCException(msg);
37  return 0.;
38  } else
39  return m_pts[ipt];
40 }
41 
42 double RPCConst::etaFromTowerNum(const int atower) {
43  int iabsitow = (atower >= 0) ? atower : -atower;
44  if (0 == iabsitow)
45  return 0.;
46  if (iabsitow > RPCConst::ITOW_MAX) {
47  //edm::LogError("RPCTrigger") << "**RPCConst::etaFromTowerNum** iabsitow>ITOW_MAX for m_tower:"
48  // << atower ;
49  std::string msg = "[RPCConst::etaFromTowerNum] iabsitow>ITOW_MAX for m_tower:";
50  std::ostringstream ostr;
51  ostr << atower;
52  msg += ostr.str();
53  throw RPCException(msg);
54  return 0.;
55  }
56  double eta = (m_etas[iabsitow] + m_etas[iabsitow + 1]) / 2.;
57  return (atower >= 0) ? eta : -eta;
58 }
59 
60 int RPCConst::towerNumFromEta(const double eta) {
61  int m_tower = 0;
62  double abseta = (eta >= 0.) ? eta : -eta;
63  while (m_tower <= ITOW_MAX) {
64  if (m_etas[m_tower] <= abseta && abseta < m_etas[m_tower + 1])
65  break;
66  m_tower++;
67  }
68  if (m_tower > ITOW_MAX)
69  m_tower = ITOW_MAX;
70  return (eta >= 0) ? m_tower : -m_tower;
71 }
72 
73 double RPCConst::phiFromSegmentNum(const int iseg) {
74  double phi = OFFSET + 2. * m_pi * (iseg) / (double)RPCConst::NSEG;
75  return (phi < 2. * m_pi) ? phi : phi - 2. * m_pi;
76 }
77 
78 double RPCConst::phiFromLogSegSec(const int logSegment, const int logSector) {
79  int iseg = logSegment * 12 + logSector;
80  double phi = OFFSET + 2. * m_pi * (iseg) / (double)RPCConst::NSEG;
81  return (phi < 2. * m_pi) ? phi : phi - 2. * m_pi;
82 }
83 
84 int RPCConst::segmentNumFromPhi(const double phi) {
85  double iphi;
86  if (phi - OFFSET < 0) {
87  iphi = 2 * m_pi + phi;
88  } else {
89  iphi = phi - OFFSET;
90  }
91  int iseg = (int)(iphi * RPCConst::NSEG / (2. * m_pi));
92  return iseg;
93 }
94 
95 /*
96 int RPCConst::checkBarrel(const int atower) {
97  int iabsitow = (atower >= 0)? atower: -atower;
98  if(iabsitow <= RPCConst::ITOW_MAX_LOWPT) {
99  return 1;
100  } else if (iabsitow <= RPCConst::ITOW_MAX) {
101  return 0;
102  }
103  return -1;
104 } */
105 
106 double RPCConst::vxMuRate(int ptCode) {
107  double pt_ev = RPCConst::ptFromIpt(ptCode);
108  if (pt_ev == 0)
109  return 0.0;
110  const double lum = 2.0e33; //defoult is 1.0e34;
111  const double dabseta = 1.0;
112  const double dpt = 1.0;
113  const double afactor = 1.0e-34 * lum * dabseta * dpt;
114  const double a = 2 * 1.3084E6;
115  const double mu = -0.725;
116  const double sigma = 0.4333;
117  const double s2 = 2 * sigma * sigma;
118 
119  double ptlog10;
120  ptlog10 = log10(pt_ev);
121  double ex = (ptlog10 - mu) * (ptlog10 - mu) / s2;
122  double rate = (a * exp(-ex) * afactor);
123 
124  //edm::LogError("RPCTrigger")<<ptCode<<" "<<rate;//<<<<<<<<<<<<<<<<<<<<<<<<
125  return rate;
126 }
127 
128 //muon rate for pt from ptCode to ptCode + 1
129 //i.e for ptCode bin
130 double RPCConst::vxIntegMuRate(int ptCode, double etaFrom, double etaTo) {
131  //calkowanie metoda trapezow - nie do konca dobre
132  double rate =
133  0.5 * (vxMuRate(ptCode) + vxMuRate(ptCode + 1)) * (RPCConst::ptFromIpt(ptCode + 1) - RPCConst::ptFromIpt(ptCode));
134 
135  rate = rate * (etaTo - etaFrom);
136 
137  //edm::LogError("RPCTrigger")<<ptCode<<" "<<rate;//<<<<<<<<<<<<<<<<<<<<<<<<
138  return rate;
139 }
140 
141 //muon rate for pt from ptCode to ptCode + 1 in a given m_tower - only one!!! (mutliply by 2 to take oalso negative!!!)
142 //i.e for ptCode bin
143 double RPCConst::vxIntegMuRate(int ptCode, int m_tower) {
144  //calkowanie metoda trapezow - nie do konca dobre
145  double rate = vxIntegMuRate(ptCode, RPCConst::m_etas[abs(m_tower)], RPCConst::m_etas[abs(m_tower) + 1]);
146 
147  //edm::LogError("RPCTrigger")<<ptCode<<" "<<rate;//<<<<<<<<<<<<<<<<<<<<<<<<
148  return rate;
149 }
150 
151 /*
152 const int RPCConst::IPT_THRESHOLD [2][RPCConst::ITOW_MAX+1]={
153 //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 m_Tower
154 {17, 17, 17, 17, 17, 16, 16, 15, 17, 14, 12, 11, 12, 17, 16, 15, 15}, //LOW
155 {12, 12, 12, 12, 12, 11, 8, 11, 12, 9, 9, 8, 7, 11, 11, 11, 11} //VLOW
156 };
157 */
158 
159 const double RPCConst::m_pts[RPCConst::IPT_MAX + 1] = {
160  0.0, 0.01, //<<<<<<<<<<<<<<<<<dla ptCode = 1 bylo 0, ale to powoduje problemy w vxMuRate
161  1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5., 6., 7., 8., 10., 12., 14., 16.,
162  18., 20., 25., 30., 35., 40., 45., 50., 60., 70., 80., 90., 100., 120., 140.};
163 
164 // m_etas contain approximate lower egges of eta towers
165 // 0:ITOW_MAX +additionaly upper edge of last m_tower
166 const double RPCConst::m_etas[RPCConst::ITOW_MAX + 2] = {
167  0.00, 0.07, 0.27, 0.44, 0.58, 0.72, 0.83, 0.93, 1.04, 1.14, 1.24, 1.36, 1.48, 1.61, 1.73, 1.85, 1.97, 2.10};
168 
169 // imported constants
170 
172  "m_LOGPLANE1", "m_LOGPLANE2", "m_LOGPLANE3", "m_LOGPLANE4", "m_LOGPLANE5", "m_LOGPLANE6"};
173 
174 const unsigned int RPCConst::m_LOGPLANE_SIZE[m_TOWER_COUNT][m_LOGPLANES_COUNT] = {
175  //LOGPLANE 1, 2, 3 4 5 6
176  {72, 56, 8, 40, 40, 24}, //TOWER 0
177  {72, 56, 8, 40, 40, 24}, //TOWER 1
178  {72, 56, 8, 40, 40, 24}, //TOWER 2
179  {72, 56, 8, 40, 40, 24}, //TOWER 3
180  {72, 56, 8, 40, 40, 24}, //TOWER 4
181  {72, 56, 40, 8, 40, 24}, //TOWER 5
182  {56, 72, 40, 8, 24, 0}, //TOWER 6
183  {72, 56, 40, 8, 24, 0}, //TOWER 7
184  {72, 24, 40, 8, 0, 0}, //TOWER 8
185  {72, 8, 40, 0, 0, 0}, //TOWER 9
186  {72, 8, 40, 24, 0, 0}, //TOWER 10
187  {72, 8, 40, 24, 0, 0}, //TOWER 11
188  {72, 8, 40, 24, 0, 0}, //TOWER 12
189  {72, 8, 40, 24, 0, 0}, //TOWER 13
190  {72, 8, 40, 24, 0, 0}, //TOWER 14
191  {72, 8, 40, 24, 0, 0}, //TOWER 15
192  {72, 8, 40, 24, 0, 0} //TOWER 16
193 };
194 
195 const int RPCConst::m_VLPT_PLANES_COUNT[m_TOWER_COUNT] = {4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3};
196 
197 const int RPCConst::m_USED_PLANES_COUNT[m_TOWER_COUNT] = {
198  //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
199  6,
200  6,
201  6,
202  6,
203  6,
204  6,
205  5,
206  5,
207  4,
208  3,
209  4,
210  4,
211  4,
212  4,
213  4,
214  4,
215  4};
216 
217 const int RPCConst::m_REF_PLANE[m_TOWER_COUNT] = {
218  // 0, 1, 2, 3, 4,
219  m_LOGPLANE3,
220  m_LOGPLANE3,
221  m_LOGPLANE3,
222  m_LOGPLANE3,
223  m_LOGPLANE3,
224  // 5, 6, 7, 8,
225  m_LOGPLANE4,
226  m_LOGPLANE4,
227  m_LOGPLANE4,
228  m_LOGPLANE4,
229  // 9, 10, 11, 12, 13, 14, 15, 16,
230  m_LOGPLANE2,
231  m_LOGPLANE2,
232  m_LOGPLANE2,
233  m_LOGPLANE2,
234  m_LOGPLANE2,
235  m_LOGPLANE2,
236  m_LOGPLANE2,
237  m_LOGPLANE2};
238 
239 /*
240  const int m_PT_CODE_MAX = 31; //!< Pt_code range = 0-m_PT_CODE_MAX
241 
242  const int m_LOGPLANE1 = 0; //!< The Logic Planes are named starting from '1', but in varoius loop indeks are from '0', that's why always use these consts
243  const int m_LOGPLANE2 = 1;
244  const int m_LOGPLANE3 = 2;
245  const int m_LOGPLANE4 = 3;
246  const int m_LOGPLANE5 = 4;
247  const int m_LOGPLANE6 = 5;
248 
249  const int m_FIRST_PLANE = m_LOGPLANE1; //!< Use ase a first index in loops.
250  const int m_LAST_PLANE = m_LOGPLANE6; //!< Use ase a last index in loops.
251 */
252 
253 //------- imported fucntions
254 
256  for (unsigned int i = 0; i < str.size(); i++)
257  if (str[i] < '0' || str[i] > '9')
258  throw RPCException("Error in stringToInt(): the string cannot be converted to a number");
259  //edm::LogError("RPCTrigger")<< "Error in stringToInt(): the string cannot be converted to a number";
260  return atoi(str.c_str());
261 }
262 
263 //inline
266  /* Some problems. AK
267  std::ostringstream ostr;
268  ostr<<number;
269  str = ostr.str();
270  edm::LogError("RPCTrigger")<<"std::string intToString(int number)";
271  edm::LogError("RPCTrigger")<<str;
272  */
273  char tmp[20];
274  sprintf(tmp, "%d", number);
275  str.append(tmp);
276  return str;
277 }
278 
280  if (m_Tower != cone.m_Tower)
281  return (m_Tower < cone.m_Tower);
282  if (m_LogSector != cone.m_LogSector)
283  return (m_LogSector < cone.m_LogSector);
284  if (m_LogSegment != cone.m_LogSegment)
285  return (m_LogSegment < cone.m_LogSegment);
286 
287  return false;
288 }
289 
291  if (m_Tower != cone.m_Tower)
292  return false;
293  if (m_LogSector != cone.m_LogSector)
294  return false;
295  if (m_LogSegment != cone.m_LogSegment)
296  return false;
297 
298  return true;
299 }
RPCConst::etaFromTowerNum
static double etaFromTowerNum(const int atower)
Definition: RPCConst.cc:42
RPCConst::intToString
std::string intToString(int number)
Converts inteager number to string.
Definition: RPCConst.cc:264
mps_fire.i
i
Definition: mps_fire.py:428
RPCConst::stringToInt
int stringToInt(std::string str)
Converts string to inteager number. If string contains chars, that are not digits,...
Definition: RPCConst.cc:255
RPCException.h
RPCConst::l1RpcConeCrdnts::m_Tower
int m_Tower
Definition: RPCConst.h:119
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
m_pi
#define m_pi
Definition: RPCConst.cc:8
mps_check.msg
tuple msg
Definition: mps_check.py:285
indexGen.s2
s2
Definition: indexGen.py:107
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
RPCpg::rate
double rate(double x)
Definition: Constants.cc:3
RPCConst.h
RPCConst::vxMuRate
static double vxMuRate(int ptCode)
Definition: RPCConst.cc:106
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
RPCConst::l1RpcConeCrdnts
The coordinates of Logic Cone: m_Tower, m_LogSector, m_LogSegment.
Definition: RPCConst.h:118
RPCConst::iptFromPt
static int iptFromPt(const double pt)
Definition: RPCConst.cc:10
RPCConst::vxIntegMuRate
static double vxIntegMuRate(int ptCode, double etaFrom, double etaTo)
Definition: RPCConst.cc:130
RPCConst::m_LOGPLANE_STR
static const std::string m_LOGPLANE_STR[]
Log Planes names.
Definition: RPCConst.h:78
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
RPCConst::OFFSET
Offset of the first trigger phi sector [deg].
Definition: RPCConst.h:33
PVValHelper::eta
Definition: PVValidationHelpers.h:70
RPCConst::m_pts
static const double m_pts[RPCConst::IPT_MAX+1]
Definition: RPCConst.h:236
str
#define str(s)
Definition: TestProcessor.cc:52
RPCConst::phiFromLogSegSec
static double phiFromLogSegSec(const int logSegment, const int logSector)
Definition: RPCConst.cc:78
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
a
double a
Definition: hdecay.h:119
PVValHelper::phi
Definition: PVValidationHelpers.h:69
RPCConst::l1RpcConeCrdnts::m_LogSegment
int m_LogSegment
Definition: RPCConst.h:121
RPCConst::l1RpcConeCrdnts::operator==
bool operator==(const l1RpcConeCrdnts &cone) const
Definition: RPCConst.cc:290
RPCConst::ITOW_MAX
Maximal number of abs(m_tower_number)
Definition: RPCConst.h:27
RPCException
Definition: RPCException.h:21
RPCConst::m_VLPT_PLANES_COUNT
static const int m_VLPT_PLANES_COUNT[m_TOWER_COUNT]
m_Number of Logic Planes used for Very Low Pt patterns.
Definition: RPCConst.h:90
createfilelist.int
int
Definition: createfilelist.py:10
RPCConst::m_REF_PLANE
static const int m_REF_PLANE[m_TOWER_COUNT]
Definition of Referenece Plane for each m_Tower.
Definition: RPCConst.h:84
RPCConst::m_USED_PLANES_COUNT
static const int m_USED_PLANES_COUNT[m_TOWER_COUNT]
m_Number of Logic Planes existing in each m_Tower.
Definition: RPCConst.h:87
DDAxes::phi
RPCConst::NSEG
Definition: RPCConst.h:31
RPCConst::l1RpcConeCrdnts::operator<
bool operator<(const l1RpcConeCrdnts &cone) const
Definition: RPCConst.cc:279
RPCConst::segmentNumFromPhi
static int segmentNumFromPhi(const double phi)
Definition: RPCConst.cc:84
RPCConst::IPT_MAX
Max pt bin code.
Definition: RPCConst.h:29
RPCConst::m_LOGPLANE_SIZE
static const unsigned int m_LOGPLANE_SIZE[m_TOWER_COUNT][m_LOGPLANES_COUNT]
Definition of Logic Cone Sizes - number of Logic m_Strips in each plane.
Definition: RPCConst.h:81
RPCConst::m_LOGPLANES_COUNT
static const int m_LOGPLANES_COUNT
Max Logic Planes Count in trigger towers.
Definition: RPCConst.h:45
RPCConst::m_etas
static const double m_etas[RPCConst::ITOW_MAX+2]
Definition: RPCConst.h:240
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
RPCConst::l1RpcConeCrdnts::m_LogSector
int m_LogSector
Definition: RPCConst.h:120
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
RPCConst::phiFromSegmentNum
static double phiFromSegmentNum(const int iseg)
Definition: RPCConst.cc:73
RPCConst::ptFromIpt
static double ptFromIpt(const int ipt)
Definition: RPCConst.cc:29
RPCConst::towerNumFromEta
static int towerNumFromEta(const double eta)
Definition: RPCConst.cc:60