<commit_before>/**************************************************************************
 * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
 *                                                                        *
 * Author: The ALICE Off-line Project.                                    *
 * Contributors are mentioned in the code where appropriate.              *
 *                                                                        *
 * Permission to use, copy, modify and distribute this software and its   *
 * documentation strictly for non-commercial purposes is hereby granted   *
 * without fee, provided that the above copyright notice appears in all   *
 * copies and that both the copyright notice and this permission notice   *
 * appear in the supporting documentation. The authors make no claims     *
 * about the suitability of this software for any purpose. It is          *
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/

//-----------------------------------------------------------------
//    Implementation of the vertexer from tracks
//
// Origin: AliITSVertexerTracks
//         <NAME>, 
//         <EMAIL>
//         M.Masera,  Torino, 
//         <EMAIL>
// Moved to STEER and adapted to ESD tracks: 
//         F.Prino,  Torino, <EMAIL>
//-----------------------------------------------------------------

//---- Root headers --------
#include <TSystem.h>
#include <TDirectory.h>
#include <TFile.h>
#include <TTree.h>
#include <TMatrixD.h>
//---- AliRoot headers -----
#include "AliLog.h"
#include "AliStrLine.h"
#include "AliExternalTrackParam.h"
#include "AliNeutralTrackParam.h"
#include "AliVEvent.h"
#include "AliVTrack.h"
#include "AliESDEvent.h"
#include "AliESDtrack.h"
#include "AliVertexerTracks.h"

ClassImp(AliVertexerTracks)


//----------------------------------------------------------------------------
AliVertexerTracks::AliVertexerTracks():
TObject(),
fVert(),
fCurrentVertex(0),
fMode(0),
fFieldkG(-999.),
fTrkArraySel(),
fIdSel(0),
fTrksToSkip(0),
fNTrksToSkip(0),
fConstraint(kFALSE),
fOnlyFitter(kFALSE),
fMinTracks(1),
fMinClusters(5),
fDCAcut(0.1),
fDCAcutIter0(0.1),
fNSigma(3.),
fMaxd0z0(0.5),
fMinDetFitter(100.),
fMaxTgl(1000.),
fITSrefit(kTRUE),
fFiducialR(3.),
fFiducialZ(30.),
fnSigmaForUi00(1.5),
fAlgo(1),
fAlgoIter0(4)
{
//
// Default constructor
//
  SetVtxStart();
  SetVtxStartSigma();
}
//----------------------------------------------------------------------------
AliVertexerTracks::AliVertexerTracks(Double_t fieldkG):
TObject(),
fVert(),
fCurrentVertex(0),
fMode(0),
fFieldkG(fieldkG),
fTrkArraySel(),
fIdSel(0),
fTrksToSkip(0),
fNTrksToSkip(0),
fConstraint(kFALSE),
fOnlyFitter(kFALSE),
fMinTracks(1),
fMinClusters(5),
fDCAcut(0.1),
fDCAcutIter0(0.1),
fNSigma(3.),
fMaxd0z0(0.5),
fMinDetFitter(100.),
fMaxTgl(1000.),
fITSrefit(kTRUE),
fFiducialR(3.),
fFiducialZ(30.),
fnSigmaForUi00(1.5),
fAlgo(1),
fAlgoIter0(4)
{
//
// Standard constructor
//
  SetVtxStart();
  SetVtxStartSigma();
}
//-----------------------------------------------------------------------------
AliVertexerTracks::~AliVertexerTracks() 
{
  // Default Destructor
  // The objects pointed by the following pointer are not owned
  // by this class and are not deleted
  fCurrentVertex = 0;
  if(fTrksToSkip) { delete fTrksToSkip; fTrksToSkip=NULL; }
  if(fIdSel) { delete fIdSel; fIdSel=NULL; }
}
//----------------------------------------------------------------------------
AliESDVertex* AliVertexerTracks::FindPrimaryVertex(AliVEvent *vEvent)
{
//
// Primary vertex for current ESD or AOD event
// (Two iterations: 
//  1st with 5*fNSigma*sigma cut w.r.t. to initial vertex
//      + cut on sqrt(d0d0+z0z0) if fConstraint=kFALSE  
//  2nd with fNSigma*sigma cut w.r.t. to vertex found in 1st iteration) 
//
  fCurrentVertex = 0;

  TString evtype = vEvent->IsA()->GetName();
  Bool_t inputAOD = ((evtype=="AliAODEvent") ? kTRUE : kFALSE);

  if(inputAOD && fMode==1) {
    printf("Error : AliVertexerTracks: no TPC-only vertex from AOD\n"); 
    TooFewTracks(); 
    return fCurrentVertex;
  }

  // accept 1-track case only if constraint is available
  if(!fConstraint && fMinTracks==1) fMinTracks=2;

  // read tracks from AlivEvent
  Int_t nTrks = (Int_t)vEvent->GetNumberOfTracks();
  if(nTrks<fMinTracks) {
    TooFewTracks();
    return fCurrentVertex;
  } 
  //

  TDirectory * olddir = gDirectory;
  TFile *f = 0;
  if(nTrks>500) f = new TFile("VertexerTracks.root","recreate");
  TObjArray trkArrayOrig(nTrks);
  UShort_t *idOrig = new UShort_t[nTrks];

  Int_t nTrksOrig=0;
  AliExternalTrackParam *t=0;
  // loop on tracks
  for(Int_t i=0; i<nTrks; i++) {
    AliVTrack *track = (AliVTrack*)vEvent->GetTrack(i);
    // check tracks to skip
    Bool_t skipThis = kFALSE;
    for(Int_t j=0; j<fNTrksToSkip; j++) { 
      if(track->GetID()==fTrksToSkip[j]) {
	AliDebug(1,Form("skipping track: %d",i));
	skipThis = kTRUE;
      }
    }
    if(skipThis) continue;

    // kITSrefit
    if(fMode==0 && fITSrefit && !(track->GetStatus()&AliESDtrack::kITSrefit)) continue;

    if(!inputAOD) {  // ESD
      AliESDtrack* esdt = (AliESDtrack*)track;
      if(esdt->GetNcls(fMode) < fMinClusters) continue;
      if(fMode==0) {        // ITS mode
	Double_t x,p[5],cov[15];
	esdt->GetExternalParameters(x,p);
	esdt->GetExternalCovariance(cov);
	t = new AliExternalTrackParam(x,esdt->GetAlpha(),p,cov);
      } else if(fMode==1) { // TPC mode
	t = (AliExternalTrackParam*)esdt->GetTPCInnerParam();<commit_msg>Ignoring the tracks marked with the kITSpureSA status bit (A.Dainese)<commit_after>/**************************************************************************
 * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
 *                                                                        *
 * Author: The ALICE Off-line Project.                                    *
 * Contributors are mentioned in the code where appropriate.              *
 *                                                                        *
 * Permission to use, copy, modify and distribute this software and its   *
 * documentation strictly for non-commercial purposes is hereby granted   *
 * without fee, provided that the above copyright notice appears in all   *
 * copies and that both the copyright notice and this permission notice   *
 * appear in the supporting documentation. The authors make no claims     *
 * about the suitability of this software for any purpose. It is          *
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/

//-----------------------------------------------------------------
//    Implementation of the vertexer from tracks
//
// Origin: AliITSVertexerTracks
//         A.Dainese, Padova, 
//         <EMAIL>
//         M.Masera,  Torino, 
//         <EMAIL>
// Moved to STEER and adapted to ESD tracks: 
//         F.Prino,  Torino, <EMAIL>
//-----------------------------------------------------------------

//---- Root headers --------
#include <TSystem.h>
#include <TDirectory.h>
#include <TFile.h>
#include <TTree.h>
#include <TMatrixD.h>
//---- AliRoot headers -----
#include "AliLog.h"
#include "AliStrLine.h"
#include "AliExternalTrackParam.h"
#include "AliNeutralTrackParam.h"
#include "AliVEvent.h"
#include "AliVTrack.h"
#include "AliESDEvent.h"
#include "AliESDtrack.h"
#include "AliVertexerTracks.h"

ClassImp(AliVertexerTracks)


//----------------------------------------------------------------------------
AliVertexerTracks::AliVertexerTracks():
TObject(),
fVert(),
fCurrentVertex(0),
fMode(0),
fFieldkG(-999.),
fTrkArraySel(),
fIdSel(0),
fTrksToSkip(0),
fNTrksToSkip(0),
fConstraint(kFALSE),
fOnlyFitter(kFALSE),
fMinTracks(1),
fMinClusters(5),
fDCAcut(0.1),
fDCAcutIter0(0.1),
fNSigma(3.),
fMaxd0z0(0.5),
fMinDetFitter(100.),
fMaxTgl(1000.),
fITSrefit(kTRUE),
fFiducialR(3.),
fFiducialZ(30.),
fnSigmaForUi00(1.5),
fAlgo(1),
fAlgoIter0(4)
{
//
// Default constructor
//
  SetVtxStart();
  SetVtxStartSigma();
}
//----------------------------------------------------------------------------
AliVertexerTracks::AliVertexerTracks(Double_t fieldkG):
TObject(),
fVert(),
fCurrentVertex(0),
fMode(0),
fFieldkG(fieldkG),
fTrkArraySel(),
fIdSel(0),
fTrksToSkip(0),
fNTrksToSkip(0),
fConstraint(kFALSE),
fOnlyFitter(kFALSE),
fMinTracks(1),
fMinClusters(5),
fDCAcut(0.1),
fDCAcutIter0(0.1),
fNSigma(3.),
fMaxd0z0(0.5),
fMinDetFitter(100.),
fMaxTgl(1000.),
fITSrefit(kTRUE),
fFiducialR(3.),
fFiducialZ(30.),
fnSigmaForUi00(1.5),
fAlgo(1),
fAlgoIter0(4)
{
//
// Standard constructor
//
  SetVtxStart();
  SetVtxStartSigma();
}
//-----------------------------------------------------------------------------
AliVertexerTracks::~AliVertexerTracks() 
{
  // Default Destructor
  // The objects pointed by the following pointer are not owned
  // by this class and are not deleted
  fCurrentVertex = 0;
  if(fTrksToSkip) { delete fTrksToSkip; fTrksToSkip=NULL; }
  if(fIdSel) { delete fIdSel; fIdSel=NULL; }
}
//----------------------------------------------------------------------------
AliESDVertex* AliVertexerTracks::FindPrimaryVertex(AliVEvent *vEvent)
{
//
// Primary vertex for current ESD or AOD event
// (Two iterations: 
//  1st with 5*fNSigma*sigma cut w.r.t. to initial vertex
//      + cut on sqrt(d0d0+z0z0) if fConstraint=kFALSE  
//  2nd with fNSigma*sigma cut w.r.t. to vertex found in 1st iteration) 
//
  fCurrentVertex = 0;

  TString evtype = vEvent->IsA()->GetName();
  Bool_t inputAOD = ((evtype=="AliAODEvent") ? kTRUE : kFALSE);

  if(inputAOD && fMode==1) {
    printf("Error : AliVertexerTracks: no TPC-only vertex from AOD\n"); 
    TooFewTracks(); 
    return fCurrentVertex;
  }

  // accept 1-track case only if constraint is available
  if(!fConstraint && fMinTracks==1) fMinTracks=2;

  // read tracks from AlivEvent
  Int_t nTrks = (Int_t)vEvent->GetNumberOfTracks();
  if(nTrks<fMinTracks) {
    TooFewTracks();
    return fCurrentVertex;
  } 
  //

  TDirectory * olddir = gDirectory;
  TFile *f = 0;
  if(nTrks>500) f = new TFile("VertexerTracks.root","recreate");
  TObjArray trkArrayOrig(nTrks);
  UShort_t *idOrig = new UShort_t[nTrks];

  Int_t nTrksOrig=0;
  AliExternalTrackParam *t=0;
  // loop on tracks
  for(Int_t i=0; i<nTrks; i++) {
    AliVTrack *track = (AliVTrack*)vEvent->GetTrack(i);
    // check tracks to skip
    Bool_t skipThis = kFALSE;
    for(Int_t j=0; j<fNTrksToSkip; j++) { 
      if(track->GetID()==fTrksToSkip[j]) {
	AliDebug(1,Form("skipping track: %d",i));
	skipThis = kTRUE;
      }
    }
    if(skipThis) continue;

    // skip pure ITS SA tracks
    if(track->GetStatus()&AliESDtrack::kITSpureSA) continue;

    // kITSrefit
    if(fMode==0 && fITSrefit && !(track->GetStatus()&AliESDtrack::kITSrefit)) continue;

    if(!inputAOD) {  // ESD
      AliESDtrack* esdt = (AliESDtrack*)track;
      if(esdt->GetNcls(fMode) < fMinClusters) continue;
      if(fMode==0) {        // ITS mode
	Double_t x,p[5],cov[15];
	esdt->GetExternalParameters(x,p);
	esdt->GetExternalCovariance(cov);
	t = new AliExternalTrackParam(x,esdt->GetAlpha(),p,cov);
      } else if(fMode==1) { // TPC mode
	t = (AliExternalTrackParam*)esdt->GetTPCInnerParam();
{'fraction_non_alphanumeric': 0.23077601410934745, 'fraction_numerical': 0.01904761904761905, 'mean_word_length': 2.4820386859072765, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6582996', 'n_tokens_mistral': 3918, 'n_tokens_neox': 3756, 'n_words': 816}