1 //**************************************************************************
2 //* This file is property of and copyright by the ALICE HLT Project *
3 //* ALICE Experiment at CERN, All rights reserved. *
5 //* Primary Authors: S.Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
6 //* for The ALICE HLT Project. *
8 //* Permission to use, copy, modify and distribute this software and its *
9 //* documentation strictly for non-commercial purposes is hereby granted *
10 //* without fee, provided that the above copyright notice appears in all *
11 //* copies and that both the copyright notice and this permission notice *
12 //* appear in the supporting documentation. The authors make no claims *
13 //* about the suitability of this software for any purpose. It is *
14 //* provided "as is" without express or implied warranty. *
15 //**************************************************************************
17 /** @file AliHLTGlobalVertexerComponent.cxx
18 @author Sergey Gorbunov
19 @brief Component for reconstruct primary vertex and V0's
22 #include "AliHLTGlobalVertexerComponent.h"
23 #include "AliHLTDataTypes.h"
24 #include "AliHLTExternalTrackParam.h"
25 #include "AliHLTGlobalBarrelTrack.h"
26 #include "AliCDBEntry.h"
27 #include "AliCDBManager.h"
30 #include "TObjString.h"
31 #include "TObjArray.h"
32 #include "AliESDEvent.h"
33 #include "AliESDtrack.h"
34 #include "AliESDVertex.h"
36 #include "AliHLTMessage.h"
38 #include "AliKFParticle.h"
39 #include "AliKFVertex.h"
40 #include "TStopwatch.h"
44 /** ROOT macro for the implementation of ROOT specific class methods */
45 ClassImp(AliHLTGlobalVertexerComponent)
47 AliHLTGlobalVertexerComponent::AliHLTGlobalVertexerComponent()
52 fFitTracksToVertex(1),
53 fConstrainedTrackDeviation(4.),
54 fV0DaughterPrimDeviation( 2.5 ),
55 fV0PrimDeviation( 3.5 ),
57 fV0DecayLengthInSigmas(3.),
59 fBenchmark("GlobalVertexer")
61 // see header file for class documentation
63 // refer to README to build package
65 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
69 AliHLTGlobalVertexerComponent::~AliHLTGlobalVertexerComponent()
71 // see header file for class documentation
73 if( fTrackInfos ) delete[] fTrackInfos;
76 // Public functions to implement AliHLTComponent's interface.
77 // These functions are required for the registration process
79 const char* AliHLTGlobalVertexerComponent::GetComponentID()
81 // see header file for class documentation
83 return "GlobalVertexer";
86 void AliHLTGlobalVertexerComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
88 // see header file for class documentation
90 list.push_back( kAliHLTDataTypeESDObject );
91 list.push_back( kAliHLTDataTypeTrack|kAliHLTDataOriginITS );
92 list.push_back( kAliHLTDataTypeTrack|kAliHLTDataOriginTPC );
95 AliHLTComponentDataType AliHLTGlobalVertexerComponent::GetOutputDataType()
97 // see header file for class documentation
98 return kAliHLTMultipleDataType;
101 int AliHLTGlobalVertexerComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
104 // see header file for class documentation
106 tgtList.push_back( kAliHLTDataTypeGlobalVertexer|kAliHLTDataOriginOut);
107 tgtList.push_back( kAliHLTDataTypeESDVertex|kAliHLTDataOriginOut);
108 tgtList.push_back( kAliHLTDataTypeESDObject|kAliHLTDataOriginOut);
109 return tgtList.size();
112 void AliHLTGlobalVertexerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
114 // see header file for class documentation
115 // XXX TODO: Find more realistic values.
117 inputMultiplier = 2.;
120 AliHLTComponent* AliHLTGlobalVertexerComponent::Spawn()
122 // see header file for class documentation
123 return new AliHLTGlobalVertexerComponent;
126 int AliHLTGlobalVertexerComponent::DoInit( int argc, const char** argv )
131 fBenchmark.SetTimer(0,"total");
132 fBenchmark.SetTimer(1,"convert");
133 fBenchmark.SetTimer(2,"vprim");
134 fBenchmark.SetTimer(3,"v0");
135 fV0TimeLimit = 10.e-3;
138 TString configuration="";
140 for (int i=0; i<argc && iResult>=0; i++) {
142 if (!configuration.IsNull()) configuration+=" ";
143 configuration+=argument;
146 if (!configuration.IsNull()) {
147 iResult=Configure(configuration.Data());
153 int AliHLTGlobalVertexerComponent::DoDeinit()
155 // see header file for class documentation
157 if( fTrackInfos ) delete[] fTrackInfos;
160 fFitTracksToVertex = 1;
161 fConstrainedTrackDeviation = 4.;
162 fV0DaughterPrimDeviation = 2.5 ;
163 fV0PrimDeviation =3.5;
165 fV0DecayLengthInSigmas = 3.;
166 fV0TimeLimit = 10.e-3;
171 int AliHLTGlobalVertexerComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/,
172 AliHLTComponentTriggerData& /*trigData*/ )
174 //cout<<"AliHLTGlobalVertexerComponent::DoEvent called"<<endl;
176 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
180 //cout<<"SG: GlobalVertexer:: DoEvent called"<<endl;
181 fBenchmark.StartNewEvent();
184 vector< AliExternalTrackParam > tracks;
185 vector< int > trackId;
186 vector< pair<int,int> > v0s;
188 AliESDEvent *event = 0;
190 for( const AliHLTComponentBlockData *i= GetFirstInputBlock(kAliHLTDataTypeESDObject); i!=NULL; i=GetNextInputBlock() ){
191 fBenchmark.AddInput(i->fSize);
195 for ( const TObject *iter = GetFirstInputObject(kAliHLTDataTypeESDObject); iter != NULL; iter = GetNextInputObject() ) {
196 event = dynamic_cast<AliESDEvent*>(const_cast<TObject*>( iter ) );
197 if( !event ) continue;
199 event->GetStdContent();
200 Int_t nESDTracks=event->GetNumberOfTracks();
202 for (Int_t iTr=0; iTr<nESDTracks; iTr++){
203 AliESDtrack *pTrack = event->GetTrack(iTr);
204 if( !pTrack ) continue;
205 if( pTrack->GetKinkIndex(0)>0) continue;
206 if( !( pTrack->GetStatus()&AliESDtrack::kTPCin ) ) continue;
207 tracks.push_back(*pTrack);
208 trackId.push_back(iTr);
213 if( tracks.size()==0 ){
215 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginITS);
216 pBlock!=NULL; pBlock=GetNextInputBlock()) {
218 fBenchmark.AddInput(pBlock->fSize);
220 AliHLTTracksData* dataPtr = reinterpret_cast<AliHLTTracksData*>( pBlock->fPtr );
221 int nTracks = dataPtr->fCount;
223 AliHLTExternalTrackParam* currOutTrack = dataPtr->fTracklets;
224 for( int itr=0; itr<nTracks; itr++ ){
225 AliHLTGlobalBarrelTrack t(*currOutTrack);
226 tracks.push_back( t );
227 trackId.push_back( currOutTrack->fTrackID );
228 unsigned int dSize = sizeof( AliHLTExternalTrackParam ) + currOutTrack->fNPoints * sizeof( unsigned int );
229 currOutTrack = ( AliHLTExternalTrackParam* )( (( Byte_t * )currOutTrack) + dSize );
234 if( tracks.size()==0 ){
235 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC);
236 pBlock!=NULL; pBlock=GetNextInputBlock()) {
238 fBenchmark.AddInput(pBlock->fSize);
240 AliHLTTracksData* dataPtr = reinterpret_cast<AliHLTTracksData*>( pBlock->fPtr );
241 int nTracks = dataPtr->fCount;
242 AliHLTExternalTrackParam* currOutTrack = dataPtr->fTracklets;
243 for( int itr=0; itr<nTracks; itr++ ){
244 AliHLTGlobalBarrelTrack t(*currOutTrack);
245 tracks.push_back( t );
246 trackId.push_back( currOutTrack->fTrackID );
247 unsigned int dSize = sizeof( AliHLTExternalTrackParam ) + currOutTrack->fNPoints * sizeof( unsigned int );
248 currOutTrack = ( AliHLTExternalTrackParam* )( (( Byte_t * )currOutTrack) + dSize );
254 // primary vertex & V0's
256 AliKFParticle::SetField( GetBz() );
260 { //* Fill fTrackInfo array
262 if( fTrackInfos ) delete[] fTrackInfos;
264 fNTracks=tracks.size();
265 fTrackInfos = new AliESDTrackInfo[ fNTracks ];
266 for (Int_t iTr=0; iTr<fNTracks; iTr++){
267 AliESDTrackInfo &info = fTrackInfos[iTr];
269 info.fPrimUsedFlag = 0;
270 info.fParticle = AliKFParticle( tracks[iTr], 211 );
271 for( int i=0; i<8; i++ ) if( !finite(info.fParticle.GetParameter(i)) ) info.fOK = 0;
272 for( int i=0; i<36; i++ ) if( !finite(info.fParticle.GetCovariance(i)) ) info.fOK = 0;
284 int *buf = new int[sizeof(AliHLTGlobalVertexerData)/sizeof(int)+1 + fNTracks + 2*v0s.size()];
285 AliHLTGlobalVertexerData *data = reinterpret_cast<AliHLTGlobalVertexerData*>(buf);
287 if( data) { // fill the output structure
289 data->fFitTracksToVertex = fFitTracksToVertex;
290 for( int i=0; i<3; i++ ) data->fPrimP[i] = fPrimaryVtx.Parameters()[i];
291 for( int i=0; i<6; i++ ) data->fPrimC[i] = fPrimaryVtx.CovarianceMatrix()[i];
292 data->fPrimChi2 = fPrimaryVtx.GetChi2();
293 data->fPrimNContributors = fPrimaryVtx.GetNContributors();
294 data->fNPrimTracks = 0;
295 for( Int_t i = 0; i<fNTracks; i++ ){
296 if( !fTrackInfos[i].fPrimUsedFlag ) continue;
297 if( fTrackInfos[i].fPrimDeviation > fConstrainedTrackDeviation ) continue;
298 data->fTrackIndices[ (data->fNPrimTracks)++ ] = trackId[i];
300 int *listV0 = data->fTrackIndices + data->fNPrimTracks;
301 data->fNV0s = v0s.size();
302 for( int i=0; i<data->fNV0s; i++ ){
303 listV0[2*i] = trackId[v0s[i].first];
304 listV0[2*i+1] = trackId[v0s[i].second];
307 unsigned int blockSize = sizeof(AliHLTGlobalVertexerData) + (data->fNPrimTracks + 2*data->fNV0s)*sizeof(int);
309 iResult = PushBack( reinterpret_cast<void*>(data), blockSize, kAliHLTDataTypeGlobalVertexer|kAliHLTDataOriginOut );
310 fBenchmark.AddOutput(blockSize);
314 // output the vertex if found
316 if( iResult==0 && data && data->fPrimNContributors >=3 ){
317 AliESDVertex vESD( data->fPrimP, data->fPrimC, data->fPrimChi2, data->fPrimNContributors );
318 iResult = PushBack( (TObject*) &vESD, kAliHLTDataTypeESDVertex|kAliHLTDataOriginOut,0 );
319 fBenchmark.AddOutput(GetLastObjectSize());
323 // output the ESD event
324 if( iResult==0 && event && data ){
325 FillESD( event, data );
326 iResult = PushBack( event, kAliHLTDataTypeESDObject|kAliHLTDataOriginOut, 0);
327 fBenchmark.AddOutput(GetLastObjectSize());
333 HLTInfo(fBenchmark.GetStatistics());
338 int AliHLTGlobalVertexerComponent::Configure(const char* arguments)
342 if (!arguments) return iResult;
344 TString allArgs=arguments;
347 TObjArray* pTokens=allArgs.Tokenize(" ");
351 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
352 argument=((TObjString*)pTokens->At(i))->GetString();
353 if (argument.IsNull()) continue;
355 if (argument.CompareTo("-fitTracksToVertex")==0) {
356 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
357 HLTInfo("fitTracksToVertex is set set to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
358 fFitTracksToVertex=((TObjString*)pTokens->At(i))->GetString().Atoi();
361 else if (argument.CompareTo("-constrainedTrackDeviation")==0) {
362 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
363 HLTInfo("constrainedTrackDeviation is set set to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
364 fConstrainedTrackDeviation=((TObjString*)pTokens->At(i))->GetString().Atof();
367 else if (argument.CompareTo("-v0DaughterPrimDeviation")==0) {
368 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
369 HLTInfo("v0DaughterPrimDeviation is set set to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
370 fV0DaughterPrimDeviation=((TObjString*)pTokens->At(i))->GetString().Atof();
373 else if (argument.CompareTo("-v0PrimDeviation")==0) {
374 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
375 HLTInfo("v0PrimDeviation is set set to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
376 fV0PrimDeviation=((TObjString*)pTokens->At(i))->GetString().Atof();
379 else if (argument.CompareTo("-v0Chi")==0) {
380 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
381 HLTInfo("v0Chi is set set to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
382 fV0Chi=((TObjString*)pTokens->At(i))->GetString().Atof();
385 else if (argument.CompareTo("-v0DecayLengthInSigmas")==0) {
386 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
387 HLTInfo("v0DecayLengthInSigmas is set set to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
388 fV0DecayLengthInSigmas=((TObjString*)pTokens->At(i))->GetString().Atof();
391 else if (argument.CompareTo("-v0MinEventRate")==0) {
392 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
393 HLTInfo("Minimum event rate for V0 finder is set set to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
394 Double_t rate = ((TObjString*)pTokens->At(i))->GetString().Atof();
395 fV0TimeLimit = (rate >0 ) ?1./rate :60; // 1 minute maximum time
399 HLTError("unknown argument %s", argument.Data());
407 HLTError("missing parameter for argument %s", argument.Data());
414 int AliHLTGlobalVertexerComponent::Reconfigure(const char* /*cdbEntry*/, const char* /*chainId*/)
416 // see header file for class documentation
418 return 0; // no CDB path is set so far
421 const char* path="HLT/ConfigTPC/KryptonHistoComponent";
422 const char* defaultNotify="";
425 defaultNotify=" (default)";
428 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
429 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path);
431 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
433 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
434 iResult=Configure(pString->GetString().Data());
436 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
439 HLTError("can not fetch object \"%s\" from CDB", path);
448 struct AliHLTGlobalVertexerDeviation
450 int fI; // track index
451 float fD; // deviation from vertex
453 bool operator<(const AliHLTGlobalVertexerDeviation &a) const { return fD<a.fD; }
457 void AliHLTGlobalVertexerComponent::FindPrimaryVertex()
459 //* Find event primary vertex
461 fPrimaryVtx.Initialize();
462 //fPrimaryVtx.SetBeamConstraint(fESD->GetDiamondX(),fESD->GetDiamondY(),0,
463 //TMath::Sqrt(fESD->GetSigma2DiamondX()),TMath::Sqrt(fESD->GetSigma2DiamondY()),5.3);
465 // select rough region (in sigmas) in which the vertex could be found, all tracks outside these limits are rejected
466 // from the primary vertex finding
467 fPrimaryVtx.SetBeamConstraint( 0, 0, 0, 3., 3., 5.3 );
469 const AliKFParticle **vSelected = new const AliKFParticle*[fNTracks]; //* Selected particles for the vertex fit
470 AliHLTGlobalVertexerDeviation *dev = new AliHLTGlobalVertexerDeviation[fNTracks];
474 for( Int_t i = 0; i<fNTracks; i++){
475 if(!fTrackInfos[i].fOK ) continue;
476 //if( fESD->GetTrack(i)->GetTPCNcls()<60 ) continue;
477 const AliKFParticle &p = fTrackInfos[i].fParticle;
478 Double_t chi = p.GetDeviationFromVertex( fPrimaryVtx );
479 if( chi > fConstrainedTrackDeviation ) continue;
480 dev[nSelected].fI = i;
481 dev[nSelected].fD = chi;
482 vSelected[nSelected] = &(fTrackInfos[i].fParticle);
488 while( nSelected>2 ){
490 //* Primary vertex finder with rejection of outliers
492 for( Int_t i = 0; i<nSelected; i++){
493 vSelected[i] = &(fTrackInfos[dev[i].fI].fParticle);
496 double xv = fPrimaryVtx.GetX();
497 double yv = fPrimaryVtx.GetY();
498 double zv = fPrimaryVtx.GetZ(); // values from previous iteration of calculations
499 fPrimaryVtx.Initialize();
500 fPrimaryVtx.SetBeamConstraint( 0, 0, 0, 3., 3., 5.3 );
501 fPrimaryVtx.SetVtxGuess( xv, yv, zv );
503 fPrimaryVtx.Construct( vSelected, nSelected, 0, -1, 1 ); // refilled for every iteration
505 for( Int_t it=0; it<nSelected; it++ ){
506 const AliKFParticle &p = fTrackInfos[dev[it].fI].fParticle;
507 if( nSelected <= 20 ){
508 AliKFVertex tmp = fPrimaryVtx - p; // exclude the current track from the sample and recalculate the vertex
509 dev[it].fD = p.GetDeviationFromVertex( tmp );
511 dev[it].fD = p.GetDeviationFromVertex( fPrimaryVtx );
514 sort(dev,dev+nSelected); // sort tracks with increasing chi2 (used for rejection)
516 int nRemove = (int) ( 0.3*nSelected ); //remove 30% of the tracks (done for performance, only if there are more than 20 tracks)
517 if( nSelected - nRemove <=20 ) nRemove = 1; // removal based on the chi2 of every track
518 int firstRemove = nSelected - nRemove;
519 while( firstRemove<nSelected ){
520 if( dev[firstRemove].fD >= fConstrainedTrackDeviation ) break;
523 if( firstRemove>=nSelected ) break;
524 nSelected = firstRemove;
527 for( Int_t i = 0; i<fNTracks; i++){
528 fTrackInfos[i].fPrimUsedFlag = 0;
531 if( nSelected < 3 ){ // no vertex for fewer than 3 contributors
532 fPrimaryVtx.NDF() = -3;
533 fPrimaryVtx.Chi2() = 0;
537 for( Int_t i = 0; i<nSelected; i++){
538 AliESDTrackInfo &info = fTrackInfos[dev[i].fI];
539 info.fPrimUsedFlag = 1;
540 info.fPrimDeviation = dev[i].fD;
543 for( Int_t i = 0; i<fNTracks; i++ ){
544 AliESDTrackInfo &info = fTrackInfos[i];
545 if( info.fPrimUsedFlag ) continue;
546 info.fPrimDeviation = info.fParticle.GetDeviationFromVertex( fPrimaryVtx );
555 void AliHLTGlobalVertexerComponent::FindV0s( vector<pair<int,int> > &v0s )
559 AliKFVertex &primVtx = fPrimaryVtx;
560 if( primVtx.GetNContributors()<3 ) return;
566 for( Int_t iTr = 0; iTr<fNTracks && run; iTr++ ){ //* first daughter
568 AliESDTrackInfo &info = fTrackInfos[iTr];
569 if( !info.fOK ) continue;
570 if( info.fParticle.GetQ() >0 ) continue;
571 if( info.fPrimDeviation < fV0DaughterPrimDeviation ) continue;
573 for( Int_t jTr = 0; jTr<fNTracks; jTr++ ){ //* second daughter
576 AliESDTrackInfo &jnfo = fTrackInfos[jTr];
577 if( !jnfo.fOK ) continue;
578 if( jnfo.fParticle.GetQ() < 0 ) continue;
579 if( jnfo.fPrimDeviation < fV0DaughterPrimDeviation ) continue;
581 // check the time once a while...
583 if( (++statN)%100 ==0 ){
584 if( timer.RealTime()>= fV0TimeLimit ){ run = 0; break; }
588 //* check if the particles fit
590 if( info.fParticle.GetDeviationFromParticle(jnfo.fParticle) > fV0Chi ) continue;
592 //* construct V0 mother
594 AliKFParticle v0( info.fParticle, jnfo.fParticle );
598 if( v0.GetChi2()<0 || v0.GetChi2() > fV0Chi*fV0Chi*v0.GetNDF() ) continue;
600 //* subtruct daughters from primary vertex
602 AliKFVertex primVtxCopy = primVtx;
604 if( info.fPrimUsedFlag ){
605 if( primVtxCopy.GetNContributors()<=2 ) continue;
606 primVtxCopy -= info.fParticle;
608 if( jnfo.fPrimUsedFlag ){
609 if( primVtxCopy.GetNContributors()<=2 ) continue;
610 primVtxCopy -= jnfo.fParticle;
612 //* Check v0 Chi^2 deviation from primary vertex
614 if( v0.GetDeviationFromVertex( primVtxCopy ) > fV0PrimDeviation ) continue;
616 //* Add V0 to primary vertex to improve the primary vertex resolution
620 //* Set production vertex for V0
622 v0.SetProductionVertex( primVtxCopy );
624 //* Get V0 decay length with estimated error
626 Double_t length, sigmaLength;
627 if( v0.GetDecayLength( length, sigmaLength ) ) continue;
629 //* Reject V0 if it decays too close[sigma] to the primary vertex
631 if( length < fV0DecayLengthInSigmas*sigmaLength ) continue;
635 v0s.push_back(pair<int,int>(iTr,jTr));
643 void AliHLTGlobalVertexerComponent::FillESD( AliESDEvent *event, AliHLTGlobalVertexerData *data
646 //* put output of a vertexer to the esd event
648 Int_t nESDTracks = event->GetNumberOfTracks();
650 const int *listPrim = data->fTrackIndices;
651 const int *listV0 = data->fTrackIndices + data->fNPrimTracks;
653 std::map<int,int> mapId;
654 bool *constrainedToVtx = new bool[nESDTracks];
656 for( int i=0; i<nESDTracks; i++ ){
657 constrainedToVtx[i] = 0;
658 if( !event->GetTrack(i) ) continue;
659 mapId[ event->GetTrack(i)->GetID() ] = i;
662 if( data->fPrimNContributors >=3 ){
664 AliESDVertex vESD( data->fPrimP, data->fPrimC, data->fPrimChi2, data->fPrimNContributors );
665 event->SetPrimaryVertexTPC( &vESD );
666 event->SetPrimaryVertexTracks( &vESD );
668 // relate tracks to the primary vertex
670 if( data->fFitTracksToVertex ){
671 for( Int_t i = 0; i<data->fNPrimTracks; i++ ){
672 Int_t id = listPrim[ i ];
673 map<int,int>::iterator it = mapId.find(id);
674 if( it==mapId.end() ) continue;
675 Int_t itr = it->second;
676 event->GetTrack(itr)->RelateToVertex( &vESD, event->GetMagneticField(),100. );
677 constrainedToVtx[ itr ] = 1;
682 //* add ESD v0s and relate tracks to v0s
685 for( int i=0; i<data->fNV0s; i++ ){
687 Int_t id1 = listV0[ 2*i ];
688 Int_t id2 = listV0[ 2*i + 1];
689 map<int,int>::iterator it = mapId.find(id1);
690 if( it==mapId.end() ) continue;
691 Int_t iTr = it->second;
692 it = mapId.find(id2);
693 if( it==mapId.end() ) continue;
694 Int_t jTr = it->second;
696 AliESDv0 v0( *event->GetTrack( iTr ), iTr, *event->GetTrack( jTr ), jTr );
699 // relate the tracks to the vertex
701 if( data->fFitTracksToVertex ){
702 if( constrainedToVtx[iTr] || constrainedToVtx[jTr] ) continue;
704 double sigma[3] = {.1,.1,.1};
706 AliESDVertex vESD(pos, sigma);
707 event->GetTrack(iTr)->RelateToVertex( &vESD, event->GetMagneticField(),100. );
708 event->GetTrack(jTr)->RelateToVertex( &vESD, event->GetMagneticField(),100. );
709 constrainedToVtx[iTr] = 1;
710 constrainedToVtx[jTr] = 1;
714 delete[] constrainedToVtx;