6#include "GaudiKernel/MsgStream.h"
7#include "GaudiKernel/AlgFactory.h"
8#include "GaudiKernel/ISvcLocator.h"
9#include "GaudiKernel/SmartDataPtr.h"
10#include "GaudiKernel/IDataProviderSvc.h"
11#include "GaudiKernel/IDataManagerSvc.h"
12#include "GaudiKernel/PropertyMgr.h"
15#include "CLHEP/Matrix/SymMatrix.h"
16#include "CLHEP/Vector/ThreeVector.h"
30string parName[5]={
"e",
"mu",
"pi",
"kaon",
"proton"};
35 myParticleName =
"pi";
40 declareProperty(
"ParticleName",myParticleName);
41 declareProperty(
"GeantGeomOptimization",myGeomOptimization=
true);
42 declareProperty(
"MessageFlag",msgFlag);
43 declareProperty(
"ResultMessageFlag",myResultFlag);
44 declareProperty(
"BFieldOn",myBFieldOn=
true);
45 declareProperty(
"InputTrk",myInputTrk);
46 declareProperty(
"UseMucKalFilter",myUseMucKal=
true);
47 declareProperty(
"MucWindow",myMucWindow=6);
48 declareProperty(
"SetSeed",m_setSeed=
false);
54 if(myExtTrack)
delete myExtTrack;
60 MsgStream log(
msgSvc(), name());
61 log << MSG::INFO <<
"initialize()" << endreq;
64 StatusCode sc_det = service(
"DetVerSvc",
detVerSvc);
65 if( sc_det.isFailure() ) {
66 log << MSG::FATAL <<
"can't retrieve DetVerSvc instance" << endreq;
71 log << MSG::INFO <<
"** ~~~~~~ ** : retrieved DetectorStage = " << m_detVer << endreq;
73 myExtTrack =
new Ext_track(msgFlag,myBFieldOn,myGeomOptimization,m_detVer,myUseMucKal,myMucWindow);
74 myExtTrack->
Initialization(msgFlag,myBFieldOn,myGeomOptimization,myUseMucKal,myMucWindow);
101 return StatusCode::SUCCESS;
109 MsgStream log(
msgSvc(), name());
110 log << MSG::INFO <<
"execute()" << endreq;
111 int eventNumber, runNumber;
113 if(m_setSeed==
true) CLHEP::HepRandom::setTheSeed(9000);
116 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
119 log << MSG::FATAL <<
"Could not find Event Header" << endreq;
120 return( StatusCode::FAILURE);
122 runNumber = eventHeader->runNumber();
123 eventNumber = eventHeader->eventNumber();
127 cout<<
"TrackExt: ******************* Start a event *******************"<<endl;
128 cout<<
"run= "<<runNumber<<
"; event= "<<eventNumber<<endl;
132 SmartDataPtr<MucDigiCol> mucDigiCol(eventSvc(),
"/Event/Digi/MucDigiCol");
134 log << MSG::FATAL <<
"Could not find MUC digi" << endreq;
135 return( StatusCode::SUCCESS);
145 if(myParticleName==
"e") parID=0;
146 else if(myParticleName==
"mu") parID=1;
147 else if(myParticleName==
"pi") parID=2;
148 else if(myParticleName==
"kaon") parID=3;
149 else if(myParticleName==
"proton"||myParticleName==
"anti_proton") parID=4;
151 if(myInputTrk==
"Mdc")
153 SmartDataPtr<RecMdcTrackCol> aMdcTrackCol(eventSvc(),
"/Event/Recon/RecMdcTrackCol");
156 log << MSG::WARNING <<
"Can't find RecMdcTrackCol in TDS!" << endreq;
157 return( StatusCode::SUCCESS);
162 else if(myInputTrk==
"Kal")
164 SmartDataPtr<RecMdcKalTrackCol> aMdcKalTrackCol(eventSvc(),
"/Event/Recon/RecMdcKalTrackCol");
167 log << MSG::WARNING <<
"Can't find RecMdcKalTrackCol in TDS!" << endreq;
168 return( StatusCode::SUCCESS);
174 log << MSG::WARNING <<
"Wrong type of inputTrk:" << myInputTrk << endreq;
175 return( StatusCode::SUCCESS);
186 for(
int i=0; i<5; i++)
198 double tofInMdc = aExtMdcTrack.
GetTrkTof();
202 cout<<
"Start From:"<<position.x()<<
' '<<position.y()<<
' '
203 <<position.z()<<endl;
205 cout<<
"Start Error matrix:"<<error<<endl;
206 cout<<
"Path before start:"<< pathInMDC << endl;
209 G4String aParticleName(
parName[i]);
211 if(!aParticleName.contains(
"proton"))
213 if(
charge>0) aParticleName +=
"+";
214 else aParticleName +=
"-";
218 if(
charge>0) aParticleName =
"proton";
219 else aParticleName =
"anti_proton";
224 cout<<
"Charge: "<<
charge<<endl;
225 cout<<
"Particle: "<<aParticleName<<endl;
232 extSteppingAction->
Reset();
235 bool m_trackstatus =
false;
236 int trk_startpart = 0;
237 while(!m_trackstatus)
242 {cout<<
"-------has modified more than 20 times---------"<<endl;
break;}
243 if(myExtTrack->
Set(position,
momentum,error,aParticleName,pathInMDC,tofInMdc))
247 m_trackstatus = extSteppingAction->
TrackStop();
250 m_trackstatus =
true;
258 if(msgFlag) cout<<
"will add aExtTrack!"<<endl;
261 if(aExtTrack) aExtTrackCol->add(aExtTrack);
262 else if(msgFlag) cout<<
"No aExtTrack!"<<endl;
266 if(msgFlag) cout<<
"No aExtTrackCol!"<<endl;
268 if(msgFlag) cout<<
"add a aExtTrack!"<<endl;
300 SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
303 DataObject *extTrackCol;
304 eventSvc()->findObject(
"/Event/Recon/RecExtTrackCol",extTrackCol);
305 if(extTrackCol != NULL) {
306 dataManSvc->clearSubTree(
"/Event/Recon/RecExtTrackCol");
307 eventSvc()->unregisterObject(
"/Event/Recon/RecExtTrackCol");
312 StatusCode sc = eventSvc()->registerObject(
"/Event/Recon/RecExtTrackCol", aExtTrackCol);
313 if(sc!=StatusCode::SUCCESS) {
314 log << MSG::FATAL <<
"Could not register RecExtTrackCol in TDS!" << endreq;
315 return( StatusCode::FAILURE);
320 SmartDataPtr<RecExtTrackCol> aExtTrkCol(eventSvc(),
"/Event/Recon/RecExtTrackCol");
322 log << MSG::FATAL <<
"Can't find RecExtTrackCol in TDS!" << endreq;
323 return( StatusCode::FAILURE);
326 RecExtTrackCol::iterator iterOfExtTrk;
329 for(iterOfExtTrk = aExtTrkCol->begin();iterOfExtTrk!=aExtTrkCol->end();iterOfExtTrk++)
333 for(
int i=0; i<5; i++)
336 cout<<
"##########track"<<j<<
": "<<
"("<<i<<
")"<<endl;
337 cout<<
"******TOF1:******"<<endl;
338 cout<<
"VolumeName: "<<(*iterOfExtTrk)->tof1VolumeName(i)<<
"\t"
339 <<
"VolumeNumber: "<<(*iterOfExtTrk)->tof1VolumeNumber(i)<<
"\t"<<endl
340 <<
"Position: "<<(*iterOfExtTrk)->tof1Position(i)<<
"\t"
341 <<
"Momentum: "<<(*iterOfExtTrk)->tof1Momentum(i)<<
"\t"<<endl
342 <<
"Error matrix: "<<(*iterOfExtTrk)->tof1ErrorMatrix(i)
343 <<
"Error z: "<<(*iterOfExtTrk)->tof1PosSigmaAlongZ(i)<<
"\t"
344 <<
"Error Tz: "<<(*iterOfExtTrk)->tof1PosSigmaAlongT(i)<<
"\t"
345 <<
"Error x: "<<(*iterOfExtTrk)->tof1PosSigmaAlongX(i)<<
"\t"
346 <<
"Error y: "<<(*iterOfExtTrk)->tof1PosSigmaAlongY(i)<<endl
347 <<
"Tof: "<<(*iterOfExtTrk)->tof1(i)<<
"\t"
348 <<
"PathOF: "<<(*iterOfExtTrk)->tof1Path(i)
350 cout<<
"******TOF2:******"<<endl;
351 cout<<
"VolumeName: "<<(*iterOfExtTrk)->tof2VolumeName(i)<<
"\t"
352 <<
"VolumeNumber: "<<(*iterOfExtTrk)->tof2VolumeNumber(i)<<
"\t"<<endl
353 <<
"Position: "<<(*iterOfExtTrk)->tof2Position(i)<<
"\t"
354 <<
"Momentum: "<<(*iterOfExtTrk)->tof2Momentum(i)<<
"\t"<<endl
355 <<
"Error matrix: "<<(*iterOfExtTrk)->tof2ErrorMatrix(i)
356 <<
"Error z: "<<(*iterOfExtTrk)->tof2PosSigmaAlongZ(i)<<
"\t"
357 <<
"Error Tz: "<<(*iterOfExtTrk)->tof2PosSigmaAlongT(i)<<
"\t"
358 <<
"Error x: "<<(*iterOfExtTrk)->tof2PosSigmaAlongX(i)<<
"\t"
359 <<
"Error y: "<<(*iterOfExtTrk)->tof2PosSigmaAlongY(i)<<endl
360 <<
"Tof: "<<(*iterOfExtTrk)->tof2(i)<<
"\t"
361 <<
"PathOF: "<<(*iterOfExtTrk)->tof2Path(i)
365 cout<<
"******EMC:******"<<endl
366 <<
"VolumeName: "<<(*iterOfExtTrk)->emcVolumeName(i)<<
"\t"
367 <<
"VolumeNumber: "<<(*iterOfExtTrk)->emcVolumeNumber(i)<<
"\t"<<endl
368 <<
"Position: "<<(*iterOfExtTrk)->emcPosition(i)<<
"\t"
369 <<
"Momentum: "<<(*iterOfExtTrk)->emcMomentum(i)<<
"\t"<<endl
370 <<
"Error matrix: "<<(*iterOfExtTrk)->emcErrorMatrix(i)
371 <<
"Error theta: "<<(*iterOfExtTrk)->emcPosSigmaAlongTheta(i)<<
"\t"
372 <<
"Error phi: "<<(*iterOfExtTrk)->emcPosSigmaAlongPhi(i)<<
"\t"
373 <<
"EMC path: "<<(*iterOfExtTrk)->emcPath(i)
377 cout<<
"******MUC:******"<<endl
378 <<
"VolumeName: "<<(*iterOfExtTrk)->mucVolumeName(i)<<
"\t"
379 <<
"VolumeNumber: "<<(*iterOfExtTrk)->mucVolumeNumber(i)<<endl
380 <<
"Position: "<<(*iterOfExtTrk)->mucPosition(i)<<
"\t"
381 <<
"Momentum: "<<(*iterOfExtTrk)->mucMomentum(i)<<
"\t"<<endl
382 <<
"Error matrix: "<<(*iterOfExtTrk)->mucErrorMatrix(i)
383 <<
"Error z: "<<(*iterOfExtTrk)->mucPosSigmaAlongZ(i)<<
"\t"
384 <<
"Error Tz: "<<(*iterOfExtTrk)->mucPosSigmaAlongT(i)<<
"\t"
385 <<
"Error x: "<<(*iterOfExtTrk)->mucPosSigmaAlongX(i)<<
"\t"
386 <<
"Error y: "<<(*iterOfExtTrk)->mucPosSigmaAlongY(i)
389 cout<<
"*******MUC KALMANFILTER***********"<<endl;
390 cout<<
"Chisq is "<<(*iterOfExtTrk)->MucKalchi2(i)<<endl;
391 cout<<
"Nfit is "<<(*iterOfExtTrk)->MucKaldof(i)<<endl;
392 cout<<
"chiL "<<(*iterOfExtTrk)->MucKalchi2()<<endl;
420 if(msgFlag) cout<<
"****************** End a event! ****************"<<endl<<endl;
548return StatusCode::SUCCESS;
554 MsgStream log(
msgSvc(), name());
555 log << MSG::INFO <<
"finalize()" << endreq;
560 return StatusCode::SUCCESS;
**********INTEGER nmxhep !maximum number of particles DOUBLE PRECISION vhep INTEGER jdahep COMMON hepevt $ !serial number $ !number of particles $ !status code $ !particle ident KF $ !parent particles $ !childreen particles $ !four momentum
ObjectVector< RecExtTrack > RecExtTrackCol
void SetTrackId(int trackId)
void SetParType(int aParType=2)
double GetParticleCharge() const
double GetTrackLength() const
bool SetMdcKalTrkCol(RecMdcKalTrackCol *aPointer)
bool SetMdcRecTrkCol(RecMdcTrackCol *aPointer)
const Hep3Vector GetPosition() const
const HepSymMatrix GetErrorMatrix() const
const Hep3Vector GetMomentum() const
void SetMsgFlag(bool aFlag)
void SetExtTrackPointer(RecExtTrack *aExtTrack)
void InfmodMuc(Hep3Vector &pos, Hep3Vector &mom, HepSymMatrix &err)
void Set_which_tof_version(int version)
void SetMucDigiColPointer(MucDigiCol *rawdigicol)
void TrackExtrapotation()
void Initialization(const bool aMsgFlag, const bool Bfield, const bool GeomOptimization, const bool aUseMucKal, const int aMucWindow)
ExtSteppingAction * GetStepAction()
bool Set(const Hep3Vector &xv3, const Hep3Vector &pv3, const HepSymMatrix &err, const std::string &particleName, const double pathInMDC, const double tofInMdc)
TrkExtAlg(const std::string &name, ISvcLocator *pSvcLocator)