LCOV - code coverage report
Current view: top level - PHOS/PHOSbase - AliPHOSRecParticle.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 10 130 7.7 %
Date: 2016-06-14 17:26:59 Functions: 3 11 27.3 %

          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             : /* $Id$ */
      16             : //_________________________________________________________________________
      17             : //  A Reconstructed Particle in PHOS    
      18             : //  To become a general class of AliRoot ?       
      19             : //  Why should I put meaningless comments
      20             : //  just to satisfy
      21             : //  the code checker                 
      22             : //       
      23             : //*-- Author: Yves Schutz (SUBATECH)
      24             : 
      25             : 
      26             : // --- ROOT system ---
      27             : 
      28             : // --- Standard library ---
      29             : 
      30             : 
      31             : // --- AliRoot header files ---
      32             : #include "AliStack.h"
      33             : #include "AliPHOSHit.h" 
      34             : #include "AliPHOSDigit.h" 
      35             : #include "AliPHOSTrackSegment.h" 
      36             : #include "AliPHOSEmcRecPoint.h" 
      37             : #include "AliPHOSRecParticle.h"
      38             : #include "AliPHOSLoader.h" 
      39             : #include "AliPHOSGeometry.h" 
      40             : #include "AliLog.h"
      41             : 
      42             : //____________________________________________________________________________
      43          10 : AliPHOSRecParticle::AliPHOSRecParticle(): 
      44          10 :   fPHOSTrackSegment(0),
      45          10 :   fDebug(kFALSE),
      46          10 :   fPos()
      47          50 : {
      48             :   // ctor
      49             :   const Int_t nSPECIES = AliPID::kSPECIESCN;
      50         300 :   for(Int_t i = 0; i<nSPECIES ; i++)
      51         140 :     fPID[i]=0.;
      52          20 : }
      53             : 
      54             : 
      55             : //____________________________________________________________________________
      56             : AliPHOSRecParticle::AliPHOSRecParticle(const AliPHOSRecParticle & rp):
      57           0 :   AliPHOSFastRecParticle(rp),
      58           0 :   fPHOSTrackSegment(rp.fPHOSTrackSegment),
      59           0 :   fDebug(kFALSE),
      60           0 :   fPos()
      61           0 : {
      62             :   // copy ctor
      63           0 :   fType             = rp.fType ; 
      64           0 :   fIndexInList      = rp.fIndexInList ;
      65             : 
      66           0 :   fPdgCode     = rp.fPdgCode;
      67           0 :   fStatusCode  = rp.fStatusCode;
      68           0 :   fMother[0]   = rp.fMother[0];
      69           0 :   fMother[1]   = rp.fMother[1];
      70           0 :   fDaughter[0] = rp.fDaughter[0];
      71           0 :   fDaughter[1] = rp.fDaughter[1];
      72           0 :   fWeight      = rp.fWeight;
      73           0 :   fCalcMass    = rp.fCalcMass;
      74           0 :   fPx          = rp.fPx;
      75           0 :   fPy          = rp.fPy;
      76           0 :   fPz          = rp.fPz;
      77           0 :   fE           = rp.fE;
      78           0 :   fVx          = rp.fVx;
      79           0 :   fVy          = rp.fVy;
      80           0 :   fVz          = rp.fVz;
      81           0 :   fVt          = rp.fVt;
      82           0 :   fPolarTheta  = rp.fPolarTheta;
      83           0 :   fPolarPhi    = rp.fPolarPhi;
      84           0 :   fParticlePDG = rp.fParticlePDG; 
      85             :   const Int_t nSPECIES = AliPID::kSPECIESCN;
      86           0 :   for(Int_t i = 0; i<nSPECIES ; i++)
      87           0 :     fPID[i]=rp.fPID[i];
      88           0 : }
      89             : 
      90             : //____________________________________________________________________________
      91             : AliPHOSRecParticle & AliPHOSRecParticle::operator = (const AliPHOSRecParticle &)
      92             : {
      93           0 :   Fatal("operator =", "not implemented");
      94           0 :   return *this;
      95             : }
      96             : 
      97             : //____________________________________________________________________________
      98             : Int_t AliPHOSRecParticle::GetNPrimaries() const  
      99             : { 
     100           0 :   return -1;
     101             : }
     102             : 
     103             : //____________________________________________________________________________
     104             : Int_t AliPHOSRecParticle::GetNPrimariesToRecParticles() const  
     105             : { 
     106             :   // Get the number of primaries at the origine of the RecParticle
     107           0 :   Int_t rv = 0 ;
     108           0 :   AliRunLoader* rl = AliRunLoader::Instance() ;
     109           0 :   AliPHOSLoader * phosLoader = static_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
     110           0 :   Int_t emcRPindex = static_cast<AliPHOSTrackSegment*>(phosLoader->TrackSegments()->At(GetPHOSTSIndex()))->GetEmcIndex();
     111           0 :   static_cast<AliPHOSEmcRecPoint*>(phosLoader->EmcRecPoints()->At(emcRPindex))->GetPrimaries(rv) ; 
     112           0 :   return rv ; 
     113           0 : }
     114             : 
     115             : //____________________________________________________________________________
     116             : const TParticle * AliPHOSRecParticle::GetPrimary() const  
     117             : {
     118             :   // Get the primary particle at the origine of the RecParticle and 
     119             :   // which has deposited the largest energy in SDigits
     120           0 :   AliRunLoader* rl = AliRunLoader::Instance() ;
     121           0 :   AliPHOSLoader * phosLoader = static_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
     122           0 :   rl->GetEvent(rl->GetEventNumber()) ;
     123           0 :   rl->LoadKinematics("READ");
     124           0 :   rl->LoadSDigits("READ");
     125             :   
     126           0 :   if(GetNPrimaries() == 0)
     127           0 :     return 0 ;
     128           0 :   if(GetNPrimaries() == 1)
     129           0 :     return GetPrimary(0) ;
     130           0 :   Int_t AbsId = 0;
     131           0 :   Int_t module ;
     132             : 
     133             :   // Get PHOS Geometry object
     134             :   AliPHOSGeometry *geom;
     135           0 :   if (!(geom = AliPHOSGeometry::GetInstance())) 
     136           0 :         geom = AliPHOSGeometry::GetInstance("IHEP","");
     137           0 :   Double_t x,z ;
     138             : //DP to be fixed: Why do we use this method here??? M.B. use RecPoint???
     139           0 :   Double_t vtx[3]={0.,0.,0.} ;
     140           0 :   geom->ImpactOnEmc(vtx,static_cast<double>(Theta()),static_cast<double>(Phi()), module,z,x);
     141             :   Int_t amp = 0 ;
     142             :   Int_t iPrim=-1 ;
     143           0 :   if(module != 0){
     144           0 :     geom->RelPosToAbsId(module,x,z,AbsId) ;
     145           0 :    TClonesArray * sdigits = phosLoader->SDigits() ;
     146             :    AliPHOSDigit * sdig ;
     147             :     
     148           0 :    for(Int_t i = 0 ; i < sdigits->GetEntriesFast() ; i++){
     149           0 :      sdig = static_cast<AliPHOSDigit *>(sdigits->At(i)) ;
     150           0 :      if((sdig->GetId() == AbsId)){
     151           0 :        if((sdig->GetAmp() > amp) && (sdig->GetNprimary())){
     152           0 :          amp = sdig->GetAmp() ;
     153           0 :          iPrim = sdig->GetPrimary(1) ;
     154           0 :        } 
     155             :        // do not scan rest of list
     156           0 :        if(sdig->GetId() > AbsId)
     157             :          continue ; 
     158             :      }
     159             :    }
     160           0 :   }
     161           0 :   if(iPrim >= 0)
     162           0 :     return rl->Stack()->Particle(iPrim) ;
     163             :   else
     164           0 :     return 0 ;
     165           0 : } 
     166             :   
     167             : //____________________________________________________________________________
     168             : Int_t AliPHOSRecParticle::GetPrimaryIndex() const  
     169             : {
     170             :   // Get the primary track index in TreeK which deposits the most energy
     171             :   // in Digits which forms EmcRecPoint, which produces TrackSegment,
     172             :   // which the RecParticle is created from
     173             : 
     174             : 
     175           0 :   AliRunLoader* rl = AliRunLoader::Instance() ;
     176           0 :   AliPHOSLoader * phosLoader = static_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
     177           0 :   rl->GetEvent(rl->GetEventNumber()) ;
     178           0 :   rl->LoadHits("READ");
     179           0 :   rl->LoadDigits("READ");
     180           0 :   rl->LoadRecPoints("READ");
     181           0 :   rl->LoadTracks("READ");
     182             :   
     183             :   // Get TrackSegment corresponding to this RecParticle
     184           0 :   const AliPHOSTrackSegment *ts          = phosLoader->TrackSegment(fPHOSTrackSegment);
     185             : 
     186             :   // Get EmcRecPoint corresponding to this TrackSegment
     187           0 :   Int_t emcRecPointIndex = ts->GetEmcIndex();
     188             : 
     189           0 :   const AliPHOSEmcRecPoint  *emcRecPoint = phosLoader->EmcRecPoint(emcRecPointIndex);
     190             : 
     191             :   // Get the list of digits forming this EmcRecParticle
     192           0 :   Int_t  nDigits   = emcRecPoint->GetDigitsMultiplicity();
     193           0 :   Int_t *digitList = emcRecPoint->GetDigitsList();
     194             : 
     195             :   // Find the digit with maximum amplitude
     196             :   Int_t maxAmp = 0;
     197             :   Int_t bestDigitIndex = -1;
     198           0 :   for (Int_t iDigit=0; iDigit<nDigits; iDigit++) {
     199           0 :     const AliPHOSDigit * digit = phosLoader->Digit(digitList[iDigit]);
     200           0 :     if (digit->GetAmp() > maxAmp) {
     201           0 :       maxAmp = digit->GetAmp();
     202             :       bestDigitIndex = iDigit;
     203           0 :     }
     204             :   }
     205           0 :   if (bestDigitIndex>-1) {
     206           0 :     const AliPHOSDigit * digit = phosLoader->Digit(digitList[bestDigitIndex]);
     207           0 :     if (digit==0) return -12345;
     208           0 :   }
     209             :   
     210             :   // Get the list of primary tracks producing this digit
     211             :   // and find which track has more track energy.
     212             :   //Int_t nPrimary = digit->GetNprimary();
     213             :   //TParticle *track = 0;
     214             :   //Double_t energyEM     = 0;
     215             :   //Double_t energyHadron = 0;
     216             :   //Int_t    trackEM      = -1;
     217             :   //Int_t    trackHadron  = -1;
     218             :   //for (Int_t iPrim=0; iPrim<nPrimary; iPrim++) {
     219             :   //  Int_t iPrimary = digit->GetPrimary(iPrim+1);
     220             :   //  if (iPrimary == -1 || TMath::Abs(iPrimary)>10000000)
     221             :   //    continue ;  //PH 10000000 is the shift of the track 
     222             :   //                //PH indexes in the underlying event
     223             :   //  track = gime->Primary(iPrimary);
     224             :   //  Int_t pdgCode   = track->GetPdgCode();
     225             :   //  Double_t energy = track->Energy();
     226             :   //  if (pdgCode==22 || TMath::Abs(pdgCode)==11) {
     227             :   //    if (energy > energyEM) {
     228             :   //    energyEM = energy;
     229             :   //    trackEM = iPrimary;
     230             :   //      }
     231             :   //   }
     232             :   //  else {
     233             :   //     if (energy > energyHadron) {
     234             :   //    energyHadron = energy;
     235             :   //    trackHadron = iPrimary;
     236             :         //    }
     237             :   //  }
     238             :   //}
     239             :   // Preferences are given to electromagnetic tracks
     240             :   //if (trackEM     != -1) return trackEM;     // track is gamma or e+-
     241             :   //if (trackHadron != -1) return trackHadron; // track is hadron
     242             :   //return -12345;                             // no track found :(
     243             : 
     244             : 
     245             :   // Get the list of hits producing this digit,
     246             :   // find which hit has deposited more energy 
     247             :   // and find the primary track.
     248             : 
     249           0 :   TClonesArray *hits = phosLoader->Hits();
     250           0 :   if (hits==0) return -12345;
     251             : 
     252             :   Double_t maxedep  =  0;
     253             :   Int_t    maxtrack = -1;
     254           0 :   Int_t    nHits    = hits ->GetEntries();
     255           0 :   Int_t    id       = (phosLoader->Digit(digitList[bestDigitIndex]))->GetId();
     256             : 
     257           0 :   for (Int_t iHit=0; iHit<nHits; iHit++) {
     258           0 :     const AliPHOSHit * hit = phosLoader->Hit(iHit);
     259           0 :     if(hit->GetId() == id){
     260           0 :       Double_t edep  = hit->GetEnergy();
     261           0 :       Int_t    track = hit->GetPrimary();
     262           0 :       if(edep > maxedep){
     263             :         maxedep  = edep;
     264             :         maxtrack = track;
     265           0 :       }
     266           0 :     }
     267             :   }
     268             : 
     269           0 :   if (maxtrack != -1) return maxtrack; // track is hadron
     270           0 :   return -12345;                       // no track found :(
     271           0 : }
     272             : 
     273             : //____________________________________________________________________________
     274             : const TParticle * AliPHOSRecParticle::GetPrimary(Int_t index) const  
     275             : {
     276             :   // Get one of the primary particles at the origine of the RecParticle
     277           0 :   if ( index > GetNPrimariesToRecParticles() ) { 
     278           0 :     if (fDebug) 
     279           0 :       Warning("GetPrimary", "AliPHOSRecParticle::GetPrimary -> %d is larger that the number of primaries %d", 
     280           0 :               index, GetNPrimaries()) ;
     281           0 :     return 0 ; 
     282             :   } 
     283             :   else { 
     284           0 :     Int_t dummy ; 
     285           0 :     AliRunLoader* rl = AliRunLoader::Instance() ;
     286           0 :     AliPHOSLoader * phosLoader = static_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
     287             : 
     288           0 :     Int_t emcRPindex = static_cast<AliPHOSTrackSegment*>(phosLoader->TrackSegments()->At(GetPHOSTSIndex()))->GetEmcIndex();
     289           0 :     Int_t primaryindex = static_cast<AliPHOSEmcRecPoint*>(phosLoader->EmcRecPoints()->At(emcRPindex))->GetPrimaries(dummy)[index] ; 
     290           0 :     return rl->Stack()->Particle(primaryindex) ;
     291           0 :    } 
     292             :   //  return 0 ; 
     293           0 : }
     294             : 
     295             : //____________________________________________________________________________
     296             : void AliPHOSRecParticle::SetPID(Int_t type, Float_t weight)
     297             : {
     298             :   // Set the probability densities that this reconstructed particle
     299             :   // has a type of i:
     300             :   // i       particle types
     301             :   // ----------------------
     302             :   // 0       electron
     303             :   // 1       muon
     304             :   // 2       pi+-
     305             :   // 3       K+-
     306             :   // 4       p/pbar
     307             :   // 5       photon
     308             :   // 6       pi0 at high pt
     309             :   // 7       neutron
     310             :   // 8       K0L
     311             :   // 9       Conversion electron
     312             :   
     313         280 :   fPID[type] = weight ; 
     314         140 : }

Generated by: LCOV version 1.11