BOSS 7.0.7
BESIII Offline Software System
Loading...
Searching...
No Matches
KalFitTrack2.cxx
Go to the documentation of this file.
4//#include "EvTimeEvent/RecEsTime.h"
5#include "GaudiKernel/MsgStream.h"
6#include "GaudiKernel/Bootstrap.h"
8#include "GaudiKernel/ISvcLocator.h"
9#include "GaudiKernel/IDataProviderSvc.h"
10#include "GaudiKernel/SmartDataPtr.h"
11#include "GaudiKernel/Algorithm.h"
12#include "MdcRawEvent/MdcDigi.h"
14#include "EventModel/Event.h"
15#include "Identifier/MdcID.h"
17#include "CLHEP/Matrix/SymMatrix.h"
18
19double KalFitTrack::EventT0_ = 0.;
20HepSymMatrix KalFitTrack::initMatrix_(5,0);
21const MdcCalibFunSvc* KalFitTrack::CalibFunSvc_ = 0;
22const IMagneticFieldSvc* KalFitTrack::MFSvc_ = 0;
23IMdcGeomSvc* KalFitTrack::iGeomSvc_ = 0;
24MdcDigiCol* KalFitTrack::mdcDigiCol_ = 0;
26
27
28//KalFitAlg* alg;
29//IDataProviderSvc* eventSvc = alg->eventDataService();
30/* SmartDataPtr<MdcDigiCol> mdcDigiCol(alg->eventSvc(),"/Event/Digi/MdcDigiCol");
31 if (!mdcDigiCol) {
32 log << MSG::ERROR << "Could not find event in MdcDigiCol" << endreq;
33 return( StatusCode::FAILURE);
34 }
35 */
36
37void KalFitTrack::setInitMatrix(HepSymMatrix m)
38{
39 initMatrix_ = m;
40}
41
42HepSymMatrix KalFitTrack::getInitMatrix() const
43{
44 return initMatrix_ ;
45}
46
47void KalFitTrack::setT0(double eventstart )
48{
49 //------------------set event start time-----------
50
51 EventT0_ = eventstart;
52 if(debug_ == 4) {
53 std::cout<<"in function KalFitTrack::setT0(...), EventT0_ = "<<EventT0_<<std::endl;
54 }
55}
56
57double KalFitTrack::getT0(void ) const
58{
59 //------------------get event start time-----------
60
61 if(debug_ == 4) {
62 std::cout<<"in function KalFitTrack::getT0 ( ), EventT0_ = "<<EventT0_<<std::endl;
63 }
64 return EventT0_ ;
65}
66
67//
68/* double KalFitTrack::get_T0(void) const
69 {
70 return 0;
71 }
72 */
73
74double KalFitTrack::getDriftTime(KalFitHitMdc& hitmdc , double toftime) const
75{
76 const double vinner = 220.0e8; // cm/s
77 const double vouter = 240.0e8; // cm/s
78
79 int layerid = hitmdc.wire().layer().layerId();
80 double zhit = (hitmdc.rechitptr())->getZhit();
81 const KalFitWire* wire = &(hitmdc.wire());
82 HepPoint3D fPoint = wire->fwd();
83 HepPoint3D bPoint = wire->bck();
84
85 // unit is centimeter
86 double wireLen = (fPoint-bPoint).x()*(fPoint-bPoint).x()+(fPoint-bPoint).y()*(fPoint-bPoint).y()+(fPoint-bPoint).z()*(fPoint-bPoint).z();
87 wireLen = sqrt(wireLen);
88 double wireZLen = fabs(fPoint.z() - bPoint.z());
89 double tp = 0.;
90 double vp = 0.;
91 // west readout
92 if(0==layerid%2){
93 // inner chamber
94 if(layerid<8){
95 vp = vinner;
96 }
97 else {
98 vp = vouter;
99 }
100 tp = wireLen*fabs(zhit - bPoint.z())/wireZLen/vp;
101 }
102
103 // east readout
104 if(1==layerid%2){
105 // inner chamber
106 if(layerid<8){
107 vp = vinner;
108 }
109 else {
110 vp = vouter;
111 }
112 tp = wireLen*fabs(zhit - fPoint.z())/wireZLen/vp;
113 }
114
115 // s to ns
116 tp = 1.0e9*tp;
117
118 if(0==tprop_) tp = 0.;
119
120 //std::cout<<"propogation time: "<<tp<<std::endl;
121
122 int wireid = hitmdc.wire().geoID();
123 double drifttime1(0.);
124 double drifttime2(0.);
125 double drifttime3(0.);
126
127 MdcDigiCol::iterator iter = mdcDigiCol_->begin();
128 for(; iter != mdcDigiCol_->end(); iter++ ) {
129 if((*iter)->identify() == (hitmdc.rechitptr())->getMdcId()) break;
130 }
131 //double t0 = get_T0();
132 // see the code of wulh in /Mdc/MdcCalibFunSvc/MdcCalibFunSvc/MdcCalibFunSvc.h,
133 // double getT0(int wireid) const { return m_t0[wireid]; }
134
135 //double getTimeWalk(int layid, double Q) const ;
136 double Q = RawDataUtil::MdcCharge((*iter)->getChargeChannel());
137 double timewalk = CalibFunSvc_->getTimeWalk(layerid, Q);
138
139 if(debug_ == 4) {
140 std::cout<<"CalibFunSvc_->getTimeWalk, timewalk ="<<timewalk<<std::endl;
141 }
142
143 double timeoffset = CalibFunSvc_->getT0(wireid);
144 if(debug_ == 4) {
145 std::cout<<"CalibFunSvc_->getT0, timeoffset ="<<timeoffset<<std::endl;
146 }
147
148 double eventt0 = getT0();
149
150 if(debug_ == 4) {
151 std::cout<<"the Event T0 we get in the function getDriftTime(...) is "<<eventt0<<std::endl;
152 }
153
154 // this tdc value come from MdcRecHit assigned by zhangyao
155 double tdctime1 = hitmdc.tdc();
156 double tdctime2(0.);
157 double tdctime3(0.);
158
159 if(debug_ == 4) {
160 std::cout<<"tdctime1 be here is .."<<tdctime1<<std::endl;
161 }
162
163 // this tdc value come from MdcDigiCol time channel
164 // attention, if we use the iter like this: for(MdcDigiCol::iterator iter = mdcDigiCol_->begin(); iter != mdcDigiCol_->end(); iter++) it cannot pass the gmake , throw an error !
165 if(debug_ == 4) {
166 // std::cout<<"the size of the mdcDigiCol_ is "<<mdcDigiCol_.size()<<std::endl;
167 }
168 // MdcDigiCol::iterator iter = mdcDigiCol_->begin();
169 // for(; iter != mdcDigiCol_->end(); iter++ ) {
170 // if((*iter)->identify() == (hitmdc.rechitptr())->getMdcId()) break;
171 // }
172 if(debug_ == 4) {
173 std::cout<<"the time channel be here is .."<<(*iter)->getTimeChannel()<<std::endl;
174 }
175 tdctime2 = RawDataUtil::MdcTime((*iter)->getTimeChannel());
176 tdctime3 = hitmdc.rechitptr()->getTdc();
177 drifttime1 = tdctime1 - eventt0 - toftime - timewalk -timeoffset - tp;
178 drifttime2 = tdctime2 - eventt0 - toftime - timewalk -timeoffset - tp;
179 drifttime3 = tdctime3 - eventt0 - toftime - timewalk -timeoffset - tp;
180 if(debug_ == 4 ) {
181 std::cout<<"we now compare the three kind of tdc , the tdc get from timeChannel() is "<<tdctime2<<" the tdc get from KalFitHitMdc is "<<tdctime1<<" the tdc from MdcRecHit is "<<tdctime3<<" the drifttime1 is ..."<<drifttime1<<" the drifttime 2 is ..."<<drifttime2<<" the drifttime3 is ..."<<drifttime3<<std::endl;
182 }
183 //return drifttime3;
184 //return drifttime1;
185 if(drifttime_choice_ == 0)
186 return drifttime2;
187 if(drifttime_choice_ == 1)
188 // use the driftT caluculated by track-finding
189 return hitmdc.rechitptr()->getDriftT();
190}
191
192
193// attention , the unit of the driftdist is mm
194double KalFitTrack::getDriftDist(KalFitHitMdc& hitmdc, double drifttime, int lr) const
195{
196 int layerid = hitmdc.wire().layer().layerId();
197 int cellid = MdcID::wire(hitmdc.rechitptr()->getMdcId());
198 if(debug_ == 4 ){
199 std::cout<<"the cellid is .."<<cellid<<std::endl;
200 }
201 double entrangle = hitmdc.rechitptr()->getEntra();
202
203 //std::cout<<" entrangle: "<<entrangle<<std::endl;
204
205 return CalibFunSvc_->driftTimeToDist(drifttime, layerid, cellid, lr, entrangle);
206}
207
208// attention , the unit of the sigma is mm
209double KalFitTrack::getSigma(KalFitHitMdc& hitmdc, double tanlam, int lr, double dist) const
210{
211 int layerid = hitmdc.wire().layer().layerId();
212 double entrangle = hitmdc.rechitptr()->getEntra();
213 // double tanlam = hitmdc.rechitptr()->getTanl();
214 double z = hitmdc.rechitptr()->getZhit();
215 double Q = hitmdc.rechitptr()->getAdc();
216 //std::cout<<" the driftdist before getsigma is "<<dist<<" the layer is"<<layerid<<std::endl;
217 //cout<<"layerid, lr, dist, entrangle, tanlam, z , Q = "<<layerid<<", "<<lr<<", "<<dist<<", "<<entrangle<<", "<<tanlam<<", "<<z<<", "<<Q<<endl;//wangll
218 double temp = CalibFunSvc_->getSigma(layerid, lr, dist, entrangle, tanlam, z , Q );
219 //std::cout<<" the sigma is "<<temp<<std::endl;
220 return temp;
221}
222
224{
225 CalibFunSvc_ = calibsvc;
226}
227
229{
230 /*ISvcLocator* svcLocator = Gaudi::svcLocator();
231 StatusCode sc = svcLocator->service("MagneticFieldSvc",MFSvc_);
232 if (sc.isFailure()){
233 std::cout << "Could not load MagneticFieldSvc!" << std::endl;
234 }*/
235 MFSvc_ = mf;
236 if(MFSvc_==0) cout<<"KalFitTrack2:: Could not load MagneticFieldSvc!"<<endl;
237}
238
240{
241 iGeomSvc_ = igeomsvc;
242}
243
245{
246 mdcDigiCol_ = digicol;
247}
248
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
ObjectVector< MdcDigi > MdcDigiCol
Definition: MdcDigi.h:39
Description of a Hit in Mdc.
Definition: KalFitHitMdc.h:17
RecMdcHit * rechitptr(void)
Definition: KalFitHitMdc.h:36
double tdc(void) const
Definition: KalFitHitMdc.h:32
const KalFitWire & wire(void) const
Definition: KalFitHitMdc.h:35
const int layerId(void) const
returns layer ID
static void setMdcDigiCol(MdcDigiCol *digicol)
double getDriftTime(KalFitHitMdc &hitmdc, double toftime) const
static int debug_
for debug
Definition: KalFitTrack.h:280
HepSymMatrix getInitMatrix(void) const
static void setInitMatrix(HepSymMatrix m)
double getSigma(int layerId, double driftDist) const
double getT0(void) const
static void setMdcCalibFunSvc(const MdcCalibFunSvc *calibsvc)
static int drifttime_choice_
the drifttime choice
Definition: KalFitTrack.h:321
static int tprop_
for signal propagation correction
Definition: KalFitTrack.h:277
double getDriftDist(KalFitHitMdc &hitmdc, double drifttime, int lr) const
static void setT0(double t0)
static void setMagneticFieldSvc(IMagneticFieldSvc *)
static void setIMdcGeomSvc(IMdcGeomSvc *igeomsvc)
Description of a Wire class.
Definition: KalFitWire.h:46
unsigned int geoID(void) const
Definition: KalFitWire.h:74
HepPoint3D bck(void) const
Definition: KalFitWire.h:93
HepPoint3D fwd(void) const
Geometry :
Definition: KalFitWire.h:92
const KalFitLayer_Mdc & layer(void) const
Definition: KalFitWire.h:70
HepPoint3D x(double dPhi=0.) const
returns position after rotating angle dPhi in phi direction.
double getSigma(int layid, int lr, double dist, double entrance=0.0, double tanlam=0.0, double z=0.0, double Q=1000.0) const
double getT0(int layid, int cellid) const
double driftTimeToDist(double drifttime, int layid, int cellid, int lr, double entrance=0.0) const
double getTimeWalk(int layid, double Q) const
static int wire(const Identifier &id)
Definition: MdcID.cxx:54
static double MdcTime(int timeChannel)
Definition: RawDataUtil.h:8
static double MdcCharge(int chargeChannel)
Definition: RawDataUtil.h:11
const double getZhit(void) const
Definition: RecMdcHit.h:55
const double getAdc(void) const
Definition: RecMdcHit.h:51
const Identifier getMdcId(void) const
Definition: RecMdcHit.h:49
const double getTdc(void) const
Definition: RecMdcHit.h:50
const double getDriftT(void) const
Definition: RecMdcHit.h:52
const double getEntra(void) const
Definition: RecMdcHit.h:54
double y[1000]