CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
CgemMdcFitAlg Class Reference

#include <CgemMdcFitAlg.h>

+ Inheritance diagram for CgemMdcFitAlg:

Public Types

enum  TrackType { lineType = 2 , circleType = 3 , helixType = 5 }
 

Public Member Functions

 CgemMdcFitAlg (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 
void updateTracks (int trackId, TrkRecoTrk *trkRecoTrk, RecMdcTrack *recMdcTrack, int trkStat)
 
void compareTracks (MdcTrackList &mdcTrackList, double dzCut)
 
TrkErrCode fit (RecMdcTrack *recMdcTrack, TrkRecoTrk *trkRecoTrk, TrackType trackType)
 
TrkErrCode check (TrkRecoTrk *trkRecoTrk, TrackType trackType)
 

Detailed Description

Definition at line 14 of file CgemMdcFitAlg.h.

Member Enumeration Documentation

◆ TrackType

Enumerator
lineType 
circleType 
helixType 

Definition at line 17 of file CgemMdcFitAlg.h.

Constructor & Destructor Documentation

◆ CgemMdcFitAlg()

CgemMdcFitAlg::CgemMdcFitAlg ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 60 of file CgemMdcFitAlg.cxx.

60 :
61 Algorithm(name, pSvcLocator)
62{
63 declareProperty("debug" ,m_debug = 0 );
64 declareProperty("tuple" ,m_tuple = 0 );
65 declareProperty("change" ,m_changeTDS = 2 );// 0:not change, 1:update, 2:replace
66 declareProperty("debugArbHit" ,m_debugArbHit= 0 );
67 declareProperty("fit2D" ,m_fit2D= 1 );
68 declareProperty("drCut" ,m_drCut= 1. );
69 declareProperty("dzCut" ,m_dzCut= 10. );
70 declareProperty("filter" ,m_filter= 0 );
71 declareProperty("eventFile" ,m_evtFile= "EventList" );
72 declareProperty("compareTrack" ,m_compareTrack= 0 );
73 declareProperty("removeBadTrack",m_removeBadTrack= 0 );
74}

Member Function Documentation

◆ check()

TrkErrCode CgemMdcFitAlg::check ( TrkRecoTrk trkRecoTrk,
TrackType  trackType 
)

Definition at line 563 of file CgemMdcFitAlg.cxx.

564{
565 m_qualityFactor=3;
566 m_dropTrkDrCut=1;
567 m_dropTrkDzCut=10;
568 if(trackType==circleType)m_dropTrkNhitCut=5;
569 if(trackType==helixType)m_dropTrkNhitCut=9;
570 m_dropTrkChi2Cut=99999;
571 m_dropTrkChi2NdfCut=99999;
572
573 TrkErrCode err;
574 int nActiveHit = trkRecoTrk->hots()->nActive();
575 TrkHitList* qhits = trkRecoTrk->hits();
576 const TrkFit* trkFit = trkRecoTrk->fitResult();
577 //if (!trkFit){cout<<"fit failed"<<endl;}
578 //else{cout<<"fit success"<<endl;}
579 //cout<<trkFit<<endl;
580 //TrkExchangePar par = trkFit->helix(0.);
581 int fit_stat=false;
582 double chi2=-999.;
583 if (!trkFit){
584 err.setFailure(12,"fit failed");
585 return err;
586 }else{
587 TrkExchangePar par = trkFit->helix(0.);
588 if( abs( 1/(par.omega()) )>0.03) {
589 fit_stat = 1;
590 chi2=trkFit->chisq();
591 }
592 else {
593 fit_stat = 0;
594 chi2=-999;
595 if(m_debug>0){
596 std::cout<<__FILE__<<" "<<__LINE__<<" drop track radius cut "<<abs(1/(par.omega()))<<" < "<<0.03 <<std::endl;
597 }
598 }
599
600 bool badQuality = false;
601 if(fabs(chi2)>m_qualityFactor*m_dropTrkChi2Cut ){
602 if(m_debug>0){
603 std::cout<<__FILE__<<" "<<__LINE__<<" drop track by chi2 "<<chi2<<" > "<<m_qualityFactor<<" * "<<m_dropTrkChi2Cut <<std::endl;
604 }
605 badQuality=1;
606 }
607 if( fabs(par.d0())>m_qualityFactor*m_dropTrkDrCut) {
608 if(m_debug>0){
609 std::cout<<__FILE__<<" "<<__LINE__<<" drop track by d0 "<<par.d0()<<" > "<<m_qualityFactor<<" * "<<m_dropTrkDrCut <<std::endl;
610 }
611 badQuality=1;
612 }
613 if( fabs(par.z0())>m_qualityFactor*m_dropTrkDzCut && trackType == helixType) {
614 if(m_debug>0){
615 std::cout<<__FILE__<<" "<<__LINE__<<" drop track by z0 "<<par.z0()<<" > "<<m_qualityFactor<<" * "<<m_dropTrkDzCut <<std::endl;
616 }
617 badQuality=1;
618 }
619 if( (fabs(chi2)/qhits->nHit()) > m_qualityFactor*m_dropTrkChi2NdfCut) {
620 if(m_debug>0){
621 std::cout<<__FILE__<<" "<<__LINE__<<" drop track by chi2/ndf "<<(fabs(chi2)/qhits->nHit()) <<" > "<<m_qualityFactor<<" * "<<m_dropTrkChi2NdfCut<<std::endl;
622 }
623 badQuality=1;
624 }
625 if( nActiveHit <= m_dropTrkNhitCut) {
626 if(m_debug>0){
627 std::cout<<__FILE__<<" "<<__LINE__<<" drop track by nhit "<<nActiveHit <<" <= "<<m_dropTrkNhitCut<<std::endl;
628 }
629 badQuality=1;
630 }
631 //badQuality = false; //not delete track in this stage
632 if( badQuality) fit_stat=0;
633 }
634 //if( fit_stat!=1 ){
635 //delete trkRecoTrk;
636 //vectrk_for_clean.pop_back();
637 //}
638 if( fit_stat==1 ){
639
640 if(m_debug>1){
641 TrkExchangePar par = trkFit->helix(0.);
642 double _d0=par.d0();
643 double _phi0=par.phi0();
644 double _omega=par.omega();
645 double _tanl=0;
646 double _z0=0;
647 if(trackType == helixType){
648 _tanl=par.tanDip();
649 _z0=par.z0();
650 }
651 //double _tanl=par.tanDip();
652 //double _z0=par.z0();
653 int _charge=trkFit->charge();
654 cout << " global 3d fit success"<<endl;
655 //cout<<__FILE__<<__LINE__<<"AFTER fit 3d "<<endl;
656 trkRecoTrk->print(std::cout);
657 double _circleR=_charge/par.omega();
658 double _circleX= sin(par.phi0()) *(par.d0()+1/par.omega()) * -1.; //z axis verse,x_babar = -x_belle
659 double _circleY= -1.*cos(par.phi0()) *(par.d0()+1/par.omega()) * -1;//???
660 double pxy=fabs(_circleR/333.567);
661 double pz=pxy*_tanl;
662 double pxyz=_charge*sqrt(pxy*pxy+pz*pz);
663 double _pt=pxy;
664 double _pz=pz;
665 double _p=pxyz;
666 cout<<" circle after globle 3d: "<<"("<<_circleX<<","<<_circleY<<","<<_circleR<<")"<<endl;
667 cout<<"pt_rec: "<<_pt<<endl;
668 cout<<"pz_rec: "<<_pz<<endl;
669 cout<<"p_rec: "<<_p<<endl;
670
671 int nfit3d=0;
672 cout<<" hot list:"<<endl;
673 TrkHotList::hot_iterator hotIter= qhits->hotList().begin();
674 int lay=((MdcHit*)(hotIter->hit()))->layernumber();
675 int wir=((MdcHit*)(hotIter->hit()))->wirenumber();
676 while (hotIter!=qhits->hotList().end()) {
677 if( typeid(*hotIter)==typeid(MdcRecoHitOnTrack) || typeid(*hotIter)==typeid(MdcHitOnTrack)){
678 cout <<"(" <<((MdcHit*)(hotIter->hit()))->layernumber()
679 <<","<<((MdcHit*)(hotIter->hit()))->wirenumber()
680 <<":"<<hotIter->isActive()<<") ";
681 }else if(typeid(*hotIter)==typeid(CgemHitOnTrack)){
682 const CgemHitOnTrack* recoHot = dynamic_cast<const CgemHitOnTrack*> (&(*hotIter));
683 const RecCgemCluster* recCgemCluster = recoHot->baseHit();
684 cout<<"(" <<recCgemCluster->getlayerid()
685 <<","<<recCgemCluster->getsheetid()
686 <<":"<<hotIter->isActive()<<") ";
687 //<<"clusterID:"<<recCgemCluster->getclusterid()
688 //<<" flag:"<<recCgemCluster->getflag()<<endl;
689 //hotIter++;
690 //continue;
691 }
692 // cout << "nuse "<<hotIter->hit()->nUsedHits()<<endl;
693 if (hotIter->isActive()==1) nfit3d++;
694 hotIter++;
695 }
696 double _nfit=nfit3d;
697 cout<<" in 3D fit number of Active hits : "<<_nfit<<endl;
698 }
699 err.setSuccess(11,"good track");
700 return err;
701 }else {
702 err.setFailure(12,"drop by cut");
703 return err;
704 }
705 //_chi2_aver=chi2/_nfit;
706 // for(int i=0;i<t_hitCol.size();i++){
707 // delete t_hitCol[i];
708 // }
709 //return fit_stat;
710
711}
double sin(const BesAngle a)
Definition: BesAngle.h:210
double cos(const BesAngle a)
Definition: BesAngle.h:213
double abs(const EvtComplex &c)
Definition: EvtComplex.hh:212
const RecCgemCluster * baseHit() const
Definition: MdcHit.h:44
int getlayerid(void) const
int getsheetid(void) const
virtual double chisq() const =0
virtual int charge() const =0
void setSuccess(int i, const char *str=0)
Definition: TrkErrCode.h:84
void setFailure(int i, const char *str=0)
Definition: TrkErrCode.h:79
double phi0() const
double omega() const
double z0() const
double d0() const
double tanDip() const
Definition: TrkFit.h:23
virtual TrkExchangePar helix(double fltL) const =0
unsigned nHit() const
Definition: TrkHitList.h:44
const TrkHotList & hotList() const
Definition: TrkHitList.cxx:51
hot_iterator end() const
Definition: TrkHotList.h:45
hot_iterator begin() const
Definition: TrkHotList.h:44
virtual int nActive(TrkEnums::TrkViewInfo view=TrkEnums::bothView) const =0
TrkHitList * hits()
Definition: TrkRecoTrk.h:107
TrkHotList * hots()
Definition: TrkRecoTrk.h:113
virtual void print(std::ostream &) const
Definition: TrkRecoTrk.cxx:166
const TrkFit * fitResult() const
Definition: TrkRecoTrk.cxx:387

Referenced by execute().

◆ compareTracks()

void CgemMdcFitAlg::compareTracks ( MdcTrackList mdcTrackList,
double  dzCut 
)

Definition at line 1185 of file CgemMdcFitAlg.cxx.

1185 {
1186 if(m_debug>1) cout<<"ntrack : "<<mdcTrackList.length()<<endl;
1187 for(int itrack=0; itrack<mdcTrackList.length(); itrack++){
1188 MdcTrack* track = mdcTrackList[itrack];
1189 TrkExchangePar par = track->track().fitResult()->helix(0.);
1190 int nhit = track->track().hots()->nHit();
1191 double pt = (1./par.omega())/333.567;
1192 if(m_debug>1) cout<<"i Track : "<<itrack<<" nHit: "<<nhit<<" pt: "<<pt<<endl;
1193 }
1194
1195 for(int itrack1=0; itrack1<mdcTrackList.length(); itrack1++){
1196 MdcTrack* track_1 = mdcTrackList[itrack1];
1197 TrkExchangePar par1 = track_1->track().fitResult()->helix(0.);
1198 int nhit1 = track_1->track().hots()->nHit();
1199 double d0_1 = par1.d0();
1200 double phi0_1 = par1.phi0();
1201 double omega_1 = par1.omega();
1202 double z0_1= par1.z0();
1203 double cr=fabs(1./par1.omega());
1204 double cx= sin(par1.phi0()) *(par1.d0()+1/par1.omega()) * -1.; //z axis verse,x_babar = -x_belle
1205 double cy= -1.*cos(par1.phi0()) *(par1.d0()+1/par1.omega()) * -1;//???
1206 if(m_debug>1) cout<<"circle 1 : "<<cr<<","<<cx<<","<<cy<<endl;
1207
1208 for(int itrack2=itrack1+1; itrack2<mdcTrackList.length(); itrack2++){
1209 MdcTrack* track_2 = mdcTrackList[itrack2];
1210 TrkExchangePar par2 = track_2->track().fitResult()->helix(0.);
1211 int nhit2 = track_2->track().hots()->nHit();
1212 double d0_2 = par2.d0();
1213 double phi0_2 = par2.phi0();
1214 double omega_2 = par2.omega();
1215 double z0_2= par2.z0();
1216 double cR=fabs(1./par2.omega());
1217 double cX= sin(par2.phi0()) *(par2.d0()+1/par2.omega()) * -1.; //z axis verse,x_babar = -x_belle
1218 double cY= -1.*cos(par2.phi0()) *(par2.d0()+1/par2.omega()) * -1;//???
1219 if(m_debug>1) cout<<"circle 2 : "<<cR<<","<<cX<<","<<cY<<endl;
1220
1221 double bestDiff = 1.0e+20;
1222 if(fabs(cr)*(1.-0.25) <= fabs(cR) && fabs(cR) <= fabs(cr)*(1.+0.25)){
1223 if(fabs(cx-cX) <= fabs(cr)*(0.25)&& fabs(cy-cY) <= fabs(cr)*(0.25) ){
1224 double diff = fabs((fabs(cr)-fabs(cR))*(cx-cX)*(cy-cY));
1225 if(diff < bestDiff){
1226 bestDiff = diff;
1227 }
1228 }
1229 }
1230
1231 double zdiff = z0_1-z0_2;
1232 if(bestDiff != 1.0e20 && fabs(zdiff)<25.){
1233 if(m_debug>1) cout<<"z0_1 : "<<z0_1<<" z0_2 : "<<z0_2<<endl;
1234 if( nhit1<nhit2 && (fabs(z0_1)>fabs(z0_2) && fabs(z0_1)>dzCut) ){ //FIXME
1235 if(m_debug>0) cout<<"remove track1 "<<1./par1.omega()/333.567<<endl;
1236 //remove 1
1237 mdcTrackList.remove( track_1 );
1238 itrack1--;
1239 break;
1240 }
1241 else{
1242 //remove 2
1243 if(m_debug>0) cout<<"remove track2 "<<1./par2.omega()/333.567<<endl;
1244 //remove 1
1245 mdcTrackList.remove( track_2 );
1246 itrack2--;
1247 }
1248 }
1249 if(bestDiff == 1.0e20) { if(m_debug>1) cout<<" no same track in hough"<<endl; }
1250 }
1251 }
1252}
void remove(MdcTrack *atrack)
TrkRecoTrk & track()
Definition: MdcTrack.h:27
virtual int nHit(TrkEnums::TrkViewInfo view=TrkEnums::bothView) const =0

Referenced by execute().

◆ execute()

StatusCode CgemMdcFitAlg::execute ( )

Definition at line 123 of file CgemMdcFitAlg.cxx.

124{
125//cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<endl;
126
127 MsgStream log(msgSvc(), name());
128 log << MSG::INFO << "In CgemMdcFitAlg execute()" << endreq;
129
130 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
131 if (!eventHeader) {
132 log << MSG::FATAL << "Could not find Event Header" << endreq;
133 return StatusCode::FAILURE;
134 }
135 int run = eventHeader->runNumber();
136 int evt = eventHeader->eventNumber();
137 SmartDataPtr<RecMdcTrackCol> recMdcTrackCol(eventSvc(), "/Event/Recon/RecMdcTrackCol");
138 if (!recMdcTrackCol){
139 log << MSG::WARNING << "Could not find RecMdcTrackCol" << endreq;
140 return StatusCode::SUCCESS;
141 }
142
143 SmartDataPtr<RecEsTimeCol> evTimeCol(eventSvc(),"/Event/Recon/RecEsTimeCol");
144 if (!evTimeCol) {
145 log << MSG::WARNING<< "Could not retrieve RecEsTimeCol" << endreq;
146 return StatusCode::SUCCESS;
147 }else{
148 RecEsTimeCol::iterator iter_evt = evTimeCol->begin();
149 if (iter_evt != evTimeCol->end()){
150 m_bunchT0 = (*iter_evt)->getTest()*1.e-9;//m_bunchT0-s, getTest-ns
151 }
152 }
153
154 SmartDataPtr<MdcDigiCol> mdcDigiCol(evtSvc(),"/Event/Digi/MdcDigiCol");
155 if (!mdcDigiCol) {
156 log << MSG::FATAL << "Could not find MdcDigiCol!" << endreq;
157 return StatusCode::SUCCESS;
158 }
159
160 if(m_filter){
161 ifstream lowPt_Evt;
162 lowPt_Evt.open(m_evtFile.c_str());
163 vector<int> evtlist;
164 int evtNum;
165 while( lowPt_Evt >> evtNum) {
166 evtlist.push_back(evtNum);
167 }
168 vector<int>::iterator iter_evt = find(evtlist.begin(),evtlist.end(),evt);
169 if( iter_evt == evtlist.end() ) { setFilterPassed(false); return StatusCode::SUCCESS; }
170 else setFilterPassed(true);
171 }
172
173 if(m_debug)cout<<endl;
174 if(m_debug)cout<<"run:"<<run<<" event:"<<evt<<endl;
175 if(m_tuple)getMcTruth();
176 if(m_debug)cout<<"tracks before fitting: "<<recMdcTrackCol->size()<<endl;
177 //if(recMdcTrackCol->size()==0)return StatusCode::SUCCESS;
178 if(m_tuple){
179 m_run = run;
180 m_event = evt;
181 m_nTrkRec = recMdcTrackCol->size();
182 }
183
184 for(RecMdcTrackCol::iterator itTrk = recMdcTrackCol->begin();itTrk != recMdcTrackCol->end();itTrk++)
185 {
186 HitRefVec vechits = (*itTrk)->getVecHits();
187 HitRefVec::iterator itHit = vechits.begin();
188 for( ; itHit != vechits.end(); itHit++)
189 {
190 double tdc = (*itHit)->getTdc();
191 double adc = (*itHit)->getAdc();
192 const Identifier mdcid = (*itHit)->getMdcId();
193 int layer = MdcID::layer(mdcid);
194 int wire = MdcID::wire(mdcid);
195 //cout<<"layer: "<<layer<<" wire: "<<wire<<" tdc: "<<tdc<<" adc: "<<adc<<endl;
196 MdcDigiCol::iterator iterDigi = mdcDigiCol->begin();
197 for(; iterDigi != mdcDigiCol->end(); iterDigi++ ) {
198 if((*iterDigi)->identify() == mdcid) break;
199 }
200 if(tdc==0)tdc = (*iterDigi)->getTimeChannel();
201 //cout<<" tdc= "<<(*iterDigi)->getTimeChannel()<<" adc= "<<(*iterDigi)->getChargeChannel()<<endl;
202
203 bool used = false;
204 vector<MdcHit*>::iterator imdcHit = mdcHitCol.begin();
205 for(;imdcHit != mdcHitCol.end();imdcHit++){
206 if((*imdcHit)->mdcId() == mdcid){
207 used = true;
208 //cout<<"layer: "<<layer<<" view: "<<mdcHit->layer()->view()<<" wire: "<<wire<<endl;
209 break;
210 }
211 }
212 if(used)continue;
213 //cout<<"layer: "<<layer<<" wire: "<<wire<<" tdc: "<<tdc<<" adc: "<<adc<<endl;
214 const MdcDigi *mdcDigi = new MdcDigi(mdcid,tdc,adc);
215 MdcHit *mdcHit = new MdcHit(mdcDigi,m_mdcDetector);
216 mdcHitCol.push_back(mdcHit);
217 }
218 }
219 //cout<<mdcHitCol.size()<<endl;
220 MdcTrackParams m_par;
221 if(m_debugArbHit>0 ) m_par.lPrint=8;
222 m_par.lRemoveInActive=1;
223 //m_par.lUseQualCuts=0;
224 //m_par.maxGapLength=99;
225 //m_par.maxChisq=99;
226 //m_par.minHits=99;
227 MdcTrackList mdcTrackList(m_par);
228
229 RecMdcTrackCol* trackList_tds;
230 RecMdcHitCol* hitList_tds;
231 //vector<MdcTrack*> vec_MdcTrack;
232 RecMdcTrackCol::iterator itTrk = recMdcTrackCol->begin();
233 for(int itrk=0;itTrk != recMdcTrackCol->end(); itrk++,itTrk++)
234 {
235/*
236 int trkId = (*itTrk)->trackId();
237 double dr = (*itTrk)->helix(0);
238 double phi0 = (*itTrk)->helix(1);
239 double kappa = (*itTrk)->helix(2);
240 double dz = (*itTrk)->helix(3);
241 double tanl = (*itTrk)->helix(4);
242 int chargeRec = (*itTrk)->charge() ;
243 int statRec = (*itTrk)->stat() ;
244 int nhitsRec = (*itTrk)->getNhits() ;
245 int nclusterRec = (*itTrk)->getNcluster() ;
246 int nsterRec = (*itTrk)->nster() ;
247 int ndofRec = (*itTrk)->ndof() ;
248 double chi2Rec = (*itTrk)->chi2() ;
249 double pxRec = (*itTrk)->px() ;
250 double pyRec = (*itTrk)->py() ;
251 double pzRec = (*itTrk)->pz() ;
252 double pxyRec = (*itTrk)->pxy() ;
253 double pRec = (*itTrk)->p() ;
254 double xRec = (*itTrk)->x() ;
255 double yRec = (*itTrk)->y() ;
256 double zRec = (*itTrk)->z() ;
257 double rRec = (*itTrk)->r() ;
258 double thetaRec = (*itTrk)->theta() ;
259 double phiRec = (*itTrk)->phi() ;
260 double fiTermRec = (*itTrk)->getFiTerm() ;
261 if(m_tuple){
262 m_trkidRec[itrk] = trkId;
263 m_drRec[itrk] = dr ;
264 m_phi0Rec[itrk] = phi0 ;
265 m_kappaRec[itrk] = kappa;
266 m_dzRec[itrk] = dz ;
267 m_tanlRec[itrk] = tanl ;
268 m_chargeRec[itrk] = chargeRec ;
269 m_statRec[itrk] = statRec ;
270 m_nhitsRec[itrk] = nhitsRec ;
271 m_nclusterRec[itrk]= nclusterRec;
272 m_nsterRec[itrk] = nsterRec ;
273 m_ndofRec[itrk] = ndofRec ;
274 m_chi2Rec[itrk] = chi2Rec ;
275 m_pxRec[itrk] = pxRec ;
276 m_pyRec[itrk] = pyRec ;
277 m_pzRec[itrk] = pzRec ;
278 m_pxyRec[itrk] = pxyRec ;
279 m_pRec[itrk] = pRec ;
280 m_xRec[itrk] = xRec ;
281 m_yRec[itrk] = yRec ;
282 m_zRec[itrk] = zRec ;
283 m_rRec[itrk] = rRec ;
284 m_thetaRec[itrk] = thetaRec ;
285 m_phiRec[itrk] = phiRec ;
286 m_fiTermRec[itrk] = fiTermRec ;
287 }
288*/
289 if(m_tuple){
290 m_trkidRec[itrk] = (*itTrk)->trackId();
291 m_drRec[itrk] = (*itTrk)->helix(0);
292 m_phi0Rec[itrk] = (*itTrk)->helix(1);
293 m_kappaRec[itrk] = (*itTrk)->helix(2);
294 m_dzRec[itrk] = (*itTrk)->helix(3);
295 m_tanlRec[itrk] = (*itTrk)->helix(4);
296 m_chargeRec[itrk] = (*itTrk)->charge() ;
297 m_statRec[itrk] = (*itTrk)->stat() ;
298 m_nhitsRec[itrk] = (*itTrk)->getNhits() ;
299 m_nclusterRec[itrk]= (*itTrk)->getNcluster() ;
300 m_nsterRec[itrk] = (*itTrk)->nster() ;
301 m_ndofRec[itrk] = (*itTrk)->ndof() ;
302 m_chi2Rec[itrk] = (*itTrk)->chi2() ;
303 m_pxRec[itrk] = (*itTrk)->px() ;
304 m_pyRec[itrk] = (*itTrk)->py() ;
305 m_pzRec[itrk] = (*itTrk)->pz() ;
306 m_pxyRec[itrk] = (*itTrk)->pxy() ;
307 m_pRec[itrk] = (*itTrk)->p() ;
308 m_xRec[itrk] = (*itTrk)->x() ;
309 m_yRec[itrk] = (*itTrk)->y() ;
310 m_zRec[itrk] = (*itTrk)->z() ;
311 m_rRec[itrk] = (*itTrk)->r() ;
312 m_thetaRec[itrk] = (*itTrk)->theta() ;
313 m_phiRec[itrk] = (*itTrk)->phi() ;
314 m_fiTermRec[itrk] = (*itTrk)->getFiTerm() ;
315 }
316
317 if(m_debug)cout<<"fitting track: "<<itrk<<endl;
318
319 //---make tracks
320 float chisum =0.;
321 bool permitFlips = true;
322 bool lPickHits = true;
323 int trkId = (*itTrk)->trackId();
324 double dr = (*itTrk)->helix(0);
325 double phi0 = (*itTrk)->helix(1);
326 double kappa = (*itTrk)->helix(2);
327 double dz = (*itTrk)->helix(3);
328 double tanl = (*itTrk)->helix(4);
329 if(m_debug)cout<<"helix parameters before fitting: "<<setw(12)<<dr<<" "<<setw(12)<<phi0<<" "<<setw(12)<<kappa<<" "<<setw(12)<<dz<<" "<<setw(12)<<tanl<<endl;
330
331 //TrkLineMaker linefactory;
332 //---fitting circle
333 if(m_fit2D){
334 TrkExchangePar circle(-dr,phi0+M_PI/2,kappa/333.567,0,0);
335
336 trackType = circleType;
337 TrkCircleMaker circlefactory;
338 TrkRecoTrk* circleTrk = circlefactory.makeTrack(circle, chisum, *m_context, m_bunchT0);
339 circlefactory.setFlipAndDrop(*circleTrk, permitFlips, lPickHits);
340 TrkErrCode fit_circle = fit((*itTrk), circleTrk, trackType);
341 TrkErrCode check_circle = check(circleTrk,trackType);
342 if (m_debug && fit_circle.failure()){cout<<"fit: "<<fit_circle<<endl;}//FIXME
343 if (m_debug && check_circle.failure()){cout<<"check: "<<check_circle<<endl;}//FIXME
344 if (fit_circle.failure() || check_circle.failure()){continue;}//FIXME
345
346 //---update initial fitting parameters of helix dr, phi0, kappa
347 TrkExchangePar par = circleTrk->fitResult()->helix(0.);
348 dr = -par.d0();
349 phi0 = par.phi0()-M_PI/2;
350 if(phi0<0)phi0+=2*M_PI;
351 kappa = par.omega()*333.567;
352 if(m_debug)cout<<"helix parameters after 2D fitting: "<<setw(12)<<dr<<" "<<setw(12)<<phi0<<" "<<setw(12)<<kappa<<" "<<setw(12)<<dz<<" "<<setw(12)<<tanl<<endl;
353 }
354
355 //--- fitting helix
356 TrkExchangePar helix(-dr,phi0+M_PI/2,kappa/333.567,dz,tanl);
357
358 trackType = helixType;
359 TrkHelixMaker helixfactory;
360 TrkRecoTrk* helixTrk = helixfactory.makeTrack(helix, chisum, *m_context, m_bunchT0);
361 //const TrkId id = helixTrk->id();
362 //cout<<"======================================================"<<long(id)<<endl;
363 helixfactory.setFlipAndDrop(*helixTrk, permitFlips, lPickHits);
364 TrkErrCode fit_helix = fit((*itTrk), helixTrk, trackType);
365 TrkErrCode check_helix = check(helixTrk,trackType);
366 if (m_debug && fit_helix.failure()){cout<<"fit: "<<fit_helix<<endl;}//FIXME
367 if (m_debug && check_helix.failure()){cout<<"check: "<<check_helix<<endl;}//FIXME
368 if (fit_helix.failure() || check_helix.failure()){continue;}//FIXME
369
370 TrkExchangePar par = helixTrk->fitResult()->helix(0.);
371 dr = -par.d0();
372 phi0 = par.phi0()-M_PI/2;
373 if(phi0<0)phi0+=2*M_PI;
374 kappa = par.omega()*333.567;
375 dz=par.z0();
376 tanl=par.tanDip();
377 if(m_debug)cout<<"helix parameters after fitting: "<<setw(12)<<dr<<" "<<setw(12)<<phi0<<" "<<setw(12)<<kappa<<" "<<setw(12)<<dz<<" "<<setw(12)<<tanl<<endl<<endl;
378
379 //RecMdcTrack* recMdcTrack = (*itTrk);
380 int trkStat = 5;//track fi by CgemMdcFitAlg set stat=5
381 if(m_changeTDS ==1)updateTracks(trkId,helixTrk,(*itTrk),trkStat);
382 //mdcTrack->storeTrack(trkId, trackList_tds, hitList_tds, trkStat);
383 //vec_MdcTrack.push_back(mdcTrack);
384 //trackList_tds->push_back(*itTrk);
385 //MdcTrack *mdcTrack ;
386 if(m_changeTDS ==2){
387 MdcTrack *mdcTrack = new MdcTrack(helixTrk);
388 //mdcTrack = new MdcTrack(helixTrk);
389 mdcTrackList.append(mdcTrack);
390 }
391
392 }
393
394 if(m_changeTDS ==2){
395 mdcTrackList.setNoInner(true);
396 if(m_removeBadTrack){
397 int nDeleted=mdcTrackList.arbitrateHits();//FIXME
398 if(m_debug>0 && nDeleted>0)cout<<nDeleted<<" tracks have been deleted by MdcTrackList..arbitrateHits()"<<endl;//FIXME
399 }
400 if(m_compareTrack>0)compareTracks(mdcTrackList, m_dzCut);
401 storeTracks(trackList_tds, hitList_tds,mdcTrackList);
402 }
403
404 if(m_tuple){
405 SmartDataPtr<RecMdcTrackCol> recMdcTrackCol(eventSvc(), "/Event/Recon/RecMdcTrackCol");
406 if (!recMdcTrackCol){
407 log << MSG::WARNING << "Could not find RecMdcTrackCol" << endreq;
408 return StatusCode::SUCCESS;
409 }
410 m_nTrkFit = recMdcTrackCol->size();
411 RecMdcTrackCol::iterator itTrk = recMdcTrackCol->begin();
412 for(int itrk=0;itTrk != recMdcTrackCol->end(); itrk++,itTrk++)
413 {
414 //RecMdcTrack* recMdcTrack = (*itTrk);
415 m_trkidFit[itrk] = (*itTrk)->trackId();
416 m_drFit[itrk] = (*itTrk)->helix(0);
417 m_phi0Fit[itrk] = (*itTrk)->helix(1);
418 m_kappaFit[itrk] = (*itTrk)->helix(2);
419 m_dzFit[itrk] = (*itTrk)->helix(3);
420 m_tanlFit[itrk] = (*itTrk)->helix(4);
421 m_chargeFit[itrk] = (*itTrk)->charge() ;
422 m_statFit[itrk] = (*itTrk)->stat() ;
423 m_nhitsFit[itrk] = (*itTrk)->getNhits() ;
424 m_nclusterFit[itrk]= (*itTrk)->getNcluster() ;
425 m_nsterFit[itrk] = (*itTrk)->nster() ;
426 m_ndofFit[itrk] = (*itTrk)->ndof() ;
427 m_chi2Fit[itrk] = (*itTrk)->chi2() ;
428 m_pxFit[itrk] = (*itTrk)->px() ;
429 m_pyFit[itrk] = (*itTrk)->py() ;
430 m_pzFit[itrk] = (*itTrk)->pz() ;
431 m_pxyFit[itrk] = (*itTrk)->pxy() ;
432 m_pFit[itrk] = (*itTrk)->p() ;
433 m_xFit[itrk] = (*itTrk)->x() ;
434 m_yFit[itrk] = (*itTrk)->y() ;
435 m_zFit[itrk] = (*itTrk)->z() ;
436 m_rFit[itrk] = (*itTrk)->r() ;
437 m_thetaFit[itrk] = (*itTrk)->theta() ;
438 m_phiFit[itrk] = (*itTrk)->phi() ;
439 m_fiTermFit[itrk] = (*itTrk)->getFiTerm() ;
440 }
441 }
442
443//cout<<"--------------------------------------------------------------------------------"<<endl;
444 if(m_tuple)ntuple_evt->write();
445 //if(m_debug)cout<<endl;
446 vector<MdcHit*>::iterator imdcHit = mdcHitCol.begin();
447 for(;imdcHit != mdcHitCol.end();imdcHit++){
448 delete (*imdcHit);
449 }
450 mdcHitCol.clear();
451 return StatusCode::SUCCESS;
452}
ObjectVector< RecMdcHit > RecMdcHitCol
Definition: RecMdcHit.h:99
ObjectVector< RecMdcTrack > RecMdcTrackCol
Definition: RecMdcTrack.h:102
SmartRefVector< RecMdcHit > HitRefVec
Definition: RecMdcTrack.h:26
IMessageSvc * msgSvc()
#define M_PI
Definition: TConstant.h:4
void updateTracks(int trackId, TrkRecoTrk *trkRecoTrk, RecMdcTrack *recMdcTrack, int trkStat)
void compareTracks(MdcTrackList &mdcTrackList, double dzCut)
TrkErrCode check(TrkRecoTrk *trkRecoTrk, TrackType trackType)
TrkErrCode fit(RecMdcTrack *recMdcTrack, TrkRecoTrk *trkRecoTrk, TrackType trackType)
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
int failure() const
Definition: TrkErrCode.h:61
bool setFlipAndDrop(TrkRecoTrk &, bool allowFlips, bool allowDrops) const
TrkRecoTrk * makeTrack(const TrkExchangePar &helix, const double chi2, const TrkContext &, double trackT0) const
std::ifstream ifstream
Definition: bpkt_streams.h:44

◆ finalize()

StatusCode CgemMdcFitAlg::finalize ( )

Definition at line 455 of file CgemMdcFitAlg.cxx.

456{
457 MsgStream log(msgSvc(), name());
458 log << MSG::INFO<< "In CgemMdcFitAlg finalize()" << endreq;
459 //delete m_bfield ;
460 return StatusCode::SUCCESS;
461}

◆ fit()

TrkErrCode CgemMdcFitAlg::fit ( RecMdcTrack recMdcTrack,
TrkRecoTrk trkRecoTrk,
TrackType  trackType 
)

Definition at line 463 of file CgemMdcFitAlg.cxx.

466{
467 //---make tracks
468 //double dr = recMdcTrack->helix(0);
469 //double phi0 = recMdcTrack->helix(1);
470 //double kappa = recMdcTrack->helix(2);
471 //double dz = recMdcTrack->helix(3);
472 //double tanl = recMdcTrack->helix(4);
473 //TrkHelixMaker trackfactory;
474 //TrkLineMaker trackfactory;
475 //TrkCircleMaker trackfactory;
476 //if(typeid(trackfactory)==typeid(TrkHelixMaker)){
477 //TrkExchangePar tt(-dr,phi0+M_PI/2,kappa/333.567,dz,tanl);
478 //}else if(typeid(trackfactory)==typeid(TrkCircleMaker)){
479 //TrkExchangePar tt(-dr,phi0+M_PI/2,kappa/333.567,0,0);
480 //}else if(typeid(trackfactory)==typeid(TrkLineMaker)){
481 //FIXME
482 //}else return TrkErrCode(TrkErrCode::fail);
483 //float chisum =0.;
484 //bool permitFlips = true;
485 //bool lPickHits = true;
486 //TrkExchangePar tt(-dr,phi0+M_PI/2,kappa/333.567,dz,tanl);
487 //trkRecoTrk = trackfactory.makeTrack(tt, chisum, *m_context, m_bunchT0);
488 //trackfactory.setFlipAndDrop(*trkRecoTrk, permitFlips, lPickHits);
489 TrkHitList* trkHitList = trkRecoTrk->hits();
490
491 //--- for ODC hits
492 double ddCut=1;
493 HitRefVec vechits = recMdcTrack->getVecHits();
494 HitRefVec::iterator itHit = vechits.begin();
495 for( ; itHit != vechits.end(); itHit++)
496 {
497 double flight = (*itHit)->getFltLen();
498 double tdc = (*itHit)->getTdc();
499 double adc = (*itHit)->getAdc();
500 const Identifier mdcid = (*itHit)->getMdcId();
501 int layer = MdcID::layer(mdcid);
502 int wire = MdcID::wire(mdcid);
503 MdcHit* mdcHit;
504 if(trackType == circleType){
505 vector<MdcHit*>::iterator imdcHit = mdcHitCol.begin();
506 for(;imdcHit != mdcHitCol.end();imdcHit++){
507 if((*imdcHit)->mdcId() == mdcid){
508 //mdcHit = *imdcHit;
509 tdc = (*imdcHit)->tdcIndex();
510 break;
511 }
512 }
513 const MdcDigi *mdcDigi = new MdcDigi(mdcid,tdc,adc);
514 mdcHit = new MdcHit(mdcDigi,m_mdcDetector);
515 }else if(trackType == helixType){
516 vector<MdcHit*>::iterator imdcHit = mdcHitCol.begin();
517 for(;imdcHit != mdcHitCol.end();imdcHit++){
518 if((*imdcHit)->mdcId() == mdcid){
519 mdcHit = *imdcHit;
520 break;
521 }
522 }
523 }else{
524 TrkErrCode err;
525 err.setFailure(10,"fit failed,track type error!");
526 return err;
527 }
528 //cout<<"layer: "<<layer<<" wire: "<<wire<<" tdc= "<<tdc<<" adc: "<<adc<<endl;
529
530 mdcHit->setCalibSvc(m_mdcCalibFunSvc);
531 mdcHit->setCountPropTime(true);
532
533 int newAmbig = 0;
534 MdcRecoHitOnTrack temp( *mdcHit, newAmbig, m_bunchT0*1.e9);
535 MdcHitOnTrack* newhot = &temp;
536 newhot->setFltLen( flight );
537 if(m_debug>1)cout<<"layer: "<<layer<<" view: "<<mdcHit->layer()->view()<<" wire: "<<wire<<endl;
538 if(mdcHit->driftTime(m_bunchT0,0)>1000)continue;
539 if(trackType==circleType && mdcHit->layer()->view())continue;
540 if(trackType==circleType && mdcHit->driftDist(m_bunchT0,0)>ddCut)continue;
541 trkHitList->appendHot(newhot);
542 //hitList_tds->push_back((*itHit));
543 }
544 //---for CGEM clusters
545 ClusterRefVec clusterRefVec = recMdcTrack->getVecClusters();
546 ClusterRefVec::iterator itCluster = clusterRefVec.begin();
547 for( ; itCluster != clusterRefVec.end(); itCluster++)
548 {
549 RecCgemCluster *recCgemCluster = *itCluster;
550 CgemHitOnTrack* newhot = new CgemHitOnTrack(*recCgemCluster,m_bunchT0*1.e9);
551 newhot->setCgemGeomSvc(m_cgemGeomSvc);
552 newhot->setCgemCalibFunSvc(m_cgemCalibFunSvc);
553 trkHitList->appendHot(newhot);
554 if(m_debug>1)cout<<"layer: "<<recCgemCluster->getlayerid()<<" flag: "<<recCgemCluster->getflag()<<" clusterId: "<<recCgemCluster->getclusterid()<<endl;
555 }
556
557 //---fitting
558 TrkHitList* qhits = trkRecoTrk->hits();
559 TrkErrCode err=qhits->fit();
560 return err;
561}
SmartRefVector< RecCgemCluster > ClusterRefVec
Definition: RecMdcTrack.h:28
void setCgemCalibFunSvc(const CgemCalibFunSvc *svc)
void setCgemGeomSvc(const CgemGeomSvc *svc)
void setCalibSvc(const MdcCalibFunSvc *calibSvc)
Definition: MdcHit.cxx:136
double driftTime(double tof, double z) const
Definition: MdcHit.cxx:142
void setCountPropTime(const bool count)
Definition: MdcHit.h:86
double driftDist(double, int, double, double, double) const
Definition: MdcHit.cxx:156
const MdcLayer * layer() const
Definition: MdcHit.h:56
int view(void) const
Definition: MdcLayer.h:28
int getclusterid(void) const
int getflag(void) const
const HitRefVec getVecHits(void) const
Definition: RecMdcTrack.h:67
const ClusterRefVec getVecClusters() const
Definition: RecMdcTrack.h:70
TrkErrCode fit()
Definition: TrkHitList.cxx:59
TrkHitOnTrk * appendHot(const TrkHitOnTrk *theHot)
Definition: TrkHitList.cxx:91
void setFltLen(double f)
Definition: TrkHitOnTrk.h:147

Referenced by execute().

◆ initialize()

StatusCode CgemMdcFitAlg::initialize ( )

Definition at line 76 of file CgemMdcFitAlg.cxx.

77{
78 MsgStream log(msgSvc(), name());
79 log << MSG::INFO << "In CgemMdcFitAlg initialize()" << endreq;
80
81 StatusCode sc;
82
84 sc = service ("MagneticFieldSvc",pIMF);
85 if(sc!=StatusCode::SUCCESS) {
86 log << MSG::ERROR << "Unable to open Magnetic field service"<<endreq;
87 }
88 BField* bfield = new BField(pIMF);
89 log << MSG::INFO << "field z = "<<bfield->bFieldNominal()<< endreq;
90 m_context = new TrkContextEv(bfield);
91
92 IMdcCalibFunSvc* imdcCalibSvc;
93 sc = service ("MdcCalibFunSvc", imdcCalibSvc);
94 m_mdcCalibFunSvc = dynamic_cast<MdcCalibFunSvc*>(imdcCalibSvc);
95 if ( sc.isFailure() ){
96 log << MSG::FATAL << "Could not load MdcCalibFunSvc!" << endreq;
97 return StatusCode::FAILURE;
98 }
99
100 ICgemCalibFunSvc* icgemCalibSvc;
101 sc = service ("CgemCalibFunSvc", icgemCalibSvc);
102 m_cgemCalibFunSvc = dynamic_cast<CgemCalibFunSvc*>(icgemCalibSvc);
103 if ( sc.isFailure() ){
104 log << MSG::FATAL << "Could not load CgemCalibFunSvc!" << endreq;
105 return StatusCode::FAILURE;
106 }
107
108 ICgemGeomSvc* icgemGeomSvc;
109 sc = service ("CgemGeomSvc",icgemGeomSvc);
110 m_cgemGeomSvc = dynamic_cast<CgemGeomSvc*>(icgemGeomSvc);
111 if ( sc.isFailure() ){
112 log << MSG::FATAL << "Could not load CgemGeomSvc!" << endreq;
113 return StatusCode::FAILURE;
114 }
115
116 m_mdcDetector = new MdcDetector();
117 if(m_tuple) sc = bookTuple();
118
119 return StatusCode::SUCCESS;
120}

◆ updateTracks()

void CgemMdcFitAlg::updateTracks ( int  trackId,
TrkRecoTrk trkRecoTrk,
RecMdcTrack recMdcTrack,
int  trkStat 
)

Definition at line 771 of file CgemMdcFitAlg.cxx.

771 {
772
773 //get the results of the fit to this track
774 const TrkFit* fitresult = trkRecoTrk->fitResult();
775 //check the fit worked
776 if (fitresult == 0) return;
777
778 //new a Rec. Track MdcTrack
779 //RecMdcTrack* recMdcTrack = new RecMdcTrack();
780 const TrkHitList* aList = trkRecoTrk->hits();
781 //some track info
782 const BField& theField = trkRecoTrk->bField();
783 double Bz = theField.bFieldZ();
784 //Fit info
785 int hitId = 0;
786 int nHits=0;
787 int nSt=0;
788 //int nAct=0; int nSeg=0;
789 //int maxlay = 0; int minlay = 43; int seg[11];/* 11 slayer */ int segme;
790 //****************************
791 //* active flag open this
792 //****************************
793 //* if (allHit>0){
794 //* nHits = aList->nHit();//add inActive hit also
795 //* }else{
796 //* nHits = fitresult->nMdc();// = nActive()
797 //* }
798 //****************************
799 //for 5.1.0 use all hits
800 nHits = aList->nHit();
801 //****************************
802 // use active only
803 // nHits = fitresult->nMdc();// = nActive()
804 //****************************
805
806 int q = fitresult->charge();
807 double chisq = fitresult->chisq();
808 int nDof = fitresult->nDof();
809 //track parameters at closest approach to beamline
810 double fltLenPoca = 0.0;
811 TrkExchangePar helix = fitresult->helix(fltLenPoca);
812 //std::cout<< __FILE__ << " phi0 " << helix.phi0() << " omega " <<helix.omega()<<std::endl;
813 double phi0 = helix.phi0();
814 double tanDip = helix.tanDip();
815 //double z0 = helix.z0();
816 double d0 = helix.d0();
817 //momenta and position
818 //CLHEP::Hep3Vector mom = fitresult->momentum(fltLenPoca);
819 HepPoint3D poca = fitresult->position(fltLenPoca);
820
821 double helixPar[5];
822 //dro =-d0
823 helixPar[0] = -d0;
824 //phi0 = phi0 - pi/2 [0,2pi)
825 double tphi0 = phi0 - Constants::pi/2.;
826 if (tphi0 < 0. ) tphi0 += Constants::pi * 2.;
827 helixPar[1] = tphi0;
828 //kappa = q/pxy
829 double pxy = fitresult->pt();
830 if (pxy == 0.) helixPar[2] = 9999.;
831 else helixPar[2] = q/fabs(pxy);
832 if(pxy>9999.) helixPar[2] = 0.00001;
833 //dz = z0
834 helixPar[3] = helix.z0();
835 //tanl
836 helixPar[4] = tanDip;
837 //error
838 //V(Y)=S * V(X) * ST , mS = S , mVy = V(Y) , helix.covariance() = V(X)
839 HepSymMatrix mS(helix.params().num_row(),0);
840 mS[0][0]=-1.;//dr0=-d0
841 mS[1][1]=1.;
842 mS[2][2]=-333.567/Bz;//pxy -> cpa
843 mS[3][3]=1.;
844 mS[4][4]=1.;
845 HepSymMatrix mVy = helix.covariance().similarity(mS);
846 double errorMat[15];
847 int k = 0;
848 for (int ie = 0 ; ie < 5 ; ie ++){
849 for (int je = ie ; je < 5 ; je ++) {
850 errorMat[k] = mVy[ie][je];
851 k++;
852 }
853 }
854 double p,px,py,pz;
855 px = pxy * (-sin(helixPar[1]));
856 py = pxy * cos(helixPar[1]);
857 pz = pxy * helixPar[4];
858 p = sqrt(pxy*pxy + pz*pz);
859 //theta, phi
860 double theta = acos(pz/p);
861 double phi = atan2(py,px);
862 recMdcTrack->setTrackId(trackId);
863 recMdcTrack->setHelix(helixPar);
864 recMdcTrack->setCharge(q);
865 recMdcTrack->setPxy(pxy);
866 recMdcTrack->setPx(px);
867 recMdcTrack->setPy(py);
868 recMdcTrack->setPz(pz);
869 recMdcTrack->setP(p);
870 recMdcTrack->setTheta(theta);
871 recMdcTrack->setPhi(phi);
872 recMdcTrack->setPoca(poca);
873 recMdcTrack->setX(poca.x());//poca
874 recMdcTrack->setY(poca.y());
875 recMdcTrack->setZ(poca.z());
876 recMdcTrack->setR(sqrt(poca.x()*poca.x() + poca.y()*poca.y()));
877 HepPoint3D pivot(0.,0.,0.);
878 recMdcTrack->setPivot(pivot);
879 recMdcTrack->setVX0(0.);//pivot
880 recMdcTrack->setVY0(0.);
881 recMdcTrack->setVZ0(0.);
882 recMdcTrack->setError(errorMat);
883 recMdcTrack->setError(mVy);
884 recMdcTrack->setChi2(chisq);
885 recMdcTrack->setNdof(nDof);
886 recMdcTrack->setStat(tkStat);
887 recMdcTrack->setNhits(nHits);
888 //-----------hit list-------------
889 HitRefVec hitRefVec;
890 ClusterRefVec clusterRefVec;
891 //vector<const RecCgemCluster*> clusterCol;
892 vector<int> vecHits;
893 //for fiterm
894 int maxLayerId = -1;
895 int minLayerId = 43;
896 double fiTerm = 999.;
897 const MdcRecoHitOnTrack* fiTermHot = NULL;
898 TrkHitList::hot_iterator hot = aList->begin();
899 for (;hot!=aList->end();hot++){
900 //cout<<__FILE__ <<" "<<__LINE__ <<" "<< typeid(*hot).name()<<endl;
901 if(typeid(*hot)==typeid(MdcRecoHitOnTrack) || typeid(*hot)==typeid(MdcHitOnTrack) /*|| typeid(*hot)==typeid(TrkHitOnTrk)*/ ){
902 const MdcRecoHitOnTrack* recoHot;
903 recoHot = dynamic_cast<const MdcRecoHitOnTrack*> (&(*hot));
904 bool findhit = false;
905 RecMdcHit* recMdcHit;
906 Identifier mdcId = recoHot->mdcHit()->digi()->identify();
907 HitRefVec vechits = recMdcTrack->getVecHits();
908 HitRefVec::iterator itHit = vechits.begin();
909 for( ; itHit != vechits.end(); itHit++)
910 {
911 Identifier mdcid = (*itHit)->getMdcId();
912 if(mdcid == mdcId){
913 recMdcHit = (*itHit);
914 findhit = true;
915 break;
916 }
917 }
918 if(!findhit)continue;
919 //if (!recoHot->mdcHit()) return;
920 //id
921 recMdcHit->setId(hitId);
922 //---------BESIII----------
923 //phiWire - phiHit <0 flagLR=0 left driftleft<0 ;
924 //phiWire - phiHit >0 flagLR=1 right driftright>0;
925 //flag = 2 ambig;
926 //-----Babar wireAmbig----
927 //-1 -> right, 0 -> don't know, +1 -> left
928 //+1 phiWire-phiHit<0 Left,
929 //-1 phiWire-phiHit>0 Right,
930 //0 don't know
931 //ambig() w.r.t track direction
932 //wireAmbig() w.r.t. wire location
933 double hotWireAmbig = recoHot->wireAmbig();
934 double driftDist = fabs(recoHot->drift());
935 double sigma = recoHot->hitRms();
936 double doca = fabs(recoHot->dcaToWire());
937 int flagLR=2;
938 if ( hotWireAmbig == 1){
939 flagLR = 0; //left driftDist <0
940 doca *= -1.;//2012-07-19
941 }else if( hotWireAmbig == -1){
942 flagLR = 1; //right driftDist >0
943 }else if( hotWireAmbig == 0){
944 flagLR = 2; //don't know
945 }
946 recMdcHit->setFlagLR(flagLR);
947 recMdcHit->setDriftDistLeft((-1)*driftDist);
948 recMdcHit->setErrDriftDistLeft(sigma);
949 recMdcHit->setDriftDistRight(driftDist);
950 recMdcHit->setErrDriftDistRight(sigma);
951 //Mdc Id
952 recMdcHit->setMdcId(mdcId);
953 //corrected ADC
954
955 //contribution to chisquare
956 //fill chisq
957 double res=999.,rese=999.;
958 if (recoHot->resid(res,rese,false)){
959 }else{}
960 double deltaChi=0;
961 recoHot->getFitStuff(deltaChi);//yzhang open 2010-09-20
962 recMdcHit->setChisqAdd( deltaChi * deltaChi );
963 //set tracks containing this hit
964 recMdcHit->setTrkId(trackId);
965 //doca
966 recMdcHit->setDoca(doca);//doca sign left<0
967 //entrance angle
968
969 recMdcHit->setEntra(recoHot->entranceAngle());
970 //z of hit
971 HepPoint3D pos; Hep3Vector dir;
972 double fltLen = recoHot->fltLen();
973 recMdcHit->setFltLen(fltLen);
974 recoHot->getParentRep()->traj().getInfo(fltLen,pos,dir);
975 recMdcHit->setZhit(pos.z());
976 double tof = recoHot->getParentRep()->arrivalTime(fltLen);
977 recMdcHit->setTdc(recoHot->mdcHit()->tdcIndex());
978 recMdcHit->setAdc(recoHot->mdcHit()->adcIndex());
979 //drift time
980 recMdcHit->setDriftT(recoHot->mdcHit()->driftTime(tof,pos.z()));
981 //for fiterm
982 int layerId = recoHot->mdcHit()->layernumber();
983 int wireId = recoHot->mdcHit()->wirenumber();
984 //std::cout<<" MdcTrack::store() ("<<layerId<<","<<wireId<<") fltLen "<<fltLen<<" wireAmbig "<<hotWireAmbig<<" y "<<pos.y()<<std::endl;
985 // <<recoHot->entranceAngle()<<std::endl;
986 if (layerId >= maxLayerId){
987 maxLayerId = layerId;
988 fiTermHot = recoHot;
989 }
990 if (layerId < minLayerId){
991 minLayerId = layerId;
992 }
993 // status flag
994 if (recoHot->isActive()) {
995 recMdcHit->setStat(1);
996 }else{
997 recMdcHit->setStat(0);
998 }
999 // for 5.1.0 use all hits
1000 if (recoHot->layer()->view()) {
1001 ++nSt;
1002 }
1003 //hitList->push_back(recMdcHit);
1004 SmartRef<RecMdcHit> refHit(recMdcHit);
1005 hitRefVec.push_back(refHit);
1006 vecHits.push_back(mdcId.get_value());
1007 ++hitId;
1008 }else if(typeid(*hot)==typeid(CgemHitOnTrack)){
1009 const CgemHitOnTrack* recoHot = dynamic_cast<const CgemHitOnTrack*> (&(*hot));
1010 const RecCgemCluster* recCgemCluster = recoHot->baseHit();
1011 //cout<<"clusterid:"<< recCgemCluster->getclusterid()<<" layer:"<<recCgemCluster->getlayerid()<<endl;
1012 clusterRefVec.push_back(recCgemCluster);
1013 //clusterCol.push_back(recCgemCluster);
1014 }
1015 }
1016 std::sort(clusterRefVec.begin(),clusterRefVec.end(),sortCluster);
1017 //std::sort(clusterCol.begin(),clusterCol.end(),sortCluster);
1018 //fi terminal angle
1019 if (fiTermHot!=NULL){
1020 fiTerm=(1./sqrt(1.+tanDip*tanDip))*fiTermHot->fltLen()*helix.omega();
1021 }
1022 recMdcTrack->setFiTerm(fiTerm);
1023 // number of stereo hits contained
1024 recMdcTrack->setNster(nSt);
1025 recMdcTrack->setFirstLayer(maxLayerId);
1026 recMdcTrack->setLastLayer(minLayerId);
1027 recMdcTrack->setVecHits(hitRefVec);
1028 recMdcTrack->setVecClusters(clusterRefVec);
1029 recMdcTrack->setNcluster(clusterRefVec.size());
1030 //trackList->push_back(recMdcTrack);
1031
1032 //cout<<__FILE__ <<" "<<__LINE__ << endl;
1033 //for(int i=0;i<clusterRefVec.size();i++)
1034 //{
1035 //cout<<clusterRefVec[i]->getlayerid()<<endl;
1036 //}
1037 //hot = aList->begin();
1038 //for (;hot!=aList->end();hot++){
1039 //if(typeid(*hot)==typeid(MdcRecoHitOnTrack) || typeid(*hot)==typeid(MdcHitOnTrack) /*|| typeid(*hot)==typeid(TrkHitOnTrk)*/ ){
1040 //const MdcRecoHitOnTrack* recoHot;
1041 //recoHot = dynamic_cast<const MdcRecoHitOnTrack*> (&(*hot));
1042 //int layerId = recoHot->mdcHit()->layernumber();
1043 //int wireId = recoHot->mdcHit()->wirenumber();
1044 //cout<<"hit ("<<layerId<<","<<wireId<<")"<<endl;
1045 //}else if(typeid(*hot)==typeid(CgemHitOnTrack)){
1046 //const CgemHitOnTrack* recoHot = dynamic_cast<const CgemHitOnTrack*> (&(*hot));
1047 //const RecCgemCluster* recCgemCluster = recoHot->baseHit();
1048 //cout<<"hit ("<<recCgemCluster->getlayerid()<<","<<recCgemCluster->getclusterid()<<")"<<endl;
1049 //clusterRefVec.push_back(recCgemCluster);
1050 //}
1051 //}
1052}//end of storeTrack
bool sortCluster(const RecCgemCluster *clusterA, const RecCgemCluster *clusterB)
****INTEGER imax DOUBLE PRECISION m_pi *DOUBLE PRECISION m_amfin DOUBLE PRECISION m_Chfin DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_sinw2 DOUBLE PRECISION m_GFermi DOUBLE PRECISION m_MfinMin DOUBLE PRECISION m_ta2 INTEGER m_out INTEGER m_KeyFSR INTEGER m_KeyQCD *COMMON c_Semalib $ !copy of input $ !CMS energy $ !beam mass $ !final mass $ !beam charge $ !final charge $ !smallest final mass $ !Z mass $ !Z width $ !EW mixing angle $ !Gmu Fermi $ alphaQED at q
Definition: KKsem.h:33
static const double pi
Definition: Constants.h:38
void setFirstLayer(const int id)
Definition: DstMdcTrack.h:101
void setPxy(const double pxy)
Definition: DstMdcTrack.h:86
void setTrackId(const int trackId)
Definition: DstMdcTrack.h:84
void setPy(const double py)
Definition: DstMdcTrack.h:88
void setZ(const double z)
Definition: DstMdcTrack.h:95
void setNster(const int ns)
Definition: DstMdcTrack.h:100
void setX(const double x)
Definition: DstMdcTrack.h:93
void setError(double err[15])
void setNdof(const int ndof)
Definition: DstMdcTrack.h:99
void setTheta(const double theta)
Definition: DstMdcTrack.h:91
void setStat(const int stat)
Definition: DstMdcTrack.h:97
void setP(const double p)
Definition: DstMdcTrack.h:90
void setHelix(double helix[5])
void setPoca(double poca[3])
void setR(const double r)
Definition: DstMdcTrack.h:96
void setCharge(const int charge)
Definition: DstMdcTrack.h:85
void setLastLayer(const int id)
Definition: DstMdcTrack.h:102
void setY(const double y)
Definition: DstMdcTrack.h:94
void setChi2(const double chi)
Definition: DstMdcTrack.h:98
void setPhi(const double phi)
Definition: DstMdcTrack.h:92
void setPz(const double pz)
Definition: DstMdcTrack.h:89
void setPx(const double px)
Definition: DstMdcTrack.h:87
value_type get_value() const
Definition: Identifier.h:163
int wireAmbig() const
double dcaToWire() const
double drift() const
Definition: MdcHitOnTrack.h:75
double entranceAngle() const
const MdcLayer * layer() const
const MdcDigi * digi() const
Definition: MdcHit.h:55
unsigned layernumber() const
Definition: MdcHit.h:61
unsigned wirenumber() const
Definition: MdcHit.h:62
unsigned adcIndex() const
Definition: MdcHit.h:64
unsigned tdcIndex() const
Definition: MdcHit.h:63
const MdcHit * mdcHit() const
virtual Identifier identify() const
Definition: RawData.cxx:15
void setMdcId(Identifier mdcid)
Definition: RecMdcHit.h:67
void setErrDriftDistRight(double erddr)
Definition: RecMdcHit.h:63
void setFltLen(double fltLen)
Definition: RecMdcHit.h:74
void setErrDriftDistLeft(double erddl)
Definition: RecMdcHit.h:62
void setDriftDistLeft(double ddl)
Definition: RecMdcHit.h:60
void setDoca(double doca)
Definition: RecMdcHit.h:71
void setStat(int stat)
Definition: RecMdcHit.h:66
void setTdc(double tdc)
Definition: RecMdcHit.h:68
void setAdc(double adc)
Definition: RecMdcHit.h:69
void setFlagLR(int lr)
Definition: RecMdcHit.h:65
void setChisqAdd(double pChisq)
Definition: RecMdcHit.h:64
void setZhit(double zhit)
Definition: RecMdcHit.h:73
void setDriftT(double driftT)
Definition: RecMdcHit.h:70
void setDriftDistRight(double ddr)
Definition: RecMdcHit.h:61
void setTrkId(int trkid)
Definition: RecMdcHit.h:59
void setId(int id)
Definition: RecMdcHit.h:58
void setEntra(double entra)
Definition: RecMdcHit.h:72
void setVecClusters(ClusterRefVec vecclusters)
Definition: RecMdcTrack.cxx:86
void setPivot(const HepPoint3D &pivot)
Definition: RecMdcTrack.h:79
void setVZ0(double z0)
Definition: RecMdcTrack.h:76
void setVY0(double y0)
Definition: RecMdcTrack.h:75
void setVecHits(HitRefVec vechits)
Definition: RecMdcTrack.cxx:80
void setNhits(int nhits)
Definition: RecMdcTrack.h:78
void setFiTerm(double fiterm)
Definition: RecMdcTrack.h:77
void setNcluster(int ncluster)
Definition: RecMdcTrack.h:83
void setVX0(double x0)
Definition: RecMdcTrack.h:74
virtual void getInfo(double fltLen, HepPoint3D &pos, Hep3Vector &direction) const =0
virtual double pt(double fltL=0.) const =0
virtual int nDof() const =0
virtual const TrkDifTraj & traj() const =0
virtual HepPoint3D position(double fltL) const =0
const HepVector & params() const
const HepSymMatrix & covariance() const
hot_iterator begin() const
Definition: TrkHitList.h:45
hot_iterator end() const
Definition: TrkHitList.h:46
double fltLen() const
Definition: TrkHitOnTrk.h:91
double resid(bool exclude=false) const
double hitRms() const
Definition: TrkHitOnTrk.h:89
const TrkRep * getParentRep() const
Definition: TrkHitOnTrk.h:73
bool isActive() const
Definition: TrkHitOnTrk.h:200
TrkErrCode getFitStuff(HepVector &derivs, double &deltaChi) const
const BField & bField() const
Definition: TrkRecoTrk.h:82
virtual double arrivalTime(double fltL) const
Definition: TrkRep.cxx:192

Referenced by execute().


The documentation for this class was generated from the following files: