<commit_before>#include <AliESDVertex.h>
#include "AliITSgeomTGeo.h"
#include "AliITSVertexer.h"
#include "AliRunLoader.h"
#include "AliITSLoader.h"
#include "AliMultiplicity.h"
#include "AliITSMultReconstructor.h"

const Float_t AliITSVertexer::fgkPipeRadius = 3.0;

ClassImp(AliITSVertexer)

//////////////////////////////////////////////////////////////////////
// Base class for primary vertex reconstruction                     //
// AliESDVertexer is a class for full 3D primary vertex finding     //
// derived classes: AliITSVertexerIons AliITSvertexer3D             //
//                  AliITSVertexerCosmics                           //
//////////////////////////////////////////////////////////////////////

//______________________________________________________________________
AliITSVertexer::AliITSVertexer():AliVertexer(),
fLadders(), 
fLadOnLay2(0)	 {
  // Default Constructor
  SetLaddersOnLayer2();
}

AliITSVertexer::AliITSVertexer(TString filename):AliVertexer(),
fLadders(), 
fLadOnLay2(0)
{
  // Standard constructor
  AliRunLoader *rl = AliRunLoader::GetRunLoader();
  if(!rl){
    Fatal("AliITSVertexer","Run Loader not found");
  }
  /*
  if(rl->LoadgAlice()){
    Fatal("AliITSVertexer","The AliRun object is not available - nothing done");
  }
  */
  fCurrentVertex  = 0;   
  SetFirstEvent(0);
  SetLastEvent(0);
  //  rl->LoadHeader();
  AliITSLoader* itsLoader =  (AliITSLoader*) rl->GetLoader("ITSLoader");
  if(!filename.Contains("default"))itsLoader->SetVerticesFileName(filename);
  if(!filename.Contains("null"))itsLoader->LoadVertices("recreate");
  itsLoader->LoadRecPoints();
  //  Int_t lst;
  SetLastEvent(rl->GetNumberOfEvents()-1);
  /*
  if(rl->TreeE()){
    lst = static_cast<Int_t>(rl->TreeE()->GetEntries());
    SetLastEvent(lst-1);
  }
  */
  SetLaddersOnLayer2();
}

//______________________________________________________________________
AliITSVertexer::AliITSVertexer(const AliITSVertexer &vtxr) : AliVertexer(vtxr) {
  // Copy constructor
  // Copies are not allowed. The method is protected to avoid misuse.
  Error("AliITSVertexer","Copy constructor not allowed\n");
}

//______________________________________________________________________
AliITSVertexer& AliITSVertexer::operator=(const AliITSVertexer& /* vtxr */){
  // Assignment operator
  // Assignment is not allowed. The method is protected to avoid misuse.
  Error("= operator","Assignment operator not allowed\n");
  return *this;
}

//______________________________________________________________________
AliITSVertexer::~AliITSVertexer() {
  // Destructor
 if(fLadders) delete [] fLadders;
}

