+ Int_t nevents = gime->MaxEvent() ;
+ Int_t ievent ;
+
+
+ for(ievent = 0; ievent < nevents; ievent++){
+ gime->Event(ievent,"TR") ;
+ if(gime->TrackSegments() && //Skip events, where no track segments made
+ gime->TrackSegments()->GetEntriesFast()) {
+ MakeRecParticles() ;
+ WriteRecParticles();
+ if(strstr(option,"deb"))
+ PrintRecParticles(option) ;
+ //increment the total number of rec particles per run
+ fRecParticlesInRun += gime->RecParticles()->GetEntriesFast() ;
+ }
+ }
+ if(strstr(option,"tim")){
+ gBenchmark->Stop("PHOSPID");
+ Info("Exec", "took %f seconds for PID %f seconds per event",
+ gBenchmark->GetCpuTime("PHOSPID"),
+ gBenchmark->GetCpuTime("PHOSPID")/nevents) ;
+ }
+
+ Unload();
+}
+
+//____________________________________________________________________________
+const TString AliPHOSPIDv1::GetFileNamePrincipal(TString particle) const
+{
+ //Get file name that contains the PCA for a particle ("photon or pi0")
+ particle.ToLower();
+ TString name;
+ if (particle=="photon") name = fFileNamePrincipalPhoton ;
+ else if (particle=="pi0" ) name = fFileNamePrincipalPi0 ;
+ else Error("GetFileNamePrincipal","Wrong particle name: %s (choose from pi0/photon)\n",particle.Data());
+ return name;
+}
+
+//____________________________________________________________________________
+const Float_t AliPHOSPIDv1::GetParameterCalibration(Int_t i) const
+{
+ // Get the i-th parameter "Calibration"
+ Float_t param = 0.;
+ if (i>2 || i<0)
+ Error("GetParameterCalibration","Invalid parameter number: %d",i);
+ else
+ param = (*fParameters)(0,i);
+ return param;
+}
+
+//____________________________________________________________________________
+const Float_t AliPHOSPIDv1::GetCalibratedEnergy(const Float_t e) const
+{
+// It calibrates Energy depending on the recpoint energy.
+// The energy of the reconstructed cluster is corrected with
+// the formula A + B* E + C* E^2, whose parameters where obtained
+// through the study of the reconstructed energy distribution of
+// monoenergetic photons.
+
+ Float_t p[]={0.,0.,0.};
+ for (Int_t i=0; i<3; i++) p[i] = GetParameterCalibration(i);
+ Float_t enerec = p[0] + p[1]*e + p[2]*e*e;
+ return enerec ;
+
+}
+
+//____________________________________________________________________________
+const Float_t AliPHOSPIDv1::GetParameterCpv2Emc(Int_t i, TString axis) const
+{
+ // Get the i-th parameter "CPV-EMC distance" for the specified axis
+ Float_t param = 0.;
+ if(i>2 || i<0)
+ Error("GetParameterCpv2Emc","Invalid parameter number: %d",i);
+ else {
+ axis.ToLower();
+ if (axis == "x") param = (*fParameters)(1,i);
+ else if (axis == "z") param = (*fParameters)(2,i);
+ else Error("GetParameterCpv2Emc","Invalid axis name: %s",axis.Data());
+ }
+ return param;
+}
+
+//____________________________________________________________________________
+const Float_t AliPHOSPIDv1::GetCpv2EmcDistanceCut(TString axis, Float_t e) const
+{
+ // Get CpvtoEmcDistance Cut depending on the cluster energy, axis and
+ // Purity-Efficiency point
+
+ axis.ToLower();
+ Float_t p[]={0.,0.,0.};
+ for (Int_t i=0; i<3; i++) p[i] = GetParameterCpv2Emc(i,axis);
+ Float_t sig = p[0] + TMath::Exp(p[1] - p[2]*e);
+ return sig;
+}
+
+//____________________________________________________________________________
+const Float_t AliPHOSPIDv1::GetEllipseParameter(TString particle, TString param, Float_t e) const
+{
+ // Calculates the parameter param of the ellipse
+
+ particle.ToLower();
+ param. ToLower();
+ Float_t p[4]={0.,0.,0.,0.};
+ Float_t value = 0.0;
+ for (Int_t i=0; i<4; i++) p[i] = GetParameterToCalculateEllipse(particle,param,i);
+ if (particle == "photon") {
+ if (param.Contains("a")) e = TMath::Min((Double_t)e,70.);
+ else if (param.Contains("b")) e = TMath::Min((Double_t)e,70.);
+ else if (param.Contains("x0")) e = TMath::Max((Double_t)e,1.1);
+ }
+
+ value = p[0]/TMath::Sqrt(e) + p[1]*e + p[2]*e*e + p[3];
+ return value;
+}
+
+//_____________________________________________________________________________
+const Float_t AliPHOSPIDv1::GetParameterPhotonBoundary (Int_t i) const
+{
+ // Get the parameter "i" to calculate the boundary on the moment M2x
+ // for photons at high p_T
+ Float_t param = 0;
+ if (i>3 || i<0)
+ Error("GetParameterPhotonBoundary","Wrong parameter number: %d\n",i);
+ else
+ param = (*fParameters)(14,i) ;
+ return param;
+}
+
+//____________________________________________________________________________
+const Float_t AliPHOSPIDv1::GetParameterPi0Boundary (Int_t i) const
+{
+ // Get the parameter "i" to calculate the boundary on the moment M2x
+ // for pi0 at high p_T
+ Float_t param = 0;
+ if (i>2 || i<0)
+ Error("GetParameterPi0Boundary","Wrong parameter number: %d\n",i);
+ else
+ param = (*fParameters)(15,i) ;
+ return param;
+}
+
+//____________________________________________________________________________
+const Float_t AliPHOSPIDv1::GetParameterTimeGate(Int_t i) const
+{
+ // Get TimeGate parameter depending on Purity-Efficiency i:
+ // i=0 - Low purity, i=1 - Medium purity, i=2 - High purity
+ Float_t param = 0.;
+ if(i>2 || i<0)
+ Error("GetParameterTimeGate","Invalid Efficiency-Purity choice %d",i);
+ else
+ param = (*fParameters)(3,i) ;
+ return param;
+}
+
+//_____________________________________________________________________________
+const Float_t AliPHOSPIDv1::GetParameterToCalculateEllipse(TString particle, TString param, Int_t i) const
+{
+ // Get the parameter "i" that is needed to calculate the ellipse
+ // parameter "param" for the particle "particle" ("photon" or "pi0")
+
+ particle.ToLower();
+ param. ToLower();
+ Int_t offset = -1;
+ if (particle == "photon") offset=0;
+ else if (particle == "pi0") offset=5;
+ else
+ Error("GetParameterToCalculateEllipse","Wrong particle name: %s (choose from pi0/photon)\n",particle.Data());
+
+ Int_t p= -1;
+ Float_t par = 0;
+
+ if (param.Contains("a")) p=4+offset;
+ else if(param.Contains("b")) p=5+offset;
+ else if(param.Contains("c")) p=6+offset;
+ else if(param.Contains("x0"))p=7+offset;
+ else if(param.Contains("y0"))p=8+offset;
+
+ if (i>4 || i<0)
+ Error("GetParameterToCalculateEllipse", "No parameter with index", i) ;
+ else if (p==-1)
+ Error("GetParameterToCalculateEllipse", "No parameter with name %s", param.Data() ) ;
+ else
+ par = (*fParameters)(p,i) ;