AliPhysics  64f4410 (64f4410)
AliEmcalAnalysisFactory.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 <cstring>
28 #include <cfloat>
29 #include <functional>
30 #include <iostream>
31 #include <memory>
32 #include <vector>
33 
34 #include <TObjArray.h>
35 #include <TObjString.h>
36 #include <TString.h>
37 
38 #include "AliAODTrack.h"
39 #include "AliESDtrackCuts.h"
42 #include "AliEmcalTrackSelection.h"
47 #include "AliTrackContainer.h"
48 
50 
51 namespace EMCalTriggerPtAnalysis {
52 
54  AliEmcalTrackSelection *result = NULL;
55  std::unique_ptr<TObjArray> cuts(cutstring.Tokenize(","));
56  std::cout << "Creating track cuts for " << (aod ? "AODs" : "ESDs") << std::endl;
57  TObjArray trackcuts;
58  if(!aod){
59  for(auto c : *cuts){
60  TString &cut = static_cast<TObjString *>(c)->String();
61  if(cut == "standard"){
62  auto esdcuts = GenerateDefaultCutsESD();
63  esdcuts->SetName("standardRAA");
64  esdcuts->SetTitle("Standard Track cuts");
65  trackcuts.Add(esdcuts);
66  }
67  if(cut == "standardcrossedrows"){
68  auto esdcuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(true, 1);
69  esdcuts->DefineHistograms(kRed);
70  esdcuts->SetName("standardRAA");
71  esdcuts->SetTitle("Standard Track cuts");
72  esdcuts->SetMinNCrossedRowsTPC(120);
73  esdcuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01");
74  trackcuts.Add(esdcuts);
75  }
76  if(cut == "hybrid"){
77  std::cout << "Configuring standard hybrid track cuts" << std::endl;
78  auto esdcuts = GenerateLooseDCACutsESD();
79  esdcuts->SetTitle("hybridglobal");
80  esdcuts->SetTitle("Global Hybrid tracks, loose DCA");
81  trackcuts.Add(esdcuts);
82  }
83  if(cut == "hybrid2010_wNoRefit"){
84  std::cout << "Configuring hybrid track cuts 2010, including non-ITSrefit tracks" << std::endl;
85  auto hybridcuts = new PWG::EMCAL::AliEmcalESDHybridTrackCuts("2010_wNoRefit", PWG::EMCAL::AliEmcalESDHybridTrackCuts::kDef2010);
86  hybridcuts->SetUseNoITSrefitTracks(kTRUE);
87  trackcuts.Add(hybridcuts);
88  }
89  if(cut == "hybrid2010_woNoRefit"){
90  std::cout << "Configuring hybrid track cuts 2010, excluding non-ITSrefit tracks" << std::endl;
91  auto hybridcuts = new PWG::EMCAL::AliEmcalESDHybridTrackCuts("2010_woNoRefit", PWG::EMCAL::AliEmcalESDHybridTrackCuts::kDef2010);
92  hybridcuts->SetUseNoITSrefitTracks(kFALSE);
93  trackcuts.Add(hybridcuts);
94  }
95  if(cut == "hybrid2011_wNoRefit"){
96  std::cout << "Configuring hybrid track cuts 2011, including non-ITSrefit tracks" << std::endl;
97  auto hybridcuts = new PWG::EMCAL::AliEmcalESDHybridTrackCuts("2011_wNoRefit", PWG::EMCAL::AliEmcalESDHybridTrackCuts::kDef2011);
98  hybridcuts->SetUseNoITSrefitTracks(kTRUE);
99  trackcuts.Add(hybridcuts);
100  }
101  if(cut == "hybrid2011_woNoRefit"){
102  std::cout << "Configuring hybrid track cuts 2011, excluding non-ITSrefit tracks" << std::endl;
103  auto hybridcuts = new PWG::EMCAL::AliEmcalESDHybridTrackCuts("2011_woNoRefit", PWG::EMCAL::AliEmcalESDHybridTrackCuts::kDef2011);
104  hybridcuts->SetUseNoITSrefitTracks(kFALSE);
105  trackcuts.Add(hybridcuts);
106  }
107 
113  if(cut.Contains("VarITSchi2")){
114  double cutvalue = ValueDecoder(cut, "VarITSchi2");
115  auto esdcuts = GenerateDefaultCutsESD();
116  esdcuts->SetName(TString::Format("VarITSchi2Cut%04d", static_cast<int>(cutvalue * 10.)));
117  esdcuts->SetTitle(TString::Format("Default cuts - variation ITS chi2 cut at %f", cutvalue));
118  esdcuts->SetMaxChi2PerClusterITS(cutvalue);
119  trackcuts.Add(esdcuts);
120  }
121  if(cut.Contains("VarTPCchi2") && !cut.Contains("Constrained")){
122  double cutvalue = ValueDecoder(cut, "VarTPCchi2");
123  auto esdcuts = GenerateDefaultCutsESD();
124  esdcuts->SetName(TString::Format("VarTPCchi2Cut%04d", static_cast<int>(cutvalue * 10.)));
125  esdcuts->SetTitle(TString::Format("Default cuts - variation TPC chi2 cut at %f", cutvalue));
126  esdcuts->SetMaxChi2PerClusterTPC(cutvalue);
127  trackcuts.Add(esdcuts);
128  }
129  if(cut.Contains("VarTPCchi2Constrained")){
130  double cutvalue = ValueDecoder(cut, "VarTPCchi2Constrained"); // in number of sigmas
131  auto esdcuts = GenerateDefaultCutsESD();
132  esdcuts->SetName(TString::Format("VarTPCchi2ConstrainedCut%04d", static_cast<int>(cutvalue * 10.)));
133  esdcuts->SetTitle(TString::Format("Default cuts - variation TPC chi2 constrained cut at %f", cutvalue));
134  esdcuts->SetMaxChi2TPCConstrainedGlobal(cutvalue);
135  trackcuts.Add(esdcuts);
136  }
137  if(cut.Contains("VarDCAz")){
138  double cutvalue = ValueDecoder(cut, "VarDCAz");
139  auto esdcuts = GenerateDefaultCutsESD();
140  esdcuts->SetName(TString::Format("VarDCAzCut%04d", static_cast<int>(cutvalue * 10.)));
141  esdcuts->SetTitle(TString::Format("Default cuts - variation DCAz cut at %f", cutvalue));
142  esdcuts->SetMaxDCAToVertexZ(cutvalue);
143  trackcuts.Add(esdcuts);
144  }
145  if(cut.Contains("VarDCAr")){
146  double cutvalue = ValueDecoder(cut, "VarDCAr");
147  double p1 = cutvalue * 0.0026, p2 = cutvalue * 0.005;
148  auto esdcuts = GenerateDefaultCutsESD();
149  esdcuts->SetName(TString::Format("VarDCArCut%04d", static_cast<int>(cutvalue * 10.)));
150  esdcuts->SetTitle(TString::Format("Default cuts - variation DCAr cut at %f sigma", cutvalue));
151  esdcuts->SetMaxDCAToVertexXYPtDep(TString::Format("%f + %f/pt^1.01", p1, p2));
152  trackcuts.Add(esdcuts);
153  }
154  if(cut.Contains("VarRatioCrossedRowsFindable")){
155  double cutvalue = ValueDecoder(cut, "VarRatioCrossedRowsFindable");
156  auto esdcuts = GenerateDefaultCutsESD();
157  esdcuts->SetName(TString::Format("VarRatioCRFindableCut%04d", static_cast<int>(cutvalue * 10.)));
158  esdcuts->SetTitle(TString::Format("Default cuts - variation ratio crossed rows over findable cut at %f", cutvalue));
159  esdcuts->SetMinRatioCrossedRowsOverFindableClustersTPC(cutvalue);
160  trackcuts.Add(esdcuts);
161  }
162  if(cut.Contains("VarFractionTPCshared")){
163  double cutvalue = ValueDecoder(cut, "VarFractionTPCshared");
164  auto esdcuts = GenerateDefaultCutsESD();
165  esdcuts->SetName(TString::Format("VarFractionTPCShared%04d", static_cast<int>(cutvalue * 10.)));
166  esdcuts->SetTitle(TString::Format("Default cuts - variation fraction TPC shared clusters %f", cutvalue));
167  esdcuts->SetMaxFractionSharedTPCClusters(cutvalue);
168  trackcuts.Add(esdcuts);
169  }
170  if(cut.Contains("VarTrackLengthDeadArea")){
171  double cutvalue = ValueDecoder(cut, "VarTrackLengthDeadArea");
172  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
173  esdcuts->SetName(TString::Format("VarTLDeadAreaCut%04d", static_cast<int>(cutvalue * 10.)));
174  esdcuts->SetTitle(TString::Format("Default cuts - variation track length dead area cut at %f", cutvalue));
175  esdcuts->SetCutGeoNcrNcl(cutvalue, 130., 1.5, 0.0, 0.0);
176  trackcuts.Add(esdcuts);
177  }
178  if(cut.Contains("VarTrackLengthTPCLength")){
179  double cutvalue = ValueDecoder(cut, "VarTrackLengthTPCLength");
180  auto esdcuts = GenerateDefaultCutsESD();
181  esdcuts->SetName(TString::Format("VarTLTPCLengthCut%04d", static_cast<int>(cutvalue * 10.)));
182  esdcuts->SetTitle(TString::Format("Default cuts - variation track length TPC length cut at %f", cutvalue));
183  esdcuts->SetCutGeoNcrNcl(3., cutvalue, 1.5, 0.0, 0.0);
184  trackcuts.Add(esdcuts);
185  }
186  if(cut.Contains("VarSPDhit")){
187  double cutvalue = ValueDecoder(cut, "VarSPDhit");
188  auto esdcuts = GenerateDefaultCutsESD();
189  if(TMath::Abs(cutvalue) > DBL_EPSILON){
190  esdcuts->SetName("VarSPDhitOn");
191  esdcuts->SetTitle("Default cuts - variation SPD hit requirement on");
192  } else {
193  esdcuts->SetName("VarSPDhitOff");
194  esdcuts->SetTitle("Default cuts - variation SPD hit requirement off");
195  esdcuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kOff);
196  }
197  trackcuts.Add(esdcuts);
198  }
204  if(cut.Contains("TestITSchi2")){
205  double itscut = ValueDecoder(cut, "TestITSchi2");
206  std::cout << "Using ITS chi2 cut variation: " << itscut << std::endl;
207 
208  auto esdcuts = GenerateLooseDCACutsESD();
209  esdcuts->SetName(Form("TestITSchi2%d", int(itscut*10.)));
210  esdcuts->SetTitle(Form("Loose track cuts, ITS chi2 var %.1f", itscut));
211 
212  // Do the variation
213  esdcuts->SetMaxChi2PerClusterITS(itscut);
214  // Set cut on the TPC global constrained chi2 to very loose
215  esdcuts->SetMaxChi2TPCConstrainedGlobal(100);
216  trackcuts.Add(esdcuts);
217  }
218  if(cut.Contains("TestTPCchi2")){
219  double tpccut = ValueDecoder(cut,"TestTPCchi2");
220  std::cout << "Using TPC chi2 cut variation: " << tpccut << std::endl;
221 
222  auto esdcuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(false, 1);
223  esdcuts->SetName(Form("VarTPCchi2%d", int(tpccut * 10.)));
224  esdcuts->SetTitle(Form("Loose track cuts, TPC chi2 var %.1f", tpccut));
225 
226  // Do the variation
227  esdcuts->SetMaxChi2PerClusterTPC(tpccut);
228  trackcuts.Add(esdcuts);
229  }
230  if(cut.Contains("TestTPCchi2Constrained")){
231  double tpcconstrainedcut = ValueDecoder(cut, "TestTPCchi2Constrained");
232  std::cout << "Using TPC chi2 constrained cut variation: " << tpcconstrainedcut << std::endl;
233 
234  auto esdcuts = GenerateLooseDCACutsESD();
235  esdcuts->SetName(Form("VarTPCchi2constrained%d", int(tpcconstrainedcut * 10.)));
236  esdcuts->SetTitle(Form("Loose track cuts, TPC constrained chi2 variation %f", tpcconstrainedcut));
237 
238  // Do the variation
239  esdcuts->SetMaxChi2TPCConstrainedGlobal(tpcconstrainedcut);
240  // Set ITS chi2 cut to very loose
241  esdcuts->SetMaxChi2PerClusterITS(100);
242  trackcuts.Add(esdcuts);
243  }
244  if(cut.Contains("geo")){
245  auto geocuts = new AliEMCalTriggerExtraCuts();
246  geocuts->SetName("geocuts");
247  geocuts->SetTitle("TPC track length cut");
248  geocuts->SetMinTPCTrackLengthCut();
249  trackcuts.Add(geocuts);
250  }
251  }
252  result = new AliEmcalTrackSelectionESD;
253  result->AddTrackCuts(&trackcuts);
254  } else {
256  result = aodsel;
257  // C++11 Lambda: Do not create multiple extra cut objects in case of AODs. If extra cut object does already exist -
258  // specify new cut in the same object.
259  auto FindTrackCuts = [] (const TObjArray &cuts) -> AliEMCalTriggerExtraCuts * {
260  AliEMCalTriggerExtraCuts *found = nullptr;
261  for(auto cutiter : cuts){
262  if(cutiter->IsA() == AliEMCalTriggerExtraCuts::Class()){
263  found = static_cast<AliEMCalTriggerExtraCuts *>(cutiter);
264  break;
265  }
266  }
267  return found;
268  };
269  for(auto c : *cuts){
270  TString &cut = static_cast<TObjString *>(c)->String();
271  if(cut == "standard"){
272  auto filterbitcuts = new PWG::EMCAL::AliEmcalAODFilterBitCuts("globalcuts", "Global track cuts");
273  filterbitcuts->SetFilterBits(AliAODTrack::kTrkGlobal);
274  std::cout << "Adding standard global track cuts" << std::endl;
275  trackcuts.Add(filterbitcuts);
276 
277  AliEMCalTriggerExtraCuts *crossedrowcut = FindTrackCuts(trackcuts);
278  if(!crossedrowcut){
279  crossedrowcut = new AliEMCalTriggerExtraCuts;
280  trackcuts.Add(crossedrowcut);
281  }
282  crossedrowcut->SetMinTPCCrossedRows(120);
283  }
284  if(cut == "hybrid"){
286  }
287  if(cut == "hybrid2010_wNoRefit"){
289  }
290  if(cut == "hybrid2010_woNoRefit"){
292  }
293  if(cut == "hybrid2011_wNoRefit"){
295  }
296  if(cut == "hybrid2011_woNoRefit"){
298  }
299  if(cut == "geo"){
300  AliEMCalTriggerExtraCuts *geocuts = FindTrackCuts(trackcuts);
301  if(!geocuts){
302  geocuts = new AliEMCalTriggerExtraCuts;
303  trackcuts.Add(geocuts);
304  }
305  geocuts->SetMinTPCTrackLengthCut();
306  }
307  }
308  result->AddTrackCuts(&trackcuts);
309  }
310 
311  return result;
312 }
313 
321  result->SetEnergyDefinition(endef);
322  return result;
323 }
324 
326  return isAOD ? "caloClusters" : "CaloClusters";
327 }
328 
330  return isAOD ? "tracks" : "Tracks";
331 }
332 
334  AliESDtrackCuts *esdcuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(true, 1);
335  esdcuts->DefineHistograms(kRed);
336  esdcuts->SetCutGeoNcrNcl(3., 130., 1.5, 0.0, 0.0);
337  esdcuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01");
338  esdcuts->SetMaxFractionSharedTPCClusters(0.4);
339  // esdcuts->SetMinNCrossedRowsTPC(0.); // Replaced by geometrical cut
340  return esdcuts;
341 
342 }
343 
345  AliESDtrackCuts *esdcuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE);
346  esdcuts->SetMaxDCAToVertexXY(2.4);
347  esdcuts->SetMaxDCAToVertexZ(3.2);
348  esdcuts->SetDCAToVertex2D(kTRUE);
349  esdcuts->SetMaxChi2TPCConstrainedGlobal(36);
350  esdcuts->SetMaxFractionSharedTPCClusters(0.4);
351  return esdcuts;
352 }
353 
354 double AliEmcalAnalysisFactory::ValueDecoder(const char *cutstring, const char *tag) {
355  TString cuttstring(cutstring);
356  Int_t position(cuttstring.Index(tag) + strlen(tag));
357  TString valuestring = cuttstring(position, 4);
358  Int_t value = valuestring.Atoi();
359  return static_cast<double>(value) / 10.;
360 }
361 
362 } /* namespace EMCalTriggerPtAnalysis */
Interface for virtual track selection.
double Double_t
Definition: External.C:58
static double ValueDecoder(const char *string, const char *tag)
TCanvas * c
Definition: TestFitELoss.C:172
Helper class selecting events on the presence of a trigger patch for the given type above threshold...
Extra track selection cuts for the high- track analysis.
static AliEmcalTrackSelection * TrackCutsFactory(TString name, Bool_t isAOD)
Fully-configure EMCAL track selection independent of the data type.
Hybrid tracks using the 2011 definition including NoITSrefit tracks (ESD-only)
Hybrid tracks using the 2010 definition including NoITSrefit tracks (ESD-only)
int Int_t
Definition: External.C:63
Hybrid tracks using the 2010 definition excluding NoITSrefit tracks (ESD-only)
static TString GetDefTrackCutsPeriod()
void SetOfflineEnergyThreshold(EmcalTriggerClass trgcls, double threshold)
Specify threshold for a given offline trigger class.
Hybrid tracks using the 2011 definition excluding NoITSrefit tracks (ESD-only)
void AddTrackCuts(AliVCuts *cuts)
Add new track cuts to the list of cuts.
Implement virtual track selection for AOD analysis.
Declaration of class AliEMCalTriggerExtraCuts.
Implementation of the AOD filter bit selection as virtual cut class.
Analysis of high- tracks in triggered events.
virtual void GenerateTrackCuts(ETrackFilterType_t type, const char *="")
Automatically generates track cuts depending on the requested type of filtering.
EmcalEnergyDefinition_t
Definition of EMCAL patch energy measurements.
void SetEnergyDefinition(EmcalEnergyDefinition_t endef)
Define according to which energy measurement a patch is selected as trigger patch.
bool Bool_t
Definition: External.C:53
Implementation of virtual track selection for ESDs.
static AliEmcalTriggerOfflineSelection * TriggerSelectionFactory(Double_t el0, Double_t eg1, Double_t eg2, Double_t ej1, Double_t ej2, AliEmcalTriggerOfflineSelection::EmcalEnergyDefinition_t endef=AliEmcalTriggerOfflineSelection::kFEEEnergy)
Configures EMCAL trigger offline selection used to restrict EMCAL triggered sample.
static TString TrackContainerNameFactory(Bool_t isAOD)
Get name of the default track container.
static TString ClusterContainerNameFactory(Bool_t isAOD)
Get name of the default cluster container.