]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUTrackCond.cxx
Updated hydro macro
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUTrackCond.cxx
1 #include "AliITSUTrackCond.h"
2 #include "AliITSUAux.h"
3 #include "AliLog.h"
4
5 using namespace AliITSUAux;
6
7 //______________________________________________________________
8 AliITSUTrackCond::AliITSUTrackCond(int nLayers)
9   :fNLayers(0)
10   ,fMaxBranches(0)
11   ,fMaxCandidates(0)
12   ,fNConditions(0)
13   ,fConditions(0)
14   ,fAuxData(0)
15 {
16   // def c-tor
17   if (nLayers) SetNLayers(nLayers);
18 }
19
20 //______________________________________________________________
21 AliITSUTrackCond::AliITSUTrackCond(const AliITSUTrackCond& src)
22   :TObject(src),
23    fNLayers(src.fNLayers)
24   ,fMaxBranches(0)
25   ,fMaxCandidates(0)
26   ,fNConditions(src.fNConditions)
27   ,fConditions(src.fConditions)
28   ,fAuxData(src.fAuxData)
29 {
30   // copy c-tor
31   if (fNLayers>0) {
32     fMaxBranches = new Short_t[fNLayers];
33     fMaxCandidates = new Short_t[fNLayers];
34     for (int i=fNLayers;i--;) {
35       SetMaxBranches(i,src.GetMaxBranches(i));
36       SetMaxCandidates(i,src.GetMaxCandidates(i));
37     }
38   }
39 }
40
41 //______________________________________________________________
42 AliITSUTrackCond& AliITSUTrackCond::operator=(const AliITSUTrackCond& src)
43 {
44   // copy op.
45   if (this!=&src) {
46     fNLayers = src.fNLayers;
47     fNConditions = src.fNConditions;
48     fConditions  = src.fConditions;
49     if (fNLayers) {
50       delete fMaxBranches;
51       delete fMaxCandidates;
52       fMaxBranches = new Short_t[fNLayers];
53       fMaxCandidates = new Short_t[fNLayers];
54       for (int i=fNLayers;i--;) {
55         SetMaxBranches(i,src.GetMaxBranches(i));
56         SetMaxCandidates(i,src.GetMaxCandidates(i));
57       }
58     }
59     fAuxData = src.fAuxData;
60   }
61   return *this;
62 }
63
64 //______________________________________________________________
65 void AliITSUTrackCond::SetNLayers(int nLayers)
66 {
67   // set number of layers
68   fNLayers = nLayers;
69   if (fNLayers>0) {
70     fMaxBranches = new Short_t[fNLayers];
71     fMaxCandidates = new Short_t[fNLayers];
72     for (int i=fNLayers;i--;) {
73       SetMaxBranches(i,kMaxBranches);
74       SetMaxCandidates(i,kMaxCandidates);
75     }
76   }
77 }
78
79 //______________________________________________________________
80 void AliITSUTrackCond::AddGroupPattern(UShort_t patt)
81 {
82   // add new group pattern to last condition
83   if (fNConditions<1) AliFatal("Can be called only after AddCondition");
84   int ind = fConditions.GetSize();
85   fConditions.Set(ind+1);
86   fConditions[ind] = patt;
87   fAuxData[(fNConditions-1)*kNAuxSz + kNGroups]++;
88 }
89
90 //______________________________________________________________
91 void AliITSUTrackCond::AddNewCondition(Int_t minClusters)
92 {
93   // add new track condition
94   fAuxData.Set( (1+fNConditions)*kNAuxSz );
95   fAuxData[fNConditions*kNAuxSz+kCondStart] = fConditions.GetSize();
96   fAuxData[fNConditions*kNAuxSz+kNGroups]   = 0;
97   fAuxData[fNConditions*kNAuxSz+kMinClus]   = minClusters;
98   fNConditions++;
99   //
100 }
101
102 //______________________________________________________________
103 Bool_t AliITSUTrackCond::CheckPattern(UShort_t patt) const
104 {
105   // check if the pattern matches to some condition
106   Short_t *arrAux = (Short_t*)fAuxData.GetArray();
107   Short_t *arrGrp = (Short_t*)fConditions.GetArray();  
108   int ncl = NumberOfBitsSet(patt);
109   int cntCond = 0;
110   for (int ic=0;ic<fNConditions;ic++) {
111     if (arrAux[cntCond+kMinClus]>ncl) {cntCond+=kNAuxSz; continue;} // check number of clusters
112     int grAddr = arrAux[cntCond+kCondStart]; // 1st group pattern address in the condition
113     Bool_t ok = kTRUE;
114     // if every group of the condition does not match, check next contition
115     for (int ig=arrAux[cntCond+kNGroups];ig--;) if ( !(patt&arrGrp[grAddr++]) ) {ok = kFALSE; break;}
116     if (ok) return kTRUE;
117     cntCond += kNAuxSz;
118   }
119   return kFALSE;
120 }
121
122 //______________________________________________________________
123 void AliITSUTrackCond::Print(Option_t*) const
124 {
125   // print conditions
126   int nc = GetNConditions();  
127   Short_t *arrAux = (Short_t*)fAuxData.GetArray();
128   Short_t *arrGrp = (Short_t*)fConditions.GetArray();  
129   int cntCond = 0;
130   printf("Conditions set ID=%d : %d entries\n",GetID(),nc);
131   for (int i=0;i<nc;i++) {
132     printf("#%2d: MinCl:%2d | %d groups :",i,arrAux[cntCond+kMinClus],arrAux[cntCond+kNGroups]);
133     int grAddr = arrAux[cntCond+kCondStart];
134     for (int ig=arrAux[cntCond+kNGroups];ig--;) {
135       printf("{");
136       PrintBits(arrGrp[grAddr++], fNLayers);
137       printf("}");
138     }
139     printf("\n");
140     cntCond += kNAuxSz;
141   }
142   printf("Max allowed branches/candidates per seed: ");
143   for (int i=0;i<fNLayers;i++) printf("L%d: %d/%d ",i,fMaxBranches[i],fMaxCandidates[i]); printf("\n");
144 }