AliPhysics  5a28df1 (5a28df1)
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"
41 #include "AliEmcalTrackSelection.h"
46 #include "AliTrackContainer.h"
47 
49 
50 namespace EMCalTriggerPtAnalysis {
51 
53  AliEmcalTrackSelection *result = NULL;
54  std::unique_ptr<TObjArray> cuts(cutstring.Tokenize(","));
55  std::cout << "Creating track cuts for " << (aod ? "AODs" : "ESDs") << std::endl;
56  TObjArray trackcuts;
57  if(!aod){
58  for(auto c : *cuts){
59  TString &cut = static_cast<TObjString *>(c)->String();
60  if(cut == "standard"){
61  auto esdcuts = GenerateDefaultCutsESD();
62  esdcuts->SetName("standardRAA");
63  esdcuts->SetTitle("Standard Track cuts");
64  trackcuts.Add(esdcuts);
65  }
66  if(cut == "standardcrossedrows"){
67  auto esdcuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(true, 1);
68  esdcuts->DefineHistograms(kRed);
69  esdcuts->SetName("standardRAA");
70  esdcuts->SetTitle("Standard Track cuts");
71  esdcuts->SetMinNCrossedRowsTPC(120);
72  esdcuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01");
73  trackcuts.Add(esdcuts);
74  }
75  if(cut == "hybrid"){
76  std::cout << "Configuring standard hybrid track cuts" << std::endl;
77  auto esdcuts = GenerateLooseDCACutsESD();
78  esdcuts->SetTitle("hybridglobal");
79  esdcuts->SetTitle("Global Hybrid tracks, loose DCA");
80  trackcuts.Add(esdcuts);
81  }
82  if(cut == "hybrid2010_wNoRefit"){
83  std::cout << "Configuring hybrid track cuts 2010, including non-ITSrefit tracks" << std::endl;
84  auto hybridcuts = new PWG::EMCAL::AliEmcalESDHybridTrackCuts("2010_wNoRefit", PWG::EMCAL::AliEmcalESDHybridTrackCuts::kDef2010);
85  hybridcuts->SetUseNoITSrefitTracks(kTRUE);
86  trackcuts.Add(hybridcuts);
87  }
88  if(cut == "hybrid2010_woNoRefit"){
89  std::cout << "Configuring hybrid track cuts 2010, excluding non-ITSrefit tracks" << std::endl;
90  auto hybridcuts = new PWG::EMCAL::AliEmcalESDHybridTrackCuts("2010_woNoRefit", PWG::EMCAL::AliEmcalESDHybridTrackCuts::kDef2010);
91  hybridcuts->SetUseNoITSrefitTracks(kFALSE);
92  trackcuts.Add(hybridcuts);
93  }
94  if(cut == "hybrid2011_wNoRefit"){
95  std::cout << "Configuring hybrid track cuts 2011, including non-ITSrefit tracks" << std::endl;
96  auto hybridcuts = new PWG::EMCAL::AliEmcalESDHybridTrackCuts("2011_wNoRefit", PWG::EMCAL::AliEmcalESDHybridTrackCuts::kDef2011);
97  hybridcuts->SetUseNoITSrefitTracks(kTRUE);
98  trackcuts.Add(hybridcuts);
99  }
100  if(cut == "hybrid2011_woNoRefit"){
101  std::cout << "Configuring hybrid track cuts 2011, excluding non-ITSrefit tracks" << std::endl;
102  auto hybridcuts = new PWG::EMCAL::AliEmcalESDHybridTrackCuts("2011_woNoRefit", PWG::EMCAL::AliEmcalESDHybridTrackCuts::kDef2011);
103  hybridcuts->SetUseNoITSrefitTracks(kFALSE);
104  trackcuts.Add(hybridcuts);
105  }
106 
112  if(cut.Contains("VarITSchi2")){
113  double cutvalue = ValueDecoder(cut, "VarITSchi2");
114  auto esdcuts = GenerateDefaultCutsESD();
115  esdcuts->SetName(TString::Format("VarITSchi2Cut%04d", static_cast<int>(cutvalue * 10.)));
116  esdcuts->SetTitle(TString::Format("Default cuts - variation ITS chi2 cut at %f", cutvalue));
117  esdcuts->SetMaxChi2PerClusterITS(cutvalue);
118  trackcuts.Add(esdcuts);
119  }
120  if(cut.Contains("VarTPCchi2") && !cut.Contains("Constrained")){
121  double cutvalue = ValueDecoder(cut, "VarTPCchi2");
122  auto esdcuts = GenerateDefaultCutsESD();
123  esdcuts->SetName(TString::Format("VarTPCchi2Cut%04d", static_cast<int>(cutvalue * 10.)));
124  esdcuts->SetTitle(TString::Format("Default cuts - variation TPC chi2 cut at %f", cutvalue));
125  esdcuts->SetMaxChi2PerClusterTPC(cutvalue);
126  trackcuts.Add(esdcuts);
127  }
128  if(cut.Contains("VarTPCchi2Constrained")){
129  double cutvalue = ValueDecoder(cut, "VarTPCchi2Constrained"); // in number of sigmas
130  auto esdcuts = GenerateDefaultCutsESD();
131  esdcuts->SetName(TString::Format("VarTPCchi2ConstrainedCut%04d", static_cast<int>(cutvalue * 10.)));
132  esdcuts->SetTitle(TString::Format("Default cuts - variation TPC chi2 constrained cut at %f", cutvalue));
133  esdcuts->SetMaxChi2TPCConstrainedGlobal(cutvalue);
134  trackcuts.Add(esdcuts);
135  }
136  if(cut.Contains("VarDCAz")){
137  double cutvalue = ValueDecoder(cut, "VarDCAz");
138  auto esdcuts = GenerateDefaultCutsESD();
139  esdcuts->SetName(TString::Format("VarDCAzCut%04d", static_cast<int>(cutvalue * 10.)));
140  esdcuts->SetTitle(TString::Format("Default cuts - variation DCAz cut at %f", cutvalue));
141  esdcuts->SetMaxDCAToVertexZ(cutvalue);
142  trackcuts.Add(esdcuts);
143  }
144  if(cut.Contains("VarDCAr")){
145  double cutvalue = ValueDecoder(cut, "VarDCAr");
146  double p1 = cutvalue * 0.0026, p2 = cutvalue * 0.005;
147  auto esdcuts = GenerateDefaultCutsESD();
148  esdcuts->SetName(TString::Format("VarDCArCut%04d", static_cast<int>(cutvalue * 10.)));
149  esdcuts->SetTitle(TString::Format("Default cuts - variation DCAr cut at %f sigma", cutvalue));
150  esdcuts->SetMaxDCAToVertexXYPtDep(TString::Format("%f + %f/pt^1.01", p1, p2));
151  trackcuts.Add(esdcuts);
152  }
153  if(cut.Contains("VarRatioCrossedRowsFindable")){
154  double cutvalue = ValueDecoder(cut, "VarRatioCrossedRowsFindable");
155  auto esdcuts = GenerateDefaultCutsESD();
156  esdcuts->SetName(TString::Format("VarRatioCRFindableCut%04d", static_cast<int>(cutvalue * 10.)));
157  esdcuts->SetTitle(TString::Format("Default cuts - variation ratio crossed rows over findable cut at %f", cutvalue));
158  esdcuts->SetMinRatioCrossedRowsOverFindableClustersTPC(cutvalue);
159  trackcuts.Add(esdcuts);
160  }
161  if(cut.Contains("VarFractionTPCshared")){
162  double cutvalue = ValueDecoder(cut, "VarFractionTPCshared");
163  auto esdcuts = GenerateDefaultCutsESD();
164  esdcuts->SetName(TString::Format("VarFractionTPCShared%04d", static_cast<int>(cutvalue * 10.)));
165  esdcuts->SetTitle(TString::Format("Default cuts - variation fraction TPC shared clusters %f", cutvalue));
166  esdcuts->SetMaxFractionSharedTPCClusters(cutvalue);
167  trackcuts.Add(esdcuts);
168  }
169  if(cut.Contains("VarTrackLengthDeadArea")){
170  double cutvalue = ValueDecoder(cut, "VarTrackLengthDeadArea");
171  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
172  esdcuts->SetName(TString::Format("VarTLDeadAreaCut%04d", static_cast<int>(cutvalue * 10.)));
173  esdcuts->SetTitle(TString::Format("Default cuts - variation track length dead area cut at %f", cutvalue));
174  esdcuts->SetCutGeoNcrNcl(cutvalue, 130., 1.5, 0.0, 0.0);
175  trackcuts.Add(esdcuts);
176  }
177  if(cut.Contains("VarTrackLengthTPCLength")){
178  double cutvalue = ValueDecoder(cut, "VarTrackLengthTPCLength");
179  auto esdcuts = GenerateDefaultCutsESD();
180  esdcuts->SetName(TString::Format("VarTLTPCLengthCut%04d", static_cast<int>(cutvalue * 10.)));
181  esdcuts->SetTitle(TString::Format("Default cuts - variation track length TPC length cut at %f", cutvalue));
182  esdcuts->SetCutGeoNcrNcl(3., cutvalue, 1.5, 0.0, 0.0);
183  trackcuts.Add(esdcuts);
184  }
185  if(cut.Contains("VarSPDhit")){
186  double cutvalue = ValueDecoder(cut, "VarSPDhit");
187  auto esdcuts = GenerateDefaultCutsESD();
188  if(TMath::Abs(cutvalue) > DBL_EPSILON){
189  esdcuts->SetName("VarSPDhitOn");
190  esdcuts->SetTitle("Default cuts - variation SPD hit requirement on");
191  } else {
192  esdcuts->SetName("VarSPDhitOff");
193  esdcuts->SetTitle("Default cuts - variation SPD hit requirement off");
194  esdcuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kOff);
195  }
196  trackcuts.Add(esdcuts);
197  }
203  if(cut.Contains("TestITSchi2")){
204  double itscut = ValueDecoder(cut, "TestITSchi2");
205  std::cout << "Using ITS chi2 cut variation: " << itscut << std::endl;
206 
207  auto esdcuts = GenerateLooseDCACutsESD();
208  esdcuts->SetName(Form("TestITSchi2%d", int(itscut*10.)));
209  esdcuts->SetTitle(Form("Loose track cuts, ITS chi2 var %.1f", itscut));
210 
211  // Do the variation
212  esdcuts->SetMaxChi2PerClusterITS(itscut);
213  // Set cut on the TPC global constrained chi2 to very loose
214  esdcuts->SetMaxChi2TPCConstrainedGlobal(100);
215  trackcuts.Add(esdcuts);
216  }
217  if(cut.Contains("TestTPCchi2")){
218  double tpccut = ValueDecoder(cut,"TestTPCchi2");
219  std::cout << "Using TPC chi2 cut variation: " << tpccut << std::endl;
220 
221  auto esdcuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(false, 1);
222  esdcuts->SetName(Form("VarTPCchi2%d", int(tpccut * 10.)));
223  esdcuts->SetTitle(Form("Loose track cuts, TPC chi2 var %.1f", tpccut));
224 
225  // Do the variation
226  esdcuts->SetMaxChi2PerClusterTPC(tpccut);
227  trackcuts.Add(esdcuts);
228  }
229  if(cut.Contains("TestTPCchi2Constrained")){
230  double tpcconstrainedcut = ValueDecoder(cut, "TestTPCchi2Constrained");
231  std::cout << "Using TPC chi2 constrained cut variation: " << tpcconstrainedcut << std::endl;
232 
233  auto esdcuts = GenerateLooseDCACutsESD();
234  esdcuts->SetName(Form("VarTPCchi2constrained%d", int(tpcconstrainedcut * 10.)));
235  esdcuts->SetTitle(Form("Loose track cuts, TPC constrained chi2 variation %f", tpcconstrainedcut));
236 
237  // Do the variation
238  esdcuts->SetMaxChi2TPCConstrainedGlobal(tpcconstrainedcut);
239  // Set ITS chi2 cut to very loose
240  esdcuts->SetMaxChi2PerClusterITS(100);
241  trackcuts.Add(esdcuts);
242  }
243  if(cut.Contains("geo")){
244  auto geocuts = new AliEMCalTriggerExtraCuts();
245  geocuts->SetName("geocuts");
246  geocuts->SetTitle("TPC track length cut");
247  geocuts->SetMinTPCTrackLengthCut();
248  trackcuts.Add(geocuts);
249  }
250  }
251  result = new AliEmcalTrackSelectionESD;
252  result->AddTrackCuts(&trackcuts);
253  } else {
255  result = aodsel;
256  // C++11 Lambda: Do not create multiple extra cut objects in case of AODs. If extra cut object does already exist -
257  // specify new cut in the same object.
258  auto FindTrackCuts = [] (const TObjArray &cuts) -> AliEMCalTriggerExtraCuts * {
259  AliEMCalTriggerExtraCuts *found = nullptr;
260  for(auto cutiter : cuts){
261  if(cutiter->IsA() == AliEMCalTriggerExtraCuts::Class()){
262  found = static_cast<AliEMCalTriggerExtraCuts *>(cutiter);
263  break;
264  }
265  }
266  return found;
267  };
268  for(auto c : *cuts){
269  TString &cut = static_cast<TObjString *>(c)->String();
270  if(cut == "standard"){
271  aodsel->AddFilterBit(AliAODTrack::kTrkGlobal);
272  AliEMCalTriggerExtraCuts *extracuts = FindTrackCuts(trackcuts);
273  if(!extracuts){
274  extracuts = new AliEMCalTriggerExtraCuts;
275  trackcuts.Add(extracuts);
276  }
277  extracuts->SetMinTPCCrossedRows(120);
278  }
279  if(cut == "hybrid"){
281  }
282  if(cut == "hybrid2010_wNoRefit"){
284  }
285  if(cut == "hybrid2010_woNoRefit"){
287  }
288  if(cut == "hybrid2011_wNoRefit"){
290  }
291  if(cut == "hybrid2011_woNoRefit"){
293  }
294  if(cut == "geo"){
295  AliEMCalTriggerExtraCuts *extracuts = FindTrackCuts(trackcuts);
296  if(!extracuts){
297  extracuts = new AliEMCalTriggerExtraCuts;
298  trackcuts.Add(extracuts);
299  }
300  extracuts->SetMinTPCTrackLengthCut();
301  }
302  }
303  result->AddTrackCuts(&trackcuts);
304  }
305 
306  return result;
307 }
308 
316  result->SetEnergyDefinition(endef);
317  return result;
318 }
319 
321  return isAOD ? "caloClusters" : "CaloClusters";
322 }
323 
325  return isAOD ? "tracks" : "Tracks";
326 }
327 
329  AliESDtrackCuts *esdcuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(true, 1);
330  esdcuts->DefineHistograms(kRed);
331  esdcuts->SetCutGeoNcrNcl(3., 130., 1.5, 0.0, 0.0);
332  esdcuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01");
333  esdcuts->SetMaxFractionSharedTPCClusters(0.4);
334  // esdcuts->SetMinNCrossedRowsTPC(0.); // Replaced by geometrical cut
335  return esdcuts;
336 
337 }
338 
340  AliESDtrackCuts *esdcuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE);
341  esdcuts->SetMaxDCAToVertexXY(2.4);
342  esdcuts->SetMaxDCAToVertexZ(3.2);
343  esdcuts->SetDCAToVertex2D(kTRUE);
344  esdcuts->SetMaxChi2TPCConstrainedGlobal(36);
345  esdcuts->SetMaxFractionSharedTPCClusters(0.4);
346  return esdcuts;
347 }
348 
349 double AliEmcalAnalysisFactory::ValueDecoder(const char *cutstring, const char *tag) {
350  TString cuttstring(cutstring);
351  Int_t position(cuttstring.Index(tag) + strlen(tag));
352  TString valuestring = cuttstring(position, 4);
353  Int_t value = valuestring.Atoi();
354  return static_cast<double>(value) / 10.;
355 }
356 
357 } /* 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...
void AddFilterBit(UInt_t filterbits)
Add a new filter bit to the track selection.
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.
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.