BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
HoughHit.cxx
Go to the documentation of this file.
1#include "MdcHoughFinder/HoughHit.h"
2#include "MdcHoughFinder/HoughGlobal.h"
3#include "RawEvent/RawDataUtil.h"
4#include "Identifier/MdcID.h"
5#include "MdcGeomSvc/IMdcGeomSvc.h"
6#include "MdcGeomSvc/MdcGeoWire.h"
7#include "MdcGeomSvc/MdcGeoLayer.h"
8#include "GaudiKernel/SvcFactory.h"
9#include "GaudiKernel/ISvcLocator.h"
10#include "GaudiKernel/StatusCode.h"
11#include <assert.h>
12
13const MdcCalibFunSvc* HoughHit::_calibPtr=NULL;
14MdcGeomSvc* HoughHit::_mdcGeomSvc=NULL;
15double HoughHit::_bunchTime;
16int HoughHit::_npart=360;
17//MdcDetector* HoughHit::_det=NULL;
18
20 _det=Global::m_gm;
21 _digiPtr=NULL;
22 _layerPtr=NULL;
23 _wirePtr=NULL;
24}
25HoughHit::HoughHit(const MdcDigi* const aDigi){
26 _det= Global::m_gm;
27 _digiPtr=aDigi;
28 _id = aDigi->identify();
29 _layer = MdcID::layer(_id);
30 _wire = MdcID::wire(_id);
31 _layerPtr = _det->Layer(_id);
32 _wirePtr = _det->Wire(_id);
33 _rawTime = RawDataUtil::MdcTime(_digiPtr->getTimeChannel());
34 _charge = _digiPtr->getChargeChannel();
35 _driftTime = driftTime();
36 _driftDist = calDriftDist(_bunchTime,0);
37 _slayerType=slayerType(_layer);
38 _lr = 0;
39 _rmid = _wirePtr->rMid();
40
41 assert(_mdcGeomSvc!=NULL);
42 const MdcGeoWire* wire = _mdcGeomSvc->Wire(_layer,_wire);
43 assert(wire!=NULL);
44 HepPoint3D eastP = wire->Backward()/10.;
45 HepPoint3D westP = wire->Forward()/10.;
46 _eastPoint = eastP;
47 _westPoint = westP;
48 _midPoint = (eastP+westP)/2.;
49
50 _type = MIDPOINT;
51 conformalTrans( _midPoint.x(), _midPoint.y(),_driftDist);
52}
53
55 _digiPtr(other._digiPtr),
56 _det(other._det),
57 _layerPtr(other._layerPtr), _wirePtr(other._wirePtr), _id(other._id),
58 _layer(other._layer), _wire(other._wire),
59 _rawTime(other._rawTime), _charge(other._charge),
60 _eastPoint(other._eastPoint),_westPoint(other._westPoint),_midPoint(other._midPoint),
61 _u(other._u),_v(other._v),
62 _type(other._type),_detectorType(other._detectorType),
63 _rmid(other._rmid), _slayerType(other._slayerType),
64 _cirlist(other._cirlist),_style(other._style),
65 _driftTime(other._driftTime), _driftDist(other._driftDist),
66 CF_drift(other.CF_drift),
67 vec_cfcir(other.vec_cfcir),
68 //truth
69 _truthU(other._truthU),
70 _truthV(other._truthV),
71 _truthR(other._truthR),
72 _truthlr(other._truthlr),
73 _truthPoint(other._truthPoint),
74 _truthDrift(other._truthDrift),
75 _deltad(other._deltad),
76 _flightLength(other._flightLength)
77 { }
78
80 _digiPtr=(other._digiPtr);
81 _det=(other._det);
82 _layerPtr=(other._layerPtr); _wirePtr=(other._wirePtr); _id=(other._id);
83 _layer=(other._layer); _wire=(other._wire);
84 _rawTime=(other._rawTime); _charge=(other._charge);
85 _eastPoint=(other._eastPoint);_westPoint=(other._westPoint);_midPoint=(other._midPoint);
86 _u=(other._u);_v=(other._v);
87 _type=(other._type);_detectorType=(other._detectorType);
88 _rmid=(other._rmid); _slayerType=(other._slayerType);
89 _cirlist=(other._cirlist);_style=(other._style);
90 _driftTime=(other._driftTime); _driftDist=(other._driftDist);
91 CF_drift = (other.CF_drift);
92 vec_cfcir = (other.vec_cfcir);
93 //truth
94 _truthU= (other._truthU);
95 _truthV= (other._truthV);
96 _truthR= (other._truthR);
97 _truthlr= (other._truthlr);
98 _truthDrift= (other._truthDrift);
99 _truthPoint= (other._truthPoint);
100 _deltad= (other._deltad);
101 _flightLength= (other._flightLength);
102}
103
104void HoughHit::setTruthInfo(const MdcMcHit*& aMcHit){
105 if(!aMcHit) return;
106 _truthDrift = aMcHit->getDriftDistance()/10.;//mm to cm
107 _truthPoint.setX(aMcHit->getPositionX()/10.);//mm to cm
108 _truthPoint.setY(aMcHit->getPositionY()/10.);
109 _truthPoint.setZ(aMcHit->getPositionZ()/10.);
110
111 int mcLR = aMcHit->getPositionFlag();
112// if (mcLR == 0) mcLR = -1;//FIXME
113// for truth reserve from digi
114 if (mcLR == 1) mcLR = -1;//
115 if (mcLR == 0) mcLR = 1;//
116 _truthId = aMcHit->getTrackIndex();
117 _truthlr = mcLR;
118
119//fix
120 _truthU = getConformal_u( _truthPoint.x(), _truthPoint.y(), _truthDrift );
121 _truthV = getConformal_v( _truthPoint.y(), _truthPoint.x(), _truthDrift );
122 _truthR = getConformal_r( _truthPoint.x(), _truthPoint.y(), _truthDrift );
123
124 //std::cout<<__FILE__<<" "<<_layer<<","<<_wire<<" "<<_truthId<<" truth "<<_truthPoint<<" truthU "<<_truthU<<std::endl;
125
126 _type = DIGIWITHTRUTH;
127}
128
129void HoughHit::conformalTrans(double x,double y,double r){
130 _u = 2*x/(x*x+y*y-r*r);
131 _v = 2*y/(x*x+y*y-r*r);
132 CF_drift = 2*r/(x*x+y*y-r*r);
133}
134
135double HoughHit::getConformal_u(double x,double y,double r) {
136 return 2*x/(x*x+y*y-r*r);
137}
138double HoughHit::getConformal_v(double x,double y,double r) {
139 return 2*x/(x*x+y*y-r*r);
140}
141double HoughHit::getConformal_r(double x,double y,double r) {
142 return 2*r/(x*x+y*y-r*r);
143}
144
145double HoughHit::driftTime() const {
146 double tprop = _calibPtr->getTprop(_layer,0);
147 double T0Walk = _calibPtr->getT0(_layer,_wire) + _calibPtr->getTimeWalk(_layer, _charge);
148 //tof in ns, driftTime in ns, _T0Walk in ns
149 double driftT = _rawTime - T0Walk - 1.e9*_bunchTime- tprop;
150 return driftT;
151}
152double HoughHit::driftTime(double tof, double z) const {
153 double tprop = _calibPtr->getTprop(_layer,z*10.);
154 double T0Walk = _calibPtr->getT0(_layer,_wire) + _calibPtr->getTimeWalk(_layer, _charge);
155 //tof in ns, driftTime in ns, _T0Walk in ns
156 double driftT = _rawTime - T0Walk - 1.e9*tof - tprop;
157
158 return driftT;
159}
160
161double HoughHit::calDriftDist(double bunchTime, int ambig) const {
162
163 // double crudeTof = 0; //FIXME
164 return calDriftDist(bunchTime+crudeTof(), ambig, 0., 0., 0. );
165}
166
167double HoughHit::calDriftDist(double tof, int ambig, double entranceAngle, double /*dipAngle*/, double z) const {
168
169 double driftD;
170 //drift time ns, layer id begin with 0, entrance angle rads,
171 //lr ambig: wire ambig 1,-1,0 -> Calib 0,1,2
172 int lrCalib=2;
173 if (ambig==1) lrCalib = 0;
174 else if (ambig==-1) lrCalib = 1;
175
176 // tof in s, driftDist in cm, dirftTime in ns
177 if (fabs(z)>150. || fabs(driftTime(tof,z))>1500.){
178 return 9999.;
179 }
180 driftD = 0.1 * _calibPtr->driftTimeToDist(driftTime(tof,z),_layer,_wire,lrCalib,entranceAngle);//to cm
181 //std::cout<<"driftDist "<<"("<<_layer <<","<<_wire <<") dd "<<driftD<<" dt "<<driftTime(tof,z) <<" lr "<<lrCalib <<" eAng "<<entranceAngle <<" tof "<<tof*1.e9<<" z "<<z <<" t0walk "<<_T0Walk<<" rawT "<<_rawTime <<" tprop "<< _rawTime - driftTime(tof,z)- _T0Walk-1.e9*tof<<std::endl;
182
183 if (abs(driftD)<0.00001) driftD = 0.00001;
184 return driftD;
185}
186
187void HoughHit::print() const{
188 std::cout<<"("<<_layer<<","<<_wire<<") "<<std::endl;
189}
190
192 std::cout<<"("<<_layer<<","<<_wire<<") id "<<this->digi()->getTrackIndex()<<" xyz "<<_midPoint<<endl;
193}
195 std::cout<<"("<<_layer<<","<<_wire<<") truth "<<_truthId<<" xyz "<<_truthPoint<<" uv "<<_truthU<<","<<_truthV<<") "<<" cir list "<<_cirlist<<" ambig "<<_truthlr<<std::endl;
196}
197
198int HoughHit::slayerType(int layer){
199 //get nominal shift cell of this layer
200 double nomShift= _mdcGeomSvc->Layer(layer)->nomShift();
201
202 if(nomShift>0) return 1;
203 else if(nomShift<0) return -1;
204 else return 0;
205
206 return -999;
207}
208
209//calcu drift cir
210void HoughHit::makeCir(int n,double phi_begin,double phi_last,double r){
211 vec_cfcir.clear();
212 vector<CFCir>().swap(vec_cfcir);
213 for(int i =0; i<n; i++){
214 double phi_slice = (phi_last-phi_begin)/n;
215 double phi = phi_begin + (1/2.+i)*phi_slice;
216 double x = _u + r*cos(phi);
217 double y = _v + r*sin(phi);
218 vec_cfcir.push_back( CFCir(x,y,phi,n,_u,_v,r) );
219 }
220}
221
const Int_t n
Double_t x[10]
double sin(const BesAngle a)
double cos(const BesAngle a)
HoughHit()
Definition: HoughHit.cxx:19
void printTruth() const
Definition: HoughHit.cxx:194
void conformalTrans(double x, double y, double r)
Definition: HoughHit.cxx:129
double driftTime() const
Definition: HoughHit.cxx:145
void printAll() const
Definition: HoughHit.cxx:191
void print() const
Definition: HoughHit.cxx:187
void makeCir(int n, double phi_begin, double phi_last, double r)
Definition: HoughHit.cxx:210
void setTruthInfo(const MdcMcHit *&mcHit)
int slayerType(int layer)
Definition: HoughHit.cxx:198
double getConformal_v(double, double, double)
Definition: HoughHit.cxx:138
double calDriftDist(double, int, double, double, double) const
Definition: HoughHit.cxx:167
double getConformal_r(double, double, double)
Definition: HoughHit.cxx:141
HoughHit & operator=(const HoughHit &other)
Definition: HoughHit.cxx:79
double getConformal_u(double, double, double)
Definition: HoughHit.cxx:135
double getT0(int layid, int cellid) const
double driftTimeToDist(double drifttime, int layid, int cellid, int lr, double entrance=0.0) const
double getTprop(int lay, double z) const
double getTimeWalk(int layid, double Q) const
const MdcLayer * Layer(unsigned id) const
const MdcSWire * Wire(unsigned id) const
const MdcGeoWire *const Wire(unsigned id)
Definition: MdcGeomSvc.cxx:768
const MdcGeoLayer *const Layer(unsigned id)
Definition: MdcGeomSvc.cxx:784
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
Definition: MdcID.cxx:49
static int wire(const Identifier &id)
Definition: MdcID.cxx:54
virtual Identifier identify() const
Definition: RawData.cxx:15
unsigned int getChargeChannel() const
Definition: RawData.cxx:45
int getTrackIndex() const
Definition: RawData.cxx:50
unsigned int getTimeChannel() const
Definition: RawData.cxx:40