EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlanarMeasurement.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PlanarMeasurement.cc
1 /* Copyright 2008-2010, Technische Universitaet Muenchen,
2  Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
3 
4  This file is part of GENFIT.
5 
6  GENFIT is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  GENFIT is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include "PlanarMeasurement.h"
21 
22 #include <Exception.h>
23 #include <RKTrackRep.h>
24 #include <HMatrixU.h>
25 #include <HMatrixV.h>
26 #include <HMatrixUV.h>
27 
28 #include <cassert>
29 #include <TBuffer.h>
30 
31 namespace genfit {
32 
34  : AbsMeasurement(nDim), physicalPlane_(), planeId_(-1), stripV_(false)
35 {
36  assert(nDim >= 1);
37 }
38 
39 PlanarMeasurement::PlanarMeasurement(const TVectorD& rawHitCoords, const TMatrixDSym& rawHitCov, int detId, int hitId, TrackPoint* trackPoint)
40  : AbsMeasurement(rawHitCoords, rawHitCov, detId, hitId, trackPoint), physicalPlane_(), planeId_(-1), stripV_(false)
41 {
42  assert(rawHitCoords_.GetNrows() >= 1);
43 }
44 
45 
47  if (!physicalPlane_) {
48  Exception exc("PlanarMeasurement::constructPlane(): No plane has been set!", __LINE__,__FILE__);
49  throw exc;
50  }
51  return physicalPlane_;
52 }
53 
54 
55 std::vector<MeasurementOnPlane*> PlanarMeasurement::constructMeasurementsOnPlane(const StateOnPlane& state) const {
56 
58  rawHitCov_,
59  state.getPlane(), state.getRep(), constructHMatrix(state.getRep()));
60 
61  std::vector<MeasurementOnPlane*> retVal;
62  retVal.push_back(mop);
63  return retVal;
64 }
65 
66 
68 
69  if (dynamic_cast<const RKTrackRep*>(rep) == nullptr) {
70  Exception exc("SpacepointMeasurement default implementation can only handle state vectors of type RKTrackRep!", __LINE__,__FILE__);
71  throw exc;
72  }
73 
74  switch(rawHitCoords_.GetNrows()) {
75  case 1:
76  if (stripV_)
77  return new HMatrixV();
78  return new HMatrixU();
79 
80  case 2:
81  return new HMatrixUV();
82 
83  default:
84  Exception exc("PlanarMeasurement default implementation can only handle 1D (strip) or 2D (pixel) measurements!", __LINE__,__FILE__);
85  throw exc;
86  }
87 
88 }
89 
90 void PlanarMeasurement::Streamer(TBuffer &R__b)
91 {
92  // Stream an object of class genfit::PlanarMeasurement.
93 
94  //This works around a msvc bug and should be harmless on other platforms
95  typedef ::genfit::PlanarMeasurement thisClass;
96  UInt_t R__s, R__c;
97  if (R__b.IsReading()) {
98  Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
99  //This works around a msvc bug and should be harmless on other platforms
100  typedef genfit::AbsMeasurement baseClass0;
101  baseClass0::Streamer(R__b);
102  char flag;
103  R__b >> flag;
104  physicalPlane_.reset();
105  if (flag) {
106  physicalPlane_.reset(new DetPlane());
107  physicalPlane_->Streamer(R__b);
108  }
109  R__b >> planeId_;
110  R__b.CheckByteCount(R__s, R__c, thisClass::IsA());
111  } else {
112  R__c = R__b.WriteVersion(thisClass::IsA(), kTRUE);
113  //This works around a msvc bug and should be harmless on other platforms
114  typedef genfit::AbsMeasurement baseClass0;
115  baseClass0::Streamer(R__b);
116  if (physicalPlane_) {
117  R__b << (char)1;
118  physicalPlane_->Streamer(R__b);
119  } else {
120  R__b << (char)0;
121  }
122  R__b << planeId_;
123  R__b.SetByteCount(R__c, kTRUE);
124  }
125 }
126 
127 } /* End of namespace genfit */