LCOV - code coverage report
Current view: top level - TPC/TPCrec - AliCosmicTracker.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 148 253 58.5 %
Date: 2016-06-14 17:26:59 Functions: 10 11 90.9 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : //
      16             : //
      17             : //
      18             : //
      19             : //-------------------------------------------------------
      20             : //          Implementation of the Cosmic tracker
      21             : //
      22             : //   Origin:  Xianguo Lu lu@physi.uni-heidelberg.de  Xianguo.Lu@cern.ch
      23             : //
      24             : //=========================================================================================
      25             : // Motivation:
      26             : // 
      27             : // In the default reconstruction in the ALICE the cosmic tracks are found  as two independent particles.
      28             : //
      29             : // In general any of  subtracks can be used for the physics studies. In order to avoid the double counting,
      30             : // the track from the upper hemisphere can be used. 
      31             : //
      32             : // The momentum resolution is determined by the lever arm (1/L^2) and by the number of clusters
      33             : // used for the track fitting (1/sqrt(Ncl)). 
      34             : // Combining/refitting  the two segments together significantly better momentum resolution can be obtained.
      35             : //    sigma_{1/pt} ~ 8x10^-3  - defaul tracking (e.g only upper track)
      36             : //    sigma_{1/pt} ~ 8x10^-4  - combined tracking
      37             : //===========================================================================================
      38             : // 
      39             : // Interface/Implementation:
      40             : // The class AliCosmicTracker provides functionality to find and refit the cosmic tracks. As a starting point, the events reconstruccted using standard tracking are used. 
      41             : // Input:  AliESDEvent
      42             : // Output: TClonesArray of the AliESDCosmicTrack
      43             : //         The array is stored as a data member of the tracker. 
      44             : //
      45             : // The cosmic tracker can be called in the user analysis code (standard analisys train, using the AliAnalysisTask, 
      46             : //    see e.g. AliAnalysisTaskCosmicTracker.h). In oreder to make an analysis simpler and faster it is planned to use the tracker already in the standard reconstruction (To be done).
      47             : //   
      48             : //===========================================================================================
      49             : // Algorithm:
      50             : // 1. Reads an ESD event      -  SetESDEvent() function
      51             : // 2. Loop over single tracks -  Process() function 
      52             : //    cuts are applied for individual ESD tracks (see function ESDtrckCut()). Only ESD tracks with TPCrefit, 
      53             : //    no kink and with ESDfriends will be selected. 
      54             : //    User defined cuts (as a pointer to the static function) can be used. (Expert usage)  
      55             : 
      56             : // 3. Double loop over tracks -  Process() function
      57             : //      a.) if not pair ( see function IsPair() ) continue; 
      58             : //         To accept the pair the tracks should be close together in the parameter space (AliExternalTrackParam - fP[0]-[4], also cut on ESD-phi and -theta)
      59             : //         Absolute, and relative (pull) cut are used
      60             : //         The cuts can be modified beyond default values via SetCut***().
      61             : //                  
      62             : //      b.) Each pair is fit via AliTPCCosmicTrackfit::CombineESDtracks
      63             : //      c.) For each pair one AliESDCosmicTrack object is stored in the fTrackStack, which can be passed out via TClonesArray *arr = fCosmicTracker->GetTrackStack();
      64             : //
      65             : //
      66             : //===========================================================================================
      67             : // Algorithm numerical debugging:
      68             : // The AliCosmicTracker can be used in the different debug/verbose level (see fDebugLevel) 
      69             : // Several intermediate variables can be stored in the trees, printout, or draw.
      70             : // Given functionality (dumping of variables to the tree) was also used for the tuning of the pair
      71             : // selection criterias, and for validation of the fit functionality. 
      72             : //
      73             : //===========================================================================================
      74             : // Usage:
      75             : // AliCosmicTracker *fCosmicTracker = new AliCosmicTracker(debuglevel, tag);
      76             : // fCosmicTracker->SetESDEvent(fESDEvent); //fTrackStack will be automatically cleared/emptied
      77             : // Int_t npair = fCosmicTracker->Process(processtag, kprint); //processtag only relavant if (debuglevel & 4) to draw the tracks in png; number of cosmic candidates are returned; if kprint the event is draw to png
      78             : //
      79             : //
      80             : // Advanced usage:
      81             : // fUserCut can be assigned externally so that additional ESDtrack cut can be applied in the very beginning together with those in ESDtrackCut()
      82             : //
      83             : // Example:
      84             : /*
      85             : //define static (important!!)  cut function in analysis task, e.g. AliAnalysisTaskCosmicTracker
      86             : //1) in AliAnalysisTaskCosmicTracker.h
      87             : static Bool_t TrackCut(AliESDtrack *trk);
      88             : 
      89             : //2) in AliAnalysisTaskCosmicTracker.cxx
      90             : Bool_t AliAnalysisTaskCosmicTracker::TrackCut(AliESDtrack *trk)
      91             : {
      92             :   //
      93             :   //external track cut in addition to the one in AliCosmicTracker (example)
      94             :   //
      95             :   if(!trk->GetTRDncls())
      96             :     return kFALSE;
      97             : 
      98             :   return kTRUE;
      99             : }
     100             : //set user cut function
     101             : fCosmicTracker = new AliCosmicTracker;
     102             : fCosmicTracker->SetUserESDtrackCut(AliAnalysisTaskCosmicTracker::TrackCut);
     103             : */ 
     104             : 
     105             : #include <TTreeStream.h>
     106             : 
     107             : #include "AliESDEvent.h"
     108             : #include "AliTPCseed.h"
     109             : #include "AliTrackerBase.h"
     110             : 
     111             : #include "AliESDCosmicTrack.h"
     112             : #include "AliCosmicTracker.h"
     113             : #include "AliTPCCosmicUtils.h"
     114             : #include "AliTPCCosmicTrackfit.h"
     115             : 
     116             : AliCosmicTracker::AliCosmicTracker(const Int_t dlev, const TString tag): 
     117          16 :   fUserCut(0x0)
     118           8 :   , fStreamer(0x0), fDebugLevel(dlev)
     119           8 :   , fESDEvent(0x0)
     120           8 :   , fCosmicTrackfit(0x0)
     121           8 :   , fTrackStack(0x0)
     122           8 :   , fTrack0()
     123           8 :   , fTrack1()
     124           8 :   , fRawVtx(-999,-999,-999)
     125           8 :   , fRawDCA(-999)
     126           8 :   , fdPhi(-999)
     127           8 :   , fCutdPhi(-999)
     128           8 :   , fdTheta(-999)
     129           8 :   , fCutdTheta(-999)
     130           8 :   , fErrFlagESDtrackCut(-999)
     131           8 :   , fErrFlagIsPair(-999)
     132           8 :   , fErrFlagCosmicTrackfit(-999)
     133           8 :   , fBFieldOn(kTRUE)
     134          16 : {
     135             :   //
     136             :   //constructor
     137             :   //
     138             : 
     139           8 :   if(fDebugLevel & 1)
     140           0 :     fStreamer = new TTreeSRedirector(Form("CosmicTracker_%s.root", tag.Data()));
     141             : 
     142          32 :   fCosmicTrackfit = new AliTPCCosmicTrackfit(0, "AliCosmicTracker");
     143          24 :   fTrackStack = new TClonesArray("AliESDCosmicTrack",100);
     144             :  
     145          96 :   for(Int_t ii=0; ii<5; ii++){
     146          40 :     fDelta[ii] = -999;
     147          40 :     fPull[ii] = -999;
     148             :   }
     149             : 
     150           8 :   fCutdPhi   = 19e-3*5;
     151           8 :   fCutdTheta = 10e-3*5;
     152             :   
     153           8 :   fCutPull[0] = 1.9 *10;
     154           8 :   fCutPull[1] = 1.5 *1e10;
     155           8 :   fCutPull[2] = 1.9 *10;//bug-fixed!
     156           8 :   fCutPull[3] = 0.4 *1e10;
     157           8 :   fCutPull[4] = 3.6 *10;
     158             : 
     159           8 :   fCutDelta[0] = 0.8   * 10;
     160           8 :   fCutDelta[1] = 2.7   * 10;
     161           8 :   fCutDelta[2] = 0.012 * 10;//bug-fixed!
     162           8 :   fCutDelta[3] = 0.007 * 10;
     163           8 :   fCutDelta[4] = 0.05  * 10;
     164          16 : }
     165             : 
     166             : AliCosmicTracker::~AliCosmicTracker()
     167          16 : {
     168             :   //
     169             :   //destructor
     170             :   //
     171          16 :   delete fStreamer;
     172          16 :   delete fCosmicTrackfit;
     173          16 :   delete fTrackStack;
     174          16 : }
     175             : 
     176             : void AliCosmicTracker::SetESDEvent(AliESDEvent *esd)
     177             : {
     178             :   //
     179             :   //set esd event
     180             :   //
     181          16 :   fESDEvent = esd;
     182           8 :   fTrackStack->Clear();
     183           8 : }
     184             : 
     185             : Int_t AliCosmicTracker::Process(const TString tag, const Bool_t kprint)
     186             : {
     187             :   //
     188             :   //double loop over combinations of esd tracks, cosmic event candidates sotred in fTrackStack
     189             :   //
     190           8 :   fBFieldOn = TMath::Abs(AliTrackerBase::GetBz())>1e-3;
     191             :   Int_t npair=0;
     192           8 :   const Int_t ntrk = fESDEvent->GetNumberOfTracks();
     193           8 :   Int_t trkcounter[ntrk];
     194         320 :   for(Int_t ii=0; ii<ntrk; ii++){
     195         152 :     trkcounter[ii]=0;
     196             :   }
     197             : 
     198           8 :   Double_t findabler0 = -999;
     199           8 :   Double_t findabler1 = -999;
     200             : 
     201           8 :   fErrFlagESDtrackCut = 0;
     202           8 :   fErrFlagIsPair = 0;
     203           8 :   fErrFlagCosmicTrackfit = 0;
     204             : 
     205         320 :   for(Int_t itrk=0; itrk<ntrk; itrk++){
     206         152 :     if(!ESDtrackCut(fESDEvent->GetTrack(itrk), findabler0)){
     207             :       continue;
     208             :     }
     209             : 
     210        1574 :     for(Int_t jtrk=itrk+1; jtrk<ntrk; jtrk++){
     211         721 :       if(!ESDtrackCut(fESDEvent->GetTrack(jtrk), findabler1))
     212             :         continue;
     213             : 
     214         564 :       AliESDtrack * trk0 = fESDEvent->GetTrack(itrk);
     215         564 :       AliESDtrack * trk1 = fESDEvent->GetTrack(jtrk);
     216         564 :       if( IsPair(trk0, trk1) ){
     217           3 :         const Bool_t kfit = fCosmicTrackfit->CombineESDtracks(trk0, trk1);
     218           3 :         fErrFlagCosmicTrackfit = fCosmicTrackfit->GetStatus();
     219             : 
     220           3 :         if(kfit){
     221           0 :           fRawVtx = fCosmicTrackfit->ImpactParameter3D();
     222           0 :           fRawDCA = fCosmicTrackfit->ImpactParameter2D().Mag();
     223             : 
     224           0 :           const Int_t ncls              = fCosmicTrackfit->GetFitNcls();
     225           0 :           const Double_t leverarm       = fCosmicTrackfit->GetFitLeverArm();
     226           0 :           const Double_t chi2percluster = fCosmicTrackfit->GetChi2PerCluster();
     227           0 :           const Double_t impactD        = fCosmicTrackfit->GetImpactD();
     228           0 :           const Double_t impactZ        = fCosmicTrackfit->GetImpactZ();
     229             : 
     230           0 :           const Double_t findableratio  = TMath::Min(findabler0, findabler1);
     231             : 
     232           0 :           trkcounter[itrk]++;
     233           0 :           trkcounter[jtrk]++;
     234           0 :           const Bool_t isreuse          = (trkcounter[itrk]>1 || trkcounter[jtrk]>1);
     235             : 
     236           0 :           const TVector3 icU = fCosmicTrackfit->GetInnerClusterUp();
     237           0 :           const TVector3 icD = fCosmicTrackfit->GetInnerClusterLow();
     238             : 
     239             :           Int_t idup = itrk;
     240             :           Int_t idlow = jtrk;
     241           0 :           if(fCosmicTrackfit->IsSwap()){
     242             :             const Int_t idtmp = idup;
     243             :             idup = idlow;
     244             :             idlow = idtmp;
     245             : 
     246           0 :             AliExternalTrackParam tptmp = fTrack0;
     247           0 :             fTrack0 = fTrack1;
     248           0 :             fTrack1 = tptmp;
     249           0 :           }
     250             : 
     251             :           if(
     252           0 :              (fDebugLevel & 4) && 
     253           0 :              ( (isreuse && ntrk<=4) || kprint )
     254             :              ){
     255           0 :             AliESDtrack * trks[]={fESDEvent->GetTrack(idup), fESDEvent->GetTrack(idlow)};
     256           0 :             AliTPCCosmicUtils::DrawTracks(trks, Form("reuse_%03d_%03d_%03d_%s", ntrk, itrk, jtrk, tag.Data()));
     257           0 :           }
     258             :           if(
     259           0 :              (fDebugLevel & 8) &&
     260           0 :              impactD > 160 && findableratio < 0.56
     261             :              ){
     262           0 :             AliESDtrack * trks[]={fESDEvent->GetTrack(idup), fESDEvent->GetTrack(idlow)};
     263           0 :             AliTPCCosmicUtils::DrawTracks(trks, Form("largevtd_%.f_%.f_%03d_%03d_%03d_%s", impactD, findableratio, ntrk, itrk, jtrk, tag.Data()));
     264           0 :           }
     265             : 
     266           0 :           AliESDCosmicTrack costrk(idup, idlow, fCosmicTrackfit->GetTrackParamUp(), fCosmicTrackfit->GetTrackParamLow(), &fTrack0, &fTrack1, ncls, leverarm, chi2percluster, impactD, impactZ, isreuse, findableratio, icU, icD);
     267           0 :           new((*fTrackStack)[npair]) AliESDCosmicTrack(costrk);
     268           0 :           npair++;
     269             : 
     270           0 :           if(fDebugLevel & 1)
     271           0 :             WriteStreamer(ntrk, &costrk);
     272             : 
     273           0 :         }
     274             :         else{
     275           6 :           if(fDebugLevel & 16){
     276           3 :             if(ntrk==2){
     277           0 :               AliESDtrack * trks[]={trk0, trk1};
     278           0 :               AliTPCCosmicUtils::DrawTracks(trks, Form("failCosmicFit_%02d_%03d_%03d_%03d_%s", fCosmicTrackfit->GetStatus(), ntrk, itrk, jtrk, tag.Data()));
     279           0 :             }
     280             :           }
     281             :         }
     282           3 :       }
     283             :       else{
     284        1122 :         if(fDebugLevel & 32){
     285         561 :           if(ntrk==2){
     286           0 :             AliESDtrack * trks[]={trk0, trk1};
     287           0 :             AliTPCCosmicUtils::DrawTracks(trks, Form("failIsPair_%02d_%03d_%03d_%03d_%s", fErrFlagIsPair, ntrk, itrk, jtrk, tag.Data()));
     288           0 :           }
     289             :         }
     290             :       }
     291         564 :     }
     292          66 :   }
     293             :   
     294             :   return npair;
     295           8 : }
     296             : 
     297             : Bool_t AliCosmicTracker::IsPair(AliESDtrack * trk0, AliESDtrack * trk1)
     298             : {
     299             :   //
     300             :   //check whether the two tracks come from one cosmic ray
     301             :   //
     302             : 
     303             :   //dphi + pi should = 0
     304        1128 :   fdPhi   = AliTPCCosmicUtils::AngleInRange(trk0->Phi()   - trk1->Phi()   + TMath::Pi());
     305         564 :   if( TMath::Abs(fdPhi) > fCutdPhi ){
     306         549 :     fErrFlagIsPair = 1;
     307         549 :     return kFALSE;
     308             :   }
     309             : 
     310          15 :   fdTheta = AliTPCCosmicUtils::AngleInRange(trk0->Theta() + trk1->Theta() + TMath::Pi());
     311          15 :   if( TMath::Abs(fdTheta) > fCutdTheta ){
     312          12 :     fErrFlagIsPair = 2;
     313          12 :     return kFALSE;
     314             :   }
     315             : 
     316             :   //use fIp, the comments on the web is wrong (M. Ivanov)
     317           3 :   if(!trk0->GetInnerParam()){
     318           0 :     fErrFlagIsPair = 3;
     319           0 :     return kFALSE;
     320             :   }
     321           3 :   if(!trk1->GetInnerParam()){
     322           0 :     fErrFlagIsPair = 4;
     323           0 :     return kFALSE;
     324             :   }
     325             : 
     326          12 :   AliExternalTrackParam tmptrk[]={*(trk0->GetInnerParam()), *(trk1->GetInnerParam())};
     327             : 
     328           3 :   if(fDebugLevel & 2){
     329           0 :     printf("\n************************ raw ESD:\n");
     330           0 :     AliTPCCosmicUtils::PrintTrackParam(100, &(tmptrk[0]));
     331           0 :     AliTPCCosmicUtils::PrintTrackParam(101, &(tmptrk[1]));
     332           0 :     tmptrk[0].Print();
     333           0 :     tmptrk[1].Print();
     334             :   }
     335             : 
     336           3 :   Double_t xyz0[3], xyz1[3];
     337           3 :   tmptrk[0].GetXYZ(xyz0);
     338           3 :   tmptrk[1].GetXYZ(xyz1);
     339           6 :   const TVector3 gpos0(xyz0), gpos1(xyz1);
     340             : 
     341             :   //============================== rotate to common angle (M. Ivanov), since it is not possible to rotate from alpha1 to alpha0 via AliExternalTrackParam::Rotate
     342           9 :   const Double_t meanalpha = (gpos0-gpos1).Phi();
     343           3 :   const Double_t alpha0 = tmptrk[0].GetAlpha();
     344             : 
     345             :   //track0 closer to mean alpha
     346           6 :   if( TMath::Abs(AliTPCCosmicUtils::AngleInRange(meanalpha-alpha0)) <TMath::PiOver2() ){
     347           9 :     if( !AliTPCCosmicUtils::RotateSafe(&(tmptrk[0]), meanalpha) || 
     348           3 :         !AliTPCCosmicUtils::RotateSafe(&(tmptrk[1]), meanalpha+TMath::Pi()) ){
     349           0 :       fErrFlagIsPair = 5;
     350           0 :       return kFALSE;
     351             :     }
     352             :   }
     353             :   //track1 closer to mean alpha
     354             :   else{
     355           0 :     if( !AliTPCCosmicUtils::RotateSafe(&(tmptrk[1]), meanalpha) || 
     356           0 :         !AliTPCCosmicUtils::RotateSafe(&(tmptrk[0]), meanalpha+TMath::Pi()) ){
     357           0 :       fErrFlagIsPair = 6;
     358           0 :       return kFALSE;
     359             :     }
     360             :   }
     361             : 
     362           3 :   if(fDebugLevel & 2){
     363           0 :     printf("\n************************ after rotation!!\n");
     364           0 :     AliTPCCosmicUtils::PrintTrackParam(300, &(tmptrk[0]));
     365           0 :     AliTPCCosmicUtils::PrintTrackParam(301, &(tmptrk[1]));
     366           0 :     tmptrk[0].Print();
     367           0 :     tmptrk[1].Print();
     368             :   }
     369             : 
     370             :   //============================== propagate from TPC inner wall to x=0 with correct dedx
     371             :   const Double_t xTogo = 0.0;
     372             :   const Double_t maxStep = 1;
     373             :   const Bool_t rotateTo = kFALSE;
     374             :   const Double_t maxSnp = 0.8;
     375           3 :   Double_t eloss[2]={-1, 1};
     376             :   //default [0]=upper [1]=lower
     377             :   //tmptrk[0].phi<0 ==> [0]=lower
     378           9 :   if(AliTPCCosmicUtils::AngleInRange(tmptrk[0].Phi())<0){
     379           3 :     eloss[0]= 1;
     380           3 :     eloss[1]=-1;
     381           3 :   }
     382             : 
     383          21 :   for(Int_t ii=0; ii<2; ii++){
     384          12 :     if(!AliTrackerBase::PropagateTrackToBxByBz(&(tmptrk[ii]), xTogo, AliTPCCosmicUtils::Mass(), maxStep, rotateTo, maxSnp, (Int_t)(eloss[ii]))){
     385           0 :       fErrFlagIsPair = 7;
     386           0 :       return kFALSE;
     387             :     }
     388             :   }
     389             :   
     390           3 :   if(fDebugLevel & 2){
     391           0 :     printf("\n************************ after dedx corr:\n");
     392           0 :     AliTPCCosmicUtils::PrintTrackParam(200, &(tmptrk[0]));
     393           0 :     AliTPCCosmicUtils::PrintTrackParam(201, &(tmptrk[1]));
     394           0 :     tmptrk[0].Print();
     395           0 :     tmptrk[1].Print();
     396             :   }
     397             : 
     398             :   //____________________________________________________________________________________
     399             :   //____________________________________________________________________________________
     400             : 
     401             :   //ESD tracks after reconstruction all have x=0 and
     402             :   //TMath::Abs(alpha0 - alpha1)~ pi ==> back-to-back with angular resolution
     403             :   //[0]: local Y-coordinate of a track (cm);  9.945702e+01 -9.961257e+01 ==> opposite
     404             :   //[1]: local Z-coordinate of a track (cm); 2.677805e+01 2.711143e+01 ==> same
     405             :   //[2]: local sine of the track momentum azimuthal angle; should be the same!! bug-fixed
     406             :   //[3]: tangent of the track momentum dip angle; 1.563563e-01 -1.542005e-01 ==> opposite
     407             :   //[4]: 1/pt (1/(GeV/c)); -1.774935e-01 1.705480e-01 ==> opposite
     408             : 
     409           9 :   fDelta[0] = tmptrk[0].GetParameter()[0] + tmptrk[1].GetParameter()[0];
     410           9 :   fDelta[1] = tmptrk[0].GetParameter()[1] - tmptrk[1].GetParameter()[1];
     411           9 :   fDelta[2] = tmptrk[0].GetParameter()[2] - tmptrk[1].GetParameter()[2];//bug-fixed!! should use "-"
     412           9 :   fDelta[3] = tmptrk[0].GetParameter()[3] + tmptrk[1].GetParameter()[3];
     413           9 :   fDelta[4] = tmptrk[0].GetParameter()[4] + tmptrk[1].GetParameter()[4];
     414             : 
     415           3 :   fPull[0] = fDelta[0]/TMath::Sqrt(tmptrk[0].GetCovariance()[0] +tmptrk[1].GetCovariance()[0]);
     416           3 :   fPull[1] = fDelta[1]/TMath::Sqrt(tmptrk[0].GetCovariance()[2] +tmptrk[1].GetCovariance()[2]);
     417           3 :   fPull[2] = fDelta[2]/TMath::Sqrt(tmptrk[0].GetCovariance()[5] +tmptrk[1].GetCovariance()[5]);
     418           3 :   fPull[3] = fDelta[3]/TMath::Sqrt(tmptrk[0].GetCovariance()[9] +tmptrk[1].GetCovariance()[9]);
     419           3 :   fPull[4] = fDelta[4]/TMath::Sqrt(tmptrk[0].GetCovariance()[14]+tmptrk[1].GetCovariance()[14]);
     420             : 
     421           3 :   int npCheck = fBFieldOn ? 5:4;
     422             : 
     423           3 :   if(fDebugLevel & 2){
     424           0 :     for(Int_t ii=0; ii<npCheck; ii++){
     425           0 :       printf("test %d %e %e -- %e\n", ii, tmptrk[0].GetParameter()[ii], tmptrk[1].GetParameter()[ii], fPull[ii]);
     426             :     }
     427           0 :   }
     428             : 
     429          39 :   for(Int_t ii=0; ii<npCheck; ii++){
     430          15 :     if( TMath::Abs(fPull[ii])  > fCutPull[ii] ){
     431           0 :       fErrFlagIsPair = 10+ii;
     432           0 :       return kFALSE;
     433             :     }
     434          15 :     if( TMath::Abs(fDelta[ii]) > fCutDelta[ii] ){
     435           0 :       fErrFlagIsPair = 20+ii;
     436           0 :       return kFALSE;
     437             :     }
     438             :   }
     439             : 
     440           3 :   fTrack0 = tmptrk[0];
     441           3 :   fTrack1 = tmptrk[1];
     442             : 
     443           3 :   return kTRUE;
     444         579 : }
     445             : 
     446             : Bool_t AliCosmicTracker::ESDtrackCut(AliESDtrack * trk, Double_t &findabler) 
     447             : {
     448             :   //
     449             :   //cut on track quality (kink, TPCrefit, findable ratio) and require TPC seed
     450             :   //
     451             : 
     452        1746 :   if(fUserCut){
     453           0 :     if(!fUserCut(trk)){
     454           0 :       fErrFlagESDtrackCut = 1;
     455           0 :       return kFALSE;
     456             :     }
     457             :   }
     458             : 
     459             :   //reject kink
     460         873 :   if(trk->GetKinkIndex(0)>0){
     461          42 :     fErrFlagESDtrackCut = 2;
     462          42 :     return kFALSE;
     463             :   }
     464             : 
     465             :   //require refit
     466         831 :   if(!trk->IsOn(AliESDtrack::kTPCrefit)){
     467         135 :     fErrFlagESDtrackCut = 3;
     468         135 :     return kFALSE;
     469             :   }
     470             : 
     471             :   // due to drift velocity calibration, a track crossing Z=0 may be reconstructed as 2 ESD tracks, so two pairs are formed, each with one part of this track. Solution: cut on findable ratio (require > 0.5) to remove split tracks due to drift velocity calibration systematics on different sides
     472             :   //there is some remaining with isreuse = true, user should cut on findable ratio according to the fraction of isreuse
     473         696 :   findabler = -999;
     474         696 :   if(!trk->GetTPCNclsF()){
     475           0 :     fErrFlagESDtrackCut = 4;
     476           0 :     return kFALSE;
     477             :   }
     478             : 
     479         696 :   findabler = (Double_t)trk->GetTPCNcls()/(Double_t) trk->GetTPCNclsF();
     480             : 
     481         696 :   if(findabler < CutFindable() ){
     482           0 :     fErrFlagESDtrackCut = 5;
     483           0 :     return kFALSE;
     484             :   }
     485             : 
     486             :   //cut on # TPC ncls on each ESDtrack
     487         696 :   if(trk->GetTPCncls()<AliTPCCosmicUtils::NclsMin()){
     488           0 :     fErrFlagESDtrackCut = 6;
     489           0 :     return kFALSE;
     490             :   }
     491             : 
     492             :   //require ESDfriends
     493         696 :   if(!AliTPCCosmicUtils::GetTPCseed(trk)){
     494          66 :     fErrFlagESDtrackCut = 7;
     495          66 :     return kFALSE;
     496             :   }
     497             : 
     498         630 :   return kTRUE;
     499         873 : }
     500             : 
     501             : Int_t AliCosmicTracker::GetErrFlag() const
     502             : {
     503             :   //
     504             :   //return the error status in process
     505             :   //
     506          16 :   return fErrFlagESDtrackCut + fErrFlagIsPair*100 + fErrFlagCosmicTrackfit*10000;
     507             : }
     508             : 
     509             : void AliCosmicTracker::WriteStreamer(Int_t ntrk, AliESDCosmicTrack *costrk)
     510             : {
     511             :   //
     512             :   //output to streamer
     513             :   //
     514             : 
     515           0 :   (*fStreamer)<<"CosmicTracker_Streamer"<<
     516           0 :     "ntrk="<<ntrk<<
     517             : 
     518           0 :     "costrk="<<costrk<<
     519             : 
     520           0 :     "rawvtx="<<&fRawVtx<<
     521           0 :     "rawdca="<<fRawDCA<<
     522             : 
     523           0 :     "dphi="<<fdPhi<<
     524           0 :     "dtheta="<<fdTheta<<
     525           0 :     "pull0="<<fPull[0]<<
     526           0 :     "pull1="<<fPull[1]<<
     527           0 :     "pull2="<<fPull[2]<<
     528           0 :     "pull3="<<fPull[3]<<
     529           0 :     "pull4="<<fPull[4]<<
     530           0 :     "delta0="<<fDelta[0]<<
     531           0 :     "delta1="<<fDelta[1]<<
     532           0 :     "delta2="<<fDelta[2]<<
     533           0 :     "delta3="<<fDelta[3]<<
     534           0 :     "delta4="<<fDelta[4]<<
     535             :     "\n";
     536           0 : }
     537             : 
     538             : TClonesArray *AliCosmicTracker::FindCosmic(AliESDEvent *event, const Bool_t kadd)
     539             : {
     540             :   //
     541             :   //do cosmic combined trackfit
     542             :   //
     543             : 
     544          16 :   AliCosmicTracker cosmicTracker;
     545           8 :   cosmicTracker.SetESDEvent(event);
     546          24 :   const Int_t npair = cosmicTracker.Process();
     547           8 :   const TClonesArray *arr = cosmicTracker.GetTrackStack();
     548             : 
     549             :   TClonesArray *stackCosmic = 0x0;
     550           8 :   if(kadd){
     551          16 :     for(Int_t ip=0; ip<npair; ip++){
     552           0 :       const AliESDCosmicTrack * esdcos = (AliESDCosmicTrack*) arr->At(ip);
     553           0 :       event->AddCosmicTrack(esdcos);
     554             :     }
     555          24 :     printf("AliCosmicTracker::FindCosmic: event %d: Number of cosmic pairs by AliCosmicTracker %d out of %d tracks, err %d\n", event->GetEventNumberInFile(), npair, event->GetNumberOfTracks(), cosmicTracker.GetErrFlag());
     556             :   }
     557             :   else{
     558           0 :     stackCosmic = new TClonesArray(*arr);
     559             :   }
     560             : 
     561             :   return stackCosmic;
     562           8 : }
     563             : 

Generated by: LCOV version 1.11