LCOV - code coverage report
Current view: top level - STEER/STEERBase - AliMCParticle.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 22 86 25.6 %
Date: 2016-06-14 17:26:59 Functions: 6 12 50.0 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-2007, 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             : /* $Id$ */
      17             : 
      18             : //-------------------------------------------------------------------------
      19             : //     Realisation of AliVParticle for MC Particles
      20             : //     Implementation wraps a TParticle and delegates the methods
      21             : //     Author: Andreas Morsch, CERN
      22             : //-------------------------------------------------------------------------
      23             : 
      24             : #include <TObjArray.h>
      25             : 
      26             : #include "AliMCParticle.h"
      27             : #include "AliExternalTrackParam.h" 
      28             : 
      29             : 
      30         176 : ClassImp(AliMCParticle)
      31             : 
      32             : AliMCParticle::AliMCParticle():
      33           0 :     AliVParticle(),
      34           0 :     fParticle(0),
      35           0 :     fTrackReferences(0),
      36           0 :     fNTrackRef(0),
      37           0 :     fLabel(-1),
      38           0 :     fMother(-1),
      39           0 :     fFirstDaughter(-1),
      40           0 :     fLastDaughter(-1),
      41           0 :     fGeneratorIndex(-1)
      42           0 : {
      43             :     // Constructor
      44           0 : }
      45             : 
      46             :     
      47             : AliMCParticle::AliMCParticle(TParticle* part, TObjArray* rarray, Int_t index):
      48        2149 :     AliVParticle(),
      49        2149 :     fParticle(part),
      50        2149 :     fTrackReferences(rarray),
      51        2149 :     fNTrackRef(0),
      52        2149 :     fLabel(index),
      53        2149 :     fMother(-1),
      54        2149 :     fFirstDaughter(-1),
      55        2149 :     fLastDaughter(-1),
      56        2149 :     fGeneratorIndex(-1)
      57       10745 : {
      58             :     // Constructor
      59        2149 :     if (rarray != 0) {
      60        4298 :       fNTrackRef = fTrackReferences->GetEntriesFast();
      61        2149 :     }
      62        4298 : }
      63             :     
      64             :     
      65             : AliMCParticle::AliMCParticle(const AliMCParticle& mcPart) :
      66           0 :     AliVParticle(mcPart),
      67           0 :     fParticle(0),    
      68           0 :     fTrackReferences(0),
      69           0 :     fNTrackRef(0),
      70           0 :     fLabel(-1),
      71           0 :     fMother(-1),
      72           0 :     fFirstDaughter(-1),
      73           0 :     fLastDaughter(-1),
      74           0 :     fGeneratorIndex(-1)
      75           0 : {
      76             : // Copy constructor
      77           0 : }
      78             : 
      79             : AliMCParticle& AliMCParticle::operator=(const AliMCParticle& mcPart)
      80             : { 
      81             : // Copy constructor
      82           0 :   if (this!=&mcPart) { 
      83           0 :     AliVParticle::operator=(mcPart);
      84           0 :   }
      85             :   
      86           0 :   return *this; 
      87             : }
      88             : 
      89             : AliMCParticle::~AliMCParticle()
      90       12894 : { 
      91             :   // delete the track references passed externally
      92             :   // fParticle should be handled by the user
      93             :   // AliStack in case of AliMCEventHandler
      94        2149 :   if(fTrackReferences){
      95        2149 :     fTrackReferences->Clear();
      96        4298 :       delete fTrackReferences;
      97        2149 :       fTrackReferences = 0;
      98        2149 :   }
      99        6447 : }
     100             : 
     101             : 
     102             : 
     103             : Float_t  AliMCParticle::GetTPCTrackLength(Float_t bz,  Float_t ptmin, Int_t &counter, Float_t deadWidth, Float_t zMax){
     104             :   //
     105             :   // return track length in geometrically active volume of TPC.
     106             :   // z nad rphi acceptance is included
     107             :   // doesn't take into account dead channel and ExB  
     108             :   // 25/04/2013 --> zMax as a parameter with default value 230 cm to take into account L1 shift introduced in AliTPC.cxx
     109             :   // Intput:
     110             :   // trackRefs
     111             :   // bz - magnetic field
     112             :   // deadWidth - dead zone in r-phi
     113             :   // Additional output:
     114             :   // counter   - number of circles
     115             : 
     116           0 :     if (fNTrackRef == 0) return 0.; 
     117             : 
     118             :     const Float_t kRMin = 90;
     119             :     const Float_t kRMax = 245;
     120             : //    const Float_t kZMax = 250;
     121             :     const Float_t kMinPt= ptmin; 
     122             : 
     123             :     Float_t length =0;
     124             :     Int_t nrefs = fNTrackRef;
     125             : 
     126             :     
     127           0 :     AliExternalTrackParam param;
     128           0 :     Double_t cv[21];
     129           0 :     for (Int_t i = 0; i < 21; i++) cv[i]=0;
     130           0 :     counter=0; 
     131             :     //
     132             :     //
     133             :     
     134           0 :     AliTrackReference *ref0 = (AliTrackReference*) (fTrackReferences->At(0));
     135             :     Float_t direction = 0;
     136             :   //
     137           0 :     for (Int_t iref = 1; iref < nrefs; iref++){
     138           0 :         AliTrackReference *ref = (AliTrackReference*) (fTrackReferences->At(iref));
     139           0 :         if (!ref) continue;
     140           0 :         if (!ref0 || ref0->DetectorId()!= AliTrackReference::kTPC){
     141             :             ref0 = ref;
     142           0 :             direction = ((ref0->X() * ref0->Px() + ref0->Y() * ref0->Py()) > 0)? 1. : -1.;
     143           0 :             continue;
     144             :         }
     145             :         
     146           0 :         Float_t newdirection = ((ref->X() * ref->Px() + ref->Y() * ref->Py()) > 0)? 1. : -1.;
     147           0 :         if (newdirection*direction<0) {
     148           0 :             counter++;  //circle counter 
     149             :             direction = newdirection;
     150           0 :             continue;
     151             :         }
     152           0 :         if (counter>0) continue;
     153           0 :         if (ref0->Pt() < kMinPt) break;
     154           0 :         Float_t radius0 = TMath::Max(TMath::Min(ref0->R(),kRMax),kRMin);;
     155           0 :         Float_t radius1 = TMath::Max(TMath::Min(ref->R(),kRMax),kRMin);
     156           0 :         Double_t xyz[3] = {ref0->X(), ref0->Y(), ref0->Z()};
     157           0 :         Double_t pxyz[3]= {ref0->Px(), ref0->Py(), ref0->Pz()};
     158             :         Double_t alpha;
     159           0 :         param.Set(xyz,pxyz,cv,TMath::Nint(fParticle->GetPDG()->Charge()/3.));
     160             :         
     161           0 :         for (Float_t radius = radius0; radius < radius1; radius+=1){
     162           0 :             param.GetXYZAt(radius, bz, xyz);
     163             : //          if (TMath::Abs(xyz[2]) > kZMax) continue;
     164           0 :             if (TMath::Abs(xyz[2]) > zMax) continue;
     165           0 :             Float_t gradius = TMath::Sqrt(xyz[1] * xyz[1] + xyz[0] * xyz[0]);
     166           0 :             if (gradius > kRMax) continue;
     167           0 :             alpha = TMath::ATan2(xyz[1],xyz[0]);
     168           0 :             if (alpha<0) alpha += TMath::TwoPi();
     169             :             //
     170           0 :             Int_t sector   = Int_t(9 * alpha / TMath::Pi());
     171           0 :             Float_t lalpha = alpha - ((sector + 0.5) * TMath::Pi() / 9.);
     172           0 :             Float_t dedge  = (TMath::Tan(TMath::Pi() / 18.) - TMath::Abs(TMath::Tan(lalpha))) * gradius; 
     173           0 :             if (dedge>deadWidth) length++;
     174           0 :         }
     175           0 :         if (ref->DetectorId()!= AliTrackReference::kTPC) break; 
     176             :         ref0 = ref;
     177           0 :     }
     178             :     return length;
     179           0 : }

Generated by: LCOV version 1.11