]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/FEMTOSCOPY/AliFemto/AliFemtoPicoEventCollectionVectorHideAway.cxx
Merge branch 'master_patch'
[u/mrichter/AliRoot.git] / PWGCF / FEMTOSCOPY / AliFemto / AliFemtoPicoEventCollectionVectorHideAway.cxx
1 ///////////////////////////////////////////////////////////////////////////
2 //                                                                       //
3 // AliFemtoPicoEventCollectionVectorHideAway: a helper class for         //
4 // managing many mixing buffers with up to three variables used for      //
5 // binning.                                                              //
6 //                                                                       //
7 ///////////////////////////////////////////////////////////////////////////
8 #include "AliFemtoPicoEventCollectionVectorHideAway.h"
9
10 // -----------------------------------
11 AliFemtoPicoEventCollectionVectorHideAway::AliFemtoPicoEventCollectionVectorHideAway(int bx, double lx, double ux,
12                                                                                      int by, double ly, double uy,
13                                                                                      int bz, double lz, double uz):
14   fBinsTot(0),
15   fBinsx(bx), fBinsy(by), fBinsz(bz),
16   fMinx(lx),  fMiny(ly),  fMinz(lz),
17   fMaxx(ux),  fMaxy(uy),  fMaxz(uz),
18   fStepx(0),  fStepy(0),  fStepz(0),
19   fCollection(0),
20   fCollectionVector(0)
21 {
22   // basic constructor
23   fBinsTot = fBinsx * fBinsy * fBinsz;
24   fStepx=0;  fStepx = (fMaxx-fMinx)/fBinsx;
25   fStepy=0;  fStepy = (fMaxy-fMiny)/fBinsy;
26   fStepz=0;  fStepz = (fMaxz-fMinz)/fBinsz;
27   
28   
29   //fCollectionVector = new AliFemtoPicoEventCollectionVector();
30   fCollection = 0;
31   for ( int i=0; i<fBinsTot; i++) {
32     fCollection = new AliFemtoPicoEventCollection();
33     fCollectionVector.push_back(fCollection);
34   }
35 }
36 // -----------------------------------
37 AliFemtoPicoEventCollection* AliFemtoPicoEventCollectionVectorHideAway::PicoEventCollection(int ix, int iy, int iz) { 
38   // return mixing event collection from a given bin
39   if ( ix<0 || ix >= fBinsx) return 0;
40   if ( iy<0 || iy >= fBinsy) return 0;
41   if ( iz<0 || iz >= fBinsz) return 0;
42   int bin = ix + iy*fBinsx + iz*fBinsy*fBinsx; 
43 //   cout << " AliFemtoPicoEventCollectionVectorHideAway::PicoEventCollection(...) - bin(ix,iy,iz): ";
44 //   cout << bin << "(" << ix <<"," << iy << "," << iz <<")" << endl;
45   return fCollectionVector[bin]; 
46 }
47 // -----------------------------------
48 AliFemtoPicoEventCollection* AliFemtoPicoEventCollectionVectorHideAway::PicoEventCollection(double x, double y, double z) {
49   // return mixing event collection for given values on x, y, z axes
50   int ix,iy,iz;
51   ix=0;iy=0;iz=0;
52
53   if(fStepx != 0 && fStepy != 0 && fStepz != 0)
54     {
55       ix = (int)floor( (x-fMinx)/fStepx );
56       iy = (int)floor( (y-fMiny)/fStepy );
57       iz = (int)floor( (z-fMinz)/fStepz );
58     }
59   return PicoEventCollection( ix,iy,iz );
60 }
61 //___________________________________
62 AliFemtoPicoEventCollectionVectorHideAway::AliFemtoPicoEventCollectionVectorHideAway(const AliFemtoPicoEventCollectionVectorHideAway& aColl):
63   fBinsTot(0),
64   fBinsx(0), fBinsy(0), fBinsz(0),
65   fMinx(0),  fMiny(0),  fMinz(0),
66   fMaxx(0),  fMaxy(0),  fMaxz(0),
67   fStepx(0),  fStepy(0),  fStepz(0),
68   fCollection(0),
69   fCollectionVector(0)
70 {
71   // copy constructor
72   fBinsTot = aColl.fBinsTot;
73   fBinsx = aColl.fBinsx;
74   fBinsy = aColl.fBinsy;
75   fBinsz = aColl.fBinsz;
76   fMinx  = aColl.fMinx;
77   fMiny  = aColl.fMiny;
78   fMinz  = aColl.fMinz;
79   fMaxx  = aColl.fMaxx;
80   fMaxy  = aColl.fMaxy;
81   fMaxz  = aColl.fMaxz;
82   fStepx = aColl.fStepx;
83   fStepy = aColl.fStepy;
84   fStepz = aColl.fStepz;
85   fCollection = aColl.fCollection;
86
87   fCollectionVector.clear();
88   for (int iter=0; aColl.fCollectionVector.size();iter++){
89     fCollectionVector.push_back(aColl.fCollectionVector[iter]);
90   }
91 }
92 //___________________________________
93 AliFemtoPicoEventCollectionVectorHideAway::~AliFemtoPicoEventCollectionVectorHideAway()
94 {
95   // destructor
96   fCollectionVector.clear();
97 }
98 //___________________________________
99 AliFemtoPicoEventCollectionVectorHideAway& AliFemtoPicoEventCollectionVectorHideAway::operator=(const AliFemtoPicoEventCollectionVectorHideAway& aColl)
100 {
101   // assignment operator
102   if (this == &aColl)
103     return *this;
104
105   fBinsTot = aColl.fBinsTot;
106   fBinsx = aColl.fBinsx;
107   fBinsy = aColl.fBinsy;
108   fBinsz = aColl.fBinsz;
109   fMinx  = aColl.fMinx;
110   fMiny  = aColl.fMiny;
111   fMinz  = aColl.fMinz;
112   fMaxx  = aColl.fMaxx;
113   fMaxy  = aColl.fMaxy;
114   fMaxz  = aColl.fMaxz;
115   fStepx = aColl.fStepx;
116   fStepy = aColl.fStepy;
117   fStepz = aColl.fStepz;
118   fCollection = aColl.fCollection;
119
120   fCollectionVector.clear();
121
122   for (int iter=0; aColl.fCollectionVector.size();iter++){
123     fCollectionVector.push_back(aColl.fCollectionVector[iter]);
124   }
125
126   return *this;
127 }
128 unsigned int AliFemtoPicoEventCollectionVectorHideAway::GetBinXNumber(double x) { return (int)floor( (x-fMinx)/fStepx ); }
129 unsigned int AliFemtoPicoEventCollectionVectorHideAway::GetBinYNumber(double y) { return (int)floor( (y-fMiny)/fStepy ); }
130 unsigned int AliFemtoPicoEventCollectionVectorHideAway::GetBinZNumber(double z) { return (int)floor( (z-fMinz)/fStepz ); }