/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Detectors.cc
Go to the documentation of this file.
00001 /* From Dan, for RPCs:
00002 
00003 Here's the numbers you probably need:
00004         Near Sites:  54 panels
00005         Far Site:       81 panels
00006         Each panel has 4 layers.
00007         Each layer has 8 channels.
00008         Each channel gives 1 bit.
00009 
00010 So according to your model, you'll have:
00011 
00012 Bits:
00013 | 3 | 2 | 7 | 8 | 8 |
00014 Contents:
00015 | channel  |  layer  |  panel  |  detector  |  site  |
00016 
00017 */
00018 
00019 /* From Dan for AD calib pmts:
00020 
00021 192:  top, target-viewing
00022 193:  bottom, target-viewing
00023 194:  top, gamma-catcher-viewing
00024 195:  bottom, gamma-catcher-viewing
00025 196:  top, mineral-oil-viewing
00026 197:  bottom, mineral-oil-viewing
00027 
00028 He counts from zero, so add +1 here
00029 */
00030 
00031 
00032 #include "Conventions/Detectors.h"
00033 
00034 #include <sstream>
00035 
00036 // Detector
00037 
00039 DayaBay::Detector DayaBay::Detector::from_short(short int sitedet)
00040 {
00041     return Detector(sitedet); 
00042 }
00043 
00044 DayaBay::Detector::Detector(Site::Site_t site,
00045                             DetectorId::DetectorId_t det)
00046  : m_data(0)
00047 {
00048     this->set(site,det);
00049 }
00050 DayaBay::Detector::Detector() : m_data(0) {}
00051 
00052 DayaBay::Detector::~Detector() {}
00053 
00054 DayaBay::Detector::Detector(int fullPackedData) 
00055 { 
00056     m_data = fullPackedData;
00057 }
00058 
00060 DayaBay::Detector::Detector(short int sitedet)
00061 {
00062     m_data = sitedet<<16;
00063 }
00064 
00065 void DayaBay::Detector::set(Site::Site_t site, DetectorId::DetectorId_t det)
00066 {
00067     m_data = (site << 24) | (det << 16);
00068 }
00069 
00070 
00071 std::string DayaBay::Detector::asString() const
00072 {
00073     std::stringstream ss;
00074     ss << *this;
00075     return ss.str();
00076 }
00077 
00078 std::string DayaBay::Detector::detName() const
00079 {
00080     std::string ret = Site::AsString(site());
00081     ret += DetectorId::AsString(detectorId());
00082 
00083     return ret;
00084 }
00085 
00086 DetectorId::DetectorId_t DayaBay::Detector::detectorId() const
00087 {
00088     return (DetectorId::DetectorId_t)((m_data&0x00ff0000)>>16);
00089 }
00090 
00091 Site::Site_t DayaBay::Detector::site() const
00092 {
00093     return (Site::Site_t)((m_data&0xff000000)>>24);
00094 }
00095 
00096 int DayaBay::Detector::fullPackedData() const
00097 {
00098     return m_data;
00099 }
00100 
00101 short int DayaBay::Detector::siteDetPackedData() const
00102 {
00103     return (short int)(m_data>>16);
00104 }
00105 
00106 bool DayaBay::Detector::bogus() const
00107 {
00108     Site::Site_t site = this->site();
00109     DetectorId::DetectorId_t det = this->detectorId();
00110 
00111     if ( (Site::kAll & site) && (det > DetectorId::kUnknown && det <= DetectorId::kAll) ) return false;
00112     return true;
00113 }
00114 
00115 short int DayaBay::Detector::siteDetPackedFromString(const std::string str){
00116   DetectorId::DetectorId_t detId = DetectorId::FromString("Unknown");
00117   Site::Site_t site = Site::FromString("Unknown");
00118 
00119   //find site
00120 
00121   if (str.find("DayaBay")!=std::string::npos) site=Site::FromString("DayaBay");
00122   if (str.find("LingAo")!=std::string::npos) site=Site::FromString("LingAo");
00123   if (str.find("Mid")!=std::string::npos) site=Site::FromString("Mid");
00124   if (str.find("Far")!=std::string::npos) site=Site::FromString("Far");
00125   if (str.find("Aberdeen")!=std::string::npos) site=Site::FromString("Aberdeen");
00126   if (str.find("SAB")!=std::string::npos) site=Site::FromString("SAB");
00127 
00128   //find detector
00129 
00130   if (str.find("AD1")!=std::string::npos) detId=DetectorId::FromString("AD1");
00131   if (str.find("AD2")!=std::string::npos) detId=DetectorId::FromString("AD2");
00132   if (str.find("AD3")!=std::string::npos) detId=DetectorId::FromString("AD3");
00133   if (str.find("AD4")!=std::string::npos) detId=DetectorId::FromString("AD4");
00134   if (str.find("IWS")!=std::string::npos) detId=DetectorId::FromString("IWS");
00135   if (str.find("OWS")!=std::string::npos) detId=DetectorId::FromString("OWS");
00136   if (str.find("RPC")!=std::string::npos) detId=DetectorId::FromString("RPC");
00137 
00138   return DayaBay::Detector(site,detId).siteDetPackedData();
00139 }
00140 
00141 
00142 std::ostream& DayaBay::operator<<(std::ostream& str, const DayaBay::Detector& det)
00143 {
00144     str
00145         << "[" << (void*)det.fullPackedData() << "] "
00146         << Site::AsString(det.site())
00147         << "-"
00148         << DetectorId::AsString(det.detectorId());
00149     if (det.bogus()) str << " IS BOGUS";
00150     return str;
00151 }
00152 
00153 bool DayaBay::operator<(const DayaBay::Detector& a, const DayaBay::Detector& b)
00154 {
00155     return a.fullPackedData() < b.fullPackedData();
00156 }
00157 
00158 // DetectorSensor
00159 
00160 DayaBay::DetectorSensor::DetectorSensor(unsigned int sensor_id,
00161                                         Site::Site_t site,
00162                                         DetectorId::DetectorId_t detid)
00163     : Detector(site,detid)
00164 {
00165     m_data += 0x0000ffff&sensor_id;
00166 }
00167 DayaBay::DetectorSensor::~DetectorSensor() {}
00168 
00169 int DayaBay::DetectorSensor::sensorId() const
00170 {
00171     return m_data&0x0000ffff;
00172 }
00173 std::ostream& DayaBay::operator<<(std::ostream& str, const DayaBay::DetectorSensor& detsens)
00174 {
00175     str 
00176         << "[" << (void*)detsens.fullPackedData() << "] "
00177         << Site::AsString(detsens.site())
00178         << DetectorId::AsString(detsens.detectorId())
00179         << " 0x"<< std::hex << detsens.sensorId() << std::dec;
00180 
00181     if (detsens.bogus()) str << " IS BOGUS";
00182     return str;
00183 }
00184 
00185 bool DayaBay::DetectorSensor::bogus() const
00186 {
00187     if (this->Detector::bogus() || 0 == this->sensorId()) return true;
00188     Site::Site_t site = this->site();
00189     return site == Site::kMid || site == Site::kAberdeen; // these sites don't have DB detectors
00190 }
00191 
00192 // AdPmtSensor
00193 
00194 DayaBay::AdPmtSensor::AdPmtSensor(int ring, int column, Site::Site_t site,
00195                                   DetectorId::DetectorId_t detid)
00196     : DetectorSensor(ring<<8|column,site,detid)
00197 {
00198 
00199 }
00200 DayaBay::AdPmtSensor::AdPmtSensor(int ring, int column, Site::Site_t site,
00201                                   int ad_number)
00202     : DetectorSensor(ring<<8|column,site,
00203                      (DetectorId::DetectorId_t)(DetectorId::kAD1 + ad_number -1))
00204 {
00205 }
00206 DayaBay::AdPmtSensor::~AdPmtSensor() {}
00207 
00208 
00209 int DayaBay::AdPmtSensor::ring() const
00210 {
00211     return (this->sensorId()&0x0000ff00)>>8;
00212 }
00213 
00214 int DayaBay::AdPmtSensor::column() const
00215 {
00216     return this->sensorId()&0x000000ff;
00217 }
00218 std::ostream& DayaBay::operator<<(std::ostream& str, const DayaBay::AdPmtSensor& adsens)
00219 {
00220     str
00221         << "[" << (void*)adsens.fullPackedData() << "] "
00222         << Site::AsString(adsens.site())
00223         << DetectorId::AsString(adsens.detectorId())
00224         << "("<<adsens.column()<<","<<adsens.ring()<<")";
00225     if (adsens.bogus()) str << " IS BOGUS";
00226     return str;
00227 }
00228 
00229 bool DayaBay::AdPmtSensor::baseBogus() const
00230 {
00231     if (this->Detector::bogus()) return true;
00232     if (! isAD() ) return true;
00233 
00234     Site::Site_t site = this->site();
00235     DetectorId::DetectorId_t det = this->detectorId();
00236 
00237     // Only far site has AD #3 and #4
00238     if ((site != Site::kFar) && (det == DetectorId::kAD3 || det == DetectorId::kAD4)) {
00239         return true;
00240     }
00241     return false;
00242 }
00243 bool DayaBay::AdPmtSensor::bogus() const
00244 {
00245     if (baseBogus()) return true;
00246 
00247     if (is2inch()) return false;
00248     if (is8inch()) return false;
00249     return true;
00250 }
00251 
00252 bool DayaBay::AdPmtSensor::is2inch() const
00253 {
00254     if (baseBogus()) return false;
00255     return ring() == 0 && 1 <= column() && column() <= 6;
00256 }
00257 
00258 bool DayaBay::AdPmtSensor::is8inch() const
00259 {
00260     if (baseBogus()) return false;
00261     return 1 <= ring() && ring() <= 8 && 1 <= column() && column() <= 24;
00262 }
00263 
00264 bool DayaBay::AdPmtSensor::isRefSig() const
00265 {
00266     if (baseBogus()) return false;
00267     return (ring() == 1) && (column() == 0);
00268 }
00269 
00270 
00271 // AdFadcSensor
00272 DayaBay::AdFadcSensor::AdFadcSensor(int /*ring*/, int column, Site::Site_t site,
00273                                    DetectorId::DetectorId_t detid)
00274     : DetectorSensor(column/4,site,detid)                    // 4 columns x 8 pmts
00275     // : DetectorSensor(column/8+3*(ring/4),site,detid)      // 8 columns x 4 pmts
00276 {
00277 }
00278 
00279 DayaBay::AdFadcSensor::AdFadcSensor(int /*ring*/, int column, Site::Site_t site,
00280                                   int ad_number)
00281     : DetectorSensor(column/4,site,
00282                      (DetectorId::DetectorId_t)(DetectorId::kAD1 + ad_number -1))
00283     // : DetectorSensor(column/8+3*(ring/4),site,
00284     //                  (DetectorId::DetectorId_t)(DetectorId::kAD1 + ad_number -1))
00285 {
00286 }
00287 
00288 DayaBay::AdFadcSensor::~AdFadcSensor() {}
00289 
00290 int DayaBay::AdFadcSensor::channel() const {
00291     return this->sensorId()&0x0000000f;
00292 }
00293 
00294 std::ostream& DayaBay::operator<<(std::ostream& str, const DayaBay::AdFadcSensor& adsens)
00295 {
00296     str
00297         << "[" << (void*)adsens.fullPackedData() << "] "
00298         << Site::AsString(adsens.site())
00299         << DetectorId::AsString(adsens.detectorId())
00300         << "("<<adsens.channel()<<")";
00301     if (adsens.bogus()) str << " IS BOGUS";
00302     return str;
00303 }
00304 
00305 bool DayaBay::AdFadcSensor::bogus() const
00306 {
00307     if (this->Detector::bogus()) return true;
00308     if (! isAD() ) return true;
00309 
00310     Site::Site_t site = this->site();
00311     DetectorId::DetectorId_t det = this->detectorId();
00312 
00313     // Only far site has AD #3 and #4
00314     if ((site != Site::kFar) && (det == DetectorId::kAD3 || det == DetectorId::kAD4)) {
00315         return true;
00316     }
00317     return false;
00318 }
00319 
00320 // PoolPmtSensor
00321 
00322 DayaBay::PoolPmtSensor::PoolPmtSensor(int wall_number, int wall_spot, bool inward_facing,
00323                                       Site::Site_t site, DetectorId::DetectorId_t detid)
00324     : DetectorSensor((inward_facing?(1<<12):0)|(wall_number<<8)|wall_spot,site,detid)
00325 {
00326 }
00327 
00328 
00329 DayaBay::PoolPmtSensor::~PoolPmtSensor()
00330 {
00331 }
00332 
00333 int DayaBay::PoolPmtSensor::wallNumber() const
00334 {
00335     return (this->sensorId()&0x00000f00)>>8;
00336 }
00337 int DayaBay::PoolPmtSensor::wallSpot() const
00338 {
00339     return this->sensorId()&0x000000ff;
00340 }
00341 
00342 bool DayaBay::PoolPmtSensor::inwardFacing() const
00343 {
00344     return this->sensorId()&0x0000f000;
00345 }
00346 
00347 
00348 std::ostream& DayaBay::operator<<(std::ostream& str, const DayaBay::PoolPmtSensor& poolsens)
00349 {
00350     str 
00351         << "[" << (void*)poolsens.fullPackedData() << "] "
00352         << Site::AsString(poolsens.site())
00353         << DetectorId::AsString(poolsens.detectorId())
00354         << "("
00355         <<poolsens.wallNumber()<<","
00356         <<poolsens.wallSpot()<<","
00357         <<poolsens.inwardFacing() << ")";
00358     if (poolsens.bogus()) str << " IS BOGUS";
00359     return str;
00360 }
00361 
00362 bool DayaBay::PoolPmtSensor::bogus() const
00363 {
00364     if (this->Detector::bogus()) return true;
00365     if (! isWaterShield() ) return true;
00366 
00367     // fixme: fill in with numerology
00368 
00369     return false;
00370 }
00371 
00372 
00373 // RpcSensor
00374 
00375 DayaBay::RpcSensor::RpcSensor(int panelRow, int panelColumn,
00376                               int layer, int strip,
00377                               Site::Site_t site, DetectorId::DetectorId_t detid)
00378   : DetectorSensor((panelRow<<12)|(panelColumn<<8)|(layer<<4)|strip,site,detid)
00379 {
00380 }
00381 
00382 
00383 DayaBay::RpcSensor::~RpcSensor()
00384 {
00385 }
00386 
00387 DayaBay::RpcSensor DayaBay::RpcSensor::panel() const
00388 {
00389     return RpcSensor(m_data & 0xffffff00);
00390 }
00391 
00392 int DayaBay::RpcSensor::panelRow() const
00393 {
00394     return (this->sensorId()&0x0000f000)>>12;
00395 }
00396 
00397 int DayaBay::RpcSensor::panelColumn() const
00398 {
00399     return (this->sensorId()&0x00000f00)>>8;
00400 }
00401 
00402 int DayaBay::RpcSensor::layer() const
00403 {
00404     return (this->sensorId()&0x000000f0)>>4;
00405 }
00406 
00407 int DayaBay::RpcSensor::strip() const
00408 {
00409     return this->sensorId()&0x0000000f;
00410 }
00411 
00412 std::ostream& DayaBay::operator<<(std::ostream& str,
00413                                   const DayaBay::RpcSensor& rpcsens)
00414 {
00415     str
00416         << "[" << (void*)rpcsens.fullPackedData() << "] "
00417         << Site::AsString(rpcsens.site())
00418         << DetectorId::AsString(rpcsens.detectorId())
00419         << "("
00420         <<rpcsens.panelRow()<<","
00421         <<rpcsens.panelColumn()<<","
00422         <<rpcsens.layer()<<","
00423         <<rpcsens.strip()<< ")";
00424     if (rpcsens.bogus()) str << " IS BOGUS";
00425     return str;
00426 }
00427 
00428 bool DayaBay::RpcSensor::bogus() const
00429 {
00430     if (this->Detector::bogus()) return true;
00431     if (detectorId() != DetectorId::kRPC) {
00432         return true;
00433     }
00434 
00435     Site::Site_t siteid = site();
00436     int row = panelRow();
00437     int col = panelColumn();
00438     // deal with telescopes first
00439     if (row==0 && col==5) // telescope
00440       return false;
00441     if (siteid == Site::kFar) {
00442       if (row==10 && col==5) // far site telescope
00443         return false;
00444     }
00445     else if (row==7 && col==5) // near site telescope
00446       return false;
00447 
00448     if (!(row && col)) // numbering convention forbids row or column to be zero
00449         return true;
00450 
00451     if (siteid == Site::kFar && row > 9) // too many rows
00452         return true;
00453 
00454     if (siteid == Site::kDayaBay && row > 6) // too many rows
00455         return true;
00456 
00457     if (siteid == Site::kLingAo && row > 6) // too many rows
00458         return true;
00459 
00460     if (col > 9) // too many columns
00461         return true;
00462 
00463     // FIXME: add checks for layer and strip
00464 
00465     return false;
00466 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:56:19 for Conventions by doxygen 1.7.4