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"
16double HoughHit::_bunchTime;
34 _layerPtr = _det->
Layer(_id);
35 _wirePtr = _det->
Wire(_id);
42 _rmid = _wirePtr->
rMid();
44 assert(_mdcGeomSvc!=NULL);
51 _midPoint = (eastP+westP)/2.;
77 _slayerType= cluster->
getflag();
81 assert(_cgemGeomSvc!=NULL);
91 _midPoint = (eastP+westP)/2.;
98 _clusterPtr = cluster;
106 _digiPtr(other._digiPtr),
108 _layerPtr(other._layerPtr), _wirePtr(other._wirePtr), _id(other._id),
109 _layer(other._layer), _wire(other._wire),
110 _rawTime(other._rawTime), _charge(other._charge),
111 _eastPoint(other._eastPoint),_westPoint(other._westPoint),_midPoint(other._midPoint),
112 _leftPoint(other._leftPoint),_rightPoint(other._rightPoint),
113 _u(other._u),_v(other._v),_lr(other._lr),
114 _type(other._type),_detectorType(other._detectorType),
115 _rmid(other._rmid), _slayerType(other._slayerType),
116 _cirlist(other._cirlist),_style(other._style),
117 _driftTime(other._driftTime), _driftDist(other._driftDist),
118 CF_drift(other.CF_drift),
119 vec_cfcir(other.vec_cfcir),
121 _truthU(other._truthU),
122 _truthV(other._truthV),
123 _truthR(other._truthR),
124 _truthlr(other._truthlr),
125 _truthId(other._truthId),
126 _truthPoint(other._truthPoint),
127 _truthDrift(other._truthDrift),
128 _deltad(other._deltad),
129 _flightLength(other._flightLength),
130 _clusterPtr(other._clusterPtr),
131 _trkid(other._trkid),
132 _hitid(other._hitid),
133 _clusterid(other._clusterid),
134 _hitMap(other._hitMap),
139 _digiPtr=(
other._digiPtr);
141 _layerPtr=(
other._layerPtr); _wirePtr=(
other._wirePtr); _id=(
other._id);
143 _rawTime=(
other._rawTime); _charge=(
other._charge);
144 _eastPoint=(
other._eastPoint);_westPoint=(
other._westPoint);_midPoint=(
other._midPoint);
145 _leftPoint=(
other._leftPoint);_rightPoint=(
other._rightPoint);
147 _type=(
other._type);_detectorType=(
other._detectorType);
148 _rmid=(
other._rmid); _slayerType=(
other._slayerType);
149 _cirlist=(
other._cirlist);_style=(
other._style);
150 _driftTime=(
other._driftTime); _driftDist=(
other._driftDist);
151 CF_drift = (
other.CF_drift);
152 vec_cfcir = (
other.vec_cfcir);
154 _truthU= (
other._truthU);
155 _truthV= (
other._truthV);
156 _truthR= (
other._truthR);
157 _truthlr= (
other._truthlr);
158 _truthId= (
other._truthId);
159 _truthDrift= (
other._truthDrift);
160 _truthPoint= (
other._truthPoint);
161 _deltad= (
other._deltad);
162 _flightLength= (
other._flightLength);
163 _clusterPtr= (
other._clusterPtr);
164 _trkid = (
other._trkid);
165 _hitid = (
other._hitid);
166 _clusterid = (
other._clusterid);
167 _hitMap = (
other._hitMap);
168 _used = (
other._used);
173 _truthDrift = aMcHit->getDriftDistance()/10.;
174 _truthPoint.setX(aMcHit->getPositionX()/10.);
175 _truthPoint.setY(aMcHit->getPositionY()/10.);
176 _truthPoint.setZ(aMcHit->getPositionZ()/10.);
178 int mcLR = aMcHit->getPositionFlag();
181 if (mcLR == 1) mcLR = -1;
182 if (mcLR == 0) mcLR = 1;
183 _truthId = aMcHit->getTrackIndex();
187 _truthU =
getConformal_u( _truthPoint.x(), _truthPoint.y(), _truthDrift );
188 _truthV =
getConformal_v( _truthPoint.y(), _truthPoint.x(), _truthDrift );
189 _truthR =
getConformal_r( _truthPoint.x(), _truthPoint.y(), _truthDrift );
198 _truthDrift = 0.00001;
199 _truthPoint.setX((aMcHit->GetPositionXOfPrePoint()+aMcHit->GetPositionXOfPostPoint())/2/10.);
200 _truthPoint.setY((aMcHit->GetPositionYOfPrePoint()+aMcHit->GetPositionYOfPostPoint())/2/10.);
201 _truthPoint.setZ((aMcHit->GetPositionZOfPrePoint()+aMcHit->GetPositionZOfPostPoint())/2/10.);
208 _truthId = aMcHit->GetTrackID();
212 _truthU =
getConformal_u( _truthPoint.x(), _truthPoint.y(), _truthDrift );
213 _truthV =
getConformal_v( _truthPoint.y(), _truthPoint.x(), _truthDrift );
214 _truthR =
getConformal_r( _truthPoint.x(), _truthPoint.y(), _truthDrift );
222 _u = 2*
x/(
x*
x+y*y-r*r);
223 _v = 2*y/(
x*
x+y*y-r*r);
224 CF_drift = 2*r/(
x*
x+y*y-r*r);
228 return 2*
x/(
x*
x+y*y-r*r);
231 return 2*
x/(
x*
x+y*y-r*r);
234 return 2*r/(
x*
x+y*y-r*r);
238 double tprop = _calibPtr->
getTprop(_layer,0);
239 double T0Walk = _calibPtr->
getT0(_layer,_wire) + _calibPtr->
getTimeWalk(_layer, _charge);
241 double driftT = _rawTime - T0Walk - 1.e9*_bunchTime- tprop;
245 double tprop = _calibPtr->
getTprop(_layer,z*10.);
246 double T0Walk = _calibPtr->
getT0(_layer,_wire) + _calibPtr->
getTimeWalk(_layer, _charge);
248 double driftT = _rawTime - T0Walk - 1.e9*tof - tprop;
256 return calDriftDist(bunchTime+crudeTof(), ambig, 0., 0., 0. );
265 if (ambig==1) lrCalib = 0;
266 else if (ambig==-1) lrCalib = 1;
269 if (fabs(z)>150. || fabs(
driftTime(tof,z))>1500.){
275 if (
abs(driftD)<0.00001) driftD = 0.00001;
280 std::cout<<
"("<<_layer<<
","<<_wire<<
") "<<std::endl;
285 if(_detectorType==
MDC){
286 std::cout<<
"("<<_layer<<
","<<_wire<<
") id "<<this->
digi()->
getTrackIndex()<<
" xyz "<<_midPoint<<endl;
290 <<
" uv "<<_u<<
" "<<_v
291 <<
" flag "<<(_clusterPtr)->getflag()
292 <<
" recphi "<<(_clusterPtr)->getrecphi()<<
" recv "<<(_clusterPtr)->getrecv()<<
" recz "<<(_clusterPtr)->getRecZ()
293 <<
" sheet "<<(_clusterPtr)->getsheetid()
294 <<
" energy "<<(_clusterPtr)->getenergydeposit()
299 std::cout<<
"("<<_layer<<
","<<_wire<<
") truth "<<_truthId<<
" xyz "<<_truthPoint<<
" uv "<<_truthU<<
","<<_truthV<<
") "<<
" cir list "<<_cirlist<<
" ambig "<<_truthlr<<std::endl;
306 if(nomShift>0)
return 1;
307 else if(nomShift<0)
return -1;
316 vector<CFCir>().swap(vec_cfcir);
317 for(
int i =0; i<
n; i++){
318 double phi_slice = (phi_last-phi_begin)/
n;
319 double phi = phi_begin + (1/2.+i)*phi_slice;
320 double x = _u + r*
cos(phi);
321 double y = _v + r*
sin(phi);
322 vec_cfcir.push_back(
CFCir(
x,y,phi,
n,_u,_v,r) );
326void HoughHit::buildMap(
int x_bin,
double x_min,
double x_max,
int y_bin,
double y_min,
double y_max,
int nPoint,
int charge)
328 if(_hitMap!=NULL)
delete _hitMap;
330 ssname<<
"id"<<_hitid<<
",layer"<<_layer<<
",wire(sheet)"<<_wire;
331 string sname = ssname.str();
332 const char * name = sname.c_str() ;
334 _hitMap =
new TH2D(name,name, x_bin, x_min, x_max, y_bin, y_min, y_max);
335 int N = x_bin*nPoint;
336 double delta_alpha = (x_max - x_min )/N;
337 double alpha = x_min-delta_alpha/2;
338 for(
int i=0;i<N;i++){
339 alpha += delta_alpha;
345 int chargeOfHitOnCir1 = (slantOfLine/fabs(slantOfLine))*(rho1/fabs(rho1));
346 int chargeOfHitOnCir2 = (slantOfLine/fabs(slantOfLine))*(rho2/fabs(rho2));
347 if(chargeOfHitOnCir1 != charge && y_min<(rho1) && (rho1)<y_max)
349 _hitMap->Fill(
alpha,rho1);
350 if(chargeOfHitOnCir2 != charge && y_min<(rho2) && (rho2)<y_max)
352 _hitMap->Fill(
alpha,rho2);
358 if(_hitMap!=NULL)
delete _hitMap;
double abs(const EvtComplex &c)
double sin(const BesAngle a)
double cos(const BesAngle a)
double getMiddleROfGapD() const
CgemGeoLayer * getCgemLayer(int i) const
const MdcDigi * digi() const
void conformalTrans(double x, double y, double r)
const MdcLayer * layer() const
void makeCir(int n, double phi_begin, double phi_last, double r)
void setTruthInfo(const MdcMcHit *&mcHit)
int slayerType(int layer)
double getConformal_v(double, double, double)
double calDriftDist(double, int, double, double, double) const
void buildMap(int x_bin, double x_min, double x_max, int y_bin, double y_min, double y_max, int nPoint, int charge)
double getConformal_r(double, double, double)
const MdcSWire * wire() const
HoughHit & operator=(const HoughHit &other)
double getConformal_u(double, double, double)
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
double nomShift(void) const
const MdcGeoWire *const Wire(unsigned id)
const MdcGeoLayer *const Layer(unsigned id)
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
static int wire(const Identifier &id)
static double MdcTime(int timeChannel)
virtual Identifier identify() const
unsigned int getChargeChannel() const
int getTrackIndex() const
unsigned int getTimeChannel() const
double getenergydeposit(void) const
double getRecZ(void) const
int getclusterid(void) const
int getlayerid(void) const
double getrecphi(void) const
int getsheetid(void) const
Index other(Index i, Index j)