AliPhysics  3337bb0 (3337bb0)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 <vector>
32 
33 #include "AliAODTrack.h"
34 #include "AliESDtrackCuts.h"
35 #include "AliEmcalTrackSelection.h"
40 
42 
43 namespace EMCalTriggerPtAnalysis {
44 
46  AliEmcalTrackSelection *result = NULL;
47  if(!aod){
48  std::vector<AliVCuts *> trackcuts;
49  if(cut.Contains("standard")){
50  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
51  esdcuts->SetName("standardRAA");
52  esdcuts->SetTitle("Standard Track cuts");
53  trackcuts.push_back(esdcuts);
54  }
55  if(cut.Contains("standardcrossedrows")){
56  AliESDtrackCuts *esdcuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(true, 1);
57  esdcuts->DefineHistograms(kRed);
58  esdcuts->SetName("standardRAA");
59  esdcuts->SetTitle("Standard Track cuts");
60  esdcuts->SetMinNCrossedRowsTPC(120);
61  esdcuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01");
62  trackcuts.push_back(esdcuts);
63  }
64  if(cut.Contains("hybrid")){
65  AliESDtrackCuts *esdcuts = GenerateLooseDCACutsESD();
66  esdcuts->SetTitle("hybridglobal");
67  esdcuts->SetTitle("Global Hybrid tracks, loose DCA");
68  trackcuts.push_back(esdcuts);
69  }
75  if(cut.Contains("VarITSchi2")){
76  double cutvalue = ValueDecoder(cut, "VarITSchi2");
77  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
78  esdcuts->SetName(TString::Format("VarITSchi2Cut%04d", static_cast<int>(cutvalue * 10.)));
79  esdcuts->SetTitle(TString::Format("Default cuts - variation ITS chi2 cut at %f", cutvalue));
80  esdcuts->SetMaxChi2PerClusterITS(cutvalue);
81  trackcuts.push_back(esdcuts);
82  }
83  if(cut.Contains("VarTPCchi2") && !cut.Contains("Constrained")){
84  double cutvalue = ValueDecoder(cut, "VarTPCchi2");
85  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
86  esdcuts->SetName(TString::Format("VarTPCchi2Cut%04d", static_cast<int>(cutvalue * 10.)));
87  esdcuts->SetTitle(TString::Format("Default cuts - variation TPC chi2 cut at %f", cutvalue));
88  esdcuts->SetMaxChi2PerClusterTPC(cutvalue);
89  trackcuts.push_back(esdcuts);
90  }
91  if(cut.Contains("VarTPCchi2Constrained")){
92  double cutvalue = ValueDecoder(cut, "VarTPCchi2Constrained"); // in number of sigmas
93  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
94  esdcuts->SetName(TString::Format("VarTPCchi2ConstrainedCut%04d", static_cast<int>(cutvalue * 10.)));
95  esdcuts->SetTitle(TString::Format("Default cuts - variation TPC chi2 constrained cut at %f", cutvalue));
96  esdcuts->SetMaxChi2TPCConstrainedGlobal(cutvalue);
97  trackcuts.push_back(esdcuts);
98  }
99  if(cut.Contains("VarDCAz")){
100  double cutvalue = ValueDecoder(cut, "VarDCAz");
101  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
102  esdcuts->SetName(TString::Format("VarDCAzCut%04d", static_cast<int>(cutvalue * 10.)));
103  esdcuts->SetTitle(TString::Format("Default cuts - variation DCAz cut at %f", cutvalue));
104  esdcuts->SetMaxDCAToVertexZ(cutvalue);
105  trackcuts.push_back(esdcuts);
106  }
107  if(cut.Contains("VarDCAr")){
108  double cutvalue = ValueDecoder(cut, "VarDCAr");
109  double p1 = cutvalue * 0.0026, p2 = cutvalue * 0.005;
110  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
111  esdcuts->SetName(TString::Format("VarDCArCut%04d", static_cast<int>(cutvalue * 10.)));
112  esdcuts->SetTitle(TString::Format("Default cuts - variation DCAr cut at %f sigma", cutvalue));
113  esdcuts->SetMaxDCAToVertexXYPtDep(TString::Format("%f + %f/pt^1.01", p1, p2));
114  trackcuts.push_back(esdcuts);
115  }
116  if(cut.Contains("VarRatioCrossedRowsFindable")){
117  double cutvalue = ValueDecoder(cut, "VarRatioCrossedRowsFindable");
118  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
119  esdcuts->SetName(TString::Format("VarRatioCRFindableCut%04d", static_cast<int>(cutvalue * 10.)));
120  esdcuts->SetTitle(TString::Format("Default cuts - variation ratio crossed rows over findable cut at %f", cutvalue));
121  esdcuts->SetMinRatioCrossedRowsOverFindableClustersTPC(cutvalue);
122  trackcuts.push_back(esdcuts);
123  }
124  if(cut.Contains("VarFractionTPCshared")){
125  double cutvalue = ValueDecoder(cut, "VarFractionTPCshared");
126  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
127  esdcuts->SetName(TString::Format("VarFractionTPCShared%04d", static_cast<int>(cutvalue * 10.)));
128  esdcuts->SetTitle(TString::Format("Default cuts - variation fraction TPC shared clusters %f", cutvalue));
129  esdcuts->SetMaxFractionSharedTPCClusters(cutvalue);
130  trackcuts.push_back(esdcuts);
131  }
132  if(cut.Contains("VarTrackLengthDeadArea")){
133  double cutvalue = ValueDecoder(cut, "VarTrackLengthDeadArea");
134  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
135  esdcuts->SetName(TString::Format("VarTLDeadAreaCut%04d", static_cast<int>(cutvalue * 10.)));
136  esdcuts->SetTitle(TString::Format("Default cuts - variation track length dead area cut at %f", cutvalue));
137  esdcuts->SetCutGeoNcrNcl(cutvalue, 130., 1.5, 0.0, 0.0);
138  trackcuts.push_back(esdcuts);
139  }
140  if(cut.Contains("VarTrackLengthTPCLength")){
141  double cutvalue = ValueDecoder(cut, "VarTrackLengthTPCLength");
142  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
143  esdcuts->SetName(TString::Format("VarTLTPCLengthCut%04d", static_cast<int>(cutvalue * 10.)));
144  esdcuts->SetTitle(TString::Format("Default cuts - variation track length TPC length cut at %f", cutvalue));
145  esdcuts->SetCutGeoNcrNcl(3., cutvalue, 1.5, 0.0, 0.0);
146  trackcuts.push_back(esdcuts);
147  }
148  if(cut.Contains("VarSPDhit")){
149  double cutvalue = ValueDecoder(cut, "VarSPDhit");
150  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
151  if(TMath::Abs(cutvalue) > DBL_EPSILON){
152  esdcuts->SetName("VarSPDhitOn");
153  esdcuts->SetTitle("Default cuts - variation SPD hit requirement on");
154  } else {
155  esdcuts->SetName("VarSPDhitOff");
156  esdcuts->SetTitle("Default cuts - variation SPD hit requirement off");
157  esdcuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kOff);
158  }
159  trackcuts.push_back(esdcuts);
160  }
166  if(cut.Contains("TestITSchi2")){
167  double itscut = ValueDecoder(cut, "TestITSchi2");
168  std::cout << "Using ITS chi2 cut variation: " << itscut << std::endl;
169 
170  AliESDtrackCuts *esdcuts = GenerateLooseDCACutsESD();
171  esdcuts->SetName(Form("TestITSchi2%d", int(itscut*10.)));
172  esdcuts->SetTitle(Form("Loose track cuts, ITS chi2 var %.1f", itscut));
173 
174  // Do the variation
175  esdcuts->SetMaxChi2PerClusterITS(itscut);
176  // Set cut on the TPC global constrained chi2 to very loose
177  esdcuts->SetMaxChi2TPCConstrainedGlobal(100);
178  trackcuts.push_back(esdcuts);
179  }
180  if(cut.Contains("TestTPCchi2")){
181  double tpccut = ValueDecoder(cut,"TestTPCchi2");
182  std::cout << "Using TPC chi2 cut variation: " << tpccut << std::endl;
183 
184  AliESDtrackCuts *esdcuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(false, 1);
185  esdcuts->SetName(Form("VarTPCchi2%d", int(tpccut * 10.)));
186  esdcuts->SetTitle(Form("Loose track cuts, TPC chi2 var %.1f", tpccut));
187 
188  // Do the variation
189  esdcuts->SetMaxChi2PerClusterTPC(tpccut);
190  trackcuts.push_back(esdcuts);
191  }
192  if(cut.Contains("TestTPCchi2Constrained")){
193  double tpcconstrainedcut = ValueDecoder(cut, "TestTPCchi2Constrained");
194  std::cout << "Using TPC chi2 constrained cut variation: " << tpcconstrainedcut << std::endl;
195 
196  AliESDtrackCuts *esdcuts = GenerateLooseDCACutsESD();
197  esdcuts->SetName(Form("VarTPCchi2constrained%d", int(tpcconstrainedcut * 10.)));
198  esdcuts->SetTitle(Form("Loose track cuts, TPC constrained chi2 variation %f", tpcconstrainedcut));
199 
200  // Do the variation
201  esdcuts->SetMaxChi2TPCConstrainedGlobal(tpcconstrainedcut);
202  // Set ITS chi2 cut to very loose
203  esdcuts->SetMaxChi2PerClusterITS(100);
204  trackcuts.push_back(esdcuts);
205  }
206  if(cut.Contains("geo")){
208  geocuts->SetName("geocuts");
209  geocuts->SetTitle("TPC track length cut");
210  geocuts->SetMinTPCTrackLengthCut();
211  trackcuts.push_back(geocuts);
212  }
213  result = new AliEmcalTrackSelectionESD;
214  for(std::vector<AliVCuts *>::iterator it = trackcuts.begin(); it != trackcuts.end(); ++it)
215  result->AddTrackCuts(*it);
216  } else {
218  result = aodsel;
219  std::vector<AliVCuts *> trackcuts;
220  // C++11 Lambda: Do not create multiple extra cut objects in case of AODs. If extra cut object does already exist -
221  // specify new cut in the same object.
222  std::function<AliEMCalTriggerExtraCuts *(const std::vector<AliVCuts *> &)> FindTrackCuts = [] (const std::vector<AliVCuts *> &cuts) -> AliEMCalTriggerExtraCuts * {
223  AliEMCalTriggerExtraCuts *found = nullptr;
224  for(std::vector<AliVCuts *>::const_iterator cutiter = cuts.begin(); cutiter != cuts.end(); ++cutiter){
225  if((*cutiter)->IsA() == AliEMCalTriggerExtraCuts::Class()){
226  found = static_cast<AliEMCalTriggerExtraCuts *>(*cutiter);
227  break;
228  }
229  }
230  return found;
231  };
232  if(cut.Contains("standard")){
233  aodsel->AddFilterBit(AliAODTrack::kTrkGlobal);
234  AliEMCalTriggerExtraCuts *extracuts = FindTrackCuts(trackcuts);
235  if(!extracuts){
236  extracuts = new AliEMCalTriggerExtraCuts;
237  trackcuts.push_back(extracuts);
238  }
239  extracuts->SetMinTPCCrossedRows(120);
240  }
241  if(cut.Contains("hybrid")){
242  aodsel->AddFilterBit(256);
243  aodsel->AddFilterBit(512);
244  }
245  if(cut.Contains("geo")){
246  AliEMCalTriggerExtraCuts *extracuts = FindTrackCuts(trackcuts);
247  if(!extracuts){
248  extracuts = new AliEMCalTriggerExtraCuts;
249  trackcuts.push_back(extracuts);
250  }
251  extracuts->SetMinTPCTrackLengthCut();
252  }
253  for(std::vector<AliVCuts *>::iterator it = trackcuts.begin(); it != trackcuts.end(); ++it)
254  result->AddTrackCuts(*it);
255  }
256 
257  return result;
258 }
259 
267  result->SetEnergyDefinition(endef);
268  return result;
269 }
270 
272  return isAOD ? "caloClusters" : "CaloClusters";
273 }
274 
276  return isAOD ? "tracks" : "Tracks";
277 }
278 
280  AliESDtrackCuts *esdcuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(true, 1);
281  esdcuts->DefineHistograms(kRed);
282  esdcuts->SetCutGeoNcrNcl(3., 130., 1.5, 0.0, 0.0);
283  esdcuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01");
284  esdcuts->SetMaxFractionSharedTPCClusters(0.4);
285  // esdcuts->SetMinNCrossedRowsTPC(0.); // Replaced by geometrical cut
286  return esdcuts;
287 
288 }
289 
291  AliESDtrackCuts *esdcuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE);
292  esdcuts->SetMaxDCAToVertexXY(2.4);
293  esdcuts->SetMaxDCAToVertexZ(3.2);
294  esdcuts->SetDCAToVertex2D(kTRUE);
295  esdcuts->SetMaxChi2TPCConstrainedGlobal(36);
296  esdcuts->SetMaxFractionSharedTPCClusters(0.4);
297  return esdcuts;
298 }
299 
300 double AliEmcalAnalysisFactory::ValueDecoder(const char *cutstring, const char *tag) {
301  TString cuttstring(cutstring);
302  Int_t position(cuttstring.Index(tag) + strlen(tag));
303  TString valuestring = cuttstring(position, 4);
304  Int_t value = valuestring.Atoi();
305  return static_cast<double>(value) / 10.;
306 }
307 
308 } /* namespace EMCalTriggerPtAnalysis */
Interface for virtual track selection.
double Double_t
Definition: External.C:58
static double ValueDecoder(const char *string, const char *tag)
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.
int Int_t
Definition: External.C:63
void SetOfflineEnergyThreshold(EmcalTriggerClass trgcls, double threshold)
Specify threshold for a given offline trigger class.
void AddTrackCuts(AliVCuts *cuts)
Add new track cuts to the list of cuts.
Implement virtual track selection for AOD analysis.
Declaration of class AliEMCalTriggerExtraCuts.
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.