]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliTrackMap.cxx
Introducing Header instead of Log
[u/mrichter/AliRoot.git] / STEER / AliTrackMap.cxx
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 /* $Header$ */
17
18 ////////////////////////////////////////////////////////////////////////
19 //
20 // AliTrackMap.cxx
21 // description: 
22 //   contains a relation between track label and it's index
23 //   in a TreeH.
24 //   The main method is At, it takes a particle label as an argument
25 //   and returns the correponding entry in TreeH (many particles
26 //   are usually stored in 1 TreeH entry, one has to check particle
27 //   labels for each hit). 'At' returns:
28 //       kNoEntry = -1 if the particle has no entry in TreeH
29 //       kOutOfBounds = -2 if the particle label is out of bounds
30 //                  
31 //  Author: Jiri Chudoba (CERN), 2002
32 //
33 ////////////////////////////////////////////////////////////////////////
34
35 #include <Riostream.h>
36
37 #include "TTree.h"
38 #include "TROOT.h"
39
40 #include "AliTrackMap.h"
41
42 #include "AliRun.h"
43
44 ClassImp(AliTrackMap)
45
46 //_______________________________________________________________________
47 AliTrackMap::AliTrackMap():
48   fSize(0),
49   fArray(0)
50 {
51   //
52   // default ctor
53   //
54 }
55
56 //_______________________________________________________________________
57 AliTrackMap::AliTrackMap(const AliTrackMap& trm):
58   TNamed(trm),
59   fSize(0),
60   fArray(0)
61 {
62   //
63   // default ctor
64   //
65   trm.Copy(*this);
66 }
67
68 //_______________________________________________________________________
69 AliTrackMap::AliTrackMap(Int_t size, Int_t *array): 
70   TNamed("AliTrackMap", "AliTrackMap"),
71   fSize(size),
72   fArray(new Int_t[fSize])
73 {
74   //
75   // ctor
76   //
77   for (Int_t i = 0; i < fSize; i++) fArray[i] = array[i];
78 }
79
80 //_______________________________________________________________________
81 void AliTrackMap::Copy(AliTrackMap& ) const
82 {
83   Fatal("Copy","Not implemented\n");
84 }
85
86 //_______________________________________________________________________
87 AliTrackMap::~AliTrackMap()
88 {
89   //
90   // dtor
91   //
92   delete [] fArray;
93 }
94
95 //_______________________________________________________________________
96 Int_t AliTrackMap::At(Int_t label) const
97 {
98   //
99   // returns entry number in the TreeH corresponding to particle with 
100   // label label
101   //
102   if (label < 0 || label >= fSize) {
103     cerr<<"AliTrackMap::At: label "<<label<<" out of range, fSize = "<<fSize<<endl;
104     return kOutOfBounds;
105   }
106   return fArray[label];
107 }
108
109 //_______________________________________________________________________
110 void AliTrackMap::SetEventNr(Int_t eventNr) 
111 {
112   //
113   // map is identified by it's name, event number is part of it
114   //
115   char name[20];
116   sprintf(name,"AliTrackMap_%5.5d",eventNr);
117   SetName(name);  
118 }
119
120 //_______________________________________________________________________
121 void AliTrackMap::PrintValues() const
122 {
123   //
124   // method for debugging
125   //
126   cout<<this->GetName()<<" contains these values: "<<endl;
127   for (Int_t i = 0; i < fSize; i++) {
128     cout<<i<<"\t"<<fArray[i]<<"\n";
129   }
130 }
131