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