15#include "CLHEP/String/Strings.h"
39#include "GaudiKernel/MsgStream.h"
40#include "GaudiKernel/AlgFactory.h"
41#include "GaudiKernel/ISvcLocator.h"
42#include "GaudiKernel/IDataManagerSvc.h"
43#include "GaudiKernel/SmartDataPtr.h"
44#include "GaudiKernel/IDataProviderSvc.h"
45#include "GaudiKernel/PropertyMgr.h"
46#include "GaudiKernel/IMessageSvc.h"
47#include "GaudiKernel/IDataProviderSvc.h"
48#include "GaudiKernel/IJobOptionsSvc.h"
49#include "GaudiKernel/Bootstrap.h"
50#include "GaudiKernel/StatusCode.h"
81 Algorithm(name, pSvcLocator),
84 _rkfitter("range fitter",
100 MsgStream log(
msgSvc(), name());
101 log << MSG::INFO <<
"in initialize()" << endreq;
107 sc = service (
"RawDataProviderSvc", irawDataProviderSvc);
109 if ( sc.isFailure() ){
110 log << MSG::FATAL <<
"Could not load RawDataProviderSvc!" << endreq;
111 return StatusCode::FAILURE;
124 sc = service (
"MdcCalibFunSvc",imdcCalibSvc);
126 if ( sc.isFailure() ){
127 log << MSG::FATAL <<
"Could not load MdcCalibFunSvc!" << endreq;
161 else if (! _confFinder) {
247 StatusCode sc = service(
"BesTimerSvc", m_timersvc);
248 if( sc.isFailure() ) {
249 log << MSG::WARNING <<
" Unable to locate BesTimerSvc" << endreq;
250 return StatusCode::FAILURE;
252 m_timer[1] = m_timersvc->
addItem(
"Execution");
256 return StatusCode::SUCCESS;
260TrkReco::cdcInit(
void) {
297 if (_confFinder)
delete _confFinder;
298 if (_curlFinder)
delete _curlFinder;
300 return StatusCode::SUCCESS;
305 StatusCode sc1 =Gaudi::svcLocator()->service(
"MdcGeomSvc", imdcGeomSvc);
306 _mdcGeomSvc =
dynamic_cast<MdcGeomSvc*
> (imdcGeomSvc);
307 if (sc1.isFailure()) {
308 return( StatusCode::FAILURE);
312 return StatusCode::SUCCESS;
322 MsgStream log(
msgSvc(), name());
323 log << MSG::INFO <<
"in execute()" << endreq;
329 for (
int ii=0;ii<43;ii++){
330 for (
int jj=0;jj<288;jj++){
331 havedigi[ii][jj]= -99;
341 IDataManagerSvc *dataManSvc;
342 DataObject *aTrackCol;
343 DataObject *aRecHitCol;
345 dataManSvc =
dynamic_cast<IDataManagerSvc*
> (eventSvc().get());
346 eventSvc()->findObject(
"/Event/Recon/RecMdcTrackCol",aTrackCol);
347 if(aTrackCol !=
NULL) {
348 dataManSvc->clearSubTree(
"/Event/Recon/RecMdcTrackCol");
349 eventSvc()->unregisterObject(
"/Event/Recon/RecMdcTrackCol");
351 eventSvc()->findObject(
"/Event/Recon/RecMdcHitCol",aRecHitCol);
352 if(aRecHitCol !=
NULL) {
353 dataManSvc->clearSubTree(
"/Event/Recon/RecMdcHitCol");
354 eventSvc()->unregisterObject(
"/Event/Recon/RecMdcHitCol");
357 DataObject *aReconEvent;
358 eventSvc()->findObject(
"/Event/Recon",aReconEvent);
361 StatusCode sc = eventSvc()->registerObject(
"/Event/Recon",recevt );
362 if(sc!=StatusCode::SUCCESS) {
363 log << MSG::FATAL <<
"Could not register ReconEvent" <<endreq;
364 return( StatusCode::FAILURE);
368 eventSvc()->findObject(
"/Event/Recon/RecMdcTrackCol",aTrackCol);
374 if(!sc.isSuccess()) {
375 log << MSG::FATAL <<
" Could not register RecMdcTrack collection" <<endreq;
376 return StatusCode::FAILURE;
380 eventSvc()->findObject(
"/Event/Recon/RecMdcHitCol",aRecHitCol);
386 if(!sc.isSuccess()) {
387 log << MSG::FATAL <<
" Could not register RecMdcHit collection" <<endreq;
388 return StatusCode::FAILURE;
395 SmartDataPtr<RecEsTimeCol> aevtimeCol(eventSvc(),
"/Event/Recon/RecEsTimeCol");
397 if (aevtimeCol && aevtimeCol->size() ) {
398 RecEsTimeCol::iterator iter_evt = aevtimeCol->begin();
399 t0_bes = (*iter_evt)->getTest();
400 t0Sta = (*iter_evt)->getStat();
402 log << MSG::WARNING <<
"Could not find EsTimeCol" << endreq;
403 return StatusCode::SUCCESS;
408 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
410 log << MSG::FATAL <<
"Could not find Event Header" << endreq;
411 return( StatusCode::FAILURE);
413 _nEvents = eventHeader->eventNumber();
414 if (
b_tuple) std::cout <<
"TrkReco ... processing ev# " << _nEvents << std::endl;
418 uint32_t getDigiFlag = 0;
423 if (0 == mdcDigiVec.size()){
424 log << MSG::WARNING <<
" No hits in MdcDigiVec" << endreq;
425 return StatusCode::SUCCESS;
432 MdcDigiVec::iterator iter1 = mdcDigiVec.begin();
433 MC_DIGI_SIZE = mdcDigiVec.size();
445 for (;iter1 != mdcDigiVec.end(); iter1++, digiId++) {
447 mdcId = (*iter1)->identify();
458 if (
b_goodTrk &&
b_tuple) havedigi[layerId][wireId] = (*iter1)->getTrackIndex();
463 mhit.
geo = _mdcGeomSvc->
Wire(layerId,wireId);
476 mhit.
adc = (*iter1)->getChargeChannel();
481 double T0 = _mdcCalibFunSvc->
getT0(layerId,wireId);
482 double drifttime = mhit.
tdc-tof-timewalk-T0;
483 double dist2 = _mdcCalibFunSvc->
driftTimeToDist(drifttime,layerId, wireId, 2, 0);
484 mhit.
erddl = _mdcCalibFunSvc->
getSigma(layerId, 2 , dist2, 0.0,0.0,0.0,mhit.
adc);
486 mhit.
ddl = dist2/10.;
496 mhit.
stat = mhit.
stat |= 1073741824;
506 t10_drift = mhit.
ddl;
507 t10_dDrift = mhit.
erddl;
509 t10_localId = wireId;
514 unsigned nT0Reset = 0;
523 if (mdcDigiVec.size() > 2000){
524 log << MSG::WARNING <<
" Too many hits in MdcDigiVec" << endreq;
525 return StatusCode::SUCCESS;
545 _perfectFinder->
doit(axialHits, stereoHits,
tracks, tracks2D);
561 _confFinder->
doit(axialHits, stereoHits,
tracks, tracks2D);
588 tracks.append(confTracks);
589 _curlFinder->
doit(axialHits, stereoHits,
tracks, tracks2D);
590 tracks.remove(confTracks);
605 _trackManager.
merge();
633 if (scTds != StatusCode::SUCCESS)
return( StatusCode::FAILURE);
643 SmartDataPtr<RecEsTimeCol> aevtimeCol(eventSvc(),
"/Event/Recon/RecEsTimeCol");
644 if (aevtimeCol && aevtimeCol->size() ) {
645 RecEsTimeCol::iterator iter_evt = aevtimeCol->begin();
646 t0_bes = (*iter_evt)->getTest();
647 t0Sta = (*iter_evt)->getStat();
649 log << MSG::WARNING <<
"Could not find EsTimeCol" << endreq;
650 return StatusCode::SUCCESS;
654 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
656 log << MSG::FATAL <<
"Could not find Event Header" << endreq;
657 return( StatusCode::FAILURE);
659 _nEvents = eventHeader->eventNumber();
660 if (
b_tuple) std::cout <<
"TrkReco ... processing ev# " << _nEvents << std::endl;
663 uint32_t getDigiFlag = 0;
668 if (0 == mdcDigiVec.size()){
669 log << MSG::WARNING <<
" No hits in MdcDigiVec" << endreq;
670 return StatusCode::SUCCESS;
672 MdcDigiVec::iterator iter1 = mdcDigiVec.begin();
673 MC_DIGI_SIZE = mdcDigiVec.size();
683 for (;iter1 != mdcDigiVec.end(); iter1++, digiId++) {
684 mdcId = (*iter1)->identify();
687 if (
b_goodTrk &&
b_tuple) havedigi[layerId][wireId] = (*iter1)->getTrackIndex();
692 mhit.
geo = _mdcGeomSvc->
Wire(layerId,wireId);
700 mhit.
adc = (*iter1)->getChargeChannel();
702 double T0 = _mdcCalibFunSvc->
getT0(layerId,wireId);
703 double drifttime = mhit.
tdc-tof-timewalk-T0;
704 double dist2 = _mdcCalibFunSvc->
driftTimeToDist(drifttime,layerId, wireId, 2, 0);
705 mhit.
erddl = _mdcCalibFunSvc->
getSigma(layerId, 2 , dist2, 0.0,0.0,0.0,mhit.
adc);
706 mhit.
ddl = dist2/10.;
716 mhit.
stat = mhit.
stat |= 1073741824;
722 t10_drift = mhit.
ddl;
723 t10_dDrift = mhit.
erddl;
725 t10_localId = wireId;
730 unsigned nT0Reset = 0;
733 if (mdcDigiVec.size() > 2000){
734 log << MSG::WARNING <<
" Too many hits in MdcDigiVec" << endreq;
735 return StatusCode::SUCCESS;
748 _allHits[2].append(_allHits[0]);
749 _allHits[2].append(_allHits[1]);
755 log << MSG::ERROR <<
"Unable to retrieve RecMdcTrackCol" << endreq;
756 return StatusCode::FAILURE;
758 log << MSG::DEBUG <<
"RecMdcTrackCol retrieved of size "<< mdcTracks->size() << endreq;
760 for(RecMdcTrackCol::iterator it=mdcTracks->begin(); it!=mdcTracks->end(); it++)
765 HitRefVec::iterator it_gothit = gothits.begin();
766 unsigned stat=(*it)->stat();
768 for( ; it_gothit != gothits.end(); it_gothit++){
769 for(
int i=0;i<_allHits[2].length();i++){
770 int lyrraw=_allHits[2][i]->wire()->layerId();
771 int wireraw=_allHits[2][i]->wire()->localId();
773 int g_wire =
MdcID::wire((*it_gothit)->getMdcId());
774 if(lyrraw==g_layer&&g_wire==wireraw){
776 t1->
append(*_allHits[2][i]);
782 int err=_rkfitter.
fit(*rr);
787 if(
nhits>10)nmax=(int)nhit*0.3;
788 for(
int ii=0;ii<nmax;ii++){
791 if(ndrop)err=_rkfitter.
fit(*rr);
794 if(err==-2) counter++;
798 for(
int i=0;i<43;i++){
799 err= _rkfitter.
fit(*tt,0,i);
806 t->setFinderType(100+stat);
813 t->setFinderType(100+stat);
824 _trackManager.
append(rktracks);
825 IDataManagerSvc *dataManSvc;
826 DataObject *aTrackCol;
827 DataObject *aRecHitCol;
829 dataManSvc =
dynamic_cast<IDataManagerSvc*
> (eventSvc().get());
830 eventSvc()->findObject(
"/Event/Recon/RecMdcTrackCol",aTrackCol);
831 if(aTrackCol !=
NULL) {
832 dataManSvc->clearSubTree(
"/Event/Recon/RecMdcTrackCol");
833 eventSvc()->unregisterObject(
"/Event/Recon/RecMdcTrackCol");
835 eventSvc()->findObject(
"/Event/Recon/RecMdcHitCol",aRecHitCol);
836 if(aRecHitCol !=
NULL) {
837 dataManSvc->clearSubTree(
"/Event/Recon/RecMdcHitCol");
838 eventSvc()->unregisterObject(
"/Event/Recon/RecMdcHitCol");
841 DataObject *aReconEvent;
842 eventSvc()->findObject(
"/Event/Recon",aReconEvent);
845 StatusCode sc = eventSvc()->registerObject(
"/Event/Recon",recevt );
846 if(sc!=StatusCode::SUCCESS) {
847 log << MSG::FATAL <<
"Could not register ReconEvent" <<endreq;
848 return( StatusCode::FAILURE);
852 eventSvc()->findObject(
"/Event/Recon/RecMdcTrackCol",aTrackCol);
858 if(!sc.isSuccess()) {
859 log << MSG::FATAL <<
" Could not register RecMdcTrack collection" <<endreq;
860 return StatusCode::FAILURE;
864 eventSvc()->findObject(
"/Event/Recon/RecMdcHitCol",aRecHitCol);
870 if(!sc.isSuccess()) {
871 log << MSG::FATAL <<
" Could not register RecMdcHit collection" <<endreq;
872 return StatusCode::FAILURE;
884 for (
unsigned i = 0; i < 3; i++) {
886 HepAListDeleteAll(_allHits[i]);
888 _allHits[i].removeAll();
891 rktracks.removeAll();
905 return StatusCode::SUCCESS;
909TrkReco::mcInformation(
void) {
916 unsigned nTrk = allTracks.length();
917 unsigned * N = (
unsigned *) malloc(nHep *
sizeof(
unsigned));
918 for (
unsigned i = 0; i < nHep; i++) N[i] = 0;
921 for (
unsigned i = 0; i < nTrk; i++) {
925 _mcTracks.append(mc);
926 allTracks[i]->_mc = mc;
930 if (mc->
hepId() != -1)
936 for (
unsigned i = 0; i < nHep; i++) {
938 for (
unsigned j = 0; j < nTrk; j++)
939 if (allTracks[j]->_mc->hepId() == i)
945 for (
unsigned i = 0; i < nTrk; i++) {
946 unsigned & quality = allTracks[i]->_mc->_quality;
959 HepAListDeleteAll(_mcTracks);
965 _trackManager.
clear();
975TrkReco::mcEvent(
void)
const {
992TrkReco::initPara(
void){
994 declareProperty(
"mcPar",
b_mcPar = 0);
995 declareProperty(
"mcHit",
b_mcHit = 0);
996 declareProperty(
"tuple",
b_tuple = 0);
997 declareProperty(
"goodTrk",
b_goodTrk = 0);
1003 declareProperty(
"useESTime",
useESTime = 1.0);
1045 declareProperty(
"doMerge",
b_doMerge = 0);
1050 declareProperty(
"test",
b_test = 0);
1055 declareProperty(
"dropHot",
m_dropHot= 0);
1082 declareProperty(
"merge_exe",
merge_exe = 1);
1083 declareProperty(
"merge_ratio",
merge_ratio = 0.1);
1093 declareProperty(
"z_cut",
z_cut = 50.0);
1109TrkReco::InitTuple(
void){
1110 m_tuple=
ntupleSvc()->book(
"FILE101/rec3D",CLID_ColumnWiseTuple,
"MdcRecEvent");
1111 m_tuple->addItem (
"mc_phi", t_mcphi);
1112 m_tuple->addItem (
"mc_theta", t_mctheta);
1113 m_tuple->addItem (
"mc_ptot", t_mcptot);
1114 m_tuple->addItem (
"mc_pt", t_mcpt);
1115 m_tuple->addItem (
"mc_pz", t_mcpz);
1116 m_tuple->addItem (
"mc_t0", t_mct0);
1117 m_tuple->addItem (
"nDigi", t_nDigi);
1119 m_tuple->addItem (
"dr", t_dr);
1120 m_tuple->addItem (
"dz", t_dz);
1121 m_tuple->addItem (
"pt", t_pt);
1122 m_tuple->addItem (
"ptot", t_ptot);
1123 m_tuple->addItem (
"tanlmd",t_tanlmd);
1124 m_tuple->addItem (
"phi", t_phi);
1125 m_tuple->addItem (
"radius",t_radius);
1126 m_tuple->addItem (
"chi2", t_chi2);
1127 m_tuple->addItem (
"nHits", t_nHits);
1128 m_tuple->addItem (
"nCores",t_nCores);
1129 m_tuple->addItem (
"nSegs", t_nSegs);
1130 m_tuple->addItem (
"ndf", t_ndf);
1132 m_tuple->addItem (
"dpt", t_dpt);
1133 m_tuple->addItem (
"dptot", t_dptot);
1134 m_tuple->addItem (
"dlmd", t_dlmd);
1135 m_tuple->addItem (
"dphi", t_dphi);
1137 m_tuple->addItem (
"t0", t_t0);
1138 m_tuple->addItem (
"t0_sta",t0_sta);
1140 m_tuple->addItem (
"evtNo", t_evtNo);
1141 m_tuple->addItem (
"length", t_length);
1142 m_tuple->addItem (
"length2", t_length2);
1144 m_tuple->addItem (
"gd_theta", t_good_theta);
1145 m_tuple->addItem (
"gd_nLayers", t_gdNLayers);
1146 m_tuple->addItem (
"mc_nLayers", t_mcNLayers);
1147 m_tuple->addItem (
"best_nLayers",t_bestNLayers);
1148 m_tuple->addItem (
"best_mc_nLayers",t_bestMcNLayers);
1150 m_tuple3=
ntupleSvc()->book(
"FILE101/raw",CLID_ColumnWiseTuple,
"Raw Data");
1151 m_tuple3->addItem (
"mc_t0", t3_mct0);
1152 m_tuple3->addItem (
"mc_theta", t3_mctheta);
1153 m_tuple3->addItem (
"mc_phi", t3_mcphi);
1154 m_tuple3->addItem (
"mc_ptot", t3_mcptot);
1155 m_tuple3->addItem (
"mc_pt", t3_mcpt);
1156 m_tuple3->addItem (
"mc_pid", t3_mcpid);
1157 m_tuple3->addItem (
"evtNo", t3_evtNo);
1159 m_tuple31=
ntupleSvc()->book(
"FILE101/rawEvt",CLID_ColumnWiseTuple,
"Raw Data");
1160 m_tuple31->addItem (
"nDigi", t3_nDigi);
1161 m_tuple31->addItem (
"goodLength", t3_goodLength);
1162 m_tuple31->addItem (
"length", t3_length);
1163 m_tuple31->addItem (
"t0_rec", t3_t0Rec);
1164 m_tuple31->addItem (
"t0", t3_t0);
1165 m_tuple31->addItem (
"t0_sta", t3_t0Sta);
1166 m_tuple31->addItem (
"finalLength", t3_finalLength);
1168 m_tuple31->addItem (
"mc_theta", t3_mctheta);
1169 m_tuple31->addItem (
"mc_ptot", t3_mcptot);
1170 m_tuple31->addItem (
"mc_pt", t3_mcpt);
1171 m_tuple31->addItem (
"evtNo", t3_evtNo);
1173 m_tuple2=
ntupleSvc()->book(
"FILE101/rec2D",CLID_ColumnWiseTuple,
"MdcRecEvent 2D");
1174 m_tuple2->addItem (
"mc_theta", t2_mctheta);
1175 m_tuple2->addItem (
"mc_pt", t2_mcpt);
1176 m_tuple2->addItem (
"nDigi", t2_nDigi);
1177 m_tuple2->addItem (
"nHits", t2_nHits);
1178 m_tuple2->addItem (
"nSegs", t2_nSegs);
1179 m_tuple2->addItem (
"chi2", t2_chi2);
1180 m_tuple2->addItem (
"evtNo", t2_evtNo);
1181 m_tuple2->addItem (
"ndf", t2_ndf);
1182 m_tuple2->addItem (
"length", t2_length);
1183 m_tuple2->addItem (
"length2", t2_length2);
1184 m_tuple2->addItem (
"radius", t2_radius);
1186 m_tuple4=
ntupleSvc()->book(
"FILE101/hit",CLID_ColumnWiseTuple,
"MdcRecEvent Hits");
1187 m_tuple4->addItem (
"d_cal", t4_Dist);
1188 m_tuple4->addItem (
"d_meas", t4_drift);
1189 m_tuple4->addItem (
"e_meas", t4_dDrift);
1190 m_tuple4->addItem (
"mc_drift", t4_mcDrift);
1191 m_tuple4->addItem (
"mcLR", t4_mcLR);
1192 m_tuple4->addItem (
"pull", t4_pull);
1193 m_tuple4->addItem (
"lyrId", t4_lyrId);
1194 m_tuple4->addItem (
"localId", t4_localId);
1195 m_tuple4->addItem (
"LR", t4_LR);
1196 m_tuple4->addItem (
"tdc", t4_tdc);
1197 m_tuple4->addItem (
"z", t4_z);
1198 m_tuple4->addItem (
"bz", t4_bz);
1199 m_tuple4->addItem (
"fz", t4_fz);
1200 m_tuple4->addItem (
"fy", t4_fy);
1201 m_tuple4->addItem (
"phi", t4_phi);
1202 m_tuple4->addItem (
"nHits", t4_nHits);
1204 m_tuple5=
ntupleSvc()->book(
"FILE101/char",CLID_ColumnWiseTuple,
"MdcRecEvent Charge");
1205 m_tuple5->addItem (
"ptotPos", t5_ptotPos);
1206 m_tuple5->addItem (
"ptotNeg", t5_ptotNeg);
1207 m_tuple5->addItem (
"drPos", t5_drPos);
1208 m_tuple5->addItem (
"drNeg", t5_drNeg);
1209 m_tuple5->addItem (
"dzPos", t5_dzPos);
1210 m_tuple5->addItem (
"dzNeg", t5_dzNeg);
1212 m_tuple6=
ntupleSvc()->book(
"FILE101/urec",CLID_ColumnWiseTuple,
"MdcRecEvent urec");
1213 m_tuple6->addItem (
"length2", u_length2);
1214 m_tuple6->addItem (
"mc_ptot", u_mcptot);
1215 m_tuple6->addItem (
"mc_pt", u_mcpt);
1216 m_tuple6->addItem (
"mc_theta", u_mctheta);
1217 m_tuple6->addItem (
"nDigi", u_nDigi);
1218 m_tuple6->addItem (
"evtNo", u_evtNo);
1219 m_tuple6->addItem (
"mc_t0", u_mct0);
1220 m_tuple6->addItem (
"t0", ut_t0);
1221 m_tuple6->addItem (
"t0_sta", ut0_sta);
1224 m_tuple7=
ntupleSvc()->book(
"FILE101/time",CLID_ColumnWiseTuple,
"MdcRecEvent time");
1225 m_tuple7->addItem (
"time", ti_eventTime);
1226 m_tuple7->addItem (
"recNum", ti_recTrkNum);
1227 m_tuple7->addItem (
"evtNo", ti_evtNo);
1228 m_tuple7->addItem (
"nHits", ti_nHits);
1229 m_tuple7->addItem (
"nDigi", ti_nDigi);
1232 m_tuple9=
ntupleSvc()->book(
"FILE101/seg",CLID_ColumnWiseTuple,
"MdcRecEvent segments");
1233 m_tuple9->addItem (
"times", t9_times);
1234 m_tuple9->addItem (
"nLinks", t9_nLinks);
1235 m_tuple9->addItem (
"nUsed", t9_nUsed);
1236 m_tuple9->addItem (
"nSL", t9_nSL);
1237 m_tuple9->addItem (
"mctheta", t9_mctheta);
1239 m_tuple10=
ntupleSvc()->book(
"FILE101/rawHit",CLID_ColumnWiseTuple,
"MdcRecEvent mchitCOL");
1240 m_tuple10->addItem (
"tdc", t10_tdc);
1241 m_tuple10->addItem (
"adc", t10_adc);
1242 m_tuple10->addItem (
"Drift", t10_drift);
1243 m_tuple10->addItem (
"dDrift", t10_dDrift);
1244 m_tuple10->addItem (
"lyrId", t10_lyrId);
1245 m_tuple10->addItem (
"localId", t10_localId);
1249TrkReco::FillTuple(
void) {
1250 MsgStream log(
msgSvc(), name());
1251 log << MSG::INFO <<
"fill Tuple()" << endreq;
1257 tracks2D = _trackManager.
tracks2D();
1260 if(
tracks.length()==0) cout<<
"zslength: 3D length=0, and the 2D length is"<<tracks2D.length()<<endl;
1265 ti_eventTime = m_timer[1]->
elapsed();
1266 ti_nDigi = MC_DIGI_SIZE;
1267 ti_recTrkNum =
tracks.length();
1268 ti_evtNo = _nEvents;
1269 for (
unsigned i = 0; i < ti_recTrkNum; ++i)
1270 ti_nHits +=
tracks[i]->nLinks();
1275 CLHEP::Hep3Vector MC_TRACK_VEC;
1276 CLHEP::HepLorentzVector MC_TRACK_LRZVEC;
1278 double MC_EVENT_TIME;
1284 SmartDataPtr<Event::McParticleCol> mcParticleCol(eventSvc(),
"/Event/MC/McParticleCol");
1285 if (mcParticleCol) {
1286 Event::McParticleCol::iterator iter_mc = mcParticleCol->begin();
1288 for (;iter_mc != mcParticleCol->end(); iter_mc++, digiId++) {
1289 if((*iter_mc)->statusFlags()==8320||(*iter_mc)->statusFlags()==128) {
1290 MC_EVENT_TIME = (*iter_mc)->initialFourMomentum().t();
1295 iter_mc = mcParticleCol->begin();
1296 MC_TRACK_LRZVEC = (*iter_mc)->initialFourMomentum();
1297 MC_TRACK_VEC = (*iter_mc)->initialFourMomentum().vect();
1298 MC_TRACK_NUM = mcParticleCol->size();
1301 iter_mc = mcParticleCol->begin();
1303 for (;iter_mc != mcParticleCol->end(); iter_mc++, digiId++) {
1304 log << MSG::INFO <<
"MDC digit No: " << digiId << endreq;
1306 <<
" particleId = " << (*iter_mc)->particleProperty()
1307 <<
" theta = " << (*iter_mc)->initialFourMomentum().theta()
1308 <<
" phi= "<< (*iter_mc)->initialFourMomentum().phi()
1309 <<
" px= "<< (*iter_mc)->initialFourMomentum().px()
1310 <<
" py= "<< (*iter_mc)->initialFourMomentum().py()
1311 <<
" pz= "<< (*iter_mc)->initialFourMomentum().pz()
1316 iter_mc = mcParticleCol->begin();
1317 for (;iter_mc != mcParticleCol->end(); iter_mc++, digiId++) {
1318 CLHEP::HepLorentzVector LRZVEC = (*iter_mc)->initialFourMomentum();
1319 CLHEP::Hep3Vector
VEC = (*iter_mc)->initialFourMomentum().vect();
1322 t3_mctheta = LRZVEC.theta();
1323 t3_mcphi =
VEC.phi();
1324 t3_mcptot =
VEC.mag()/1000.;
1325 t3_mcpt =
VEC.perp()/1000.;
1326 t3_mct0 = (*iter_mc)->initialFourMomentum().t();
1327 t3_mcpid = (*iter_mc)->particleProperty();
1328 t3_evtNo = _nEvents;
1329 if((t3_mcpid==211||t3_mcpid==-211||t3_mcpid==321)&&fabs(
cos(t3_mctheta))<0.93) ++num_par;
1336 if (
tracks.length()==0) {
1337 u_length2 = tracks2D.length();
1338 u_mct0 = MC_EVENT_TIME;
1339 u_mcptot = MC_TRACK_VEC.mag()/1000.;
1340 u_mcpt = MC_TRACK_VEC.perp()/1000.;
1341 u_mctheta = MC_TRACK_LRZVEC.theta();
1342 u_nDigi = MC_DIGI_SIZE;
1352 int flagi = -1, flagj = -1;
1355 for (
unsigned i = 0; i <
tracks.length(); i++){
1356 if(
tracks.length()<2)
break;
1358 ppp1 =
tracks[i]->p().unit();
1359 for (
unsigned j = 0; j <
tracks.length(); j++){
1361 ppp2 =
tracks[j]->p().unit();
1362 pppdDot = ppp1.dot(ppp2);
1372 if (flagi != -1 && flagj != -1 && dDot < 0) {
1373 t5_ptotPos =
tracks[flagi]->ptot();
1374 t5_ptotNeg =
tracks[flagj]->ptot();
1375 t5_drPos =
tracks[flagi]->helix().dr();
1376 t5_drNeg =
tracks[flagj]->helix().dr();
1377 t5_dzPos =
tracks[flagi]->helix().dz();
1378 t5_dzNeg =
tracks[flagj]->helix().dz();
1383 for (
unsigned i = 0; i <
tracks.length(); i++){
1384 for(
unsigned k = 0; k <
tracks[i]->links().length(); k++){
1385 t4_Dist =
tracks[i]->links()[k]->distance();
1386 t4_drift =
tracks[i]->links()[k]->drift();
1387 t4_dDrift=
tracks[i]->links()[k]->dDrift();
1388 t4_pull =
tracks[i]->links()[k]->pull();
1390 t4_LR =
tracks[i]->links()[k]->leftRight();
1391 if (t4_LR == 0) t4_LR = -1;
1392 t4_lyrId =
tracks[i]->links()[k]->wire()->layerId();
1393 t4_localId =
tracks[i]->links()[k]->wire()->localId();
1394 t4_tdc =
tracks[i]->links()[k]->hit()->reccdc()->tdc;
1395 t4_z =
tracks[i]->links()[k]->positionOnTrack().z();
1396 t4_bz =
tracks[i]->links()[k]->wire()->backwardPosition().z();
1397 t4_fz =
tracks[i]->links()[k]->wire()->forwardPosition().z();
1398 t4_fy =
tracks[i]->links()[k]->wire()->forwardPosition().y();
1399 t4_nHits =
tracks[i]->links().length();
1400 unsigned lyrID =
tracks[i]->links()[k]->wire()->layerId();
1403 t4_phi = phi0 + t4_localId*2*
pi/nWir;
1404 if(t4_phi<0) t4_phi+=2*
pi;
1407 SmartDataPtr<Event::MdcMcHitCol> mcMdcMcHitCol(eventSvc(),
"/Event/MC/MdcMcHitCol");
1408 if (mcMdcMcHitCol) {
1409 Event::MdcMcHitCol::iterator iter_mchit1 = mcMdcMcHitCol->begin();
1411 for (;iter_mchit1 != mcMdcMcHitCol->end(); iter_mchit1++, digiId++) {
1412 const Identifier ident = (*iter_mchit1)->identify();
1415 t4_mcDrift = (*iter_mchit1)->getDriftDistance();
1416 t4_mcLR = (*iter_mchit1)->getPositionFlag();
1417 if (t4_mcLR == 0) t4_mcLR = -1;
1428 unsigned segSize =
tracks[i]->segments().length();
1429 for(
unsigned kk = 0; kk < segSize; ++kk) {
1430 unsigned segLength =
tracks[i]->segments()[kk]->links().length();
1433 for(
unsigned nn = 0; nn < segLength; ++nn) {
1434 double tmpX = ll[nn]->positionD().x();
1435 double tmpY = ll[nn]->positionD().y();
1436 double tmpA =
tracks[i]->segments()[kk]->lineTsf().x();
1437 double tmpB =
tracks[i]->segments()[kk]->lineTsf().y();
1438 double tmpC =
tracks[i]->segments()[kk]->lineTsf().z();
1439 double dis = fabs(tmpA * tmpX + tmpB * tmpY + tmpC) / sqrt(tmpA * tmpA + tmpB * tmpB);
1440 double idealDis = maxdDistance(ll[nn]);
1441 if(fabs(dis-ll[nn]->cDrift())/idealDis<0.001 && nSmall<2) {
1445 t9_times += fabs(dis-ll[nn]->cDrift())/idealDis;
1447 t9_nSL = ll[0]->wire()->superLayerId();
1448 t9_nLinks = segLength;
1449 t9_mctheta = MC_TRACK_LRZVEC.theta();
1450 t9_times = t9_times / (t9_nLinks - nSmall);
1454 t_mcphi = MC_TRACK_VEC.phi();
1455 t_mctheta = MC_TRACK_LRZVEC.theta();
1456 t_mcptot = MC_TRACK_VEC.mag()/1000.;
1457 t_mcpt = MC_TRACK_VEC.perp()/1000.;
1458 t_mcpz = MC_TRACK_LRZVEC.pz()/1000.;
1459 t_mct0 = MC_EVENT_TIME;
1460 t_nDigi = MC_DIGI_SIZE;
1462 t_dr =
tracks[i]->helix().dr();
1463 t_dz =
tracks[i]->helix().dz();
1465 t_ptot =
tracks[i]->ptot();
1466 t_tanlmd =
tracks[i]->helix().tanl();
1467 t_phi =
tracks[i]->helix().phi0();
1468 t_chi2 =
tracks[i]->chi2();
1469 t_nHits =
tracks[i]->nLinks();
1470 t_nCores =
tracks[i]->nCores();
1471 t_nSegs =
tracks[i]->segments().length();
1472 t_ndf =
tracks[i]->ndf();
1473 t_radius =
tracks[i]->radius();
1475 t_length =
tracks.length();
1476 t_length2 = tracks2D.length();
1478 t_dpt =
tracks[i]->pt() - t_mcpt;
1479 t_dptot =
tracks[i]->ptot() - t_mcptot;
1480 t_dlmd = atan(
tracks[i]->helix().tanl()) - (
pi/2 - t_mctheta);
1481 t_dphi =
tracks[i]->helix().phi0() - t_mcphi;
1488 unsigned mcTrackSize = MC_TRACK_NUM;
1489 unsigned recTrackSize =
tracks.length();
1490 const unsigned matchSize = 20;
1493 int mLayers[matchSize];
1494 for (
int ii=0; ii<matchSize; ii++)
1496 for(
int jj = 0; jj < 43; ++jj) {
1498 for(
unsigned kk = 0; kk < matchSize; ++kk)
1500 for(
int kk = 0; kk < 288; ++kk) {
1501 if (havedigi[jj][kk]<0)
continue;
1502 tmp[havedigi[jj][kk]] = 1;
1504 for(
int kk = 0; kk < matchSize; ++kk)
1505 if(tmp[kk] == 1) ++mLayers[kk];
1508 unsigned trackSize =
tracks[i]->nLinks();
1510 int nLayers[matchSize];
1511 for (
int j = 0; j < 43; ++j)
1513 for (
int j = 0; j < matchSize; ++j)
1516 for (
int j = 0; j < trackSize; ++j) {
1517 unsigned lId =
tracks[i]->links()[j]->wire()->layerId();
1518 unsigned loId =
tracks[i]->links()[j]->wire()->localId();
1519 if (havedigi[lId][loId] >= 0) trkIndex[lId] = havedigi[lId][loId];
1521 for (
int j = 0; j < 43; ++j)
1522 if (trkIndex[j] >= 0) ++nLayers[trkIndex[j]];
1524 for (
int j = 0; j < matchSize; ++j) {
1526 if (nLayers[j]==0)
continue;
1527 if ((
float)nLayers[j]/(
float)mLayers[j] > 0.51) {
1528 t_gdNLayers = nLayers[j];
1529 t_mcNLayers = mLayers[j];
1530 t_good_theta = MC_TRACK_LRZVEC.theta();
1535 if (t_good_theta == 0.) {
1538 for (
int j = 0; j < matchSize; ++j) {
1539 if (nLayers[j]==0)
continue;
1540 if (nLayers[j] > tmpLayers) {
1541 tmpLayers = nLayers[j];
1546 t_bestNLayers = nLayers[tmpi];
1547 t_bestMcNLayers = mLayers[tmpi];
1551 t_bestMcNLayers = -1;
1556 t_bestMcNLayers = -2;
1563 t3_mctheta = MC_TRACK_LRZVEC.theta();
1564 t3_mcptot = MC_TRACK_VEC.mag()/1000.;
1565 t3_mcpt = MC_TRACK_VEC.perp()/1000.;
1567 t3_nDigi = MC_DIGI_SIZE;
1570 t3_goodLength = nGood;
1571 t3_length =
tracks.length();
1572 t3_finalLength = num_par;
1575 for (
unsigned i = 0; i < tracks2D.length(); i++) {
1576 t2_mctheta = MC_TRACK_LRZVEC.theta();
1577 t2_mcpt = MC_TRACK_VEC.perp()/1000.;
1579 t2_nDigi = MC_DIGI_SIZE;
1580 t2_nHits = tracks2D[i]->nLinks();
1581 t2_nSegs = tracks2D[i]->segments().length();
1582 t2_chi2 = tracks2D[i]->chi2();
1583 t2_ndf = tracks2D[i]->ndf();
1584 t2_radius = tracks2D[i]->radius();
1585 t2_evtNo = _nEvents;
1586 t2_length =
tracks.length();
1587 t2_length2 = tracks2D.length();
1593TrkReco::maxdDistance(
TMLink *l)
const{
1596 double _averR[11] = {9.7, 14.5, 22.14, 28.62, 35.1, 42.39, 48.87, 55.35, 61.83, 69.12, 74.79};
1597 double _averR2[43] = { 7.885, 9.07, 10.29, 11.525,
1598 12.72, 13.875, 15.01, 16.16,
1599 19.7, 21.3, 22.955, 24.555,
1600 26.215, 27.82, 29.465, 31.06,
1601 32.69, 34.265, 35.875, 37.455,
1602 39.975, 41.52, 43.12, 44.76,
1603 46.415, 48.02, 49.685, 51.37,
1604 53.035, 54.595, 56.215, 57.855,
1605 59.475, 60.995, 62.565, 64.165,
1606 66.68, 68.285, 69.915, 71.57,
1607 73.21, 74.76, 76.345};
1608 double radius = _averR2[lId];
1609 const double singleSigma = l->
dDrift();
1610 return 2 * singleSigma / (radius * radius);
double cos(const BesAngle a)
std::vector< double > VEC
std::vector< MdcDigi * > MdcDigiVec
ObjectVector< RecMdcHit > RecMdcHitCol
ObjectVector< RecMdcTrack > RecMdcTrackCol
SmartRefVector< RecMdcHit > HitRefVec
const HepPoint3D ORIGIN
Constants.
#define WireHitFindingValid
float TrkRecoHelixFitterChisqMax
float TrkRecoHelixFitterChisqMax
void propName(std::string name)
float elapsed(void) const
virtual void print(void)=0
virtual BesTimer * addItem(const std::string &name)=0
double getSigma(int layid, int lr, double dist, double entrance=0.0, double tanlam=0.0, double z=0.0, double Q=1000.0) const
double getT0(int layid, int cellid) const
double driftTimeToDist(double drifttime, int layid, int cellid, int lr, double entrance=0.0) const
double getTimeWalk(int layid, double Q) const
double Radius(void) const
MdcGeoLayer * Lyr(void) const
const MdcGeoWire *const Wire(unsigned id)
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
static int wire(const Identifier &id)
static vector< MdcRec_wirhit > * getMdcRecWirhitCol(void)
MdcDigiVec & getMdcDigiVec(uint32_t control=0)
static double MdcTime(int timeChannel)
int doit(const AList< TMDCWireHit > &axialHits, const AList< TMDCWireHit > &stereoHits, AList< TTrack > &tracks, AList< TTrack > &tracks2D)
main function
void clear(void)
cleans all members of this class
virtual int debugLevel(void) const
returns debug level.
virtual bool doStereo(bool)
sets flag to reconstruct 3D.
virtual bool doSalvage(bool)
sets flag to salvage hits.
virtual void clear(void)=0
clear internal information.
virtual int doit(const AList< TMDCWireHit > &axialHits, const AList< TMDCWireHit > &stereoHits, AList< TTrack > &tracks3D, AList< TTrack > &tracks2D)=0
finds tracks. 'hits' are used to reconstruct. 'tracks' can be used for both inputs and outputs....
float offset(void) const
returns offset.
unsigned nWires(void) const
returns # of wires.
unsigned layerId(void) const
returns layer id.
unsigned superLayerId(void) const
returns super layer id.
void fastClear(void)
clears TMDC information.
void update(bool mcAnalysis=true)
updates TMDC information. clear() is called in this function.
float fudgeFactor(void) const
returns fudge factor for drift time error.
const AList< TMDCWireHit > & hits(unsigned mask=0) const
returns a list of TMDCWireHit. 'update()' must be called before calling this function.
static TMDC * getTMDC(void)
const AList< TMDCWireHit > & axialHits(unsigned mask=0) const
returns a list of axial hits. 'update()' must be called before calling this function.
const TMDCLayer *const layer(unsigned id) const
returns a pointer to a layer. 0 will be returned if 'id' is invalid.
const AList< TMDCWireHit > & stereoHits(unsigned mask=0) const
returns a list of stereo hits. 'update()' must be called before calling this function.
int debugLevel(void) const
returns debug level.
A class to relate TMDCWireHit and TTrack objects.
float dDrift(void) const
returns/sets drift distance error.
const TMDCWire *const wire(void) const
returns a pointer to a wire.
void setBesFromGdml(void)
virtual int fit(TTrackBase &) const
A class to represent a track in tracking.
virtual void removeLinks(void)
void append(TMLink &)
appends a TMLink.
const AList< TMLink > & links(unsigned mask=0) const
returns a list of masked TMLinks assigned to this track. 'mask' will be applied if mask is not 0.
static const AList< TTrackHEP > & list(void)
returns a list of TTrackHEP's.
A class to have MC information of TTrack.
int hepId(void) const
returns HEP ID.
void update(void)
updates information.
bool charge(void) const
returns charge matching.
void append2D(AList< TTrack > &list)
void clearTables(void) const
clears tables.
void append(AList< TTrack > &list)
appends (2D) tracks. 'list' will be cleaned up.
const AList< TTrack > & tracksFinal(void) const
returns a list of tracks writen to MdcRec_trk.
StatusCode makeTds(RecMdcTrackCol *trackList, RecMdcHitCol *hitList, int tkStat=1, int runge=0, int cal=0)
stores track info. into TDS. by Zang Shilei
const AList< TTrack > & tracks2D(void) const
returns a list of 2D tracks.
const AList< TTrack > & tracks(void) const
returns a list of reconstructed tracks.
int debugLevel(void) const
returns/sets debug level.
void mask(void) const
masks hits out which are in tail of curly tracks.
double maxMomentum(double)
sets the max. momentum.
void maskCurlHits(const AList< TMDCWireHit > &axial, const AList< TMDCWireHit > &stereo, const AList< TTrack > &tracks) const
masks hits on found curl tracks.
void fittingFlag(unsigned)
sets fitting flag.
StatusCode determineT0(unsigned level, unsigned nMaxTracks)
determines T0 and refit all tracks.
void salvage(const AList< TMDCWireHit > &) const
salvages remaining hits.
void clear(void)
clears all internal information.
A class to represent a track in tracking.
int b_conformalSalvageLoadWidth
float b_conformalStereoZ3
double selector_replace_dz
double good_distance_for_salvage
int b_doConformalFastFinder
double range_for_stereo_last2d_search
int b_conformalFittingFlag
int b_doConformalFinderStereo
double MIN_RADIUS_OF_STRANGE_TRACK
int superlayer_for_stereo_search
double z_diff_for_last_attend
float b_conformalStereoSzLinkDistance
int b_conformalFittingCorrections
float b_helixFitterChisqMax
double bad_distance_for_salvage
int b_conformalMinNLinksForSegment
double range_for_stereo_search
float b_conformalStereoZ4
double selector_max_sigma
double minimum_2DTrackLength
float b_conformalMaxSigma
double minimum_closeHitsLength
float b_conformalStereoChisq3
double ULTIMATE_MIN_RADIUS_OF_STRANGE_TRACK
double minimum_seedLength
void fastClear(void)
clears TMDC information.
int b_conformalStereoMode
double selector_strange_pz
int b_conformalMinNSegments
const AList< TTrack > & tracks(void) const
returns a list of reconstructed tracks.
void clear(void)
clears all TMDC information.
double trace2d_first_distance
int b_conformalStereoLoadWidth
float b_conformalStereoSzSegmentDistance
double minimum_3DTrackLength
int b_doConformalSlowFinder
float b_conformalFraction
int b_RungeKuttaCorrection
double range_for_axial_last2d_search
float b_conformalStereoMaxSigma
int b_conformalPerfectSegmentFinding
double range_for_axial_search
float b_conformalStereoChisq4
void disp_stat(const char *)
initializes TrkReco.
double selector_max_impact
int b_doConformalFinderCosmic
_EXTERN_ std::string RecMdcTrackCol
_EXTERN_ std::string RecMdcHitCol