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