00001 #include <cmath>
00002 #include <iostream>
00003 #include <sstream>
00004 #include <cstdio>
00005 #include "L1Trigger/RPCTrigger/interface/RPCConst.h"
00006 #include "L1Trigger/RPCTrigger/interface/RPCException.h"
00007
00008 #define m_pi 3.14159265358979
00009
00010 int RPCConst::iptFromPt(const double pt) {
00011 if(pt == 0.)return 0;
00012 if(pt<m_pts[0]) {
00013
00014 std::string msg = "[RPCConst::iptFromPt] called with illegal pt=";
00015 std::ostringstream ostr;
00016 ostr<<pt;
00017 msg += ostr.str();
00018 throw RPCException(msg.c_str());
00019 return 0;
00020 }
00021 int ipt=RPCConst::IPT_MAX;
00022 while (pt < m_pts[ipt]) { ipt--; };
00023 return ipt;
00024
00025 }
00026
00027
00028 double RPCConst::ptFromIpt(const int ipt) {
00029
00030 if ( ipt<0 || ipt>RPCConst::IPT_MAX ) {
00031
00032 std::string msg = "[RPCConst::ptFromIpt] problem with ipt: ";
00033 std::ostringstream ostr;
00034 ostr<<ipt;
00035 msg += ostr.str();
00036 throw RPCException(msg.c_str());
00037 return 0.;
00038 }
00039 else return m_pts[ipt];
00040 }
00041
00042
00043 double RPCConst::etaFromTowerNum(const int atower){
00044
00045 int iabsitow = (atower >= 0)? atower: -atower;
00046 if (0==iabsitow) return 0.;
00047 if( iabsitow>RPCConst::ITOW_MAX) {
00048
00049
00050 std::string msg = "[RPCConst::etaFromTowerNum] iabsitow>ITOW_MAX for m_tower:";
00051 std::ostringstream ostr;
00052 ostr<<atower;
00053 msg += ostr.str();
00054 throw RPCException(msg.c_str());
00055 return 0.;
00056 }
00057 double eta = (m_etas[iabsitow]+m_etas[iabsitow+1])/2.;
00058 return (atower>= 0) ? eta : -eta;
00059 }
00060
00061
00062 int RPCConst::towerNumFromEta(const double eta){
00063 int m_tower=0;
00064 double abseta = (eta >=0.) ? eta:-eta;
00065 while (m_tower<=ITOW_MAX){
00066 if(m_etas[m_tower] <= abseta && abseta< m_etas[m_tower+1])break;
00067 m_tower++;
00068 }
00069 if(m_tower > ITOW_MAX)
00070 m_tower = ITOW_MAX;
00071 return (eta>=0) ? m_tower:-m_tower;
00072 }
00073
00074 double RPCConst::phiFromSegmentNum(const int iseg) {
00075 double phi = OFFSET + 2.*m_pi*(iseg)/ (double) RPCConst::NSEG;
00076 return (phi <2.*m_pi) ? phi: phi-2.*m_pi;
00077 }
00078
00079 double RPCConst::phiFromLogSegSec(const int logSegment, const int logSector) {
00080 int iseg = logSegment*12 + logSector;
00081 double phi = OFFSET + 2.*m_pi*(iseg)/ (double) RPCConst::NSEG;
00082 return (phi <2.*m_pi) ? phi: phi-2.*m_pi;
00083 }
00084
00085 int RPCConst::segmentNumFromPhi(const double phi) {
00086 double iphi;
00087 if(phi-OFFSET < 0) {
00088 iphi = 2*m_pi + phi;
00089 }
00090 else {
00091 iphi = phi-OFFSET;
00092 }
00093 int iseg = (int)(iphi * RPCConst::NSEG/(2.*m_pi));
00094 return iseg;
00095 }
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 double RPCConst::vxMuRate(int ptCode) {
00109 double pt_ev = RPCConst::ptFromIpt(ptCode);
00110 if (pt_ev == 0)
00111 return 0.0;
00112 const double lum = 2.0e33;
00113 const double dabseta = 1.0;
00114 const double dpt = 1.0;
00115 const double afactor = 1.0e-34*lum*dabseta*dpt;
00116 const double a = 2*1.3084E6;
00117 const double mu=-0.725;
00118 const double sigma=0.4333;
00119 const double s2=2*sigma*sigma;
00120
00121 double ptlog10;
00122 ptlog10 = log10(pt_ev);
00123 double ex = (ptlog10-mu)*(ptlog10-mu)/s2;
00124 double rate = (a * exp(-ex) * afactor);
00125
00126
00127 return rate;
00128 }
00129
00130
00131
00132 double RPCConst::vxIntegMuRate(int ptCode, double etaFrom, double etaTo) {
00133
00134 double rate = 0.5 * (vxMuRate(ptCode) + vxMuRate(ptCode+1))*
00135 (RPCConst::ptFromIpt(ptCode + 1) - RPCConst::ptFromIpt(ptCode));
00136
00137 rate = rate * (etaTo - etaFrom);
00138
00139
00140 return rate;
00141 }
00142
00143
00144
00145 double RPCConst::vxIntegMuRate(int ptCode, int m_tower) {
00146
00147 double rate = vxIntegMuRate(ptCode, RPCConst::m_etas[abs(m_tower)], RPCConst::m_etas[abs(m_tower)+1]);
00148
00149
00150 return rate;
00151 }
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 const double RPCConst::m_pts[RPCConst::IPT_MAX+1]={
00165 0.0, 0.01,
00166 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5,
00167 5., 6., 7., 8.,
00168 10., 12., 14., 16., 18.,
00169 20., 25., 30., 35., 40., 45.,
00170 50., 60., 70., 80., 90., 100., 120., 140.};
00171
00172
00173
00174 const double RPCConst::m_etas[RPCConst::ITOW_MAX+2]=
00175 {0.00, 0.07, 0.27, 0.44, 0.58, 0.72,
00176 0.83, 0.93, 1.04, 1.14, 1.24, 1.36,
00177 1.48, 1.61, 1.73, 1.85, 1.97, 2.10};
00178
00179
00180
00181 const std::string RPCConst::m_LOGPLANE_STR[RPCConst::m_LOGPLANES_COUNT] = {
00182 "m_LOGPLANE1", "m_LOGPLANE2", "m_LOGPLANE3", "m_LOGPLANE4", "m_LOGPLANE5", "m_LOGPLANE6"
00183 };
00184
00185 const unsigned int RPCConst::m_LOGPLANE_SIZE[m_TOWER_COUNT][m_LOGPLANES_COUNT] = {
00186
00187 {72, 56, 8, 40, 40, 24},
00188 {72, 56, 8, 40, 40, 24},
00189 {72, 56, 8, 40, 40, 24},
00190 {72, 56, 8, 40, 40, 24},
00191 {72, 56, 8, 40, 40, 24},
00192 {72, 56, 40, 8, 40, 24},
00193 {56, 72, 40, 8, 24, 0},
00194 {72, 56, 40, 8, 24, 0},
00195 {72, 24, 40, 8, 0, 0},
00196 {72, 8, 40, 0, 0, 0},
00197 {72, 8, 40, 24, 0, 0},
00198 {72, 8, 40, 24, 0, 0},
00199 {72, 8, 40, 24, 0, 0},
00200 {72, 8, 40, 24, 0, 0},
00201 {72, 8, 40, 24, 0, 0},
00202 {72, 8, 40, 24, 0, 0},
00203 {72, 8, 40, 24, 0, 0}
00204 };
00205
00206
00207
00208 const int RPCConst::m_VLPT_PLANES_COUNT[m_TOWER_COUNT] = {
00209 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3
00210 };
00211
00212 const int RPCConst::m_USED_PLANES_COUNT[m_TOWER_COUNT] = {
00213
00214 6, 6, 6, 6, 6, 6, 5, 5, 4, 3, 4, 4, 4, 4, 4, 4, 4
00215 };
00216
00217 const int RPCConst::m_REF_PLANE[m_TOWER_COUNT] = {
00218
00219 m_LOGPLANE3, m_LOGPLANE3, m_LOGPLANE3, m_LOGPLANE3, m_LOGPLANE3,
00220
00221 m_LOGPLANE4, m_LOGPLANE4, m_LOGPLANE4, m_LOGPLANE4,
00222
00223 m_LOGPLANE2, m_LOGPLANE2, m_LOGPLANE2, m_LOGPLANE2, m_LOGPLANE2, m_LOGPLANE2, m_LOGPLANE2, m_LOGPLANE2
00224 };
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243 int RPCConst::stringToInt(std::string str) {
00244 for(unsigned int i = 0; i < str.size(); i++)
00245 if(str[i] < '0' || str[i] > '9')
00246 throw RPCException("Error in stringToInt(): the string cannot be converted to a number");
00247
00248 return atoi(str.c_str());
00249 }
00250
00251
00252 std::string RPCConst::intToString(int number) {
00253 std::string str;
00254
00255
00256
00257
00258
00259
00260
00261 char tmp[20];
00262 sprintf(tmp,"%d",number);
00263 str.append(tmp);
00264 return str;
00265 }
00266
00267 bool RPCConst::l1RpcConeCrdnts::operator <(const l1RpcConeCrdnts& cone) const{
00268 if(m_Tower != cone.m_Tower)
00269 return (m_Tower < cone.m_Tower);
00270 if(m_LogSector != cone.m_LogSector)
00271 return (m_LogSector < cone.m_LogSector);
00272 if(m_LogSegment != cone.m_LogSegment)
00273 return (m_LogSegment < cone.m_LogSegment);
00274
00275 return false;
00276 }
00277
00278 bool RPCConst::l1RpcConeCrdnts::operator ==(const l1RpcConeCrdnts& cone) const{
00279 if(m_Tower != cone.m_Tower)
00280 return false;
00281 if(m_LogSector != cone.m_LogSector)
00282 return false;
00283 if(m_LogSegment != cone.m_LogSegment)
00284 return false;
00285
00286 return true;
00287 }
00288
00289
00290