BOSS 7.0.3
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcHoughFinder Class Reference

#include <Hough.h>

+ Inheritance diagram for MdcHoughFinder:

Public Member Functions

 MdcHoughFinder (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 
StatusCode beginRun ()
 
StatusCode bookTuple ()
 
 MdcHoughFinder (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 
StatusCode beginRun ()
 
StatusCode bookTuple ()
 

Detailed Description

Constructor & Destructor Documentation

◆ MdcHoughFinder() [1/2]

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

Definition at line 76 of file Hough.cxx.

76 :
77 Algorithm(name, pSvcLocator)
78{
79 // Declare the properties
80 declareProperty("debug", m_debug = 0);
81 declareProperty("debugMap", m_debugMap = 0);
82 declareProperty("debug2D", m_debug2D = 0);
83 declareProperty("debugTrack", m_debugTrack = 0);
84 declareProperty("debugStereo", m_debugStereo= 0);
85 declareProperty("debugZs", m_debugZs= 0);
86 declareProperty("debug3D", m_debug3D= 0);
87 declareProperty("debugArbHit", m_debugArbHit= 0);
88 declareProperty("hist", m_hist = 1);
89 declareProperty("filter", m_filter= 0);
90 //read raw data setup
91 declareProperty("keepBadTdc", m_keepBadTdc = 0);
92 declareProperty("dropHot", m_dropHot= 0);
93 declareProperty("keepUnmatch", m_keepUnmatch = 0);
94 // combine pattsf
95 declareProperty("combineTracking",m_combineTracking = false);
96 declareProperty("removeBadTrack", m_removeBadTrack = 0);
97 declareProperty("dropTrkDrCut", m_dropTrkDrCut= 1.);
98 declareProperty("dropTrkDzCut", m_dropTrkDzCut= 10.);
99 declareProperty("dropTrkPtCut", m_dropTrkPtCut= 0.12);
100 declareProperty("dropTrkChi2Cut", m_dropTrkChi2Cut = 10000.);
101 //input setup
102 declareProperty("inputType", m_inputType = 0);
103 //set MdcHoughFinder map
104 declareProperty("mapCharge", m_mapCharge= -1); //0 use whole ; 1 only half
105 declareProperty("useHalf", m_useHalf= 0); //0 use whole ; 1 only half
106 declareProperty("mapHitStyle", m_mapHit= 0); //0 : all ; 1 :axial
107 declareProperty("nbinTheta", m_nBinTheta = 100);
108 declareProperty("nbinRho", m_nBinRho = 100);
109 declareProperty("rhoRange", m_rhoRange = 0.1);
110 declareProperty("peakWidth", m_peakWidth= 3);
111 declareProperty("peakHigh", m_peakHigh= 1);
112 declareProperty("hitPro", m_hitPro= 0.4);
113
114 declareProperty("recpos", m_recpos= 1);
115 declareProperty("recneg", m_recneg= 1);
116 declareProperty("combineSelf", m_combine= 1);
117 declareProperty("z0CutCompareHough", m_z0Cut_compareHough= 10);
118
119 //split drift circle
120 declareProperty("n1", m_npart= 100);
121 declareProperty("n2", m_n2= 16);
122
123 declareProperty("d1", m_d1= 0.2);
124 declareProperty("d2", m_d2= 0.2);
125
126 declareProperty("pdtFile", m_pdtFile = "pdt.table");
127 declareProperty("eventFile", m_evtFile= "EventList");
128
129}

◆ MdcHoughFinder() [2/2]

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

Member Function Documentation

◆ beginRun() [1/2]

StatusCode MdcHoughFinder::beginRun ( )

Definition at line 131 of file Hough.cxx.

131 {
132 //Initailize MdcDetector
134 if(NULL == Global::m_gm) return StatusCode::FAILURE;
135
136 return StatusCode::SUCCESS;
137}
static MdcDetector * instance()
Definition: MdcDetector.cxx:21

◆ beginRun() [2/2]

StatusCode MdcHoughFinder::beginRun ( )

◆ bookTuple() [1/2]

StatusCode MdcHoughFinder::bookTuple ( )

Definition at line 1333 of file Hough.cxx.

1333 {
1334 MsgStream log(msgSvc(), name());
1335 NTuplePtr nt1(ntupleSvc(), "MdcHoughFinder/evt");
1336 if ( nt1 ){
1337 ntuple_evt = nt1;
1338 } else {
1339 ntuple_evt = ntupleSvc()->book("MdcHoughFinder/evt", CLID_ColumnWiseTuple, "evt");
1340 if(ntuple_evt){
1341 ntuple_evt->addItem("eventNum", m_eventNum);
1342 ntuple_evt->addItem("runNum", m_runNum);
1343
1344 ntuple_evt->addItem("nHit", m_nHit,0, 6796);
1345
1346 //ntuple_evt->addItem("layer", m_nHit, m_layer);
1347 //ntuple_evt->addItem("cell", m_nHit, m_cell);
1348 //ntuple_evt->addItem("x", m_nHit, m_x);
1349 //ntuple_evt->addItem("y", m_nHit, m_y);
1350 //ntuple_evt->addItem("u", m_nHit, m_u);
1351 //ntuple_evt->addItem("v", m_nHit, m_v);
1352 //ntuple_evt->addItem("drift", m_nHit, m_drift);
1353 //ntuple_evt->addItem("r", m_nHit, m_r);
1354
1355 //ntuple_evt->addItem("uTruth", m_nHit, m_uTruth);
1356 //ntuple_evt->addItem("vTruth", m_nHit, m_vTruth);
1357 //ntuple_evt->addItem("xTruth", m_nHit, m_xTruth);
1358 //ntuple_evt->addItem("yTruth", m_nHit, m_yTruth);
1359 //ntuple_evt->addItem("driftTruth", m_nHit, m_driftTruth);
1360 //ntuple_evt->addItem("rTruth", m_nHit, m_rTruth);
1361 //ntuple_evt->addItem("type", m_nHit, m_type);
1362
1363 //ntuple_evt->addItem("deltaD", m_nHit, m_deltaD);
1364 //ntuple_evt->addItem("flt", m_nHit, m_flt);
1365 //ntuple_evt->addItem("slant", m_nHit, m_slant);
1366
1367 //ntuple_evt->addItem("nSigAxial", m_nSig_Axial, 0, 6796);
1368 //ntuple_evt->addItem("xybinNum", m_xybinNum, 0,10000000);
1369 //ntuple_evt->addItem("xybinMax", m_xybinMax);
1370 //ntuple_evt->addItem("xybinNL", m_xybinNum, m_xybinNL);
1371 //ntuple_evt->addItem("xybinRL", m_xybinNum, m_xybinRL);
1372 //ntuple_evt->addItem("xybinS", m_xybinNum, m_xybinS);
1373 //ntuple_evt->addItem("theta_left", m_theta_left);
1374 //ntuple_evt->addItem("theta_right", m_theta_right);
1375 //ntuple_evt->addItem("rho_down", m_rho_down);
1376 //ntuple_evt->addItem("rho_up", m_rho_up);
1377 ////by houghmap maxbin value 0~M_PI
1378 //ntuple_evt->addItem("theta", m_theta);
1379 //ntuple_evt->addItem("rho", m_rho);
1380 //ntuple_evt->addItem("height", m_height);
1381 //ntuple_evt->addItem("aver", m_aver);
1382 //ntuple_evt->addItem("sigma", m_sigma);
1383
1384 ////multiturn
1385 //ntuple_evt->addItem("multiturn", m_exit_multiturn);
1386
1387 ////diff two charge
1388 //ntuple_evt->addItem("nMap1pk", m_nMap1Pk, 0,100);
1389 //ntuple_evt->addItem("nMap1tk", m_nMap1Tk, 0,100);
1390 //ntuple_evt->addItem("nMap2pk", m_nMap2Pk, 0,100);
1391 //ntuple_evt->addItem("nMap2tk", m_nMap2Tk, 0,100);
1392 //ntuple_evt->addItem("map1_pkrho", m_nMap1Pk, m_PkRho1);
1393 //ntuple_evt->addItem("map1_pktheta", m_nMap1Pk, m_PkTheta1);
1394 //ntuple_evt->addItem("map1_tkrho", m_nMap1Tk, m_TkRho1);
1395 //ntuple_evt->addItem("map1_tktheta", m_nMap1Tk, m_TkTheta1);
1396 //ntuple_evt->addItem("map2_pkrho", m_nMap2Pk, m_PkRho2);
1397 //ntuple_evt->addItem("map2_pktheta", m_nMap2Pk, m_PkTheta2);
1398 //ntuple_evt->addItem("map2_tkrho", m_nMap2Tk, m_TkRho2);
1399 //ntuple_evt->addItem("map2_tktheta", m_nMap2Tk, m_TkTheta2);
1400
1401 ////MC truth
1402 //ntuple_evt->addItem("thetaline", m_theta_line);
1403 //ntuple_evt->addItem("rholine", m_rho_line);
1404
1405 // ntuple_evt->addItem("nmax", m_nMaxLayerSlant,0,200);
1406 // ntuple_evt->addItem("maxslant", m_nMaxLayerSlant, m_MaxLayerSlant);
1407 // ntuple_evt->addItem("maxslantlayer", m_nMaxLayerSlant, m_MaxLayer);
1408 // ntuple_evt->addItem("nnomax", m_nNoMaxLayerSlant,0,1000);
1409 // ntuple_evt->addItem("nomaxslant", m_nNoMaxLayerSlant, m_NoMaxLayerSlant);
1410 // ntuple_evt->addItem("nomaxlayerid", m_nNoMaxLayerSlant, m_NoMaxLayerid);
1411
1412 // ntuple_evt->addItem("MapMax", m_MapMax );
1413 ntuple_evt->addItem("nMapPk", m_nMapPk, 0,100);
1414 // ntuple_evt->addItem("nPeakNum", m_nMapPk, m_PeakOrder);
1415 // ntuple_evt->addItem("nPeakRho", m_nMapPk, m_PeakRho);
1416 // ntuple_evt->addItem("nPeakTheta", m_nMapPk, m_PeakTheta);
1417 // ntuple_evt->addItem("nPeakHeight", m_nMapPk, m_PeakHeight);
1418 // ntuple_evt->addItem("nPeakHit", m_nMapPk, m_PeakHit);
1419 // ntuple_evt->addItem("nPeakHitA", m_nMapPk, m_PeakHitA);
1420 // ntuple_evt->addItem("nMapTrk", m_nMapTrk, 0,1000);
1421 // ntuple_evt->addItem("nTrkRho", m_nMapTrk, m_TrackRho);
1422 // ntuple_evt->addItem("nTrkTheta", m_nMapTrk, m_TrackTheta);
1423 // ntuple_evt->addItem("nTrkHitA", m_nMapTrk, m_TrackHitA);
1424
1425 //rec - charge
1426 //global 2d fit
1427 // ntuple_evt->addItem("nTrk2D_neg", m_nTrk2D_neg, 0,100);
1428 // ntuple_evt->addItem("pt2D_neg", m_nTrk2D_neg, m_pt2D_neg);
1429 // ntuple_evt->addItem("nHit2D_neg", m_nTrk2D_neg, m_nHit2D_neg);
1430 // ntuple_evt->addItem("chi2_2D_neg", m_nTrk2D_neg, m_chi2_2D_neg);
1431 // //global 3d fit
1432 // ntuple_evt->addItem("nTrk3D_neg", m_nTrk3D_neg, 0,100);
1433 // ntuple_evt->addItem("tanl_neg", m_nTrk3D_neg, m_tanl_neg);
1434 // ntuple_evt->addItem("tanl3D_neg", m_nTrk3D_neg, m_tanl3D_neg);
1435 // ntuple_evt->addItem("z0_neg", m_nTrk3D_neg, m_z0_neg);
1436 // ntuple_evt->addItem("z0_3D_neg", m_nTrk3D_neg, m_z0_3D_neg);
1437 // ntuple_evt->addItem("pro_neg", m_nTrk3D_neg, m_pro_neg);
1438 // ntuple_evt->addItem("pt3D_neg", m_nTrk3D_neg, m_pt3D_neg);
1439 // ntuple_evt->addItem("nHit3D_neg", m_nTrk3D_neg, m_nHit3D_neg);
1440 // ntuple_evt->addItem("chi2_3D_neg", m_nTrk3D_neg, m_chi2_3D_neg);
1441 //
1442 // //truth inf
1443 // // ntuple_evt->addItem("nTrkMC", m_nTrkMC,0,10);
1444 // ntuple_evt->addItem("pidTruth", m_pidTruth);
1445 // ntuple_evt->addItem("costaTruth", m_costaTruth);
1446 // ntuple_evt->addItem("ptTruth", m_ptTruth);
1447 // ntuple_evt->addItem("pzTruth", m_pzTruth);
1448 // ntuple_evt->addItem("pTruth", m_pTruth);
1449 // ntuple_evt->addItem("qTruth", m_qTruth);
1450 // ntuple_evt->addItem("drTruth", m_drTruth);
1451 // ntuple_evt->addItem("phiTruth", m_phi0Truth);
1452 // ntuple_evt->addItem("omegaTruth", m_omegaTruth);
1453 // ntuple_evt->addItem("dzTruth", m_dzTruth);
1454 // ntuple_evt->addItem("tanlTruth", m_tanl_mc);
1455 // ntuple_evt->addItem("rhoTruth", m_rho_mc);
1456 // ntuple_evt->addItem("thetaTruth", m_theta_mc);
1457
1458
1459 ntuple_evt->addItem("time", m_time);
1460
1461 } else { log << MSG::ERROR << "Cannot book tuple MdcHoughFinder/hough" <<endmsg;
1462 return StatusCode::FAILURE;
1463 }
1464 }
1465 /*
1466 NTuplePtr nt2(ntupleSvc(), "MdcHoughFinder/hit");
1467 if ( nt2 ){
1468 ntuplehit= nt2;
1469 } else {
1470 ntuplehit= ntupleSvc()->book("MdcHoughFinder/hit", CLID_ColumnWiseTuple, "hit");
1471 if(ntuplehit){
1472 ntuplehit->addItem("evt_stereo", m_evt_stereo);
1473 ntuplehit->addItem("run_stereo", m_run_stereo);
1474 ntuplehit->addItem("cos_stereo", m_cos_stereo);
1475 ntuplehit->addItem("tanlTruth_stereo", m_tanlTruth_stereo);
1476 ntuplehit->addItem("ncir_stereo", m_ncir_stereo);
1477 ntuplehit->addItem("npair_stereo", m_npair_stereo);
1478 ntuplehit->addItem("tanl_stereo", m_tanl_stereo);
1479 ntuplehit->addItem("tanl3D_stereo", m_tanl3D_stereo);
1480 ntuplehit->addItem("z0_stereo", m_z0_stereo);
1481 ntuplehit->addItem("z03D_stereo", m_z03D_stereo);
1482 ntuplehit->addItem("nHit_axial", m_nHit_axial, 0, 6796);
1483 ntuplehit->addItem("axial_layer", m_nHit_axial, m_axial_layer);
1484 ntuplehit->addItem("axial_wire", m_nHit_axial, m_axial_wire);
1485 ntuplehit->addItem("axial_deltaD", m_nHit_axial, m_axial_deltaD);
1486 ntuplehit->addItem("axial_flt", m_nHit_axial, m_axial_flt);
1487 ntuplehit->addItem("nHit_stereo", m_nHit_stereo, 0, 6796);
1488 ntuplehit->addItem("stereo_layer", m_nHit_stereo, m_stereo_layer);
1489 ntuplehit->addItem("stereo_wire", m_nHit_stereo, m_stereo_wire);
1490 ntuplehit->addItem("stereo_style", m_nHit_stereo, m_stereo_style);
1491 ntuplehit->addItem("stereo_z0", m_nHit_stereo, m_stereo_z0);
1492 ntuplehit->addItem("stereo_z1", m_nHit_stereo, m_stereo_z1);
1493 ntuplehit->addItem("stereo_s0", m_nHit_stereo, m_stereo_s0);
1494 ntuplehit->addItem("stereo_s1", m_nHit_stereo, m_stereo_s1);
1495 ntuplehit->addItem("stereo_z", m_nHit_stereo, m_stereo_z);
1496 ntuplehit->addItem("stereo_s", m_nHit_stereo, m_stereo_s);
1497 ntuplehit->addItem("stereo_zTruth", m_nHit_stereo, m_stereo_zTruth);
1498 ntuplehit->addItem("stereo_sTruth", m_nHit_stereo, m_stereo_sTruth);
1499 ntuplehit->addItem("stereo_deltaZ", m_nHit_stereo, m_stereo_deltaZ);
1500 ntuplehit->addItem("stereo_nsol", m_nHit_stereo, m_stereo_nsol);
1501 ntuplehit->addItem("stereo_ambig", m_nHit_stereo, m_stereo_ambig);
1502 ntuplehit->addItem("stereo_ambig_truth", m_nHit_stereo, m_stereo_ambig_truth);
1503 ntuplehit->addItem("stereo_disToCir", m_nHit_stereo, m_stereo_disToCir);
1504 ntuplehit->addItem("stereo_cirlist", m_nHit_stereo, m_stereo_cirlist);
1505 }
1506 }
1507 */
1508
1509 return StatusCode::SUCCESS;
1510}

Referenced by initialize().

◆ bookTuple() [2/2]

StatusCode MdcHoughFinder::bookTuple ( )

◆ execute() [1/2]

StatusCode MdcHoughFinder::execute ( )

Definition at line 248 of file Hough.cxx.

248 {
249
250 MsgStream log(msgSvc(), name());
251 log << MSG::INFO << "in execute()" << endreq;
252 cout.precision(6);
253
254
255 m_timer_all->start();
256
257 //event start time
258 SmartDataPtr<RecEsTimeCol> evTimeCol(eventSvc(),"/Event/Recon/RecEsTimeCol");
259 if (!evTimeCol) {
260 log << MSG::WARNING << "Could not find EvTimeCol" << endreq;
261 return StatusCode::SUCCESS;
262 }else{
263 RecEsTimeCol::iterator iter_evt = evTimeCol->begin();
264 if (iter_evt != evTimeCol->end()){
265 m_bunchT0 = (*iter_evt)->getTest()*1.e-9;//m_bunchT0-s, getTest-ns
266 }
267 }
268 HoughHit::setBunchTime(m_bunchT0);
269
270 //-- Get the event header, print out event and run number
271 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
272 if (!eventHeader) {
273 log << MSG::FATAL << "Could not find Event Header" << endreq;
274 return StatusCode::FAILURE;
275 }
276
277 t_eventNum=eventHeader->eventNumber();
278 t_runNum=eventHeader->runNumber();
279 if(m_hist){
280 m_eventNum=eventHeader->eventNumber();
281 m_runNum=eventHeader->runNumber();
282 }
283 if(m_debug>0) cout<<"begin evt "<<eventHeader->eventNumber()<<endl;
284
285 //prepare tds
286 RecMdcTrackCol* trackList_tds;
287 RecMdcHitCol* hitList_tds;
288 vector<RecMdcTrack*> vec_trackPatTds;
289 int nTdsTk = storeTracks(trackList_tds,hitList_tds,vec_trackPatTds);
290 //print track in pattsf with bad vertex
291 if(m_debug>0){
292 RecMdcTrackCol::iterator iteritrk_pattsf = vec_trackPatTds.begin();
293 for(;iteritrk_pattsf!=vec_trackPatTds.end();iteritrk_pattsf++){
294 cout<<"in PATTSF LOST: "<<(*iteritrk_pattsf)->helix(0)<<" "<<(*iteritrk_pattsf)->helix(1)<<" "<<(*iteritrk_pattsf)->helix(2)<<" "<<(*iteritrk_pattsf)->helix(3)<<" "<<(*iteritrk_pattsf)->helix(4)<<" chi2 "<<(*iteritrk_pattsf)->chi2()<<endl;
295 }
296 }
297
298 //for arbi hits
299 MdcTrackParams m_par;
300 if(m_debugArbHit>0 ) m_par.lPrint=8;
301 m_par.lRemoveInActive=1;
302 //m_par.lUseQualCuts=0;
303 //m_par.maxGapLength=99;
304 //m_par.maxChisq=99;
305 //m_par.minHits=99;
306
307 // if filter read eventNum in file
308 if(m_filter){
309 ifstream lowPt_Evt;
310 lowPt_Evt.open(m_evtFile.c_str());
311 vector<int> evtlist;
312 int evtNum;
313 while( lowPt_Evt >> evtNum) {
314 evtlist.push_back(evtNum);
315 }
316 vector<int>::iterator iter_evt = find(evtlist.begin(),evtlist.end(),t_eventNum);
317 if( iter_evt == evtlist.end() ) { setFilterPassed(false); return StatusCode::SUCCESS; }
318 else setFilterPassed(true);
319 }
320
321 if(m_inputType == -1) GetMcInfo();
322
323 //-- Get MDC digi vector
324 if(m_debug>0) cout<<"step1 : prepare digi "<<endl;
325 MdcDigiVec mdcDigiVec = prepareDigi();
326
327 //-- Create MdcHoughFinder hit list
328 bool debugTruth = false;
329 if(m_inputType == -1) debugTruth= true;
330 if(m_debug>0) cout<<"step2 : hits-> hough hit list "<<endl;
331 HoughHitList houghHitList(mdcDigiVec);
332 // if( mdcDigiVec.size() < 10 ) return StatusCode::SUCCESS;
333 if( houghHitList.nHit() < 10 || houghHitList.nHit()>500 ) return StatusCode::SUCCESS;
334 if(m_debug>0) houghHitList.printAll();
335 if(debugTruth) houghHitList.addTruthInfo(g_tkParTruth);
336
337 vector<MdcHit*> mdcHitCol_neg;
338 vector<MdcHit*> mdcHitCol_pos;
339 MdcDigiVec::iterator iter = mdcDigiVec.begin();
340 for (;iter != mdcDigiVec.end(); iter++) {
341 const MdcDigi* digi = (*iter);
342 if( HoughHit(digi).driftTime()>1000 || HoughHit(digi).driftTime()<=0 ) continue;
343 MdcHit *mdcHit= new MdcHit(digi, Global::m_gm);
344 MdcHit *mdcHit_pos= new MdcHit(digi, Global::m_gm);
345 mdcHitCol_neg.push_back(mdcHit);
346 mdcHitCol_pos.push_back(mdcHit_pos);
347 }
348
349 HoughMap *m_map = new HoughMap(-1,houghHitList,m_mapHit,m_nBinTheta,m_nBinRho,-1.*m_rhoRange,m_rhoRange,m_peakWidth,m_peakHigh,m_hitPro);//, 2dOr3d);
350
351 // if(m_hist) dumpHoughHitList(houghHitList);
352 if(m_hist) m_nHit = houghHitList.nHit();
353 if(m_hist) dumpHoughMap(*m_map);
354
355 //track
356 if(m_debug>0) cout<<"step3 : neg track list "<<endl;
357 vector<HoughTrack*> vec_track_neg;
358 vector<HoughTrack*> vec_track2D_neg;
359 MdcTrackList mdcTrackList_neg(m_par) ;
360 if(m_recneg){
361 HoughTrackList trackList_neg(*m_map);
362 int trackList_size = trackList_neg.getTrackNum();
363 vector< vector<int> > stat_2d(2,vector<int>(trackList_size,0) );
364 vector< vector<int> > stat_3d(2,vector<int>(trackList_size,0) );
365 int ifit=0;
366 int ifit3D=0;
367 for(int itrack=0;itrack<trackList_size;itrack++){
368 if(m_debug>0) cout<<"begin track: "<<itrack<<endl;
369 //suppose charge -
370 if(m_debug>0) cout<<" suppose charge -1 "<<endl;
371 HoughTrack &track_neg = trackList_neg.getTrack(itrack);
372 track_neg.setMdcHit( &mdcHitCol_neg);
373 track_neg.setHoughHitList(houghHitList.getList());
374 track_neg.setCharge(-1);
375 stat_2d[0][itrack] = track_neg.fit2D(m_bunchT0);
376 int track_charge_2d = track_neg.trackCharge2D();
377 if(m_debug>0) cout<<" charge -1 stat2d "<<stat_2d[0][itrack]<<" "<<track_charge_2d<<endl;
378 if( stat_2d[0][itrack] == 0 || track_charge_2d ==0 ) continue;
379 //vec_track2D_neg.push_back( &track_neg );
380 //fill 2D inf
381 ifit++;
382 //3D fit
383 int nHit3d = track_neg.find_stereo_hit();
384 int npair= track_neg.find_pair_hit();
385 //cout<<"npair "<<npair<<endl;
386
387 int track_charge_3d = track_neg.trackCharge3D();
388 if(m_debug>0) cout<<" nhitstereo -1 "<<nHit3d<<" "<<track_charge_3d<<endl;
389 if( nHit3d <3 || track_charge_3d==0 ) continue;
390
391 //choose fit method
392 if( npair==0 ) stat_3d[0][itrack] = track_neg.fit3D();
393 else stat_3d[0][itrack] = track_neg.fit3D_inner();
394 //else stat_3d[0][itrack] = track_neg.fit3D();
395
396 if(m_debug>0) cout<<" charge -1 stat3d "<<stat_3d[0][itrack]<<" "<<endl;
397 if( stat_3d[0][itrack]==0 ) continue;
398 vec_track_neg.push_back( &track_neg );
399 //fill 3D inf
400 /*
401 if(m_hist){
402 m_tanl_neg[ifit3D] = track_neg.getTanl_zs();
403 m_tanl3D_neg[ifit3D] = track_neg.getTanl();
404 m_z0_neg[ifit3D] = track_neg.getZ0_zs();
405 m_z0_3D_neg[ifit3D] = track_neg.getZ0();
406 m_pro_neg[ifit3D] = track_neg.getPro();
407 m_pt3D_neg[ifit3D] = track_neg.getPt3D();
408 m_nHit3D_neg[ifit3D] = track_neg.getNfit3D();
409 m_chi2_3D_neg[ifit3D] = track_neg.getChi2_3D();
410 }
411 ifit3D++;
412 int axial_use=0;
413 int stereo_use=0;
414 int cir0=0;
415 int cirmore=0;
416 int ncir_track;
417 for(int ister =0;ister<track_neg.getHoughHitList().size();ister++){
418 HoughRecHit *rechit = &(track_neg.getHoughHitList().at(ister));
419 if( rechit->getSlayerType()==0 ) {
420 double deltaD = rechit->getDeltaD();
421 double flt= rechit->getFltLen();
422 if(m_hist){
423 m_axial_layer[axial_use]=rechit->getLayerId();
424 m_axial_wire[axial_use]=rechit->getWireId();
425 m_axial_deltaD[axial_use] = deltaD;
426 m_axial_flt[axial_use] = flt;
427 }
428 //judge which circle
429 int cirlist = rechit->getCirList();
430 if(cirlist == 0) cir0++;
431 else cirmore++;
432 axial_use++;
433 }
434 if( rechit->getSlayerType()!=0 ) {
435 //stereo hit info
436 double z0= rechit->getzAmb(0);
437 double z1= rechit->getzAmb(1);
438 double s0= rechit->getsAmb(0);
439 double s1= rechit->getsAmb(1);
440 int ambig = rechit->getAmbig();
441 int ambigTruth = rechit->getLrTruth();
442 int style = rechit->getStyle();
443 //cout<<"ambig ambigTruth "<<ambig<<" "<<ambigTruth<<endl;
444 double z = rechit->getzPos();
445 double s = rechit->getsPos();
446 double zTruth;
447 double sTruth;
448 if(ambigTruth == 1 ) {zTruth = z0;sTruth=s0;}
449 else if(ambigTruth == -1 ) {zTruth = z1;sTruth=s1;}
450 //calcu dist of hitz to zsline
451 double deltaZ = zTruth - ( sTruth * track_neg.getTanl_zs()+track_neg.getZ0_zs());
452 //else cout<<" not get ambig truth info "<<endl;
453 int nsol = rechit->getnsol();
454 double disToCir= rechit->getDisToCir();
455 int multicir = rechit->getCirList();
456 if(m_hist){
457 m_stereo_layer[stereo_use]=rechit->getLayerId();
458 m_stereo_wire[stereo_use]=rechit->getWireId();
459 m_stereo_style[stereo_use]=style;
460 m_stereo_z0[stereo_use]=z0;
461 m_stereo_z1[stereo_use]=z1;
462 m_stereo_s0[stereo_use]=s0;
463 m_stereo_s1[stereo_use]=s1;
464 m_stereo_z[stereo_use]=z;
465 m_stereo_s[stereo_use]=s;
466 m_stereo_zTruth[stereo_use]=zTruth;
467 m_stereo_sTruth[stereo_use]=sTruth;
468 m_stereo_deltaZ[stereo_use]=deltaZ;
469 m_stereo_nsol[stereo_use]=nsol;
470 m_stereo_ambig[stereo_use]=ambig;
471 m_stereo_ambig_truth[stereo_use]=ambigTruth;
472 m_stereo_disToCir[stereo_use]=disToCir;
473 m_stereo_cirlist[stereo_use]=multicir;
474 }
475 stereo_use++;
476 }
477 }
478 if( cir0>cirmore ) ncir_track = 0;
479 else ncir_track = 1;
480 if(m_hist){
481 m_evt_stereo= t_eventNum;
482 m_run_stereo= t_runNum;
483 m_cos_stereo= t_cos;
484 m_tanlTruth_stereo= t_tanl;
485 m_ncir_stereo= ncir_track;
486 m_npair_stereo= npair;
487 m_tanl_stereo= track_neg.getTanl_zs();
488 m_z0_stereo= track_neg.getZ0_zs();
489 m_tanl3D_stereo= track_neg.getTanl();
490 m_z03D_stereo= track_neg.getZ0();
491 m_nHit_axial= axial_use;
492 m_nHit_stereo = stereo_use;
493 ntuplehit->write();
494 }
495 */
496 }
497
498 std::sort ( vec_track_neg.begin(),vec_track_neg.end(),more_pt);
499 //track for clear
500 vector<MdcTrack*> vec_MdcTrack_neg;
501 for( unsigned int i =0;i<vec_track_neg.size();i++){
502 MdcTrack *mdcTrack = new MdcTrack(vec_track_neg[i]->getTrk());
503 vec_MdcTrack_neg.push_back(mdcTrack);
504 if(m_debug>0) cout<<"trackneg: "<<i<<" pt "<<vec_track_neg[i]->getPt3D()<<endl;
505 if(m_debug>0) vec_track_neg[i]->print();
506 }
507 if(m_debug>0) cout<<"step4 : judge neg track list "<<endl;
508 judgeHit(mdcTrackList_neg,vec_MdcTrack_neg);
509 if(m_debug>0) cout<<"finish - charge "<<endl;
510 }
511
512 //do rec pos charge
513
514 HoughMap *m_map2 = new HoughMap(1,houghHitList,m_mapHit,m_nBinTheta,m_nBinRho,-1.*m_rhoRange,m_rhoRange,m_peakWidth,m_peakHigh,m_hitPro);//, 2dOr3d);
515 if(m_debug>0) cout<<"step5 : pos track list "<<endl;
516 vector<HoughTrack*> vec_track_pos;
517 MdcTrackList mdcTrackList_pos(m_par) ;
518 if(m_recpos){
519 HoughTrackList tracklist_pos(*m_map2);
520 int tracklist_size2 = tracklist_pos.getTrackNum();
521 vector< vector<int> > stat_2d2(2,vector<int>(tracklist_size2,0) );
522 vector< vector<int> > stat_3d2(2,vector<int>(tracklist_size2,0) );
523 int ifit=0;
524 int ifit3D=0;
525 for(int itrack=0;itrack<tracklist_size2;itrack++){
526 //suppose charge +
527 if(m_debug>0) cout<<" suppose charge +1 "<<endl;
528 HoughTrack &track_pos = tracklist_pos.getTrack(itrack);
529 track_pos.setMdcHit( &mdcHitCol_pos);
530 track_pos.setHoughHitList(houghHitList.getList());
531 track_pos.setCharge(1);
532 stat_2d2[0][itrack] = track_pos.fit2D(m_bunchT0);
533 int track_charge_2d = track_pos.trackCharge2D();
534 if(m_debug>0) cout<<" charge +1 stat2d "<<stat_2d2[1][itrack]<<" "<<track_charge_2d<<endl;
535 if( stat_2d2[0][itrack] == 0 || track_charge_2d==0 ) continue;
536 //fill 2d inf
537 ifit++;
538 //3d fit
539 int nHit3d = track_pos.find_stereo_hit();
540 int npair= track_pos.find_pair_hit();
541 //cout<<"npair "<<npair<<endl;
542
543 int track_charge_3d = track_pos.trackCharge3D();
544 if(m_debug>0) cout<<" nhitstereo +1 "<<nHit3d<<" "<<track_charge_3d<<endl;
545 if( nHit3d <3 || track_pos.trackCharge3D()==0 ) continue;
546 //choose fit method
547 if( npair==0 ) stat_3d2[0][itrack] = track_pos.fit3D();
548 else stat_3d2[0][itrack] = track_pos.fit3D_inner();
549 //else stat_3d2[0][itrack] = track_neg.fit3D();
550
551 if(m_debug>0) cout<<" charge +1 stat3d "<<stat_3d2[1][itrack]<<" "<<endl;
552 if( stat_3d2[0][itrack]==0 ) continue;
553 vec_track_pos.push_back( &track_pos );
554 //fill 3d inf
555 ifit3D++;
556 }
557
558 //sort pos tracklist
559 std::sort ( vec_track_pos.begin(),vec_track_pos.end(),more_pt);
560
561 // clear pos track
562 vector<MdcTrack*> vec_MdcTrack_pos;
563 for( unsigned int i =0;i<vec_track_pos.size();i++){
564 MdcTrack *mdcTrack = new MdcTrack(vec_track_pos[i]->getTrk());
565 vec_MdcTrack_pos.push_back(mdcTrack);
566 if(m_debug>0) cout<<"trackpos : "<<i<<" pt "<<vec_track_pos[i]->getPt3D()<<endl;
567 if(m_debug>0) vec_track_pos[i]->print();
568 }
569 if(m_debug>0) cout<<"step6 : judge pos track list "<<endl;
570 judgeHit(mdcTrackList_pos,vec_MdcTrack_pos);
571 }
572
573 //combine hough itself
574 // if(m_debug>0) cout<<"step7 : combine neg&pos track list "<<endl;
575 if(m_combine){
576 compareHough(mdcTrackList_neg);
577 compareHough(mdcTrackList_pos);
578 }
579 if( mdcTrackList_neg.length()!=0 && mdcTrackList_pos.length()!=0 ) judgeChargeTrack(mdcTrackList_neg,mdcTrackList_pos);
580 //add tracklist
581 mdcTrackList_neg+=mdcTrackList_pos; //neg -> all charge
582
583 //compare pattsf&hough self
584 if(m_combineTracking) nTdsTk = comparePatTsf(mdcTrackList_neg,trackList_tds);
585
586 // store tds
587 if(m_debug>0) cout<<"step8 : store tds "<<endl;
588 if(m_debug>0) cout<<"store tds "<<endl;
589 int tkId = nTdsTk ; //trkid
590 for( unsigned int i =0;i<mdcTrackList_neg.length();i++){
591 if(m_debug>0) cout<<"- charge size i : "<<i<<" "<<mdcTrackList_neg.length()<<endl;
592 int tkStat = 4;//track find by houghspace set stat=4
593 mdcTrackList_neg[i]->storeTrack(tkId, trackList_tds, hitList_tds, tkStat);
594 tkId++;
595 delete mdcTrackList_neg[i];
596 }
597 if(m_debug>0) m_mdcPrintSvc->printRecMdcTrackCol();
598
599 m_timer_all->stop();
600 double t_teventTime = m_timer_all->elapsed();
601 if(m_hist) m_time = t_teventTime;
602
603 if( m_hist ) ntuple_evt->write();
604
605 delete m_map;
606 delete m_map2;
607 if(m_debug>0) cout<<"after delete map "<<endl;
608 for(int ihit=0;ihit<mdcHitCol_neg.size();ihit++){
609 delete mdcHitCol_neg[ihit];
610 delete mdcHitCol_pos[ihit];
611 }
612
613 if(m_debug>0) cout<<"after delete hit"<<endl;
614 //clearMem(mdcTrackList_neg,mdcTrackList_pos);
615 if(m_debug>0) cout<<"end event "<<endl;
616
617 return StatusCode::SUCCESS;
618}
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
ObjectVector< RecMdcHit > RecMdcHitCol
ObjectVector< RecMdcTrack > RecMdcTrackCol
bool more_pt(const HoughTrack *tracka, const HoughTrack *trackb)
Definition: Hough.cxx:960
void start(void)
Definition: BesTimer.cxx:27
void stop(void)
Definition: BesTimer.cxx:39
int trackCharge2D()
Definition: HoughTrack.cxx:820
int find_stereo_hit()
Definition: HoughTrack.cxx:697
int fit2D(double bunchtime)
Definition: HoughTrack.cxx:190
int trackCharge3D()
Definition: HoughTrack.cxx:838
void setMdcHit(const vector< MdcHit * > *mdchit)
int fit3D_inner()
Definition: HoughTrack.cxx:312
int find_pair_hit()
Definition: HoughTrack.cxx:946
void printRecMdcTrackCol() const

◆ execute() [2/2]

StatusCode MdcHoughFinder::execute ( )

◆ finalize() [1/2]

StatusCode MdcHoughFinder::finalize ( )

Definition at line 621 of file Hough.cxx.

621 {
622 MsgStream log(msgSvc(), name());
623 delete m_bfield ;
624 log << MSG::INFO<< "in finalize()" << endreq;
625
626 return StatusCode::SUCCESS;
627}

◆ finalize() [2/2]

StatusCode MdcHoughFinder::finalize ( )

◆ initialize() [1/2]

StatusCode MdcHoughFinder::initialize ( )

Definition at line 140 of file Hough.cxx.

140 {
141
142 MsgStream log(msgSvc(), name());
143 log << MSG::INFO << "in initialize()" << endreq;
144
145 StatusCode sc;
146
147 //particle
148 IPartPropSvc* p_PartPropSvc;
149 static const bool CREATEIFNOTTHERE(true);
150 sc = service("PartPropSvc", p_PartPropSvc, CREATEIFNOTTHERE);
151 if (!sc.isSuccess() || 0 == p_PartPropSvc) {
152 log << MSG::ERROR << " Could not initialize PartPropSvc" << endreq;
153 return sc;
154 }
155 m_particleTable = p_PartPropSvc->PDT();
156
157 // RawData
158 IRawDataProviderSvc* irawDataProviderSvc;
159 sc = service ("RawDataProviderSvc", irawDataProviderSvc);
160 m_rawDataProviderSvc = dynamic_cast<RawDataProviderSvc*> (irawDataProviderSvc);
161 if ( sc.isFailure() ){
162 log << MSG::FATAL << name()<<" Could not load RawDataProviderSvc!" << endreq;
163 return StatusCode::FAILURE;
164 }
165
166 // Geometry
167 IMdcGeomSvc* imdcGeomSvc;
168 sc = service ("MdcGeomSvc", imdcGeomSvc);
169 m_mdcGeomSvc = dynamic_cast<MdcGeomSvc*> (imdcGeomSvc);
170 if ( sc.isFailure() ){
171 log << MSG::FATAL << "Could not load MdcGeoSvc!" << endreq;
172 return StatusCode::FAILURE;
173 }
174
175 // magneticfield
176 sc = service ("MagneticFieldSvc",m_pIMF);
177 if(sc!=StatusCode::SUCCESS) {
178 log << MSG::ERROR << "Unable to open Magnetic field service"<<endreq;
179 }
180 m_bfield = new BField(m_pIMF);
181 log << MSG::INFO << "field z = "<<m_bfield->bFieldNominal()<< endreq;
182 m_context = new TrkContextEv(m_bfield);
183
184 //read pdt
185 Pdt::readMCppTable(m_pdtFile);
186
187 //Get MdcCalibFunSvc
188 IMdcCalibFunSvc* imdcCalibSvc;
189 sc = service ("MdcCalibFunSvc", imdcCalibSvc);
190 m_mdcCalibFunSvc = dynamic_cast<MdcCalibFunSvc*>(imdcCalibSvc);
191 if ( sc.isFailure() ){
192 log << MSG::FATAL << "Could not load MdcCalibFunSvc!" << endreq;
193 return StatusCode::FAILURE;
194 }
195
196 //initialize MdcPrintSvc
197 IMdcPrintSvc* imdcPrintSvc;
198 sc = service ("MdcPrintSvc", imdcPrintSvc);
199 m_mdcPrintSvc = dynamic_cast<MdcPrintSvc*> (imdcPrintSvc);
200 if ( sc.isFailure() ){
201 log << MSG::FATAL << "Could not load MdcPrintSvc!" << endreq;
202 return StatusCode::FAILURE;
203 }
204
205 //time
206 sc = service( "BesTimerSvc", m_timersvc);
207 if( sc.isFailure() ) {
208 log << MSG::WARNING << " Unable to locate BesTimerSvc" << endreq;
209 return StatusCode::FAILURE;
210 }
211 m_timer_all = m_timersvc->addItem("Execution");
212 m_timer_all->propName("nExecution");
213
214 //initialize static
215 HoughHit::setMdcCalibFunSvc(m_mdcCalibFunSvc);
216 HoughHit::setMdcGeomSvc(m_mdcGeomSvc);
217 HoughHit::setBunchTime(m_bunchT0);
218 Hough2D::setContext(m_context);
219 Hough2D::setCalib(m_mdcCalibFunSvc);
220 Hough3D::setContext(m_context);
221 Hough3D::setCalib(m_mdcCalibFunSvc);
222
223 HoughHit::_npart=m_npart;
224 HoughMap::m_useHalfCir=m_useHalf;
225 HoughMap::m_N1=m_npart;
226 HoughMap::m_N2=m_n2;
227
230
231 if(m_debugMap> 0) HoughMap::m_debug = 1;
232 if(m_debug2D > 0) Hough2D::m_debug = 1;
233 if(m_debug3D > 0) Hough3D::m_debug = 1;
234 if(m_debugTrack> 0) HoughTrack::m_debug = 1;
235 if(m_debugStereo> 0) HoughStereo::m_debug = 1;
236 if(m_debugZs> 0) HoughZsFit::m_debug = 1;
237 if(m_debug3D > 4) TrkHelixFitter::m_debug = 1;
238
239 if(m_hist) sc = bookTuple();
240 if ( sc.isFailure() ){
241 log << MSG::FATAL << "Could not book Tuple !" << endreq;
242 return StatusCode::FAILURE;
243 }
244 return StatusCode::SUCCESS;
245}
static void setContext(TrkContextEv *context)
static void setCalib(const MdcCalibFunSvc *mdcCalibFunSvc)
static void setContext(TrkContextEv *context)
static void setCalib(const MdcCalibFunSvc *mdcCalibFunSvc)
static void setMdcGeomSvc(MdcGeomSvc *geomSvc)
static void setMdcCalibFunSvc(const MdcCalibFunSvc *calibSvc)
virtual BesTimer * addItem(const std::string &name)=0
StatusCode bookTuple()
Definition: Hough.cxx:1333
static void readMCppTable(std::string filenm)

◆ initialize() [2/2]

StatusCode MdcHoughFinder::initialize ( )

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