CMS 3D CMS Logo

RPCConst.cc

Go to the documentation of this file.
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     //edm::LogError("RPCTrigger")<<"** RPCConst ** iptFromPt called with illegal pt="<<pt;
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     //edm::LogError("RPCTrigger") <<"**RPCConst::ptFromIpt** problem with ipt: "<<ipt;
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     //edm::LogError("RPCTrigger") << "**RPCConst::etaFromTowerNum** iabsitow>ITOW_MAX for m_tower:"
00048     //     << atower ;
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 int RPCConst::checkBarrel(const int atower) {
00098   int iabsitow = (atower >= 0)? atower: -atower;
00099   if(iabsitow <= RPCConst::ITOW_MAX_LOWPT) {
00100     return 1;
00101   } else if (iabsitow <= RPCConst::ITOW_MAX) {
00102     return 0;
00103   }
00104   return -1;
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; //defoult is 1.0e34;
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   //edm::LogError("RPCTrigger")<<ptCode<<" "<<rate;//<<<<<<<<<<<<<<<<<<<<<<<<
00126   return rate;
00127 }
00128 
00129 //muon rate for pt from ptCode to ptCode + 1
00130 //i.e for ptCode bin
00131 double RPCConst::vxIntegMuRate(int ptCode, double etaFrom, double etaTo) {  
00132   //calkowanie metoda trapezow - nie do konca dobre
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   //edm::LogError("RPCTrigger")<<ptCode<<" "<<rate;//<<<<<<<<<<<<<<<<<<<<<<<<
00139   return rate;
00140 }
00141 
00142 //muon rate for pt from ptCode to ptCode + 1 in a given m_tower - only one!!! (mutliply by 2 to take oalso negative!!!)
00143 //i.e for ptCode bin
00144 double RPCConst::vxIntegMuRate(int ptCode, int m_tower) {  
00145   //calkowanie metoda trapezow - nie do konca dobre
00146   double rate = vxIntegMuRate(ptCode, RPCConst::m_etas[abs(m_tower)], RPCConst::m_etas[abs(m_tower)+1]);
00147 
00148   //edm::LogError("RPCTrigger")<<ptCode<<" "<<rate;//<<<<<<<<<<<<<<<<<<<<<<<<
00149   return rate;
00150 }
00151 
00152 
00153 /*
00154 const int RPCConst::IPT_THRESHOLD [2][RPCConst::ITOW_MAX+1]={
00155 //0   1   2   3   4     5   6   7   8   9    10  11  12  13  14  15  16  m_Tower
00156 {17, 17, 17, 17, 17,   16, 16, 15, 17, 14,   12, 11, 12, 17, 16, 15, 15}, //LOW
00157 {12, 12, 12, 12, 12,   11, 8,  11, 12, 9,    9,  8,  7,  11, 11, 11, 11} //VLOW
00158 };
00159 */
00160 
00161 
00162 
00163 const double RPCConst::m_pts[RPCConst::IPT_MAX+1]={
00164                         0.0,  0.01,    //<<<<<<<<<<<<<<<<<dla ptCode = 1 bylo 0, ale to powoduje problemy w vxMuRate
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 // m_etas contain approximate lower egges of eta towers
00172 // 0:ITOW_MAX  +additionaly upper edge  of last m_tower
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 // imported constants
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     //LOGPLANE  1,  2,  3   4   5   6
00186               {72, 56,  8, 40, 40, 24}, //TOWER 0
00187               {72, 56,  8, 40, 40, 24}, //TOWER 1
00188               {72, 56,  8, 40, 40, 24}, //TOWER 2
00189               {72, 56,  8, 40, 40, 24}, //TOWER 3
00190               {72, 56,  8, 40, 40, 24}, //TOWER 4
00191               {72, 56, 40,  8, 40, 24}, //TOWER 5
00192               {56, 72, 40,  8, 24,  0}, //TOWER 6
00193               {72, 56, 40,  8, 24,  0}, //TOWER 7
00194               {72, 24, 40,  8,  0,  0}, //TOWER 8
00195               {72,  8, 40,  0,  0,  0}, //TOWER 9
00196               {72,  8, 40, 24,  0,  0}, //TOWER 10
00197               {72,  8, 40, 24,  0,  0}, //TOWER 11
00198               {72,  8, 40, 24,  0,  0}, //TOWER 12
00199               {72,  8, 40, 24,  0,  0}, //TOWER 13
00200               {72,  8, 40, 24,  0,  0}, //TOWER 14
00201               {72,  8, 40, 24,  0,  0}, //TOWER 15
00202               {72,  8, 40, 24,  0,  0}  //TOWER 16
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     //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
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     //     0,         1,         2,         3,         4,
00218       m_LOGPLANE3, m_LOGPLANE3, m_LOGPLANE3, m_LOGPLANE3, m_LOGPLANE3,
00219     //     5,         6,         7,         8,
00220       m_LOGPLANE4,  m_LOGPLANE4, m_LOGPLANE4, m_LOGPLANE4,
00221     //     9,         10,       11,        12,        13,        14,         15,        16,
00222       m_LOGPLANE2, m_LOGPLANE2, m_LOGPLANE2, m_LOGPLANE2, m_LOGPLANE2,  m_LOGPLANE2, m_LOGPLANE2, m_LOGPLANE2
00223     };
00224     
00225     
00226 /*    
00227     const int m_PT_CODE_MAX = 31; //!< Pt_code range = 0-m_PT_CODE_MAX
00228     
00229     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 
00230     const int m_LOGPLANE2 = 1;
00231     const int m_LOGPLANE3 = 2;
00232     const int m_LOGPLANE4 = 3;
00233     const int m_LOGPLANE5 = 4;
00234     const int m_LOGPLANE6 = 5;
00235     
00236     const int m_FIRST_PLANE = m_LOGPLANE1; //!< Use ase a first index in loops.
00237     const int m_LAST_PLANE  = m_LOGPLANE6; //!< Use ase a last index in loops.
00238 */
00239     
00240 //------- imported fucntions
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       //edm::LogError("RPCTrigger")<< "Error in stringToInt(): the string cannot be converted to a number";
00247   return atoi(str.c_str());
00248 }
00249 
00250 //inline
00251 std::string RPCConst::intToString(int number) {
00252   std::string str;
00253   /* Some problems. AK
00254   std::ostringstream ostr;
00255   ostr<<number;
00256   str = ostr.str();
00257   edm::LogError("RPCTrigger")<<"std::string intToString(int number)";
00258   edm::LogError("RPCTrigger")<<str;
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 

Generated on Tue Jun 9 17:40:21 2009 for CMSSW by  doxygen 1.5.4