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"
13#include "EventModel/EventHeader.h"
15#include "CLHEP/Matrix/SymMatrix.h"
16#include "CLHEP/Vector/ThreeVector.h"
18#include "ExtEvent/RecExtTrack.h"
19#include "TrkExtAlg/TrkExtAlg.h"
20#include "TrkExtAlg/ExtSteppingAction.h"
23#include "TrackUtil/Helix.h"
24#include "DetVerSvc/IDetVerSvc.h"
26#include "TrkExtAlg/ExtMdcTrack.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);
53 if(myExtTrack)
delete myExtTrack;
59 MsgStream log(
msgSvc(), name());
60 log << MSG::INFO <<
"initialize()" << endreq;
63 StatusCode sc_det = service(
"DetVerSvc",
detVerSvc);
64 if( sc_det.isFailure() ) {
65 log << MSG::FATAL <<
"can't retrieve DetVerSvc instance" << endreq;
70 log << MSG::INFO <<
"** ~~~~~~ ** : retrieved DetectorStage = " << m_detVer << endreq;
72 myExtTrack =
new Ext_track(msgFlag,myBFieldOn,myGeomOptimization,m_detVer,myUseMucKal,myMucWindow);
73 myExtTrack->
Initialization(msgFlag,myBFieldOn,myGeomOptimization,myUseMucKal,myMucWindow);
100 return StatusCode::SUCCESS;
108 MsgStream log(
msgSvc(), name());
109 log << MSG::INFO <<
"execute()" << endreq;
110 int eventNumber, runNumber;
112 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
115 log << MSG::FATAL <<
"Could not find Event Header" << endreq;
116 return( StatusCode::FAILURE);
118 runNumber = eventHeader->runNumber();
119 eventNumber = eventHeader->eventNumber();
123 cout<<
"TrackExt: ******************* Start a event *******************"<<endl;
124 cout<<
"run= "<<runNumber<<
"; event= "<<eventNumber<<endl;
128 SmartDataPtr<MucDigiCol> mucDigiCol(eventSvc(),
"/Event/Digi/MucDigiCol");
130 log << MSG::FATAL <<
"Could not find MUC digi" << endreq;
131 return( StatusCode::SUCCESS);
141 if(myParticleName==
"e") parID=0;
142 else if(myParticleName==
"mu") parID=1;
143 else if(myParticleName==
"pi") parID=2;
144 else if(myParticleName==
"kaon") parID=3;
145 else if(myParticleName==
"proton"||myParticleName==
"anti_proton") parID=4;
147 if(myInputTrk==
"Mdc")
149 SmartDataPtr<RecMdcTrackCol> aMdcTrackCol(eventSvc(),
"/Event/Recon/RecMdcTrackCol");
152 log << MSG::WARNING <<
"Can't find RecMdcTrackCol in TDS!" << endreq;
153 return( StatusCode::SUCCESS);
158 else if(myInputTrk==
"Kal")
160 SmartDataPtr<RecMdcKalTrackCol> aMdcKalTrackCol(eventSvc(),
"/Event/Recon/RecMdcKalTrackCol");
163 log << MSG::WARNING <<
"Can't find RecMdcKalTrackCol in TDS!" << endreq;
164 return( StatusCode::SUCCESS);
170 log << MSG::WARNING <<
"Wrong type of inputTrk:" << myInputTrk << endreq;
171 return( StatusCode::SUCCESS);
182 for(
int i=0; i<5; i++)
194 double tofInMdc = aExtMdcTrack.
GetTrkTof();
198 cout<<
"Start From:"<<position.x()<<
' '<<position.y()<<
' '
199 <<position.z()<<endl;
201 cout<<
"Start Error matrix:"<<error<<endl;
202 cout<<
"Path before start:"<< pathInMDC << endl;
205 G4String aParticleName(
parName[i]);
207 if(!aParticleName.contains(
"proton"))
209 if(charge>0) aParticleName +=
"+";
210 else aParticleName +=
"-";
214 if(charge>0) aParticleName =
"proton";
215 else aParticleName =
"anti_proton";
220 cout<<
"Charge: "<<charge<<endl;
221 cout<<
"Particle: "<<aParticleName<<endl;
228 extSteppingAction->
Reset();
231 bool m_trackstatus =
false;
232 int trk_startpart = 0;
233 while(!m_trackstatus)
238 {cout<<
"-------has modified more than 20 times---------"<<endl;
break;}
239 if(myExtTrack->
Set(position,
momentum,error,aParticleName,pathInMDC,tofInMdc))
243 m_trackstatus = extSteppingAction->
TrackStop();
246 m_trackstatus =
true;
254 if(msgFlag) cout<<
"will add aExtTrack!"<<endl;
257 if(aExtTrack) aExtTrackCol->add(aExtTrack);
258 else if(msgFlag) cout<<
"No aExtTrack!"<<endl;
262 if(msgFlag) cout<<
"No aExtTrackCol!"<<endl;
264 if(msgFlag) cout<<
"add a aExtTrack!"<<endl;
296 SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
299 DataObject *extTrackCol;
300 eventSvc()->findObject(
"/Event/Recon/RecExtTrackCol",extTrackCol);
301 if(extTrackCol != NULL) {
302 dataManSvc->clearSubTree(
"/Event/Recon/RecExtTrackCol");
303 eventSvc()->unregisterObject(
"/Event/Recon/RecExtTrackCol");
308 StatusCode sc = eventSvc()->registerObject(
"/Event/Recon/RecExtTrackCol", aExtTrackCol);
309 if(sc!=StatusCode::SUCCESS) {
310 log << MSG::FATAL <<
"Could not register RecExtTrackCol in TDS!" << endreq;
311 return( StatusCode::FAILURE);
316 SmartDataPtr<RecExtTrackCol> aExtTrkCol(eventSvc(),
"/Event/Recon/RecExtTrackCol");
318 log << MSG::FATAL <<
"Can't find RecExtTrackCol in TDS!" << endreq;
319 return( StatusCode::FAILURE);
322 RecExtTrackCol::iterator iterOfExtTrk;
325 for(iterOfExtTrk = aExtTrkCol->begin();iterOfExtTrk!=aExtTrkCol->end();iterOfExtTrk++)
329 for(
int i=0; i<5; i++)
332 cout<<
"##########track"<<j<<
": "<<
"("<<i<<
")"<<endl;
333 cout<<
"******TOF1:******"<<endl;
334 cout<<
"VolumeName: "<<(*iterOfExtTrk)->tof1VolumeName(i)<<
"\t"
335 <<
"VolumeNumber: "<<(*iterOfExtTrk)->tof1VolumeNumber(i)<<
"\t"<<endl
336 <<
"Position: "<<(*iterOfExtTrk)->tof1Position(i)<<
"\t"
337 <<
"Momentum: "<<(*iterOfExtTrk)->tof1Momentum(i)<<
"\t"<<endl
338 <<
"Error matrix: "<<(*iterOfExtTrk)->tof1ErrorMatrix(i)
339 <<
"Error z: "<<(*iterOfExtTrk)->tof1PosSigmaAlongZ(i)<<
"\t"
340 <<
"Error Tz: "<<(*iterOfExtTrk)->tof1PosSigmaAlongT(i)<<
"\t"
341 <<
"Error x: "<<(*iterOfExtTrk)->tof1PosSigmaAlongX(i)<<
"\t"
342 <<
"Error y: "<<(*iterOfExtTrk)->tof1PosSigmaAlongY(i)<<endl
343 <<
"Tof: "<<(*iterOfExtTrk)->tof1(i)<<
"\t"
344 <<
"PathOF: "<<(*iterOfExtTrk)->tof1Path(i)
346 cout<<
"******TOF2:******"<<endl;
347 cout<<
"VolumeName: "<<(*iterOfExtTrk)->tof2VolumeName(i)<<
"\t"
348 <<
"VolumeNumber: "<<(*iterOfExtTrk)->tof2VolumeNumber(i)<<
"\t"<<endl
349 <<
"Position: "<<(*iterOfExtTrk)->tof2Position(i)<<
"\t"
350 <<
"Momentum: "<<(*iterOfExtTrk)->tof2Momentum(i)<<
"\t"<<endl
351 <<
"Error matrix: "<<(*iterOfExtTrk)->tof2ErrorMatrix(i)
352 <<
"Error z: "<<(*iterOfExtTrk)->tof2PosSigmaAlongZ(i)<<
"\t"
353 <<
"Error Tz: "<<(*iterOfExtTrk)->tof2PosSigmaAlongT(i)<<
"\t"
354 <<
"Error x: "<<(*iterOfExtTrk)->tof2PosSigmaAlongX(i)<<
"\t"
355 <<
"Error y: "<<(*iterOfExtTrk)->tof2PosSigmaAlongY(i)<<endl
356 <<
"Tof: "<<(*iterOfExtTrk)->tof2(i)<<
"\t"
357 <<
"PathOF: "<<(*iterOfExtTrk)->tof2Path(i)
361 cout<<
"******EMC:******"<<endl
362 <<
"VolumeName: "<<(*iterOfExtTrk)->emcVolumeName(i)<<
"\t"
363 <<
"VolumeNumber: "<<(*iterOfExtTrk)->emcVolumeNumber(i)<<
"\t"<<endl
364 <<
"Position: "<<(*iterOfExtTrk)->emcPosition(i)<<
"\t"
365 <<
"Momentum: "<<(*iterOfExtTrk)->emcMomentum(i)<<
"\t"<<endl
366 <<
"Error matrix: "<<(*iterOfExtTrk)->emcErrorMatrix(i)
367 <<
"Error theta: "<<(*iterOfExtTrk)->emcPosSigmaAlongTheta(i)<<
"\t"
368 <<
"Error phi: "<<(*iterOfExtTrk)->emcPosSigmaAlongPhi(i)<<
"\t"
369 <<
"EMC path: "<<(*iterOfExtTrk)->emcPath(i)
373 cout<<
"******MUC:******"<<endl
374 <<
"VolumeName: "<<(*iterOfExtTrk)->mucVolumeName(i)<<
"\t"
375 <<
"VolumeNumber: "<<(*iterOfExtTrk)->mucVolumeNumber(i)<<endl
376 <<
"Position: "<<(*iterOfExtTrk)->mucPosition(i)<<
"\t"
377 <<
"Momentum: "<<(*iterOfExtTrk)->mucMomentum(i)<<
"\t"<<endl
378 <<
"Error matrix: "<<(*iterOfExtTrk)->mucErrorMatrix(i)
379 <<
"Error z: "<<(*iterOfExtTrk)->mucPosSigmaAlongZ(i)<<
"\t"
380 <<
"Error Tz: "<<(*iterOfExtTrk)->mucPosSigmaAlongT(i)<<
"\t"
381 <<
"Error x: "<<(*iterOfExtTrk)->mucPosSigmaAlongX(i)<<
"\t"
382 <<
"Error y: "<<(*iterOfExtTrk)->mucPosSigmaAlongY(i)
385 cout<<
"*******MUC KALMANFILTER***********"<<endl;
386 cout<<
"Chisq is "<<(*iterOfExtTrk)->MucKalchi2(i)<<endl;
387 cout<<
"Nfit is "<<(*iterOfExtTrk)->MucKaldof(i)<<endl;
388 cout<<
"chiL "<<(*iterOfExtTrk)->MucKalchi2()<<endl;
416 if(msgFlag) cout<<
"****************** End a event! ****************"<<endl<<endl;
544return StatusCode::SUCCESS;
550 MsgStream log(
msgSvc(), name());
551 log << MSG::INFO <<
"finalize()" << endreq;
556 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)