LCOV - code coverage report
Current view: top level - ITS/ITSsim - AliITSmodule.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 44 212 20.8 %
Date: 2016-06-14 17:26:59 Functions: 9 23 39.1 %

          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             : /* $Id$ */
      17             : 
      18             : #include <TArrayI.h>
      19             : 
      20             : #include <stdlib.h>
      21             : 
      22             : #include "AliRun.h"
      23             : #include "AliITS.h"
      24             : #include "AliITShit.h"
      25             : #include "AliITSmodule.h"
      26             : #include "AliITSgeomTGeo.h"
      27             : 
      28         116 : ClassImp(AliITSmodule)
      29             : 
      30             : //_______________________________________________________________________
      31             : //
      32             : // Impementation of class AliITSmodule
      33             : //
      34             : // created by: A. Bouchm, W. Peryt, S. Radomski, P. Skowronski 
      35             : //             R. Barbers, B. Batyunia, B. S. Nilsen
      36             : // ver 1.0     CERN 16.09.1999
      37             : //_______________________________________________________________________
      38             : //________________________________________________________________________
      39             : // 
      40             : // Constructors and deconstructor
      41             : //________________________________________________________________________
      42             : //
      43           0 : AliITSmodule::AliITSmodule():
      44           0 : fITS(0),
      45           0 : fIndex(0),
      46           0 : fHitsM(0),
      47           0 : fTrackIndex(0),
      48           0 : fHitIndex(0) {
      49             :     // constructor
      50             : 
      51           0 : }
      52             : //_________________________________________________________________________
      53       35168 : AliITSmodule::AliITSmodule(Int_t index):
      54       35168 : fITS(0),
      55       35168 : fIndex(index),
      56       35168 : fHitsM(0),
      57       35168 : fTrackIndex(0),
      58      211008 : fHitIndex(0) {
      59             :   // constructor
      60             : 
      61      105504 :     fHitsM      = new TObjArray();
      62      105504 :     fTrackIndex = new TArrayI(16);
      63      105504 :     fHitIndex   = new TArrayI(16);
      64       70336 :     fITS        = (AliITS*)(gAlice->GetDetector("ITS"));
      65       70336 : }
      66             : //__________________________________________________________________________
      67      211008 : AliITSmodule::~AliITSmodule() {
      68             :     // The destructor for AliITSmodule. Before destoring AliITSmodule
      69             :     // we must first destroy all of it's members.
      70             : 
      71       35168 :     if(fHitsM){
      72       35168 :       fHitsM->Delete();
      73       70336 :       delete fHitsM;
      74       35168 :       fHitsM = 0;
      75       35168 :     } // end if
      76       70336 :     delete fTrackIndex;
      77       70336 :     delete fHitIndex;
      78       35168 :     fITS = 0; // We don't delete this pointer since it is just a copy.
      79      105504 : }
      80             : //____________________________________________________________________________
      81           0 : AliITSmodule::AliITSmodule(const AliITSmodule &source):TObject(source),
      82           0 : fITS(source.fITS),
      83           0 : fIndex(source.fIndex),
      84           0 : fHitsM(source.fHitsM),
      85           0 : fTrackIndex(source.fTrackIndex),
      86           0 : fHitIndex(source.fHitIndex){
      87             : ////////////////////////////////////////////////////////////////////////
      88             : //     Copy Constructor 
      89             : ////////////////////////////////////////////////////////////////////////
      90             : 
      91           0 : }
      92             : //_____________________________________________________________________________
      93             : AliITSmodule& AliITSmodule::operator=(const AliITSmodule &source){
      94             : ////////////////////////////////////////////////////////////////////////
      95             : //    Assignment operator 
      96             : ////////////////////////////////////////////////////////////////////////
      97           0 :   this->~AliITSmodule();
      98           0 :   new(this) AliITSmodule(source);
      99           0 :   return *this;
     100           0 : }
     101             : //_________________________________________________________________________
     102             : // 
     103             : // Hits management
     104             : //__________________________________________________________________________
     105             : Int_t AliITSmodule::AddHit(AliITShit* hit,Int_t t,Int_t h) {
     106             : // Hits management
     107             : 
     108             :   //printf("AddHit: beginning hit %p t h %d %d\n",hit,t,h);
     109       10572 :     fHitsM->AddLast(new AliITShit(*hit));
     110        3524 :     Int_t fNhitsM = fHitsM->GetEntriesFast();
     111        3524 :     if(fNhitsM-1>=fTrackIndex->GetSize()){ // need to expand the TArrayI
     112           0 :       fTrackIndex->Set(fNhitsM+64);
     113           0 :     } // end if
     114        3524 :     if(fNhitsM-1>=fHitIndex->GetSize()){ // need to expand the TArrayI
     115           0 :       fHitIndex->Set(fNhitsM+64);
     116           0 :     } // end if
     117        3524 :     (*fTrackIndex)[fNhitsM-1] = t;
     118        3524 :     (*fHitIndex)[fNhitsM-1]   = h;
     119        3524 :     return fNhitsM;
     120           0 : }
     121             : //___________________________________________________________________________
     122             : Double_t AliITSmodule::PathLength(const AliITShit *itsHit1,
     123             :                                   const AliITShit *itsHit2) {
     124             :   // path lenght
     125           0 :    Float_t  x1g,y1g,z1g;   
     126           0 :    Float_t  x2g,y2g,z2g;
     127             :    Double_t s;
     128             : 
     129           0 :    itsHit1->GetPositionG(x1g,y1g,z1g);
     130           0 :    itsHit2->GetPositionG(x2g,y2g,z2g);
     131             : 
     132           0 :    s = TMath::Sqrt( ((Double_t)(x2g-x1g)*(Double_t)(x2g-x1g)) +
     133           0 :                     ((Double_t)(y2g-y1g)*(Double_t)(y2g-y1g)) +
     134           0 :                     ((Double_t)(z2g-z1g)*(Double_t)(z2g-z1g))  );
     135           0 :    return s;
     136           0 : }
     137             : //___________________________________________________________________________
     138             : void AliITSmodule::PathLength(Float_t x,Float_t y,Float_t z,
     139             :                               Int_t status,Int_t &nseg,
     140             :                               Float_t &x1,Float_t &y1,Float_t &z1,
     141             :                               Float_t &dx1,Float_t &dy1,Float_t &dz1,
     142             :                               Int_t &flag) const{
     143             :   // path length
     144             :     static Float_t x0,y0,z0;
     145             : 
     146           0 :     if ((status&0x0002)!=0){ // entering
     147           0 :         x0 = x;
     148           0 :         y0 = y;
     149           0 :         z0 = z;
     150           0 :         nseg = 0;
     151           0 :         flag = 1;
     152           0 :     }else{
     153           0 :         x1 = x0;
     154           0 :         y1 = y0;
     155           0 :         z1 = z0;
     156           0 :         dx1 = x-x1;
     157           0 :         dy1 = y-y1;
     158           0 :         dz1 = z-z1;
     159           0 :         nseg++;
     160           0 :         if ((status&0x0004)!=0) flag = 0; //exiting
     161           0 :         if ((status&0x0001)!=0) flag = 2; // inside
     162             :         else flag = 2; //inside ?
     163           0 :         x0 = x;
     164           0 :         y0 = y;
     165           0 :         z0 = z;
     166             :     } // end if
     167           0 : }
     168             : //___________________________________________________________________________
     169             : Bool_t AliITSmodule::LineSegmentL(Int_t hitindex,Double_t &a,Double_t &b,
     170             :                                   Double_t &c,Double_t &d,
     171             :                                   Double_t &e,Double_t &f,Double_t &de){
     172             :   // line segment
     173             :     AliITShit *h1;
     174           0 :     Double_t t;
     175             : 
     176           0 :     if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
     177             : 
     178           0 :     h1 = (AliITShit *) (fHitsM->At(hitindex));
     179           0 :     if(h1->StatusEntering()){ // if track entering volume, get index for next
     180             :                               // step
     181           0 :         return kFALSE;
     182             :     } // end if StatusEntering()
     183             :     // else stepping
     184           0 :     de = h1->GetIonization();
     185           0 :     h1->GetPositionL0(a,c,e,t);
     186           0 :     h1->GetPositionL(b,d,f);
     187           0 :     b = b - a;
     188           0 :     d = d - c;
     189           0 :     f = f - e;
     190           0 :     return kTRUE;
     191           0 : }
     192             : //___________________________________________________________________________
     193             : Bool_t AliITSmodule::LineSegmentG(Int_t hitindex,Double_t &a,Double_t &b,
     194             :                                   Double_t &c,Double_t &d,
     195             :                                   Double_t &e,Double_t &f,Double_t &de){
     196             :   // line segment
     197             :     AliITShit *h1;
     198           0 :     Double_t t;
     199             : 
     200           0 :     if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
     201             : 
     202           0 :     h1 = (AliITShit *) (fHitsM->At(hitindex));
     203           0 :     if(h1->StatusEntering()){ // if track entering volume, get index for next
     204             :                               // step
     205           0 :         return kFALSE;
     206             :     } // end if StatusEntering()
     207             :     // else stepping
     208           0 :     de = h1->GetIonization();
     209           0 :     h1->GetPositionG0(a,c,e,t);
     210           0 :     h1->GetPositionG(b,d,f);
     211           0 :     b = b - a;
     212           0 :     d = d - c;
     213           0 :     f = f - e;
     214           0 :     return kTRUE;
     215           0 : }
     216             : //___________________________________________________________________________
     217             : Bool_t AliITSmodule::LineSegmentL(Int_t hitindex,Double_t &a,Double_t &b,
     218             :                                   Double_t &c,Double_t &d,
     219             :                                   Double_t &e,Double_t &f,
     220             :                                   Double_t &de,Int_t &track){
     221             :   // line segmente
     222             :     AliITShit *h1;
     223        1762 :     Double_t t;
     224             : 
     225         881 :     if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
     226             : 
     227         881 :     h1 = (AliITShit *) (fHitsM->At(hitindex));
     228         881 :     if(h1->StatusEntering()){ // if track entering volume, get index for next
     229             :                               // step
     230           0 :         track = h1->GetTrack();
     231           0 :         return kFALSE;
     232             :     } // end if StatusEntering()
     233             :     // else stepping
     234         881 :     de = h1->GetIonization();
     235         881 :     h1->GetPositionL0(a,c,e,t);
     236         881 :     h1->GetPositionL(b,d,f);
     237         881 :     b = b - a;
     238         881 :     d = d - c;
     239         881 :     f = f - e;
     240         881 :     track = h1->GetTrack();
     241         881 :     return kTRUE;
     242         881 : }
     243             : //___________________________________________________________________________
     244             : Bool_t AliITSmodule::LineSegmentG(Int_t hitindex,Double_t &a,Double_t &b,
     245             :                                   Double_t &c,Double_t &d,
     246             :                                   Double_t &e,Double_t &f,
     247             :                                   Double_t &de,Int_t &track){
     248             :   // line segment
     249             :     AliITShit *h1;
     250           0 :     Double_t t;
     251             : 
     252           0 :     if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
     253             : 
     254           0 :     h1 = (AliITShit *) (fHitsM->At(hitindex));
     255           0 :     if(h1->StatusEntering()){ // if track entering volume, get index for next
     256             :                               // step
     257           0 :         track = h1->GetTrack();
     258           0 :         return kFALSE;
     259             :     } // end if StatusEntering()
     260             :     // else stepping
     261           0 :     de = h1->GetIonization();
     262           0 :     h1->GetPositionG0(a,c,e,t);
     263           0 :     h1->GetPositionG(b,d,f);
     264           0 :     b = b - a;
     265           0 :     d = d - c;
     266           0 :     f = f - e;
     267           0 :     track = h1->GetTrack();
     268           0 :     return kTRUE;
     269           0 : }
     270             : //______________________________________________________________________
     271             : Bool_t AliITSmodule::MedianHitG(AliITShit *h1,AliITShit *h2,
     272             :                                 Float_t &x,Float_t &y,Float_t &z){
     273             :     // Computes the mean hit location for a set of hits that make up a track
     274             :     // passing through a volume. Returns kFALSE untill the the track leaves
     275             :     // the volume.
     276             :     // median hit
     277           0 :    Float_t x1l=0.,y1l=0.,z1l=0.;
     278           0 :    Float_t x2l=0.,y2l=0.,z2l=0.;
     279             :    Float_t xMl,yMl=0,zMl;
     280           0 :    Double_t l[3], g[3];
     281             : 
     282           0 :    h1->GetPositionG(x1l,y1l,z1l);
     283           0 :    h2->GetPositionG(x2l,y2l,z2l);
     284             : 
     285           0 :    if((y2l*y1l)<0.) {
     286           0 :      xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l;
     287           0 :      zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l;
     288           0 :    } else {
     289           0 :      xMl = 0.5*(x1l+x2l);
     290           0 :      zMl = 0.5*(z1l+z2l);
     291             :    }
     292             : 
     293           0 :    l[0] = xMl;
     294           0 :    l[1] = yMl;
     295           0 :    l[2] = zMl;
     296           0 :    AliITSgeomTGeo::LocalToGlobal(h1->GetModule(),l,g);
     297           0 :    x = g[0];
     298           0 :    y = g[1];
     299           0 :    z = g[2];
     300           0 :    return kTRUE;
     301           0 : }
     302             : //___________________________________________________________________________
     303             : void AliITSmodule::MedianHitG(Int_t index,
     304             :                               Float_t hitx1,Float_t hity1,Float_t hitz1,
     305             :                               Float_t hitx2,Float_t hity2,Float_t hitz2,
     306             :                               Float_t &xMg, Float_t &yMg, Float_t &zMg){
     307             :   // median hit
     308             :    Float_t x1l,y1l,z1l;
     309             :    Float_t x2l,y2l,z2l;
     310             :    Float_t xMl,yMl=0,zMl;
     311           0 :    Double_t l[3], g[3];
     312             : 
     313           0 :    g[0] = hitx1;
     314           0 :    g[1] = hity1;
     315           0 :    g[2] = hitz1;
     316           0 :    AliITSgeomTGeo::GlobalToLocal(index,g,l);
     317           0 :    x1l = l[0];
     318           0 :    y1l = l[1];
     319           0 :    z1l = l[2];
     320             : 
     321           0 :    g[0] = hitx2;
     322           0 :    g[1] = hity2;
     323           0 :    g[2] = hitz2;
     324           0 :    AliITSgeomTGeo::GlobalToLocal(index,g,l);
     325           0 :    x2l = l[0];
     326           0 :    y2l = l[1];
     327           0 :    z2l = l[2];
     328             : 
     329           0 :    if((y2l*y1l)<0.) {
     330           0 :      xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l;
     331           0 :      zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l;
     332           0 :    } else {
     333           0 :      xMl = 0.5*(x1l+x2l);
     334           0 :      zMl = 0.5*(z1l+z2l);
     335             :    }
     336             : 
     337           0 :    l[0] = xMl;
     338           0 :    l[1] = yMl;
     339           0 :    l[2] = zMl;
     340           0 :    AliITSgeomTGeo::LocalToGlobal(index,l,g);
     341           0 :    xMg = g[0];
     342           0 :    yMg = g[1];
     343           0 :    zMg = g[2];
     344           0 : }
     345             : //___________________________________________________________________________
     346             : Bool_t AliITSmodule::MedianHitL( AliITShit *itsHit1, 
     347             :                              AliITShit *itsHit2, 
     348             :                              Float_t &xMl, Float_t &yMl, Float_t &zMl) const{
     349             :   // median hit
     350           0 :    Float_t x1l,y1l,z1l;
     351           0 :    Float_t x2l,y2l,z2l;
     352             : 
     353           0 :    itsHit1->GetPositionL(x1l,y1l,z1l);
     354           0 :    itsHit2->GetPositionL(x2l,y2l,z2l);
     355             : 
     356           0 :    yMl = 0.0;
     357           0 :    if((y2l*y1l)<0.) {
     358           0 :      xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l;
     359           0 :      zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l;       
     360           0 :    } else {
     361           0 :      xMl = 0.5*(x1l+x2l);
     362           0 :      zMl = 0.5*(z1l+z2l);
     363             :    }
     364           0 :    return kTRUE;
     365           0 : }
     366             : //___________________________________________________________________________
     367             : void AliITSmodule::MedianHit(Int_t index,
     368             :                              Float_t xg,Float_t yg,Float_t zg,
     369             :                              Int_t status,
     370             :                              Float_t &xMg,Float_t &yMg,Float_t &zMg,
     371             :                              Int_t &flag){
     372             :   // median hit
     373             :    static Float_t x1,y1,z1;
     374             : 
     375           0 :    if ((status&0x0002)!=0){ // entering
     376           0 :        x1 = xg;
     377           0 :        y1 = yg;
     378           0 :        z1 = zg;
     379           0 :        flag = 1;
     380           0 :    } else if ((status&0x0004)!=0){ // exiting
     381           0 :        MedianHitG(index,x1,y1,z1,xg,yg,zg,xMg,yMg,zMg);
     382           0 :        flag = 0;
     383           0 :    } // end if
     384           0 :    else  flag = 1;
     385           0 : }
     386             : //___________________________________________________________________________
     387             : void AliITSmodule::GetID(Int_t &lay,Int_t &lad,Int_t &det){
     388             :   // get ID
     389         620 :   AliITSgeomTGeo::GetModuleId(fIndex,lay,lad,det);
     390         310 :   return ;
     391             : }
     392             : 

Generated by: LCOV version 1.11