BOSS 7.0.4
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("dsigma", m_dsigma= 1);
124 declareProperty("dsigma2", m_dsigma2= 2);
125
126 declareProperty("pdtFile", m_pdtFile = "pdt.table");
127 declareProperty("sigmaFile", m_sigmaFile = "sigma.table");
128 declareProperty("eventFile", m_evtFile= "EventList");
129
130}

◆ MdcHoughFinder() [2/2]

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

Member Function Documentation

◆ beginRun() [1/2]

StatusCode MdcHoughFinder::beginRun ( )

Definition at line 132 of file Hough.cxx.

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

◆ beginRun() [2/2]

StatusCode MdcHoughFinder::beginRun ( )

◆ bookTuple() [1/2]

StatusCode MdcHoughFinder::bookTuple ( )

Definition at line 1350 of file Hough.cxx.

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

Referenced by initialize().

◆ bookTuple() [2/2]

StatusCode MdcHoughFinder::bookTuple ( )

◆ execute() [1/2]

StatusCode MdcHoughFinder::execute ( )

Definition at line 250 of file Hough.cxx.

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

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

◆ finalize() [2/2]

StatusCode MdcHoughFinder::finalize ( )

◆ initialize() [1/2]

StatusCode MdcHoughFinder::initialize ( )

Definition at line 141 of file Hough.cxx.

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

◆ initialize() [2/2]

StatusCode MdcHoughFinder::initialize ( )

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