Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:27

0001 /* Copyright 2008-2010, Technische Universitaet Muenchen,
0002    Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
0003 
0004    This file is part of GENFIT.
0005 
0006    GENFIT is free software: you can redistribute it and/or modify
0007    it under the terms of the GNU Lesser General Public License as published
0008    by the Free Software Foundation, either version 3 of the License, or
0009    (at your option) any later version.
0010 
0011    GENFIT is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014    GNU Lesser General Public License for more details.
0015 
0016    You should have received a copy of the GNU Lesser General Public License
0017    along with GENFIT.  If not, see <http://www.gnu.org/licenses/>.
0018 */
0019 
0020 #include "PlanarMeasurement.h"
0021 
0022 #include <Exception.h>
0023 #include <RKTrackRep.h>
0024 #include <HMatrixU.h>
0025 #include <HMatrixV.h>
0026 #include <HMatrixUV.h>
0027 
0028 #include <cassert>
0029 #include <TBuffer.h>
0030 
0031 namespace genfit {
0032 
0033 PlanarMeasurement::PlanarMeasurement(int nDim)
0034   : AbsMeasurement(nDim), physicalPlane_(), planeId_(-1), stripV_(false)
0035 {
0036   assert(nDim >= 1);
0037 }
0038 
0039 PlanarMeasurement::PlanarMeasurement(const TVectorD& rawHitCoords, const TMatrixDSym& rawHitCov, int detId, int hitId, TrackPoint* trackPoint)
0040   : AbsMeasurement(rawHitCoords, rawHitCov, detId, hitId, trackPoint), physicalPlane_(), planeId_(-1), stripV_(false)
0041 {
0042   assert(rawHitCoords_.GetNrows() >= 1);
0043 }
0044 
0045 
0046 SharedPlanePtr PlanarMeasurement::constructPlane(const StateOnPlane&) const {
0047   if (!physicalPlane_) {
0048     Exception exc("PlanarMeasurement::constructPlane(): No plane has been set!", __LINE__,__FILE__);
0049     throw exc;
0050   }
0051   return physicalPlane_;
0052 }
0053 
0054 
0055 std::vector<MeasurementOnPlane*> PlanarMeasurement::constructMeasurementsOnPlane(const StateOnPlane& state) const {
0056 
0057   MeasurementOnPlane* mop = new MeasurementOnPlane(rawHitCoords_,
0058        rawHitCov_,
0059        state.getPlane(), state.getRep(), constructHMatrix(state.getRep()));
0060 
0061   std::vector<MeasurementOnPlane*> retVal;
0062   retVal.push_back(mop);
0063   return retVal;
0064 }
0065 
0066 
0067 const AbsHMatrix* PlanarMeasurement::constructHMatrix(const AbsTrackRep* rep) const {
0068 
0069   if (dynamic_cast<const RKTrackRep*>(rep) == nullptr) {
0070     Exception exc("SpacepointMeasurement default implementation can only handle state vectors of type RKTrackRep!", __LINE__,__FILE__);
0071     throw exc;
0072   }
0073 
0074   switch(rawHitCoords_.GetNrows()) {
0075   case 1:
0076     if (stripV_)
0077       return new HMatrixV();
0078     return new HMatrixU();
0079 
0080   case 2:
0081     return new HMatrixUV();
0082 
0083   default:
0084     Exception exc("PlanarMeasurement default implementation can only handle 1D (strip) or 2D (pixel) measurements!", __LINE__,__FILE__);
0085     throw exc;
0086   }
0087 
0088 }
0089 
0090 void PlanarMeasurement::Streamer(TBuffer &R__b)
0091 {
0092    // Stream an object of class genfit::PlanarMeasurement.
0093 
0094    //This works around a msvc bug and should be harmless on other platforms
0095    typedef ::genfit::PlanarMeasurement thisClass;
0096    UInt_t R__s, R__c;
0097    if (R__b.IsReading()) {
0098       Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
0099       //This works around a msvc bug and should be harmless on other platforms
0100       typedef genfit::AbsMeasurement baseClass0;
0101       baseClass0::Streamer(R__b);
0102       char flag;
0103       R__b >> flag;
0104       physicalPlane_.reset();
0105       if (flag) {
0106         physicalPlane_.reset(new DetPlane());
0107         physicalPlane_->Streamer(R__b);
0108       }
0109       R__b >> planeId_;
0110       R__b.CheckByteCount(R__s, R__c, thisClass::IsA());
0111    } else {
0112       R__c = R__b.WriteVersion(thisClass::IsA(), kTRUE);
0113       //This works around a msvc bug and should be harmless on other platforms
0114       typedef genfit::AbsMeasurement baseClass0;
0115       baseClass0::Streamer(R__b);
0116       if (physicalPlane_) {
0117         R__b << (char)1;
0118         physicalPlane_->Streamer(R__b);
0119       } else {
0120         R__b << (char)0;
0121       }
0122       R__b << planeId_;
0123       R__b.SetByteCount(R__c, kTRUE);
0124    }
0125 }
0126 
0127 } /* End of namespace genfit */