]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/SPECTRA/XtAnalysis/AliJCard.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / XtAnalysis / AliJCard.cxx
1 //====================================
2 //last modified FK 6.NOV 2009
3 //====================================
4 //blah
5 // blah
6
7 #include "AliJCard.h"
8
9 //ClassImp(AliJCard);
10
11 AliJCard::AliJCard():
12     AliJBaseCard(),
13     fhCorr(0),
14     fpi0massbin(0)
15 {   
16     //constructor
17 }
18
19 AliJCard::AliJCard(const char *filename):
20     AliJBaseCard(filename),
21     fhCorr(0),
22     fpi0massbin(0)
23 {  
24     //constructor
25     InitCard();
26     MakeFastCorrTypeIndex();
27 }
28
29
30
31 AliJCard::AliJCard(const AliJCard& obj){
32     // copy constructor
33 }
34
35
36 AliJCard& AliJCard::operator=(const AliJCard& obj){
37     // copy constructor
38     return *this;
39 }
40
41 AliJCard::~AliJCard(){
42     // destructor
43     if( fpi0massbin ){
44         for( int i = 0; i < GetNoOfBins( kCentrType ); i++ ){
45             delete [] fpi0massbin[i];
46         }    // destructor
47         delete [] fpi0massbin;
48     }
49     if( fhCorr ){
50         delete fhCorr;
51     }
52 }
53
54 void AliJCard::MakeFastCorrTypeIndex(){
55     // make fast findex array
56     for( unsigned int i=0;i<fKeyWordVector.size();i++ ){
57         int corrIndex = GetCorrType( fKeyWordVector[i] );
58         if( corrIndex != kNoType )
59             fIndexVector[corrIndex] = i;
60     }
61
62 }
63
64 int AliJCard::IsLessThanUpperPairPtCut(double inPairPt){ 
65     // pt cut
66     int nB = GetN("UpperPairPtCut");
67     if(inPairPt == -999) return nB;
68     if(-999 < inPairPt && inPairPt <=0) return int(Get("UpperPairPtCut",-int(inPairPt)));
69     int bin=-1, i=0;
70     while(i<nB && inPairPt>Get("UpperPairPtCut",i)) i++;
71     if(i<nB) bin=i;
72     //cout<<" i="<<i<<" bin="<<bin<<" inval="<<inPairPt<<endl;;
73     return bin;
74 }
75
76
77
78 TString AliJCard::GetKeyWord(corrType ctype){
79     // get keyword
80     TString kw;
81
82     switch(ctype){
83         case kTriggType:  kw = "TriggPtBorders"; break;
84         case kAssocType:  kw = "AssocPtBorders"; break;
85         case kXeType:     kw = "xEBorders"; break;
86         case kLongType:   kw = "KlongBorders"; break;
87         case kCentrType:  kw = "CentBinBorders"; break;
88         case kZVertType:  kw = "zVertBins"; break;
89         case kMassType:   kw = "PairInvariantMassBins"; break;
90         case kEtaGapType: kw = "EtaGapThresholds"; break;
91         case kDiJetType:  kw = "DiJetMassBorders"; break;
92         case kRGapType:   kw = "RGapThresholds"; break;
93                           //case kEPType:  kw = "EPBorders"; break;
94         default : cout<<"ERROR: kNoType on input to AliJCard::GetKeyWord"<<endl; exit(1); break;
95     }
96     return kw; 
97 }
98
99 corrType AliJCard::GetCorrType( TString inStr ){
100     // get corr type
101     TString kw;
102
103     int i;
104     TString s;
105
106     // go through all corrType to check if the parameter should be added
107     // into fast findex array
108     for( i = 0; i < kNcorrType; i++ ){
109         if( i == kNoType )
110             continue;
111
112         s = GetKeyWord( (corrType)i );
113         if( ! strcmp( s.Data(), inStr.Data() ))
114             return (corrType)i;
115     }
116
117     return kNoType; 
118 }
119
120 int AliJCard::GetN(corrType ctype){
121     //returns size of TVector
122     return GetN(GetKeyWord(ctype));
123 }
124
125 int AliJCard::GetNFast(corrType ctype){
126     //returns size of TVector
127     int findex = fIndexVector[ctype];
128     if( findex > -1 ){
129         return (int) fValuesVector[findex].GetNrows();
130     }else{
131         cout<<"ERROR: fValuesVector fast findex out of range "<< findex << " " << (GetKeyWord( ctype )).Data() << endl;
132         exit(1);
133     }
134 }
135
136
137 float AliJCard::Get(corrType ctype, int VectorComponent){
138     //returns VectorComponent Component of  fValuesVecto`uor TVector for given keyword
139     return Get(GetKeyWord(ctype), VectorComponent);
140 }
141
142 float AliJCard::GetFast(corrType ctype, int VectorComponent){
143     // fast get
144
145     if(0<=VectorComponent && VectorComponent<GetNFast(ctype) && fIndexVector[ctype] > -1 ){
146         return fValuesVector[fIndexVector[ctype]][VectorComponent+1];
147     }else{
148         cout<<"ERROR: fValuesVector fast findex out of range "<< (GetKeyWord(ctype)).Data()<<endl;
149         exit(1);
150     }
151 }
152
153
154 void AliJCard::InitCard(){
155     // Init card
156     cout<<"Init of AliJCard"<<endl;
157     // set the length of fIndexVector and disable all indices
158     fIndexVector.resize( kNcorrType  );
159     for( int i = 0; i < kNcorrType; i++ )
160         fIndexVector[i] = -1;
161 }
162
163 void AliJCard::FinishCard(){
164     // Finish loading of card
165     AliJBaseCard::FinishCard();
166     // recompute fast idices
167
168     fpi0massbin = new Double_t*[GetNoOfBins( kCentrType )];
169
170     char centstr[10];
171
172     // read the pi0 mass bin parameters
173     for( int i = 0; i < GetNoOfBins( kCentrType ); i++ ){
174         fpi0massbin[i] = new Double_t[8];
175
176         for( int j = 0; j < 8; j++ ){
177             sprintf( centstr, "cent%d", i );
178             fpi0massbin[i][j] = Get( centstr, j );
179         }
180     }
181
182 }
183
184 void AliJCard::PrintOut(){
185     // Print out contents of card
186     AliJBaseCard::PrintOut();
187     cout << "----- fast array ----------" << endl;
188     for( unsigned int ii = 0; ii < fIndexVector.size(); ii++ ){
189         if( ii == kNoType )
190             continue;
191         cout << (GetKeyWord( (corrType)ii )).Data() << " " << fIndexVector[ii];
192         if( fIndexVector[ii] > -1 ){
193             cout<<" (dim ="<<fValuesVector[fIndexVector[ii]].GetNrows()<<") ";//print size of TVector
194             for(int j=1; j<=fValuesVector[fIndexVector[ii]].GetNrows(); j++){
195                 cout<<fValuesVector[fIndexVector[ii]][j]<<" ";//TVector components
196             }
197         }
198         else
199             cout << " no link!";
200
201         cout << endl;  
202     }
203 }
204
205 int AliJCard::GetBin(corrType ctype, float val){
206     // get bin
207
208     if(ctype == kNoType) return 0;
209
210     TVector * v = &fValuesVector[fIndexVector[ctype]];
211     int iBin2 = TMath::BinarySearch( v->GetNrows(), v->GetMatrixArray(), val );
212     if( iBin2 >= v->GetNrows()-1 ) iBin2 = -1;
213
214     return iBin2;
215 }
216
217 int AliJCard::GetBinFast(corrType ctype, float val){
218     // fast get bin
219
220     if(ctype == kNoType) return 0;
221
222     for(int i=0; i<(GetNFast(ctype)-1); i++)
223         if(GetFast(ctype,i)<=val && val<GetFast(ctype,i+1))
224             return i;
225
226     return -1;
227 }
228
229
230
231 bool AliJCard::IsGoodRun(int runID){
232     // run quality
233     bool isgood = true;
234     for(int i=0; i<GetN("badRuns");i++) if(((int) Get("badRuns",i)) == runID) isgood = false;
235
236     return isgood;
237 }
238
239 bool AliJCard::MbTrigger(int triggin) const {
240     // MB trigger
241     return (triggin & (1<<kMinBiasTriggerBitJCorran)) > 0; //masking on >0 masking off ==0 desired trigger
242 }
243
244
245 bool AliJCard::SimilarVertZ(float Z1, float Z2){
246     // z vert
247     static double v = Get("maxMixDZ");
248     if( v < 0 ) return 1;
249     return fabs(Z1-Z2) < v ;
250 }
251
252 bool AliJCard::SimilarMultiplicity(float mult1, float mult2){
253     // multi
254     static double v = Get("maxMixDMult");
255     if( v <0) return 1;
256     return fabs(mult1-mult2) < v;
257 }
258
259
260 bool AliJCard::SimilarCentrality(float c1, float c2, int cbin){
261     // centra
262     static TVector *v = GetVector("maxDCent");
263     if(v==NULL) return 1;
264     return fabs(c1-c2) < (*v)[cbin+1]; // TODO
265 }
266
267
268 //--------- P H E N I X    C G L --------------
269
270 /*
271 bool AliJCard::InPhiRange(float Phi){
272     // phi
273     bool isIn = false; 
274     for(int i=1; i<GetN("phiDCRange"); i+=2 ) 
275         isIn = isIn || (Get("phiDCRange",i-1)<Phi && Phi<Get("phiDCRange",i));
276     return isIn;
277
278 */
279
280
281 bool  AliJCard::CheckTrackParamsInTPC(int NClustersTPC,float Chi2PerClusterTPC){
282     // tpc pars
283     bool isGoodTrack = true;
284     if(NClustersTPC < Get("MinNClustersTPC"))           isGoodTrack = false;
285     if(Chi2PerClusterTPC > Get("MaxChi2PerClusterTPC")) isGoodTrack = false;
286     return isGoodTrack;
287 }
288
289 bool  AliJCard::CheckMinNumTPCClustPt(int NClustersTPC, float fpt){
290     // tpc pars
291     float minNTPCCls =  Get("ParMinNClustTPCPt",0)*log(Get("ParMinNClustTPCPt",1)*fpt + Get("ParMinNClustTPCPt",2)); 
292     if(NClustersTPC > minNTPCCls) return true; //track had enough clusters
293     else return false;  //track did not have sufficient number of clusters
294 }
295
296
297 bool  AliJCard::CheckTrackImpact(float xyIm, float zIm, float fpt){
298     // tpc pars
299     bool isGoodTrack = true;
300     if(TMath::Abs(xyIm) > Get("ParMaxDCAToVertexXYPtDep",0)+Get("ParMaxDCAToVertexXYPtDep",1)/pow(fpt,Get("ParMaxDCAToVertexXYPtDep",2))){
301         isGoodTrack = false;
302     }
303     if(TMath::Abs(zIm) > Get("MaxDCAToVertexZ")) isGoodTrack = false;
304
305     return isGoodTrack;
306 }
307
308
309 /*
310 bool AliJCard::DeltaEtaCheck(const AliJBaseTrack *ftk1, const AliJBaseTrack *ftk2) {
311     // deta
312     double delta = fabs( log(tan(ftk1->Theta()/2.0)) -  log(tan(ftk2->Theta()/2.0)) );
313     if(Get("etaCut")>0) return delta < Get("etaCut");
314     if(Get("etaCut")<0) return delta > Get("etaCut");
315
316     return true;
317 }
318 */
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338