//______________________________________________________________________
void AliITSVertexer::FindMultiplicity(Int_t evnumber){
  // Invokes AliITSMultReconstructor to determine the
  // charged multiplicity in the pixel layers
  if(fMult){delete fMult; fMult = 0;}
  Bool_t success=kTRUE;
  if(!fCurrentVertex)success=kFALSE;
  if(fCurrentVertex && fCurrentVertex->GetNContributors()<1)success=kFALSE;
  if(!success){
    AliWarning("Tracklets multiplicity not determined because the primary vertex was not found");
    return;
  }
  AliITSMultReconstructor* multReco = new AliITSMultReconstructor();
  AliRunLoader *rl =AliRunLoader::GetRunLoader();
  AliITSLoader* itsLoader = (AliITSLoader*)rl->GetLoader("ITSLoader");
  multReco->SetGeometry(itsLoader->GetITSgeom());
  itsLoader->LoadRecPoints();
  rl->GetEvent(evnumber);
  TTree* itsClusterTree = itsLoader->TreeR();
  if (!itsClusterTree) {
    AliError(" Can't get the ITS cluster tree !\n");
    return;
  }
  Double_t vtx[3];
  fCurrentVertex->GetXYZ(vtx);
  Float_t vtxf[3];
  for(Int_t i=0;i<3;i++)vtxf[i]=vtx[i];
  multReco->SetHistOn(kFALSE);
  multReco->Reconstruct(itsClusterTree,vtxf,vtxf);
  Int_t notracks=multReco->GetNTracklets();
  Float_t *tht = new Float_t [notracks];
  Float_t *phi = new Float_t [notracks];
  Float_t *dphi = new Float_t [notracks];
  Int_t *labels = new Int_t[notracks];
  for(Int_t i=0;i<multReco->GetNTracklets();i++){
    tht[i] = multReco->GetTracklet(i)[0];
    phi[i] =  multReco->GetTracklet(i)[1];
    dphi[i] = multReco->GetTracklet(i)[2];
    labels[i] = static_cast<Int_t>(multReco->GetTracklet(i)[3]);
  }
  Int_t nosingleclus=multReco->GetNSingleClusters();
  Float_t *ths = new Float_t [nosingleclus];
  Float_t *phs = new Float_t [nosingleclus];
  for(Int_t i=0;i<nosingleclus;i++){
    ths[i] = multReco->GetCluster(i)[0];
    phs[i] =  multReco->GetCluster(i)[1];
  }
  fMult = new AliMultiplicity(notracks,tht,phi,dphi,labels,nosingleclus,ths,phs);
  delete [] tht;
  delete [] phi;
  delete [] dphi;
  delete [] ths;
  delete [] phs;
  itsLoader->UnloadRecPoints();
  delete multReco;
  return;
}

