AliPhysics  8dc8609 (8dc8609)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliEmcalAODHybridTrackCuts.cxx
Go to the documentation of this file.
1 /************************************************************************************
2  * Copyright (C) 2017, Copyright Holders of the ALICE Collaboration *
3  * All rights reserved. *
4  * *
5  * Redistribution and use in source and binary forms, with or without *
6  * modification, are permitted provided that the following conditions are met: *
7  * * Redistributions of source code must retain the above copyright *
8  * notice, this list of conditions and the following disclaimer. *
9  * * Redistributions in binary form must reproduce the above copyright *
10  * notice, this list of conditions and the following disclaimer in the *
11  * documentation and/or other materials provided with the distribution. *
12  * * Neither the name of the <organization> nor the *
13  * names of its contributors may be used to endorse or promote products *
14  * derived from this software without specific prior written permission. *
15  * *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND *
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED *
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
19  * DISCLAIMED. IN NO EVENT SHALL ALICE COLLABORATION BE LIABLE FOR ANY *
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; *
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND *
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
26  ************************************************************************************/
27 #include "AliAODTrack.h"
30 #include "AliLog.h"
31 #include <iostream>
32 
36 
37 using namespace PWG::EMCAL;
38 
41  fSelectNonITSrefitTracks(kTRUE)
42 {
43  fHybridFilterBits[0] = -1;
44  fHybridFilterBits[1] = -1;
45 }
46 
47 AliEmcalAODHybridTrackCuts::AliEmcalAODHybridTrackCuts(const char *name):
48  AliEmcalCutBase(name,""),
49  fSelectNonITSrefitTracks(kTRUE)
50 {
51 
52 }
53 
55  AliAODTrack *aodtrack = dynamic_cast<AliAODTrack *>(o);
56  if(!aodtrack) return AliEmcalTrackSelResultPtr(nullptr, kFALSE);
57  bool selectionresult = aodtrack->IsHybridGlobalConstrainedGlobal();
58  // Reject non-ITSrefit tracks if requested
59  if((fSelectNonITSrefitTracks == false) && (!(aodtrack->GetStatus() & AliVTrack::kITSrefit))) selectionresult = false;
60  AliEmcalTrackSelResultPtr result(aodtrack, selectionresult);
61  // Create user object defining the hybrid track type (only in case the object is selected as hybrid track)
62  if(selectionresult){
64  if(fHybridFilterBits[0] > -1 && fHybridFilterBits[1 ] > -1) {
65  if(aodtrack->TestFilterBit(BIT(fHybridFilterBits[0]))) tracktype = AliEmcalTrackSelResultHybrid::kHybridGlobal;
66  else if(aodtrack->TestFilterBit(BIT(fHybridFilterBits[1]))){
67  if(aodtrack->GetStatus() & AliVTrack::kITSrefit) tracktype = AliEmcalTrackSelResultHybrid::kHybridConstrained;
69  }
70  }
71  result.SetUserInfo(new AliEmcalTrackSelResultHybrid(tracktype));
72 
73  }
74  return result;
75 }
76 
78  TObject(),
79  fDef2010wRefit(nullptr),
80  fDef2010woRefit(nullptr),
81  fDef2011(nullptr)
82 {
83 
84 }
85 
87  if(fDef2010wRefit) delete fDef2010wRefit;
89  if(fDef2011) delete fDef2011;
90 }
91 
93  fDef2010wRefit = new AliEmcalAODHybridTrackCuts("def2010wNoRefit");
96  fDef2010woRefit = new AliEmcalAODHybridTrackCuts("def2010woNoRefit");
99  fDef2011 = new AliEmcalAODHybridTrackCuts("def2011");
101 }
102 
105 }
106 
108  AliInfoStream() << "Running test for 2010 Definition with non-refit tracks" << std::endl;
109  AliAODTrack testCat1WithRefit, testCat2WithRefit, testCat2WithoutRefit, testNoHybrid;
110  testCat1WithRefit.SetIsHybridGlobalConstrainedGlobal();
111  testCat2WithRefit.SetIsHybridGlobalConstrainedGlobal();
112  testCat2WithoutRefit.SetIsHybridGlobalConstrainedGlobal();
113  testCat1WithRefit.SetStatus(AliVTrack::kITSrefit);
114  testCat2WithRefit.SetStatus(AliVTrack::kITSrefit);
115  testCat1WithRefit.SetFilterMap(BIT(8));
116  testCat2WithRefit.SetFilterMap(BIT(4));
117  testCat2WithoutRefit.SetFilterMap(BIT(4));
118 
119  int nfailure = 0;
120  auto result_cat1_wrefit = fDef2010wRefit->IsSelected(&testCat1WithRefit);
121  if(!result_cat1_wrefit){
122  AliErrorStream() << "Track CAT1 not selected as hybrid track" << std::endl;
123  nfailure++; // track not selected - failure
124  } else {
125  auto tracktype = dynamic_cast<const AliEmcalTrackSelResultHybrid *>(result_cat1_wrefit.GetUserInfo());
126  if(!tracktype){
127  AliErrorStream() << "Hybrid track information not found for track CAT1" << std::endl;
128  nfailure++; // no hybrid track type found - failure
129  } else {
130  if(tracktype->GetHybridTrackType() != AliEmcalTrackSelResultHybrid::kHybridGlobal){
131  AliErrorStream() << "Track not selected as hybrid track CAT1: " << int(tracktype->GetHybridTrackType()) << std::endl;
132  nfailure++; // wrong hybrid track type
133  }
134  }
135  }
136 
137  auto result_cat2_wrefit = fDef2010wRefit->IsSelected(&testCat2WithRefit);
138  if(!result_cat2_wrefit){
139  AliErrorStream() << "Track CAT2 not selected as hybrid track" << std::endl;
140  nfailure++; // track not selected - failure
141  } else {
142  auto tracktype = dynamic_cast<const AliEmcalTrackSelResultHybrid *>(result_cat2_wrefit.GetUserInfo());
143  if(!tracktype){
144  AliErrorStream() << "Hybrid track information not found for track CAT2" << std::endl;
145  nfailure++; // no hybrid track type found - failure
146  } else {
147  if(tracktype->GetHybridTrackType() != AliEmcalTrackSelResultHybrid::kHybridConstrained){
148  AliErrorStream() << "Track not selected as hybrid track CAT2: " << int(tracktype->GetHybridTrackType()) << std::endl;
149  nfailure++; // wrong hybrid track type
150  }
151  }
152  }
153 
154  auto result_cat2_worefit = fDef2010wRefit->IsSelected(&testCat2WithoutRefit);
155  if(!result_cat2_worefit){
156  AliErrorStream() << "Track CAT3 not selected as hybrid track" << std::endl;
157  nfailure++; // track not selected - failure
158  } else {
159  auto tracktype = dynamic_cast<const AliEmcalTrackSelResultHybrid *>(result_cat2_worefit.GetUserInfo());
160  if(!tracktype){
161  AliErrorStream() << "Hybrid track information not found for track CAT3" << std::endl;
162  nfailure++; // no hybrid track type found - failure
163  } else {
164  if(tracktype->GetHybridTrackType() != AliEmcalTrackSelResultHybrid::kHybridConstrainedNoITSrefit){
165  AliErrorStream() << "Track not selected as hybrid track CAT3: " << int(tracktype->GetHybridTrackType()) << std::endl;
166  nfailure++; // wrong hybrid track type
167  }
168  }
169  }
170 
171  auto result_nohybrid = fDef2010wRefit->IsSelected(&testNoHybrid);
172  if(result_nohybrid || result_nohybrid.GetUserInfo()){
173  AliErrorStream() << "Non-hybrid track selected or user object attached " << std::endl;
174  nfailure++; // Non-hybrid track selected as hybrid track
175  }
176 
177  return nfailure == 0;
178 }
179 
181  AliInfoStream() << "Running test for 2010 Definition without non-refit tracks" << std::endl;
182  AliAODTrack testCat1WithRefit, testCat2WithRefit, testCat2WithoutRefit, testNoHybrid;
183  testCat1WithRefit.SetIsHybridGlobalConstrainedGlobal();
184  testCat2WithRefit.SetIsHybridGlobalConstrainedGlobal();
185  testCat2WithoutRefit.SetIsHybridGlobalConstrainedGlobal();
186  testCat1WithRefit.SetStatus(AliVTrack::kITSrefit);
187  testCat2WithRefit.SetStatus(AliVTrack::kITSrefit);
188  testCat1WithRefit.SetFilterMap(BIT(8));
189  testCat2WithRefit.SetFilterMap(BIT(4));
190  testCat2WithoutRefit.SetFilterMap(BIT(4));
191 
192  int nfailure = 0;
193  auto result_cat1_wrefit = fDef2010woRefit->IsSelected(&testCat1WithRefit);
194  if(!result_cat1_wrefit) {
195  AliErrorStream() << "Track CAT1 not selected as hybrid track" << std::endl;
196  nfailure++; // track not selected - failure
197  } else {
198  auto tracktype = dynamic_cast<const AliEmcalTrackSelResultHybrid *>(result_cat1_wrefit.GetUserInfo());
199  if(!tracktype) {
200  AliErrorStream() << "Hybrid track information not found for track CAT1" << std::endl;
201  nfailure++; // no hybrid track type found - failure
202  } else {
203  if(tracktype->GetHybridTrackType() != AliEmcalTrackSelResultHybrid::kHybridGlobal){
204  AliErrorStream() << "Track not selected as hybrid track CAT1: " << int(tracktype->GetHybridTrackType()) << std::endl;
205  nfailure++; // wrong hybrid track type
206  }
207  }
208  }
209 
210  auto result_cat2_wrefit = fDef2010woRefit->IsSelected(&testCat2WithRefit);
211  if(!result_cat2_wrefit){
212  AliErrorStream() << "Track CAT2 not selected as hybrid track" << std::endl;
213  nfailure++; // track not selected - failure
214  } else {
215  auto tracktype = dynamic_cast<const AliEmcalTrackSelResultHybrid *>(result_cat2_wrefit.GetUserInfo());
216  if(!tracktype){
217  AliErrorStream() << "Hybrid track information not found for track CAT2" << std::endl;
218  nfailure++; // no hybrid track type found - failure
219  } else {
220  if(tracktype->GetHybridTrackType() != AliEmcalTrackSelResultHybrid::kHybridConstrained){
221  AliErrorStream() << "Track not selected as hybrid track CAT2: " << int(tracktype->GetHybridTrackType()) << std::endl;
222  nfailure++; // wrong hybrid track type
223  }
224  }
225  }
226 
227  auto result_cat2_worefit = fDef2010woRefit->IsSelected(&testCat2WithoutRefit);
228  if(result_cat2_worefit || result_cat2_worefit.GetUserInfo()) {
229  AliErrorStream() << "Non-refit track selected or user object attached " << std::endl;
230  nfailure++; // hybrid tracks without refit rejected in this test
231  }
232 
233  auto result_nohybrid = fDef2010woRefit->IsSelected(&testNoHybrid);
234  if(result_nohybrid || result_nohybrid.GetUserInfo()){
235  AliErrorStream() << "Non-hybrid track selected or user object attached " << std::endl;
236  nfailure++; // Non-hybrid track selected as hybrid track
237  }
238 
239  return nfailure == 0;
240 }
241 
243  AliInfoStream() << "Running test for 2011 Definition" << std::endl;
244  AliAODTrack testCat1, testCat2, testNoHybrid;
245  testCat1.SetIsHybridGlobalConstrainedGlobal(kTRUE);
246  testCat2.SetIsHybridGlobalConstrainedGlobal(kTRUE);
247  testCat1.SetStatus(AliVTrack::kITSrefit);
248  testCat2.SetStatus(AliVTrack::kITSrefit);
249  testCat1.SetFilterMap(BIT(8));
250  testCat2.SetFilterMap(BIT(9));
251 
252  int nfailure = 0;
253 
254  auto result_cat1 = fDef2011->IsSelected(&testCat1);
255  if(!result_cat1){
256  AliErrorStream() << "Track CAT1 not selected as hybrid track" << std::endl;
257  nfailure++; // track not selected - failure
258  } else {
259  auto tracktype = dynamic_cast<const AliEmcalTrackSelResultHybrid *>(result_cat1.GetUserInfo());
260  if(!tracktype){
261  AliErrorStream() << "Hybrid track information not found for track CAT1" << std::endl;
262  nfailure++;
263  } else {
264  if(tracktype->GetHybridTrackType() != AliEmcalTrackSelResultHybrid::kHybridGlobal){
265  AliErrorStream() << "Track not selected as hybrid track CAT1: " << int(tracktype->GetHybridTrackType()) << std::endl;
266  nfailure++;
267  }
268  }
269  }
270 
271  auto result_cat2 = fDef2011->IsSelected(&testCat2);
272  if(!result_cat2){
273  AliErrorStream() << "Track CAT2 not selected as hybrid track" << std::endl;
274  nfailure++; // track not selected - failure
275  } else {
276  auto tracktype = dynamic_cast<const AliEmcalTrackSelResultHybrid *>(result_cat2.GetUserInfo());
277  if(!tracktype){
278  AliErrorStream() << "Hybrid track information not found for track CAT2" << std::endl;
279  nfailure++;
280  } else {
281  if(tracktype->GetHybridTrackType() != AliEmcalTrackSelResultHybrid::kHybridConstrained){
282  AliErrorStream() << "Track not selected as hybrid track CAT2: " << int(tracktype->GetHybridTrackType()) << std::endl;
283  nfailure++;
284  }
285  }
286  }
287 
288  auto result_nohybrid = fDef2011->IsSelected(&testNoHybrid);
289  if(result_nohybrid || result_nohybrid.GetUserInfo()){
290  AliErrorStream() << "Non-hybrid track selected or user object attached " << std::endl;
291  nfailure++;
292  }
293 
294  return nfailure == 0;
295 }
AliEmcalAODHybridTrackCuts * fDef2010woRefit
Hybrid track definition from 2010 excluding non-refit tracks.
AliEmcalAODHybridTrackCuts * fDef2011
Hybrid track definition from 2011 e.
bool TestDef2010wRefit() const
Test for hybrid tracks according to the 2010 definition including non-refit tracks.
void Init()
Initializing track selection objects.
Structure containing the result of a given track selection step.
AliEmcalAODHybridTrackCuts * fDef2010wRefit
Hybrid track definition from 2010 including non-refit tracks.
void SetSelectNonITSrefitTracks(bool doReject)
Switch on/off selection of hybrid tracks without ITSrefit.
bool TestDef2011() const
Test for hybrid tracks according to the 2011 definition.
void SetHybridFilterBits(Int_t globalfilterbit, Int_t constrainedfilterbit)
Set the filterbits used to distinguish the different hybrid track types.
bool TestDef2010woRefit() const
Test for hybrid tracks according to the 2010 definition excluding non-refit tracks.
Cut class selecting hybrid tracks using the IsHybrid function.
Bool_t fSelectNonITSrefitTracks
Select non-refit tracks.
Int_t fHybridFilterBits[2]
Bit numbers for various hybrid filter bits.
bool RunAllTests() const
Run all unit tests for the class AliEmcalAODHybridTrackCuts.
Interface for a cut class returning selection status and user information.
virtual AliEmcalTrackSelResultPtr IsSelected(TObject *o)
Run track selection of hybrid tracks.