BOSS 7.0.9
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 ()
 

Detailed Description

Definition at line 45 of file Hough.h.

Constructor & Destructor Documentation

◆ MdcHoughFinder()

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("pdtFile", m_pdtFile = "pdt.table");
124 declareProperty("eventFile", m_evtFile= "EventList");
125
126}

Member Function Documentation

◆ beginRun()

StatusCode MdcHoughFinder::beginRun ( )

Definition at line 128 of file Hough.cxx.

128 {
129 //Initailize MdcDetector
131 if(NULL == Global::m_gm) return StatusCode::FAILURE;
132
133 return StatusCode::SUCCESS;
134}
#define NULL
static MdcDetector * instance()
Definition: MdcDetector.cxx:21
const MdcDetector * m_gm
Definition: HoughGlobal.cxx:3

◆ bookTuple()

StatusCode MdcHoughFinder::bookTuple ( )

Definition at line 1328 of file Hough.cxx.

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

Referenced by initialize().

◆ execute()

StatusCode MdcHoughFinder::execute ( )

Definition at line 243 of file Hough.cxx.

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

◆ finalize()

StatusCode MdcHoughFinder::finalize ( )

Definition at line 616 of file Hough.cxx.

616 {
617 MsgStream log(msgSvc(), name());
618 delete m_bfield ;
619 log << MSG::INFO<< "in finalize()" << endreq;
620
621 return StatusCode::SUCCESS;
622}

◆ initialize()

StatusCode MdcHoughFinder::initialize ( )

Definition at line 137 of file Hough.cxx.

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

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