AliPhysics  41af4b0 (41af4b0)
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::kHybridConstrainedTrue; // no module map -> set all complementary hybrid tracks to true complementary hybrid tracks
69  }
70  }
71  result.SetUserInfo(new AliEmcalTrackSelResultHybrid(tracktype));
72  }
73  return result;
74 }
75 
77  TObject(),
78  fDef2010wRefit(nullptr),
79  fDef2010woRefit(nullptr),
80  fDef2011(nullptr)
81 {
82 
83 }
84 
86  if(fDef2010wRefit) delete fDef2010wRefit;
88  if(fDef2011) delete fDef2011;
89 }
90 
92  fDef2010wRefit = new AliEmcalAODHybridTrackCuts("def2010wNoRefit");
95  fDef2010woRefit = new AliEmcalAODHybridTrackCuts("def2010woNoRefit");
98  fDef2011 = new AliEmcalAODHybridTrackCuts("def2011");
100 }
101 
104 }
105 
107  AliInfoStream() << "Running test for 2010 Definition with non-refit tracks" << std::endl;
108  AliAODTrack testCat1WithRefit, testCat2WithRefit, testCat2WithoutRefit, testNoHybrid;
109  testCat1WithRefit.SetIsHybridGlobalConstrainedGlobal();
110  testCat2WithRefit.SetIsHybridGlobalConstrainedGlobal();
111  testCat2WithoutRefit.SetIsHybridGlobalConstrainedGlobal();
112  testCat1WithRefit.SetStatus(AliVTrack::kITSrefit);
113  testCat2WithRefit.SetStatus(AliVTrack::kITSrefit);
114  testCat1WithRefit.SetFilterMap(BIT(8));
115  testCat2WithRefit.SetFilterMap(BIT(4));
116  testCat2WithoutRefit.SetFilterMap(BIT(4));
117 
118  int nfailure = 0;
119  auto result_cat1_wrefit = fDef2010wRefit->IsSelected(&testCat1WithRefit);
120  if(!result_cat1_wrefit){
121  AliErrorStream() << "Track CAT1 not selected as hybrid track" << std::endl;
122  nfailure++; // track not selected - failure
123  } else {
124  auto tracktype = dynamic_cast<const AliEmcalTrackSelResultHybrid *>(result_cat1_wrefit.GetUserInfo());
125  if(!tracktype){
126  AliErrorStream() << "Hybrid track information not found for track CAT1" << std::endl;
127  nfailure++; // no hybrid track type found - failure
128  } else {
129  if(tracktype->GetHybridTrackType() != AliEmcalTrackSelResultHybrid::kHybridGlobal){
130  AliErrorStream() << "Track not selected as hybrid track CAT1: " << int(tracktype->GetHybridTrackType()) << std::endl;
131  nfailure++; // wrong hybrid track type
132  }
133  }
134  }
135 
136  auto result_cat2_wrefit = fDef2010wRefit->IsSelected(&testCat2WithRefit);
137  if(!result_cat2_wrefit){
138  AliErrorStream() << "Track CAT2 not selected as hybrid track" << std::endl;
139  nfailure++; // track not selected - failure
140  } else {
141  auto tracktype = dynamic_cast<const AliEmcalTrackSelResultHybrid *>(result_cat2_wrefit.GetUserInfo());
142  if(!tracktype){
143  AliErrorStream() << "Hybrid track information not found for track CAT2" << std::endl;
144  nfailure++; // no hybrid track type found - failure
145  } else {
146  if(tracktype->IsHybridTrackConstrained()){
147  AliErrorStream() << "Track not selected as hybrid track CAT2: " << int(tracktype->GetHybridTrackType()) << std::endl;
148  nfailure++; // wrong hybrid track type
149  }
150  }
151  }
152 
153  auto result_cat2_worefit = fDef2010wRefit->IsSelected(&testCat2WithoutRefit);
154  if(!result_cat2_worefit){
155  AliErrorStream() << "Track CAT3 not selected as hybrid track" << std::endl;
156  nfailure++; // track not selected - failure
157  } else {
158  auto tracktype = dynamic_cast<const AliEmcalTrackSelResultHybrid *>(result_cat2_worefit.GetUserInfo());
159  if(!tracktype){
160  AliErrorStream() << "Hybrid track information not found for track CAT3" << std::endl;
161  nfailure++; // no hybrid track type found - failure
162  } else {
163  if(tracktype->GetHybridTrackType() != AliEmcalTrackSelResultHybrid::kHybridConstrainedNoITSrefit){
164  AliErrorStream() << "Track not selected as hybrid track CAT3: " << int(tracktype->GetHybridTrackType()) << std::endl;
165  nfailure++; // wrong hybrid track type
166  }
167  }
168  }
169 
170  auto result_nohybrid = fDef2010wRefit->IsSelected(&testNoHybrid);
171  if(result_nohybrid || result_nohybrid.GetUserInfo()){
172  AliErrorStream() << "Non-hybrid track selected or user object attached " << std::endl;
173  nfailure++; // Non-hybrid track selected as hybrid track
174  }
175 
176  return nfailure == 0;
177 }
178 
180  AliInfoStream() << "Running test for 2010 Definition without non-refit tracks" << std::endl;
181  AliAODTrack testCat1WithRefit, testCat2WithRefit, testCat2WithoutRefit, testNoHybrid;
182  testCat1WithRefit.SetIsHybridGlobalConstrainedGlobal();
183  testCat2WithRefit.SetIsHybridGlobalConstrainedGlobal();
184  testCat2WithoutRefit.SetIsHybridGlobalConstrainedGlobal();
185  testCat1WithRefit.SetStatus(AliVTrack::kITSrefit);
186  testCat2WithRefit.SetStatus(AliVTrack::kITSrefit);
187  testCat1WithRefit.SetFilterMap(BIT(8));
188  testCat2WithRefit.SetFilterMap(BIT(4));
189  testCat2WithoutRefit.SetFilterMap(BIT(4));
190 
191  int nfailure = 0;
192  auto result_cat1_wrefit = fDef2010woRefit->IsSelected(&testCat1WithRefit);
193  if(!result_cat1_wrefit) {
194  AliErrorStream() << "Track CAT1 not selected as hybrid track" << std::endl;
195  nfailure++; // track not selected - failure
196  } else {
197  auto tracktype = dynamic_cast<const AliEmcalTrackSelResultHybrid *>(result_cat1_wrefit.GetUserInfo());
198  if(!tracktype) {
199  AliErrorStream() << "Hybrid track information not found for track CAT1" << std::endl;
200  nfailure++; // no hybrid track type found - failure
201  } else {
202  if(tracktype->GetHybridTrackType() != AliEmcalTrackSelResultHybrid::kHybridGlobal){
203  AliErrorStream() << "Track not selected as hybrid track CAT1: " << int(tracktype->GetHybridTrackType()) << std::endl;
204  nfailure++; // wrong hybrid track type
205  }
206  }
207  }
208 
209  auto result_cat2_wrefit = fDef2010woRefit->IsSelected(&testCat2WithRefit);
210  if(!result_cat2_wrefit){
211  AliErrorStream() << "Track CAT2 not selected as hybrid track" << std::endl;
212  nfailure++; // track not selected - failure
213  } else {
214  auto tracktype = dynamic_cast<const AliEmcalTrackSelResultHybrid *>(result_cat2_wrefit.GetUserInfo());
215  if(!tracktype){
216  AliErrorStream() << "Hybrid track information not found for track CAT2" << std::endl;
217  nfailure++; // no hybrid track type found - failure
218  } else {
219  if(tracktype->IsHybridTrackConstrained()){
220  AliErrorStream() << "Track not selected as hybrid track CAT2: " << int(tracktype->GetHybridTrackType()) << std::endl;
221  nfailure++; // wrong hybrid track type
222  }
223  }
224  }
225 
226  auto result_cat2_worefit = fDef2010woRefit->IsSelected(&testCat2WithoutRefit);
227  if(result_cat2_worefit || result_cat2_worefit.GetUserInfo()) {
228  AliErrorStream() << "Non-refit track selected or user object attached " << std::endl;
229  nfailure++; // hybrid tracks without refit rejected in this test
230  }
231 
232  auto result_nohybrid = fDef2010woRefit->IsSelected(&testNoHybrid);
233  if(result_nohybrid || result_nohybrid.GetUserInfo()){
234  AliErrorStream() << "Non-hybrid track selected or user object attached " << std::endl;
235  nfailure++; // Non-hybrid track selected as hybrid track
236  }
237 
238  return nfailure == 0;
239 }
240 
242  AliInfoStream() << "Running test for 2011 Definition" << std::endl;
243  AliAODTrack testCat1, testCat2, testNoHybrid;
244  testCat1.SetIsHybridGlobalConstrainedGlobal(kTRUE);
245  testCat2.SetIsHybridGlobalConstrainedGlobal(kTRUE);
246  testCat1.SetStatus(AliVTrack::kITSrefit);
247  testCat2.SetStatus(AliVTrack::kITSrefit);
248  testCat1.SetFilterMap(BIT(8));
249  testCat2.SetFilterMap(BIT(9));
250 
251  int nfailure = 0;
252 
253  auto result_cat1 = fDef2011->IsSelected(&testCat1);
254  if(!result_cat1){
255  AliErrorStream() << "Track CAT1 not selected as hybrid track" << std::endl;
256  nfailure++; // track not selected - failure
257  } else {
258  auto tracktype = dynamic_cast<const AliEmcalTrackSelResultHybrid *>(result_cat1.GetUserInfo());
259  if(!tracktype){
260  AliErrorStream() << "Hybrid track information not found for track CAT1" << std::endl;
261  nfailure++;
262  } else {
263  if(tracktype->GetHybridTrackType() != AliEmcalTrackSelResultHybrid::kHybridGlobal){
264  AliErrorStream() << "Track not selected as hybrid track CAT1: " << int(tracktype->GetHybridTrackType()) << std::endl;
265  nfailure++;
266  }
267  }
268  }
269 
270  auto result_cat2 = fDef2011->IsSelected(&testCat2);
271  if(!result_cat2){
272  AliErrorStream() << "Track CAT2 not selected as hybrid track" << std::endl;
273  nfailure++; // track not selected - failure
274  } else {
275  auto tracktype = dynamic_cast<const AliEmcalTrackSelResultHybrid *>(result_cat2.GetUserInfo());
276  if(!tracktype){
277  AliErrorStream() << "Hybrid track information not found for track CAT2" << std::endl;
278  nfailure++;
279  } else {
280  if(tracktype->IsHybridTrackConstrained()){
281  AliErrorStream() << "Track not selected as hybrid track CAT2: " << int(tracktype->GetHybridTrackType()) << std::endl;
282  nfailure++;
283  }
284  }
285  }
286 
287  auto result_nohybrid = fDef2011->IsSelected(&testNoHybrid);
288  if(result_nohybrid || result_nohybrid.GetUserInfo()){
289  AliErrorStream() << "Non-hybrid track selected or user object attached " << std::endl;
290  nfailure++;
291  }
292 
293  return nfailure == 0;
294 }
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.
Namespace for EMCAL framework classes and task.
void SetSelectNonITSrefitTracks(bool doReject)
Switch on/off selection of hybrid tracks without ITSrefit.
Complementary hybrid track without alive SPD module (type IIa)
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.
Namespace for PWG framework classes.
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.
Selection result of the hybrid track selection.
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.