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"
29string parName[5]={
"e",
"mu",
"pi",
"kaon",
"proton"};
34 myParticleName =
"pi";
39 declareProperty(
"ParticleName",myParticleName);
40 declareProperty(
"GeantGeomOptimization",myGeomOptimization=
true);
41 declareProperty(
"MessageFlag",msgFlag);
42 declareProperty(
"ResultMessageFlag",myResultFlag);
43 declareProperty(
"BFieldOn",myBFieldOn=
true);
44 declareProperty(
"InputTrk",myInputTrk);
45 declareProperty(
"Tof",m_tof=2);
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;
62 myExtTrack =
new Ext_track(msgFlag,myBFieldOn,myGeomOptimization,m_tof,myUseMucKal,myMucWindow);
63 myExtTrack->
Initialization(msgFlag,myBFieldOn,myGeomOptimization,myUseMucKal,myMucWindow);
90 return StatusCode::SUCCESS;
98 MsgStream log(
msgSvc(), name());
99 log << MSG::INFO <<
"execute()" << endreq;
100 int eventNumber, runNumber;
102 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),
"/Event/EventHeader");
105 log << MSG::FATAL <<
"Could not find Event Header" << endreq;
106 return( StatusCode::FAILURE);
108 runNumber = eventHeader->runNumber();
109 eventNumber = eventHeader->eventNumber();
110 if(runNumber==13219&&eventNumber==3031231)
return( StatusCode::SUCCESS);
114 cout<<
"TrackExt: ******************* Start a event *******************"<<endl;
115 cout<<
"run= "<<runNumber<<
"; event= "<<eventNumber<<endl;
119 SmartDataPtr<MucDigiCol> mucDigiCol(eventSvc(),
"/Event/Digi/MucDigiCol");
121 log << MSG::FATAL <<
"Could not find MUC digi" << endreq;
122 return( StatusCode::SUCCESS);
132 if(myParticleName==
"e") parID=0;
133 else if(myParticleName==
"mu") parID=1;
134 else if(myParticleName==
"pi") parID=2;
135 else if(myParticleName==
"kaon") parID=3;
136 else if(myParticleName==
"proton"||myParticleName==
"anti_proton") parID=4;
138 if(myInputTrk==
"Mdc")
140 SmartDataPtr<RecMdcTrackCol> aMdcTrackCol(eventSvc(),
"/Event/Recon/RecMdcTrackCol");
143 log << MSG::WARNING <<
"Can't find RecMdcTrackCol in TDS!" << endreq;
144 return( StatusCode::SUCCESS);
149 else if(myInputTrk==
"Kal")
151 SmartDataPtr<RecMdcKalTrackCol> aMdcKalTrackCol(eventSvc(),
"/Event/Recon/RecMdcKalTrackCol");
154 log << MSG::WARNING <<
"Can't find RecMdcKalTrackCol in TDS!" << endreq;
155 return( StatusCode::SUCCESS);
161 log << MSG::WARNING <<
"Wrong type of inputTrk:" << myInputTrk << endreq;
162 return( StatusCode::SUCCESS);
173 for(
int i=0; i<5; i++)
185 double tofInMdc = aExtMdcTrack.
GetTrkTof();
189 cout<<
"Start From:"<<position.x()<<
' '<<position.y()<<
' '
190 <<position.z()<<endl;
192 cout<<
"Start Error matrix:"<<error<<endl;
193 cout<<
"Path before start:"<< pathInMDC << endl;
196 G4String aParticleName(
parName[i]);
198 if(!aParticleName.contains(
"proton"))
200 if(charge>0) aParticleName +=
"+";
201 else aParticleName +=
"-";
205 if(charge>0) aParticleName =
"proton";
206 else aParticleName =
"anti_proton";
211 cout<<
"Charge: "<<charge<<endl;
212 cout<<
"Particle: "<<aParticleName<<endl;
217 extSteppingAction->
Reset();
220 bool m_trackstatus =
false;
221 int trk_startpart = 0;
222 while(!m_trackstatus)
227 {cout<<
"-------has modified more than 20 times---------"<<endl;
break;}
228 if(myExtTrack->
Set(position,
momentum,error,aParticleName,pathInMDC,tofInMdc))
232 m_trackstatus = extSteppingAction->
TrackStop();
235 m_trackstatus =
true;
243 if(msgFlag) cout<<
"will add aExtTrack!"<<endl;
246 if(aExtTrack) aExtTrackCol->add(aExtTrack);
247 else if(msgFlag) cout<<
"No aExtTrack!"<<endl;
251 if(msgFlag) cout<<
"No aExtTrackCol!"<<endl;
253 if(msgFlag) cout<<
"add a aExtTrack!"<<endl;
285 SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
288 DataObject *extTrackCol;
289 eventSvc()->findObject(
"/Event/Recon/RecExtTrackCol",extTrackCol);
290 if(extTrackCol != NULL) {
291 dataManSvc->clearSubTree(
"/Event/Recon/RecExtTrackCol");
292 eventSvc()->unregisterObject(
"/Event/Recon/RecExtTrackCol");
297 StatusCode sc = eventSvc()->registerObject(
"/Event/Recon/RecExtTrackCol", aExtTrackCol);
298 if(sc!=StatusCode::SUCCESS) {
299 log << MSG::FATAL <<
"Could not register RecExtTrackCol in TDS!" << endreq;
300 return( StatusCode::FAILURE);
305 SmartDataPtr<RecExtTrackCol> aExtTrkCol(eventSvc(),
"/Event/Recon/RecExtTrackCol");
307 log << MSG::FATAL <<
"Can't find RecExtTrackCol in TDS!" << endreq;
308 return( StatusCode::FAILURE);
311 RecExtTrackCol::iterator iterOfExtTrk;
314 for(iterOfExtTrk = aExtTrkCol->begin();iterOfExtTrk!=aExtTrkCol->end();iterOfExtTrk++)
318 for(
int i=0; i<5; i++)
321 cout<<
"##########track"<<j<<
": "<<
"("<<i<<
")"<<endl;
322 cout<<
"******TOF1:******"<<endl;
323 cout<<
"VolumeName: "<<(*iterOfExtTrk)->tof1VolumeName(i)<<
"\t"
324 <<
"VolumeNumber: "<<(*iterOfExtTrk)->tof1VolumeNumber(i)<<
"\t"<<endl
325 <<
"Position: "<<(*iterOfExtTrk)->tof1Position(i)<<
"\t"
326 <<
"Momentum: "<<(*iterOfExtTrk)->tof1Momentum(i)<<
"\t"<<endl
327 <<
"Error matrix: "<<(*iterOfExtTrk)->tof1ErrorMatrix(i)
328 <<
"Error z: "<<(*iterOfExtTrk)->tof1PosSigmaAlongZ(i)<<
"\t"
329 <<
"Error Tz: "<<(*iterOfExtTrk)->tof1PosSigmaAlongT(i)<<
"\t"
330 <<
"Error x: "<<(*iterOfExtTrk)->tof1PosSigmaAlongX(i)<<
"\t"
331 <<
"Error y: "<<(*iterOfExtTrk)->tof1PosSigmaAlongY(i)<<endl
332 <<
"Tof: "<<(*iterOfExtTrk)->tof1(i)<<
"\t"
333 <<
"PathOF: "<<(*iterOfExtTrk)->tof1Path(i)
335 cout<<
"******TOF2:******"<<endl;
336 cout<<
"VolumeName: "<<(*iterOfExtTrk)->tof2VolumeName(i)<<
"\t"
337 <<
"VolumeNumber: "<<(*iterOfExtTrk)->tof2VolumeNumber(i)<<
"\t"<<endl
338 <<
"Position: "<<(*iterOfExtTrk)->tof2Position(i)<<
"\t"
339 <<
"Momentum: "<<(*iterOfExtTrk)->tof2Momentum(i)<<
"\t"<<endl
340 <<
"Error matrix: "<<(*iterOfExtTrk)->tof2ErrorMatrix(i)
341 <<
"Error z: "<<(*iterOfExtTrk)->tof2PosSigmaAlongZ(i)<<
"\t"
342 <<
"Error Tz: "<<(*iterOfExtTrk)->tof2PosSigmaAlongT(i)<<
"\t"
343 <<
"Error x: "<<(*iterOfExtTrk)->tof2PosSigmaAlongX(i)<<
"\t"
344 <<
"Error y: "<<(*iterOfExtTrk)->tof2PosSigmaAlongY(i)<<endl
345 <<
"Tof: "<<(*iterOfExtTrk)->tof2(i)<<
"\t"
346 <<
"PathOF: "<<(*iterOfExtTrk)->tof2Path(i)
350 cout<<
"******EMC:******"<<endl
351 <<
"VolumeName: "<<(*iterOfExtTrk)->emcVolumeName(i)<<
"\t"
352 <<
"VolumeNumber: "<<(*iterOfExtTrk)->emcVolumeNumber(i)<<
"\t"<<endl
353 <<
"Position: "<<(*iterOfExtTrk)->emcPosition(i)<<
"\t"
354 <<
"Momentum: "<<(*iterOfExtTrk)->emcMomentum(i)<<
"\t"<<endl
355 <<
"Error matrix: "<<(*iterOfExtTrk)->emcErrorMatrix(i)
356 <<
"Error theta: "<<(*iterOfExtTrk)->emcPosSigmaAlongTheta(i)<<
"\t"
357 <<
"Error phi: "<<(*iterOfExtTrk)->emcPosSigmaAlongPhi(i)<<
"\t"
358 <<
"EMC path: "<<(*iterOfExtTrk)->emcPath(i)
362 cout<<
"******MUC:******"<<endl
363 <<
"VolumeName: "<<(*iterOfExtTrk)->mucVolumeName(i)<<
"\t"
364 <<
"VolumeNumber: "<<(*iterOfExtTrk)->mucVolumeNumber(i)<<endl
365 <<
"Position: "<<(*iterOfExtTrk)->mucPosition(i)<<
"\t"
366 <<
"Momentum: "<<(*iterOfExtTrk)->mucMomentum(i)<<
"\t"<<endl
367 <<
"Error matrix: "<<(*iterOfExtTrk)->mucErrorMatrix(i)
368 <<
"Error z: "<<(*iterOfExtTrk)->mucPosSigmaAlongZ(i)<<
"\t"
369 <<
"Error Tz: "<<(*iterOfExtTrk)->mucPosSigmaAlongT(i)<<
"\t"
370 <<
"Error x: "<<(*iterOfExtTrk)->mucPosSigmaAlongX(i)<<
"\t"
371 <<
"Error y: "<<(*iterOfExtTrk)->mucPosSigmaAlongY(i)
374 cout<<
"*******MUC KALMANFILTER***********"<<endl;
375 cout<<
"Chisq is "<<(*iterOfExtTrk)->MucKalchi2(i)<<endl;
376 cout<<
"Nfit is "<<(*iterOfExtTrk)->MucKaldof(i)<<endl;
377 cout<<
"chiL "<<(*iterOfExtTrk)->MucKalchi2()<<endl;
405 if(msgFlag) cout<<
"****************** End a event! ****************"<<endl<<endl;
533return StatusCode::SUCCESS;
539 MsgStream log(
msgSvc(), name());
540 log << MSG::INFO <<
"finalize()" << endreq;
545 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 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)