1 #include <sdet/Station.h>
2 #include <sdet/SDetector.h>
3 #include <mdet/MDetector.h>
4 #include <utl/GeometryUtilities.h>
5 #include <utl/UTMPoint.h>
7 #include <utl/UTCDateTime.h>
10 #include <boost/lexical_cast.hpp>
11 #include <boost/dynamic_bitset.hpp>
25 Station::InternalPartnerStationFunctor::operator()(
const int stationId)
28 return Detector::GetInstance().GetSDetector().GetStation(stationId);
32 Station::Station(
const int id) :
61 return Detector::GetInstance().GetMDetector().ExistsAssociatedCounter(
GetId());
69 return Detector::GetInstance().GetMDetector().GetAssociatedCounterId(
GetId());
81 err <<
"Invalid request for PMT with Id: " << id;
100 std::ostringstream err;
101 err <<
"The station appears to contain more than one small PMT"
102 "which is neither expected nor allowed.";
110 std::ostringstream err;
111 err <<
"Small PMT does not exist.";
123 std::ostringstream err;
124 err <<
"The station appears to contain more than one scintillator PMT"
125 "which is neither expected nor allowed.";
133 std::ostringstream err;
134 err <<
"Scintillator PMT does not exist.";
170 double frequency = 0;
171 GetStationData(frequency,
"frequency",
"electronics",
"fadc electronics frequency");
342 GetStationData(is,
"station_in_acquisition",
"is_in_acquisition",
"station in acquisition flag");
367 GetStationData(timeString,
"commission",
"stationList",
"commission time");
368 const auto start = boost::lexical_cast<
UTCDateTime>(timeString).GetTimeStamp();
369 GetStationData(timeString,
"decommission",
"stationList",
"commission time");
370 const auto stop = boost::lexical_cast<UTCDateTime>(timeString).GetTimeStamp();
383 GetStationData(timeString,
"commissionUUB",
"stationList",
"uub commissioning time");
404 GetStationData(ellipsoid,
"ellipsoid",
"stationList",
"ellipsoid for UTM conversion");
405 fEllipsoid = ReferenceEllipsoid::GetEllipsoidIDFromString(ellipsoid);
407 GetStationData(band,
"band",
"stationList",
"band for UTM conversion");
409 GetStationData(zone,
"zone",
"stationList",
"zone for UTM conversion");
451 for (
size_t i = 0, nd = data.size(), ni = inGrid.size(); i < nd && i < ni; ++i)
460 return inGrid[index];
464 const vector<double>&
485 const auto levelIt =
fCrowns.find(i);
489 return levelIt->second;
494 indexMap[
"crown"] = boost::lexical_cast<string>(i);
496 const auto& manager = Detector::GetInstance().GetSManagerRegister();
499 const auto status = manager.GetData(crown,
"crown",
"stationList", indexMap);
501 if (status == VManager::eNotFound) {
503 err <<
"Crown level " << i <<
" "
504 "for station " <<
fId <<
" "
505 "has not been found by any of the available managers.";
509 const auto where =
fCrowns.insert(make_pair(i, crown));
510 return where.first->second;
517 Station::NotFoundAndThrow(
const string& msg)
521 err <<
"Did not find requested component: '" << msg
522 <<
"' for station = " << fStationIndexMap[
"stationId"];
528 Station::GetLocalCoordinateSystem()
531 if (!fReferenceSystem)
534 return fReferenceSystem;
544 fIsInAcquisition.SetValid(
false);
545 fPartnerIds.SetValid(
false);
548 fPosition.SetValid(
false);
551 const auto& dTime = Detector::GetInstance().GetTime();
552 const bool isUUB = (GetUUBCommissionTime() < dTime);
554 UpdateElectronics(isUUB);
558 fScintillator->Update();
560 for (
const auto p : fPMTVector)
568 Station::UpdateElectronics(
const bool isuub)
576 fFADCTraceLength.SetValid(
false);
577 fFADCBinSize.SetValid(
false);
578 fTimingUncertainty.SetValid(
false);
579 fLatchBin.SetValid(
false);
580 fSaturationValue.SetValid(
false);
581 fElectronicsImpulseResponse =
nullptr;
598 const bool hadSmallPMT = HasSmallPMT();
600 for (
const auto p : fPMTVector)
605 fStationIndexMap[
"isUUB"] = boost::lexical_cast<
string>(fIsUUB);
610 for (
unsigned int i = kFirstWaterCherenkovLargePMTId;
611 i <= kLastWaterCherenkovLargePMTId; ++i) {
613 fPMTVector.push_back(pmt);
623 fScintillator =
nullptr;
630 Station::MakeScintillator()
639 fPMTVector.push_back(pmt);
644 Station::RemoveScintillator()
650 fScintillator =
nullptr;
652 for (
auto pmtIt = fPMTVector.begin(); pmtIt != fPMTVector.end(); ) {
653 const auto pmtPtr = *pmtIt;
656 fPMTVector.erase(pmtIt);
665 Station::MakeSmallPMT()
672 fPMTVector.push_back(pmt);
677 Station::RemoveSmallPMT()
684 for (
auto pmtIt = fPMTVector.begin(); pmtIt != fPMTVector.end(); ) {
685 const auto pmtPtr = *pmtIt;
688 fPMTVector.erase(pmtIt);
701 return fPMTVector.size();
704 for (
const auto p : fPMTVector)
705 if (
p->GetType() == type)
712 Station::InitializeShape(vector<double>& histox,
const int nBins,
const double dt)
715 histox.reserve(nBins + 1);
716 for (
int i = 0; i <= nBins; ++i)
717 histox.push_back(i * dt);
721 const vector<double>&
722 Station::GetMuonShapeHistogramBinning(
const int calibrationVersion)
727 static vector<double> muShapeUUB;
728 if (muShapeUUB.empty())
729 InitializeShape(muShapeUUB, 70, fFADCBinSize.Get());
735 if (calibrationVersion == 13) {
737 static vector<double> muShape13;
738 if (muShape13.empty())
739 InitializeShape(muShape13, 19, fFADCBinSize.Get());
743 static vector<double> muShape;
745 InitializeShape(muShape, 20, fFADCBinSize.Get());
751 Station::HasSmallPMT()
754 for (
const auto p : fPMTVector)
765 const auto& cs = GetLocalCoordinateSystem();
766 const double stationRadius = GetRadius();
767 const double stationHeight = GetHeight();
768 return (pos.
GetRho(cs) < stationRadius && pos.
GetZ(cs) < stationHeight);
777 const Line particleLine(particlePoint, particleDirection);
779 double minDistance2 = farAway2;
783 const double radius2 =
Sqr(GetRadius());
784 const auto& cs = GetLocalCoordinateSystem();
786 Plane topPlane(
Point(0, 0, GetHeight() + GetThickness(), cs),
Vector(0,0,1, cs));
790 if ((where - topPlane.
GetAnchor()).GetMag2() < radius2) {
791 const double dist2 = (particlePoint - where).GetMag2();
792 if (dist2 < minDistance2)
793 minDistance2 = dist2;
798 if ((where - bottomPlane.
GetAnchor()).GetMag2() < radius2) {
799 const double dist2 = (particlePoint - where).GetMag2();
800 if (dist2 < minDistance2)
801 minDistance2 = dist2;
805 const double ax = particleDirection.
GetX(cs);
806 const double ay = particleDirection.
GetY(cs);
807 const double px = particlePoint.
GetX(cs);
808 const double py = particlePoint.
GetY(cs);
809 const double a =
Sqr(ax) +
Sqr(ay);
810 const double b = 2*(ax*px + ay*py);
811 const double c =
Sqr(px) +
Sqr(py) - radius2;
812 const double disc =
Sqr(b) - 4*a*
c;
815 const double ta = 2*
a;
816 const double s0 = -b/ta;
817 const double delta = fabs(
sqrt(disc)/ta);
818 const double s = s0 - delta;
822 if (
Sqr(s) < minDistance2 &&
824 minDistance2 =
Sqr(s);
unsigned int GetNPMTs(const PMTConstants::PMTType type=PMTConstants::eAnyType) const
Number of pmts in station.
const utl::TimeRange & GetCommissionTimeRange() const
Station commission time range.
const StationIdCollection & GetCrown(const int level) const
Returns a list of station id's in the crown. If the argument is 0, it returns the station id...
InternalPMTVector fPMTVector
double GetTimingUncertainty() const
constexpr T Sqr(const T &x)
void NotFoundAndThrow(const std::string &msg) const
int GetAssociatedCounterId() const
the identifier of the associated muon Counter.
class to hold data at PMT level
utl::Validated< double > fFADCBinSize
int GetGroupId() const
returns unique identifier of a group of stations or zero (if single)
Time interval defined by two TimeStamps.
Detector description interface for PMT-related data.
Class to hold and convert a point in geodetic coordinates.
utl::Validated< utl::TimeRange > fCommissionTimeRange
utl::Validated< int > fGroupId
Class to hold collection (x,y) points and provide interpolation between them.
utl::Validated< utl::TimeStamp > fUUBCommissionTime
Status GetDataOrThrow(T &returnData, const std::string &component, const std::string &property, const IndexMap &index=IndexMap()) const
bool is(const double a, const double b)
const utl::TabulatedFunction & GetLinerSpecularLobe() const
Tyvek liner specular lobe constant as a function of photon energy.
const Point & GetAnchor() const
void Update(std::vector< double > &init, const std::vector< double > &res)
bool IsInGrid(const SDetectorConstants::GridIndex index=SDetectorConstants::eStandard) const
Tells whether the station is in the regular triangular grid.
utl::ShadowPtr< utl::TabulatedFunction > fLinerSpecularLobe
int crown(double x1, double x2, double y1, double y2)
const PMT & GetPMT(const int id) const
Get specified PMT by id.
utl::Validated< double > fHeight
Base class for exceptions trying to access non-existing components.
det::VManager::IndexMap fStationIndexMap
utl::Validated< double > fTimingUncertainty
unsigned int GetId() const
Return Id of the PMT.
const utl::TabulatedFunction & GetWaterAbsorptionLength() const
Water absorption length as a function of photon energy.
const utl::TimeStamp & GetUUBCommissionTime() const
utl::Validated< double > fThickness
A TimeStamp holds GPS second and nanosecond for some event.
const std::string & GetName() const
Station name.
Line Intersection(const Plane &p1, const Plane &p2)
utl::Point GetPosition() const
Tank position.
utl::ShadowPtr< utl::TabulatedFunction > fWaterAbsLength
static const unsigned int kFirstWaterCherenkovLargePMTId
utl::ShadowPtr< utl::TabulatedFunction > fWaterRefractionIndex
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
utl::ShadowPtr< utl::TabulatedFunction > fLinerSpecularSpike
utl::Validated< std::vector< int > > fPartnerIds
utl::Validated< int > fLatchBin
const utl::TabulatedFunction & GetLinerReflectivity() const
Tyvek liner reflectivity as a function of photon energy.
const std::vector< int > & SetPartnerIds() const
InternalCrownCollection fCrowns
Class describing a Plane object.
double GetX(const CoordinateSystemPtr &coordinateSystem) const
unsigned int GetSaturationValue() const
utl::Validated< InGridType > fInGrid
std::vector< int > StationIdCollection
const std::vector< double > & GetAxes() const
Point Propagate(const double s) const
utl::ReferenceEllipsoid::EllipsoidID fEllipsoid
double GetRadius() const
Radius of the tank (water only)
double GetHeight() const
Height of the tank (water only)
static const unsigned int kLastWaterCherenkovLargePMTId
bool ExistsAssociatedCounter() const
if this Station has an associated muon Counter.
utl::Validated< std::vector< double > > fAxes
bool IsInAcquisition() const
Station in data acquisition.
Base class for inconsistency/illogicality exceptions.
utl::Validated< double > fRadius
utl::ShadowPtr< utl::TabulatedFunction > fElectronicsImpulseResponse
const utl::TabulatedFunction & GetLinerSpecularSpike() const
Tyvek liner specular spike constant as a function of photon energy.
double GetRho(const CoordinateSystemPtr &coordinateSystem) const
radius r in cylindrical coordinates (distance to z axis)
double GetY(const CoordinateSystemPtr &coordinateSystem) const
double Distance(const Point &p, const sdet::Station &s)
const PMT & GetScintillatorPMT() const
std::bitset< SDetectorConstants::kGridIndexSize > InGridType
utl::Validated< unsigned int > fSaturationValue
double GetFADCBinSize() const
utl::Validated< std::string > fName
double GetThickness() const
Thickness of the tank walls.
utl::Validated< int > fIsInAcquisition
Register for detector description managers.
const utl::TabulatedFunction & GetWaterRefractionIndex() const
Water refraction index as a function of photon energy.
constexpr double kilometer
void SetValid(const bool valid=true)
const PMT & GetSmallPMT() const
unsigned int GetFADCTraceLength() const
utl::Validated< unsigned int > fFADCTraceLength
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
double GetLinerSigmaAlpha() const
Tyvek liner sigma_alpha roughness parameter.
static Policy::type Create(const utl::Point &theOrigin)
Create the standard local coordinate system for a Point.
int GetId() const
Station ID.
det::VManager::Status GetStationData(T &requestedData, const std::string &property, const std::string &component, const std::string &errorMsg, const bool throwOnFailure=true) const
Point GetPoint(const CoordinateSystemPtr &theCS=CoordinateSystemPtr()) const
Get a cartesian point from an UTMPoint.
#define ERROR(message)
Macro for logging error messages.
int GetNumberOfPartners() const
Number of partners the station has.
const utl::TabulatedFunction & GetElectronicsImpulseResponse() const
utl::ShadowPtr< utl::TabulatedFunction > fLinerReflectivity
utl::Validated< double > fLinerSigmaAlpha
utl::Validated< utl::Point > fPosition