| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Calibration.cc

Go to the documentation of this file.
00001 #include "Conventions/Calibration.h"
00002 
00003 #include <cctype>
00004 #include <string>
00005 #include <cmath>
00006 #include <sstream>
00007 using namespace std;
00008 using namespace DayaBay::Calibration;
00009 
00010 
00011 static const char* sourceNames[] = {
00012     "Unknown",
00013     "LED",
00014     "Germanium_68",
00015     "Americium_Carbon_Cobalt_60",
00016     0
00017 };
00018 static int kSourceNames = 4;
00019 
00020 static const char* locationNames[] = {
00021     "Unknown",
00022     "ACU_A_Center",
00023     "ACU_B_GdlsEdge",
00024     "ACU_C_GammaCatcher",
00025     "AD_WallUpper",
00026     "AD_WallCenter",
00027     "AD_WallLower",
00028     0
00029 };
00030 static int kLocationNames = 7;
00031 
00032 const char* SourceType::AsString(SourceType_t id)
00033 {
00034 
00035     if (id < 0 || id > kSourceNames) return sourceNames[0];
00036     return sourceNames[id];
00037 }
00038 
00039 SourceType::SourceType_t SourceType::FromString(const char* str)
00040 {
00041     string s = str;
00042 
00043     for (int ind=1; sourceNames[ind]; ++ind) {
00044       if (s == sourceNames[ind]) return (SourceType::SourceType_t)(ind);
00045     }
00046     return kUnknown;
00047 }
00048 
00049 const char* Location::AsString(Location_t id)
00050 {
00051 
00052     if (id < 0 || id > kLocationNames) return locationNames[0];
00053     return locationNames[id];
00054 }
00055 
00056 Location::Location_t Location::FromString(const char* str)
00057 {
00058     string s = str;
00059 
00060     for (int ind=1; locationNames[ind]; ++ind) {
00061       if (s == locationNames[ind]) return (Location::Location_t)(ind);
00062     }
00063     return kUnknown;
00064 }
00065 
00066 
00067 DayaBay::CalibSourceId::CalibSourceId(SourceType::SourceType_t type,
00068                                       Location::Location_t location,
00069                                       Site::Site_t site,
00070                                       DetectorId::DetectorId_t det)
00071   : Detector(site,det)
00072 {
00073   m_data += (0x000000ff & type) | (0x000000ff & location)<<8;
00074 }
00075 
00076 DayaBay::CalibSourceId::CalibSourceId(const std::string& name)
00077 {
00078   short int siteDetId = DayaBay::Detector::siteDetPackedFromString(name); 
00079   Location::Location_t location = Location::kUnknown;
00080   SourceType::SourceType_t type = SourceType::kUnknown;
00081   
00082   // Find location
00083   for(int id=0; id<kLocationNames; id++){
00084     if( name.find(locationNames[id]) != std::string::npos ) 
00085       location=Location::FromString(locationNames[id]);
00086   }
00087   // Find Source Type
00088   for(int id=0; id<kSourceNames; id++){
00089     if( name.find(sourceNames[id]) != std::string::npos ) 
00090       type=SourceType::FromString(sourceNames[id]);
00091   }
00092   m_data = (siteDetId << 16) | (0x000000ff & location)<<8 | (0x000000ff & type);
00093 }
00094 
00095 DayaBay::CalibSourceId::~CalibSourceId() {}
00096 
00097 
00098 SourceType::SourceType_t DayaBay::CalibSourceId::type() const
00099 {
00100   return SourceType::SourceType_t(m_data & 0x000000ff);
00101 }
00102 
00103 Location::Location_t DayaBay::CalibSourceId::location() const
00104 {
00105   return Location::Location_t((m_data & 0x0000ff00)>>8);
00106 }
00107 
00108 bool DayaBay::CalibSourceId::isWallMounted() const
00109 {
00110   return (location() == Location::kAdWallUpper
00111           || location() == Location::kAdWallCenter
00112           || location() == Location::kAdWallLower);
00113 }
00114 
00115 string DayaBay::CalibSourceId::name() const
00116 {
00117   ostringstream name;
00118   name << this->detName()
00119        << "_" << Location::AsString(this->location())
00120        << "_" << SourceType::AsString(this->type());
00121   return name.str();
00122 }
00123 
00124 double DayaBay::CalibSourceId::nominalX() const
00125 {
00126   // Nominal calibration source X position
00127   switch (this->location()) {
00128   case Location::kAcuA_Center:
00129     return AD_AxisA_r * cos( AD_AxisA_phi );
00130   case Location::kAcuB_GdlsEdge:
00131     return AD_AxisB_r * cos( AD_AxisB_phi );
00132   case Location::kAcuC_GammaCatcher:
00133     return AD_AxisC_r * cos( AD_AxisC_phi );
00134   case Location::kAdWallUpper:
00135   case Location::kAdWallCenter:
00136   case Location::kAdWallLower:
00137     return AD_Wall_r * cos( AD_Wall_phi );
00138   default:
00139     return 0.0;
00140   }
00141 }
00142 
00143 double DayaBay::CalibSourceId::nominalY() const
00144 {
00145   // Nominal calibration source Y position
00146   switch (this->location()) {
00147   case Location::kAcuA_Center:
00148     return AD_AxisA_r * sin( AD_AxisA_phi );
00149   case Location::kAcuB_GdlsEdge:
00150     return AD_AxisB_r * sin( AD_AxisB_phi );
00151   case Location::kAcuC_GammaCatcher:
00152     return AD_AxisC_r * sin( AD_AxisC_phi );
00153   case Location::kAdWallUpper:
00154   case Location::kAdWallCenter:
00155   case Location::kAdWallLower:
00156     return AD_Wall_r * sin( AD_Wall_phi );
00157   default:
00158     return 0.0;
00159   }
00160 }
00161 
00162 double DayaBay::CalibSourceId::nominalZ() const
00163 {
00164   // Nominal calibration source Z position
00165   switch (this->location()) {
00166   case Location::kAdWallUpper:
00167     return AD_WallUpper_z;
00168   case Location::kAdWallCenter:
00169     return AD_WallCenter_z;
00170   case Location::kAdWallLower:
00171     return AD_WallLower_z;
00172   default:
00173     return 0.0;
00174   }
00175 }
00176 
00177 std::ostream& DayaBay::operator<<(std::ostream& str, 
00178                                   const DayaBay::CalibSourceId& sourceId)
00179 {
00180   return str << sourceId.name();
00181 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:14:47 2011 for Conventions by doxygen 1.4.7