ROOT logo
#if !defined(__CINT__) || defined(__MAKECINT__)
#include <TH1F.h>
#include <TSystem.h>
#include <TMath.h>
#include <TParticle.h>
#include <TRandom.h>
#include <TROOT.h>
#include "AliESDVertex.h"
#include "AliExternalTrackParam.h"
#include "FT2.h"

FT2* det=0;
#endif

TH1F* hdca=0,*hdcaN=0;
TH1F* hdcaZ=0,*hdcaZN=0;
TH1F* hFdca=0,*hFdcaN=0;
TH1F* hFdcaZ=0,*hFdcaZN=0;
TH1F* hPatternITS=0;
TH1F* hFPatternITS=0;

void testF(int ntrials=10000, double dndy=2100., Bool_t useKalmanOut=kTRUE)
{
#if defined(__CINT__) && !defined(__MAKECINT__)
  gSystem->Load("libITSUpgradeBase.so");
  gSystem->Load("libITSUpgradeSim.so");
  gSystem->Load("libITSUpgradeRec.so");
  gROOT->ProcessLine(".L FT2.cxx+");
  FT2* det=0;
#endif
  //
  det = new FT2();
  det->InitEnvLocal();
  det->InitDetector();
  det->SetSimMat(kTRUE);
  det->SetMaxStepTGeo(1.);
  det->SetdNdY(dndy);
  det->SetUseKalmanOut(useKalmanOut);
  //
  hdca  = new TH1F("hdca","dca",  100,-0.1,.1);
  hdcaN = new TH1F("hdcaN","dcaN",100,-10.,10.);
  hdcaZ  = new TH1F("hdcaZ","dcaZ",  100,-0.1,.1);
  hdcaZN = new TH1F("hdcaZN","dcaZN",100,-10.,10.);
  //
  hFdca  = new TH1F("hFdca","dca fake",  100,-0.1,.1);
  hFdcaN = new TH1F("hFdcaN","dcaN fake",100,-10.,10.);
  hFdcaZ  = new TH1F("hFdcaZ","dcaZ fake",  100,-0.1,.1);
  hFdcaZN = new TH1F("hFdcaZN","dcaZN fake",100,-10.,10.);
  //
  hPatternITS  = new TH1F("itsPattern","ITS hits pattern"      ,7,-0.5,6.5);
  hFPatternITS = new TH1F("itsFPattern","ITS fake hits pattern",7,-0.5,6.5);
  //
  AliESDVertex *vtx = new AliESDVertex();
  double vcov[6] = {1e-4, 0, 1e-4, 0, 0, 1e-4};
  vtx->SetCovarianceMatrix(vcov);
  vtx->Print();
  //
  TParticle prt;
  double p = 0.25;
  for (int ntr=0;ntr<ntrials;ntr++) {
    
    vtx->SetXv(gRandom->Gaus(-0.1, 50e-4));
    vtx->SetYv(gRandom->Gaus(0.2,  50e-4));
    vtx->SetZv(gRandom->Gaus(0.5, 5.0));
    //
    double phi = gRandom->Rndm()*TMath::TwoPi();
    double eta =  2*(gRandom->Rndm()-0.5)*0.8;
    double theta = 2*TMath::ATan(TMath::Exp(-eta));
    double pz = p*TMath::Cos(theta);
    double pt = p*TMath::Sin(theta);
    double pxyz[3]={pt*TMath::Cos(phi),pt*TMath::Sin(phi),pz};
    double en = TMath::Sqrt(p*p+0.14*0.14);
    prt.SetPdgCode(gRandom->Rndm()>0.5 ? 211 : -211);
    //prt.SetPdgCode(-211);
    prt.SetMomentum(pxyz[0],pxyz[1],pxyz[2],en);
    prt.SetProductionVertex(vtx->GetX(),vtx->GetY(),vtx->GetZ(),0);
    //
    if (det->ProcessTrack(&prt,vtx)) {
      //const AliExternalTrackParam& prob = det->GetProbe();
      //      printf("%d %d\n",det->GetNClITS(),det->GetNClTPC());
      //    prob.Print();
      //      /*
      const double* dca = det->GetDCA();
      const double* cov = det->GetDCACov();
      hdca->Fill(dca[0]);
      hdcaN->Fill(dca[0]/TMath::Sqrt(cov[0]));
      hdcaZ->Fill(dca[1]);
      hdcaZN->Fill(dca[1]/TMath::Sqrt(cov[2]));
      //
      if (det->GetNClITSFakes()) {
	hFdca->Fill(dca[0]);
	hFdcaN->Fill(dca[0]/TMath::Sqrt(cov[0]));
	hFdcaZ->Fill(dca[1]);
	hFdcaZN->Fill(dca[1]/TMath::Sqrt(cov[2]));
      }
      int hits  = det->GetITSPattern();
      int hitsF = det->GetITSPatternFakes();
      for (int j=7;j--;) {
	if (hits&(0x1<<j))  hPatternITS->Fill(j);
	if (hitsF&(0x1<<j)) hFPatternITS->Fill(j);	
      }
    }
    else {
      printf("Failed on track %d\n",ntr);
    }
  }
  //
}
 testF.C:1
 testF.C:2
 testF.C:3
 testF.C:4
 testF.C:5
 testF.C:6
 testF.C:7
 testF.C:8
 testF.C:9
 testF.C:10
 testF.C:11
 testF.C:12
 testF.C:13
 testF.C:14
 testF.C:15
 testF.C:16
 testF.C:17
 testF.C:18
 testF.C:19
 testF.C:20
 testF.C:21
 testF.C:22
 testF.C:23
 testF.C:24
 testF.C:25
 testF.C:26
 testF.C:27
 testF.C:28
 testF.C:29
 testF.C:30
 testF.C:31
 testF.C:32
 testF.C:33
 testF.C:34
 testF.C:35
 testF.C:36
 testF.C:37
 testF.C:38
 testF.C:39
 testF.C:40
 testF.C:41
 testF.C:42
 testF.C:43
 testF.C:44
 testF.C:45
 testF.C:46
 testF.C:47
 testF.C:48
 testF.C:49
 testF.C:50
 testF.C:51
 testF.C:52
 testF.C:53
 testF.C:54
 testF.C:55
 testF.C:56
 testF.C:57
 testF.C:58
 testF.C:59
 testF.C:60
 testF.C:61
 testF.C:62
 testF.C:63
 testF.C:64
 testF.C:65
 testF.C:66
 testF.C:67
 testF.C:68
 testF.C:69
 testF.C:70
 testF.C:71
 testF.C:72
 testF.C:73
 testF.C:74
 testF.C:75
 testF.C:76
 testF.C:77
 testF.C:78
 testF.C:79
 testF.C:80
 testF.C:81
 testF.C:82
 testF.C:83
 testF.C:84
 testF.C:85
 testF.C:86
 testF.C:87
 testF.C:88
 testF.C:89
 testF.C:90
 testF.C:91
 testF.C:92
 testF.C:93
 testF.C:94
 testF.C:95
 testF.C:96
 testF.C:97
 testF.C:98
 testF.C:99
 testF.C:100
 testF.C:101
 testF.C:102
 testF.C:103
 testF.C:104
 testF.C:105
 testF.C:106
 testF.C:107
 testF.C:108
 testF.C:109