]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/FEMTOSCOPY/AliFemtoUser/AliFemtoShareQualityPairCut.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / PWGCF / FEMTOSCOPY / AliFemtoUser / AliFemtoShareQualityPairCut.cxx
1 /////////////////////////////////////////////////////////////////////////////
2 //                                                                         //
3 // AliFemtoShareQualityPairCut - a pair cut which checks for some pair     //
4 // qualities that attempt to identify slit/doubly reconstructed tracks     //
5 //                                                                         //
6 /////////////////////////////////////////////////////////////////////////////
7 /***************************************************************************
8  *
9  * $Id: AliFemtoShareQualityPairCut.cxx 53713 2011-12-20 12:31:21Z akisiel $
10  *
11  * Author: Adam Kisiel, Ohio State, kisiel@mps.ohio-state.edu
12  ***************************************************************************
13  *
14  * Description: part of STAR HBT Framework: AliFemtoMaker package
15  *   a cut to remove "shared" and "split" pairs
16  *
17  ***************************************************************************
18  *
19  *
20  **************************************************************************/
21
22 #include "AliFemtoShareQualityPairCut.h"
23 #include <string>
24 #include <cstdio>
25
26 #ifdef __ROOT__
27 ClassImp(AliFemtoShareQualityPairCut)
28 #endif
29
30 //__________________
31 AliFemtoShareQualityPairCut::AliFemtoShareQualityPairCut():
32   fNPairsPassed(0),
33   fNPairsFailed(0),
34   fShareQualityMax(1.0),
35   fShareFractionMax(1.0),
36   fRemoveSameLabel(0)
37 {
38   // Default constructor
39   // Nothing to do
40 }
41 //__________________
42 AliFemtoShareQualityPairCut::~AliFemtoShareQualityPairCut(){
43   /* no-op */
44 }
45 AliFemtoShareQualityPairCut& AliFemtoShareQualityPairCut::operator=(const AliFemtoShareQualityPairCut& cut)
46 {
47   if (this != &cut) {
48     AliFemtoPairCut::operator=(cut);
49     fNPairsPassed = 0;
50     fNPairsFailed = 0;
51     fShareQualityMax = cut.fShareQualityMax;
52     fShareFractionMax = cut.fShareFractionMax;
53     fRemoveSameLabel = cut.fRemoveSameLabel;
54   }
55   
56   return *this;
57 }
58 //__________________
59 bool AliFemtoShareQualityPairCut::Pass(const AliFemtoPair* pair){
60   // Check for pairs that are possibly shared/double reconstruction
61   bool temp;
62   
63   Int_t nh = 0;
64   Int_t an = 0;
65   Int_t ns = 0;
66   
67   if ((fShareFractionMax >= 1.0) && ( fShareQualityMax >= 1.0)) {
68      temp = true;
69   }
70   else {
71      for (unsigned int imap=0; imap<pair->Track1()->Track()->TPCclusters().GetNbits(); imap++) {
72         // If both have clusters in the same row
73         if (pair->Track1()->Track()->TPCclusters().TestBitNumber(imap) && 
74             pair->Track2()->Track()->TPCclusters().TestBitNumber(imap)) {
75            // Do they share it ?
76            if (pair->Track1()->Track()->TPCsharing().TestBitNumber(imap) &&
77                pair->Track2()->Track()->TPCsharing().TestBitNumber(imap))
78            {
79               //          cout << "A shared cluster !!!" << endl;
80               //        cout << "imap idx1 idx2 " 
81               //             << imap << " "
82               //             << tP1idx[imap] << " " << tP2idx[imap] << endl;
83               an++;
84               nh+=2;
85               ns+=2;
86            }
87            // Different hits on the same padrow
88            else {
89               an--;
90               nh+=2;
91            }
92         }
93         else if (pair->Track1()->Track()->TPCclusters().TestBitNumber(imap) ||
94                  pair->Track2()->Track()->TPCclusters().TestBitNumber(imap)) {
95            // One track has a hit, the other does not
96            an++;
97            nh++;
98         }
99      }
100      Float_t hsmval = 0.0;
101      Float_t hsfval = 0.0;
102
103      if (nh >0) {
104         hsmval = an*1.0/nh;
105         hsfval = ns*1.0/nh;
106      }
107     //  if (hsmval > -0.4) {
108     //   cout << "Pair quality: " << hsmval << " " << an << " " << nh << " " 
109     //        << (pair->Track1()->Track()) << " " 
110     //        << (pair->Track2()->Track()) << endl;
111     //   cout << "Bits: " << pair->Track1()->Track()->TPCclusters().GetNbits() << endl;
112     //  }
113     //   if (hsfval > 0.0) {
114     //     cout << "Pair sharity: " << hsfval << " " << ns << " " << nh << "    " << hsmval << " " << an << " " << nh << endl;
115     //   }
116      if( (fShareQualityMax < 1) && (fShareFractionMax < 1)  )
117         temp = (hsmval < fShareQualityMax) && (hsfval < fShareFractionMax);
118      else if (fShareQualityMax < 1)
119         temp = (hsmval < fShareQualityMax);
120      else if (fShareFractionMax < 1)
121         temp = (hsmval < fShareFractionMax);
122      else temp = false;
123   }
124
125   if (fRemoveSameLabel) {
126     if (abs(pair->Track1()->Track()->Label()) == abs(pair->Track2()->Track()->Label())) {
127 //       cout << "Found a pair with same label " << pair->Track1()->Track()->Label() << endl;
128 //       cout << "Quality Sharity Passed " << hsmval << " " << hsfval << " " << pair->QInv() << " " << temp << endl;
129       temp = kFALSE;
130     }
131   }
132
133   temp ? fNPairsPassed++ : fNPairsFailed++;
134   return temp;
135 }
136 //__________________
137 AliFemtoString AliFemtoShareQualityPairCut::Report(){
138   // Prepare the report from the execution
139   string stemp = "AliFemtoShareQuality Pair Cut - remove shared and split pairs\n";  char ctemp[100];
140   snprintf(ctemp , 100, "Number of pairs which passed:\t%ld  Number which failed:\t%ld\n",fNPairsPassed,fNPairsFailed);
141   stemp += ctemp;
142   AliFemtoString returnThis = stemp;
143   return returnThis;}
144 //__________________
145
146 void AliFemtoShareQualityPairCut::SetShareQualityMax(Double_t aShareQualityMax) {
147   fShareQualityMax = aShareQualityMax;
148 }
149
150 Double_t AliFemtoShareQualityPairCut::GetAliFemtoShareQualityMax() const {
151   return fShareQualityMax;
152 }
153
154 void AliFemtoShareQualityPairCut::SetShareFractionMax(Double_t aShareFractionMax) {
155   fShareFractionMax = aShareFractionMax;
156 }
157 Double_t AliFemtoShareQualityPairCut::GetAliFemtoShareFractionMax() const {
158   return fShareFractionMax;
159 }
160
161 TList *AliFemtoShareQualityPairCut::ListSettings()
162 {
163   // return a list of settings in a writable form
164   TList *tListSetttings = new TList();
165   char buf[200];
166   snprintf(buf, 200, "AliFemtoShareQualityPairCut.sharequalitymax=%f", fShareQualityMax);
167   snprintf(buf, 200, "AliFemtoShareQualityPairCut.sharefractionmax=%f", fShareFractionMax);
168   tListSetttings->AddLast(new TObjString(buf));
169
170   return tListSetttings;
171 }
172
173 void     AliFemtoShareQualityPairCut::SetRemoveSameLabel(Bool_t aRemove)
174 {
175   fRemoveSameLabel = aRemove;
176 }