//______________________________________________________________________
void AliITSVertexer::SetLaddersOnLayer2(Int_t ladwid){<commit_msg>Memory leak fixed<commit_after>#include <AliESDVertex.h>
#include "AliITSgeomTGeo.h"
#include "AliITSVertexer.h"
#include "AliRunLoader.h"
#include "AliITSLoader.h"
#include "AliMultiplicity.h"
#include "AliITSMultReconstructor.h"

const Float_t AliITSVertexer::fgkPipeRadius = 3.0;

ClassImp(AliITSVertexer)

//////////////////////////////////////////////////////////////////////
// Base class for primary vertex reconstruction                     //
// AliESDVertexer is a class for full 3D primary vertex finding     //
// derived classes: AliITSVertexerIons AliITSvertexer3D             //
//                  AliITSVertexerCosmics                           //
//////////////////////////////////////////////////////////////////////

//______________________________________________________________________
AliITSVertexer::AliITSVertexer():AliVertexer(),
fLadders(), 
fLadOnLay2(0)	 {
  // Default Constructor
  SetLaddersOnLayer2();
}

AliITSVertexer::AliITSVertexer(TString filename):AliVertexer(),
fLadders(), 
fLadOnLay2(0)
{
  // Standard constructor
  AliRunLoader *rl = AliRunLoader::GetRunLoader();
  if(!rl){
    Fatal("AliITSVertexer","Run Loader not found");
  }
  /*
  if(rl->LoadgAlice()){
    Fatal("AliITSVertexer","The AliRun object is not available - nothing done");
  }
  */
  fCurrentVertex  = 0;   
  SetFirstEvent(0);
  SetLastEvent(0);
  //  rl->LoadHeader();
  AliITSLoader* itsLoader =  (AliITSLoader*) rl->GetLoader("ITSLoader");
  if(!filename.Contains("default"))itsLoader->SetVerticesFileName(filename);
  if(!filename.Contains("null"))itsLoader->LoadVertices("recreate");
  itsLoader->LoadRecPoints();
  //  Int_t lst;
  SetLastEvent(rl->GetNumberOfEvents()-1);
  /*
  if(rl->TreeE()){
    lst = static_cast<Int_t>(rl->TreeE()->GetEntries());
    SetLastEvent(lst-1);
  }
  */
  SetLaddersOnLayer2();
}

//______________________________________________________________________
AliITSVertexer::AliITSVertexer(const AliITSVertexer &vtxr) : AliVertexer(vtxr) {
  // Copy constructor
  // Copies are not allowed. The method is protected to avoid misuse.
  Error("AliITSVertexer","Copy constructor not allowed\n");
}

//______________________________________________________________________
AliITSVertexer& AliITSVertexer::operator=(const AliITSVertexer& /* vtxr */){
  // Assignment operator
  // Assignment is not allowed. The method is protected to avoid misuse.
  Error("= operator","Assignment operator not allowed\n");
  return *this;
}

//______________________________________________________________________
AliITSVertexer::~AliITSVertexer() {
  // Destructor
 if(fLadders) delete [] fLadders;
}

//______________________________________________________________________
void AliITSVertexer::FindMultiplicity(Int_t evnumber){
  // Invokes AliITSMultReconstructor to determine the
  // charged multiplicity in the pixel layers
  if(fMult){delete fMult; fMult = 0;}
  Bool_t success=kTRUE;
  if(!fCurrentVertex)success=kFALSE;
  if(fCurrentVertex && fCurrentVertex->GetNContributors()<1)success=kFALSE;
  if(!success){
    AliWarning("Tracklets multiplicity not determined because the primary vertex was not found");
    return;
  }
  AliITSMultReconstructor* multReco = new AliITSMultReconstructor();
  AliRunLoader *rl =AliRunLoader::GetRunLoader();
  AliITSLoader* itsLoader = (AliITSLoader*)rl->GetLoader("ITSLoader");
  multReco->SetGeometry(itsLoader->GetITSgeom());
  itsLoader->LoadRecPoints();
  rl->GetEvent(evnumber);
  TTree* itsClusterTree = itsLoader->TreeR();
  if (!itsClusterTree) {
    AliError(" Can't get the ITS cluster tree !\n");
    return;
  }
  Double_t vtx[3];
  fCurrentVertex->GetXYZ(vtx);
  Float_t vtxf[3];
  for(Int_t i=0;i<3;i++)vtxf[i]=vtx[i];
  multReco->SetHistOn(kFALSE);
  multReco->Reconstruct(itsClusterTree,vtxf,vtxf);
  Int_t notracks=multReco->GetNTracklets();
  Float_t *tht = new Float_t [notracks];
  Float_t *phi = new Float_t [notracks];
  Float_t *dphi = new Float_t [notracks];
  Int_t *labels = new Int_t[notracks];
  for(Int_t i=0;i<multReco->GetNTracklets();i++){
    tht[i] = multReco->GetTracklet(i)[0];
    phi[i] =  multReco->GetTracklet(i)[1];
    dphi[i] = multReco->GetTracklet(i)[2];
    labels[i] = static_cast<Int_t>(multReco->GetTracklet(i)[3]);
  }
  Int_t nosingleclus=multReco->GetNSingleClusters();
  Float_t *ths = new Float_t [nosingleclus];
  Float_t *phs = new Float_t [nosingleclus];
  for(Int_t i=0;i<nosingleclus;i++){
    ths[i] = multReco->GetCluster(i)[0];
    phs[i] =  multReco->GetCluster(i)[1];
  }
  fMult = new AliMultiplicity(notracks,tht,phi,dphi,labels,nosingleclus,ths,phs);
  delete [] tht;
  delete [] phi;
  delete [] dphi;
  delete [] ths;
  delete [] phs;
  delete [] labels;
  itsLoader->UnloadRecPoints();
  delete multReco;
  return;
}

//______________________________________________________________________
void AliITSVertexer::SetLaddersOnLayer2(Int_t ladwid){
{'fraction_non_alphanumeric': 0.15888137676705594, 'fraction_numerical': 0.006146281499692686, 'mean_word_length': 4.288732394366197, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6053596', 'n_tokens_mistral': 3175, 'n_tokens_neox': 3166, 'n_words': 563}