AliPhysics  7f1bdba (7f1bdba)
AliEmcalTrackSelectionESD.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 <TBits.h>
28 #include <TClonesArray.h>
29 #include <TList.h>
30 #include <TObjArray.h>
31 #include <memory>
32 #include <iostream>
33 
38 #include "AliEmcalCutBase.h"
39 #include "AliESDEvent.h"
40 #include "AliESDtrack.h"
41 #include "AliESDtrackCuts.h"
42 #include "AliLog.h"
43 #include "AliPicoTrack.h"
44 #include "AliVCuts.h"
45 
49 
50 using namespace PWG::EMCAL;
51 
54 {
55 }
56 
59 {
60  if(cuts) this->AddTrackCuts(cuts);
61 }
62 
65 {
66  GenerateTrackCuts(type, period);
67 }
68 
70 {
71  using PWG::EMCAL::AliEmcalESDHybridTrackCuts;
72  if (fListOfCuts) fListOfCuts->Clear();
73  fSelectionModeAny = kTRUE;
74 
75  switch (type) {
76  case kHybridTracks:
77  AliDebugStream(1) << "Generate std hybrid track cuts" << std::endl;
78  AliEmcalESDTrackCutsGenerator::AddHybridTrackCuts(this, period);
79  break;
80 
81  case kTPCOnlyTracks:
82  AliEmcalESDTrackCutsGenerator::AddTPCOnlyTrackCuts(this, period);
83  break;
84 
85  case kITSPureTracks:
86  AddTrackCuts(AliESDtrackCuts::GetStandardITSPureSATrackCuts2010(kTRUE, kFALSE));
87  break;
88 
90  {
91  AliDebugStream(1) << "Generate 2010 hybrid track cuts wNoRefit" << std::endl;
92  auto hybridcuts = new AliEmcalESDHybridTrackCuts("hybrid_2010_wNoRefit", AliEmcalESDHybridTrackCuts::kDef2010);
93  hybridcuts->SetUseNoITSrefitTracks(kTRUE);
94  AddTrackCuts(hybridcuts);
95  break;
96  }
97 
99  {
100  AliDebugStream(1) << "Generate 2010 hybrid track cuts woNoRefit" << std::endl;
101  auto hybridcuts = new AliEmcalESDHybridTrackCuts("hybrid_2010_woNoRefit", AliEmcalESDHybridTrackCuts::kDef2010);
102  hybridcuts->SetUseNoITSrefitTracks(kFALSE);
103  AddTrackCuts(hybridcuts);
104  break;
105  }
106 
108  {
109  AliDebugStream(1) << "Generate 2011 hybrid track cuts wNoRefit" << std::endl;
110  auto hybridcuts = new AliEmcalESDHybridTrackCuts("hybrid_2011_wNoRefit", AliEmcalESDHybridTrackCuts::kDef2011);
111  hybridcuts->SetUseNoITSrefitTracks(kTRUE);
112  AddTrackCuts(hybridcuts);
113  break;
114  }
115 
117  {
118  AliDebugStream(1) << "Generate 2011 hybrid track cuts woNoRefit" << std::endl;
119  auto hybridcuts = new AliEmcalESDHybridTrackCuts("hybrid_2011_woNoRefit", AliEmcalESDHybridTrackCuts::kDef2011);
120  hybridcuts->SetUseNoITSrefitTracks(kFALSE);
121  AddTrackCuts(hybridcuts);
122  break;
123  }
124 
125  default:
126  break;
127  }
128 }
129 
131  if (!fListOfCuts){
132  AliDebugStream(2) << "No cut array " << std::endl;
133  return PWG::EMCAL::AliEmcalTrackSelResultPtr(nullptr, kFALSE);
134  }
135  AliESDtrack *esdt = dynamic_cast<AliESDtrack *>(trk);
136  if (!esdt) {
137  AliPicoTrack *picoTrack = dynamic_cast<AliPicoTrack *>(trk);
138  if (picoTrack) {
139  esdt = dynamic_cast<AliESDtrack*>(picoTrack->GetTrack());
140  }
141  else {
142  AliError("Neither Pico nor ESD track");
143  return PWG::EMCAL::AliEmcalTrackSelResultPtr(nullptr, kFALSE);
144  }
145  }
146 
147  TBits trackbitmap(64);
148  trackbitmap.ResetAllBits();
149  UInt_t cutcounter = 0;
150  AliDebugStream(2) << "Found cut array with " << fListOfCuts->GetEntries() << " cuts\n" << std::endl;
151  TClonesArray selectionStatus("PWG::EMCAL::AliEmcalTrackSelResultPtr", fListOfCuts->GetEntries());
152  selectionStatus.SetOwner(kTRUE);
153  for(auto cutIter : *fListOfCuts){
154  AliDebugStream(3) << "executing nect cut: " << static_cast<AliVCuts *>(static_cast<AliEmcalManagedObject *>(cutIter)->GetObject())->GetName() << std::endl;
155  PWG::EMCAL::AliEmcalCutBase *mycuts = static_cast<PWG::EMCAL::AliEmcalCutBase *>(static_cast<AliEmcalManagedObject *>(cutIter)->GetObject());
156  PWG::EMCAL::AliEmcalTrackSelResultPtr selresult = mycuts->IsSelected(esdt);
157  if(selresult) trackbitmap.SetBitNumber(cutcounter);
158  new(selectionStatus[selectionStatus.GetEntries()]) PWG::EMCAL::AliEmcalTrackSelResultPtr(selresult);
159  cutcounter++;
160  }
161  // In case of ANY at least one bit has to be set, while in case of ALL all bits have to be set
162  PWG::EMCAL::AliEmcalTrackSelResultPtr result(esdt, kFALSE, new PWG::EMCAL::AliEmcalTrackSelResultCombined(&selectionStatus));
163  if (fSelectionModeAny){
164  result.SetSelectionResult(trackbitmap.CountBits() > 0 || cutcounter == 0);
165  } else {
166  result.SetSelectionResult(trackbitmap.CountBits() == cutcounter);
167  }
168  return result;
169 }
170 
172  for(auto cutIter : *fListOfCuts){
173  AliEmcalManagedObject *ptr = static_cast<AliEmcalManagedObject *>(cutIter);
174  if(ptr->GetObject()->IsA() == AliESDtrackCuts::Class()){
175  outputList->Add(ptr->GetObject());
176  // Remove ownership - taken over by output list
177  ptr->SetOwner(false);
178  }
179  }
180 }
Interface for virtual track selection.
TObject * GetObject(const TCollection *parent, const TString &name, const TClass *cls=0, Bool_t verbose=true)
TObject * GetObject()
Providing access to managed object.
TObjArray * fListOfCuts
List of track cut objects.
Structure containing the result of a given track selection step.
virtual AliEmcalTrackSelResultPtr IsSelected(TObject *o)=0
void SetOwner(bool owner=true)
Specifying ownership over object.
void SetSelectionResult(Bool_t selectionResult)
AliEmcalTrackSelectionESD()
Dummy constructor.
Namespace for EMCAL framework classes and task.
Hybrid tracks using the 2011 definition including NoITSrefit tracks (ESD-only)
Hybrid tracks using the 2010 definition including NoITSrefit tracks (ESD-only)
unsigned int UInt_t
Definition: External.C:33
Hybrid tracks using the 2010 definition excluding NoITSrefit tracks (ESD-only)
Hybrid tracks using the 2011 definition excluding NoITSrefit tracks (ESD-only)
Declaration of class AliEmcalESDTrackCutsGenerator.
Namespace for PWG framework classes.
void AddTrackCuts(AliVCuts *cuts)
Add new track cuts to the list of cuts.
AliVTrack * GetTrack() const
Definition: AliPicoTrack.h:60
virtual void SaveQAObjects(TList *outputList)
Bool_t fSelectionModeAny
Accept track if any of the cuts is fulfilled.
ETrackFilterType_t
Pre-defined track filters.
virtual void GenerateTrackCuts(ETrackFilterType_t type, const char *period="")
Automatically generates track cuts depending on the requested type of filtering.
Smart pointer implementation for objects inheriting from TObject.
Interface for a cut class returning selection status and user information.
virtual PWG::EMCAL::AliEmcalTrackSelResultPtr IsTrackAccepted(AliVTrack *const trk)
Check whether track is accepted.
Implementation of virtual track selection for ESDs.