]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/FEMTOSCOPY/AliFemtoUser/AliFemtoShareQualityPairCut.cxx
Migration of PWG2/FEMTOSCOPY to PWGCF/FEMTOSCOPY
[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$
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     for (unsigned int imap=0; imap<pair->Track1()->Track()->TPCclusters().GetNbits(); imap++) {
69       // If both have clusters in the same row
70       if (pair->Track1()->Track()->TPCclusters().TestBitNumber(imap) && 
71           pair->Track2()->Track()->TPCclusters().TestBitNumber(imap)) {
72         // Do they share it ?
73         if (pair->Track1()->Track()->TPCsharing().TestBitNumber(imap) &&
74             pair->Track2()->Track()->TPCsharing().TestBitNumber(imap))
75           {
76             //    cout << "A shared cluster !!!" << endl;
77             //  cout << "imap idx1 idx2 " 
78             //       << imap << " "
79             //       << tP1idx[imap] << " " << tP2idx[imap] << endl;
80             an++;
81             nh+=2;
82             ns+=2;
83           }
84         
85         // Different hits on the same padrow
86         else {
87           an--;
88           nh+=2;
89         }
90       }
91       else if (pair->Track1()->Track()->TPCclusters().TestBitNumber(imap) ||
92                pair->Track2()->Track()->TPCclusters().TestBitNumber(imap)) {
93         // One track has a hit, the other does not
94         an++;
95         nh++;
96       }
97     }
98     
99     Float_t hsmval = 0.0;
100     Float_t hsfval = 0.0;
101     
102     if (nh >0) {
103       hsmval = an*1.0/nh;
104       hsfval = ns*1.0/nh;
105     }
106     //  if (hsmval > -0.4) {
107     //   cout << "Pair quality: " << hsmval << " " << an << " " << nh << " " 
108     //        << (pair->Track1()->Track()) << " " 
109     //        << (pair->Track2()->Track()) << endl;
110     //   cout << "Bits: " << pair->Track1()->Track()->TPCclusters().GetNbits() << endl;
111     //  }
112     //   if (hsfval > 0.0) {
113     //     cout << "Pair sharity: " << hsfval << " " << ns << " " << nh << "    " << hsmval << " " << an << " " << nh << endl;
114     //   }
115     
116     temp = (hsmval < fShareQualityMax) && (hsfval < fShareFractionMax);
117   }
118   else
119     temp = true;
120
121   if (fRemoveSameLabel) {
122     if (abs(pair->Track1()->Track()->Label()) == abs(pair->Track2()->Track()->Label())) {
123 //       cout << "Found a pair with same label " << pair->Track1()->Track()->Label() << endl;
124 //       cout << "Quality Sharity Passed " << hsmval << " " << hsfval << " " << pair->QInv() << " " << temp << endl;
125       temp = kFALSE;
126     }
127   }
128
129   temp ? fNPairsPassed++ : fNPairsFailed++;
130   return temp;
131 }
132 //__________________
133 AliFemtoString AliFemtoShareQualityPairCut::Report(){
134   // Prepare the report from the execution
135   string stemp = "AliFemtoShareQuality Pair Cut - remove shared and split pairs\n";  char ctemp[100];
136   snprintf(ctemp , 100, "Number of pairs which passed:\t%ld  Number which failed:\t%ld\n",fNPairsPassed,fNPairsFailed);
137   stemp += ctemp;
138   AliFemtoString returnThis = stemp;
139   return returnThis;}
140 //__________________
141
142 void AliFemtoShareQualityPairCut::SetShareQualityMax(Double_t aShareQualityMax) {
143   fShareQualityMax = aShareQualityMax;
144 }
145
146 Double_t AliFemtoShareQualityPairCut::GetAliFemtoShareQualityMax() const {
147   return fShareQualityMax;
148 }
149
150 void AliFemtoShareQualityPairCut::SetShareFractionMax(Double_t aShareFractionMax) {
151   fShareFractionMax = aShareFractionMax;
152 }
153 Double_t AliFemtoShareQualityPairCut::GetAliFemtoShareFractionMax() const {
154   return fShareFractionMax;
155 }
156
157 TList *AliFemtoShareQualityPairCut::ListSettings()
158 {
159   // return a list of settings in a writable form
160   TList *tListSetttings = new TList();
161   char buf[200];
162   snprintf(buf, 200, "AliFemtoShareQualityPairCut.sharequalitymax=%f", fShareQualityMax);
163   snprintf(buf, 200, "AliFemtoShareQualityPairCut.sharefractionmax=%f", fShareFractionMax);
164   tListSetttings->AddLast(new TObjString(buf));
165
166   return tListSetttings;
167 }
168
169 void     AliFemtoShareQualityPairCut::SetRemoveSameLabel(Bool_t aRemove)
170 {
171   fRemoveSameLabel = aRemove;
172 }