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