AliPhysics  ec7afe5 (ec7afe5)
 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) 1998-2016, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 #include <cstring>
16 #include <cfloat>
17 #include <functional>
18 #include <iostream>
19 #include <vector>
20 
21 #include "AliAODTrack.h"
22 #include "AliESDtrackCuts.h"
23 #include "AliEmcalTrackSelection.h"
28 
30 
35 namespace EMCalTriggerPtAnalysis {
36 
37 AliEmcalTrackSelection *AliEmcalAnalysisFactory::TrackCutsFactory(TString cut, Bool_t aod){
38  AliEmcalTrackSelection *result = NULL;
39  if(!aod){
40  std::vector<AliVCuts *> trackcuts;
41  if(cut.Contains("standard")){
42  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
43  esdcuts->SetName("standardRAA");
44  esdcuts->SetTitle("Standard Track cuts");
45  trackcuts.push_back(esdcuts);
46  }
47  if(cut.Contains("standardcrossedrows")){
48  AliESDtrackCuts *esdcuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(true, 1);
49  esdcuts->DefineHistograms(kRed);
50  esdcuts->SetName("standardRAA");
51  esdcuts->SetTitle("Standard Track cuts");
52  esdcuts->SetMinNCrossedRowsTPC(120);
53  esdcuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01");
54  trackcuts.push_back(esdcuts);
55  }
56  if(cut.Contains("hybrid")){
57  AliESDtrackCuts *esdcuts = GenerateLooseDCACutsESD();
58  esdcuts->SetTitle("hybridglobal");
59  esdcuts->SetTitle("Global Hybrid tracks, loose DCA");
60  trackcuts.push_back(esdcuts);
61  }
67  if(cut.Contains("VarITSchi2")){
68  double cutvalue = ValueDecoder(cut, "VarITSchi2");
69  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
70  esdcuts->SetName(TString::Format("VarITSchi2Cut%04d", static_cast<int>(cutvalue * 10.)));
71  esdcuts->SetTitle(TString::Format("Default cuts - variation ITS chi2 cut at %f", cutvalue));
72  esdcuts->SetMaxChi2PerClusterITS(cutvalue);
73  trackcuts.push_back(esdcuts);
74  }
75  if(cut.Contains("VarTPCchi2")){
76  double cutvalue = ValueDecoder(cut, "VarTPCchi2");
77  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
78  esdcuts->SetName(TString::Format("VarTPCchi2Cut%04d", static_cast<int>(cutvalue * 10.)));
79  esdcuts->SetTitle(TString::Format("Default cuts - variation TPC chi2 cut at %f", cutvalue));
80  esdcuts->SetMaxChi2PerClusterTPC(cutvalue);
81  trackcuts.push_back(esdcuts);
82  }
83  if(cut.Contains("VarTPCchi2Constrained")){
84  double cutvalue = ValueDecoder(cut, "VarTPCchi2Constrained"); // in number of sigmas
85  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
86  esdcuts->SetName(TString::Format("VarTPCchi2ConstrainedCut%04d", static_cast<int>(cutvalue * 10.)));
87  esdcuts->SetTitle(TString::Format("Default cuts - variation TPC chi2 constrained cut at %f", cutvalue));
88  esdcuts->SetMaxChi2TPCConstrainedGlobal(cutvalue);
89  trackcuts.push_back(esdcuts);
90  }
91  if(cut.Contains("VarDCAz")){
92  double cutvalue = ValueDecoder(cut, "VarDCAz");
93  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
94  esdcuts->SetName(TString::Format("VarDCAzCut%04d", static_cast<int>(cutvalue * 10.)));
95  esdcuts->SetTitle(TString::Format("Default cuts - variation DCAz cut at %f", cutvalue));
96  esdcuts->SetMaxDCAToVertexZ(cutvalue);
97  trackcuts.push_back(esdcuts);
98  }
99  if(cut.Contains("VarDCAr")){
100  double cutvalue = ValueDecoder(cut, "VarDCAr");
101  double p1 = cutvalue * 0.0026, p2 = cutvalue * 0.005;
102  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
103  esdcuts->SetName(TString::Format("VarDCArCut%04d", static_cast<int>(cutvalue * 10.)));
104  esdcuts->SetTitle(TString::Format("Default cuts - variation DCAr cut at %f sigma", cutvalue));
105  esdcuts->SetMaxDCAToVertexXYPtDep(TString::Format("%f + %f/pt^1.01", p1, p2));
106  trackcuts.push_back(esdcuts);
107  }
108  if(cut.Contains("VarRatioCrossedRowsFindable")){
109  double cutvalue = ValueDecoder(cut, "VarRatioCrossedRowsFindable");
110  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
111  esdcuts->SetName(TString::Format("VarRatioCRFindableCut%04d", static_cast<int>(cutvalue * 10.)));
112  esdcuts->SetTitle(TString::Format("Default cuts - variation ratio crossed rows over findable cut at %f", cutvalue));
113  esdcuts->SetMinRatioCrossedRowsOverFindableClustersTPC(cutvalue);
114  trackcuts.push_back(esdcuts);
115  }
116  if(cut.Contains("VarFractionTPCshared")){
117  double cutvalue = ValueDecoder(cut, "VarFractionTPCshared");
118  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
119  esdcuts->SetName(TString::Format("VarFractionTPCShared%04d", static_cast<int>(cutvalue * 10.)));
120  esdcuts->SetTitle(TString::Format("Default cuts - variation fraction TPC shared clusters %f", cutvalue));
121  esdcuts->SetMaxFractionSharedTPCClusters(cutvalue);
122  trackcuts.push_back(esdcuts);
123  }
124  if(cut.Contains("VarTrackLengthDeadArea")){
125  double cutvalue = ValueDecoder(cut, "VarTrackLengthDeadArea");
126  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
127  esdcuts->SetName(TString::Format("VarTLDeadAreaCut%04d", static_cast<int>(cutvalue * 10.)));
128  esdcuts->SetTitle(TString::Format("Default cuts - variation track length dead area cut at %f", cutvalue));
129  esdcuts->SetCutGeoNcrNcl(cutvalue, 130., 1.5, 0.0, 0.0);
130  trackcuts.push_back(esdcuts);
131  }
132  if(cut.Contains("VarTrackLengthTPCLength")){
133  double cutvalue = ValueDecoder(cut, "VarTrackLengthTPCLength");
134  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
135  esdcuts->SetName(TString::Format("VarTLTPCLengthCut%04d", static_cast<int>(cutvalue * 10.)));
136  esdcuts->SetTitle(TString::Format("Default cuts - variation track length TPC length cut at %f", cutvalue));
137  esdcuts->SetCutGeoNcrNcl(3., cutvalue, 1.5, 0.0, 0.0);
138  trackcuts.push_back(esdcuts);
139  }
140  if(cut.Contains("VarSPDhit")){
141  double cutvalue = ValueDecoder(cut, "VarSPDhit");
142  AliESDtrackCuts *esdcuts = GenerateDefaultCutsESD();
143  if(TMath::Abs(cutvalue) > DBL_EPSILON){
144  esdcuts->SetName("VarSPDhitOn");
145  esdcuts->SetTitle("Default cuts - variation SPD hit requirement on");
146  } else {
147  esdcuts->SetName("VarSPDhitOff");
148  esdcuts->SetTitle("Default cuts - variation SPD hit requirement off");
149  esdcuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kOff);
150  }
151  trackcuts.push_back(esdcuts);
152  }
158  if(cut.Contains("TestITSchi2")){
159  double itscut = ValueDecoder(cut, "TestITSchi2");
160  std::cout << "Using ITS chi2 cut variation: " << itscut << std::endl;
161 
162  AliESDtrackCuts *esdcuts = GenerateLooseDCACutsESD();
163  esdcuts->SetName(Form("TestITSchi2%d", int(itscut*10.)));
164  esdcuts->SetTitle(Form("Loose track cuts, ITS chi2 var %.1f", itscut));
165 
166  // Do the variation
167  esdcuts->SetMaxChi2PerClusterITS(itscut);
168  // Set cut on the TPC global constrained chi2 to very loose
169  esdcuts->SetMaxChi2TPCConstrainedGlobal(100);
170  trackcuts.push_back(esdcuts);
171  }
172  if(cut.Contains("TestTPCchi2")){
173  double tpccut = ValueDecoder(cut,"TestTPCchi2");
174  std::cout << "Using TPC chi2 cut variation: " << tpccut << std::endl;
175 
176  AliESDtrackCuts *esdcuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(false, 1);
177  esdcuts->SetName(Form("VarTPCchi2%d", int(tpccut * 10.)));
178  esdcuts->SetTitle(Form("Loose track cuts, TPC chi2 var %.1f", tpccut));
179 
180  // Do the variation
181  esdcuts->SetMaxChi2PerClusterTPC(tpccut);
182  trackcuts.push_back(esdcuts);
183  }
184  if(cut.Contains("TestTPCchi2Constrained")){
185  double tpcconstrainedcut = ValueDecoder(cut, "TestTPCchi2Constrained");
186  std::cout << "Using TPC chi2 constrained cut variation: " << tpcconstrainedcut << std::endl;
187 
188  AliESDtrackCuts *esdcuts = GenerateLooseDCACutsESD();
189  esdcuts->SetName(Form("VarTPCchi2constrained%d", int(tpcconstrainedcut * 10.)));
190  esdcuts->SetTitle(Form("Loose track cuts, TPC constrained chi2 variation %f", tpcconstrainedcut));
191 
192  // Do the variation
193  esdcuts->SetMaxChi2TPCConstrainedGlobal(tpcconstrainedcut);
194  // Set ITS chi2 cut to very loose
195  esdcuts->SetMaxChi2PerClusterITS(100);
196  trackcuts.push_back(esdcuts);
197  }
198  if(cut.Contains("geo")){
200  geocuts->SetName("geocuts");
201  geocuts->SetTitle("TPC track length cut");
202  geocuts->SetMinTPCTrackLengthCut();
203  trackcuts.push_back(geocuts);
204  }
205  result = new AliEmcalTrackSelectionESD;
206  for(std::vector<AliVCuts *>::iterator it = trackcuts.begin(); it != trackcuts.end(); ++it)
207  result->AddTrackCuts(*it);
208  } else {
210  result = aodsel;
211  std::vector<AliVCuts *> trackcuts;
212  // C++11 Lambda: Do not create multiple extra cut objects in case of AODs. If extra cut object does already exist -
213  // specify new cut in the same object.
214  std::function<AliEMCalTriggerExtraCuts *(const std::vector<AliVCuts *> &)> FindTrackCuts = [] (const std::vector<AliVCuts *> &cuts) -> AliEMCalTriggerExtraCuts * {
215  AliEMCalTriggerExtraCuts *found = nullptr;
216  for(std::vector<AliVCuts *>::const_iterator cutiter = cuts.begin(); cutiter != cuts.end(); ++cutiter){
217  if((*cutiter)->IsA() == AliEMCalTriggerExtraCuts::Class()){
218  found = static_cast<AliEMCalTriggerExtraCuts *>(*cutiter);
219  break;
220  }
221  }
222  return found;
223  };
224  if(cut.Contains("standard")){
225  aodsel->AddFilterBit(AliAODTrack::kTrkGlobal);
226  AliEMCalTriggerExtraCuts *extracuts = FindTrackCuts(trackcuts);
227  if(!extracuts){
228  extracuts = new AliEMCalTriggerExtraCuts;
229  trackcuts.push_back(extracuts);
230  }
231  extracuts->SetMinTPCCrossedRows(120);
232  }
233  if(cut.Contains("hybrid")){
234  aodsel->AddFilterBit(256);
235  aodsel->AddFilterBit(512);
236  }
237  if(cut.Contains("geo")){
238  AliEMCalTriggerExtraCuts *extracuts = FindTrackCuts(trackcuts);
239  if(!extracuts){
240  extracuts = new AliEMCalTriggerExtraCuts;
241  trackcuts.push_back(extracuts);
242  }
243  extracuts->SetMinTPCTrackLengthCut();
244  }
245  for(std::vector<AliVCuts *>::iterator it = trackcuts.begin(); it != trackcuts.end(); ++it)
246  result->AddTrackCuts(*it);
247  }
248 
249  return result;
250 }
251 
252 AliEmcalTriggerOfflineSelection *AliEmcalAnalysisFactory::TriggerSelectionFactory(Double_t el0, Double_t eg1, Double_t eg2, Double_t ej1, Double_t ej2, AliEmcalTriggerOfflineSelection::EmcalEnergyDefinition_t endef){
254  result->SetOfflineEnergyThreshold(AliEmcalTriggerOfflineSelection::kTrgEL0, el0);
255  result->SetOfflineEnergyThreshold(AliEmcalTriggerOfflineSelection::kTrgEG1, eg1);
256  result->SetOfflineEnergyThreshold(AliEmcalTriggerOfflineSelection::kTrgEG2, eg2);
257  result->SetOfflineEnergyThreshold(AliEmcalTriggerOfflineSelection::kTrgEJ1, ej1);
258  result->SetOfflineEnergyThreshold(AliEmcalTriggerOfflineSelection::kTrgEJ2, ej2);
259  result->SetEnergyDefinition(endef);
260  return result;
261 }
262 
263 TString AliEmcalAnalysisFactory::ClusterContainerNameFactory(Bool_t isAOD){
264  return isAOD ? "caloClusters" : "CaloClusters";
265 }
266 
267 AliESDtrackCuts *AliEmcalAnalysisFactory::GenerateDefaultCutsESD() {
268  AliESDtrackCuts *esdcuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(true, 1);
269  esdcuts->DefineHistograms(kRed);
270  esdcuts->SetCutGeoNcrNcl(3., 130., 1.5, 0.0, 0.0);
271  esdcuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01");
272  return esdcuts;
273 
274 }
275 
276 AliESDtrackCuts *AliEmcalAnalysisFactory::GenerateLooseDCACutsESD(){
277  AliESDtrackCuts *esdcuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE);
278  esdcuts->SetMaxDCAToVertexXY(2.4);
279  esdcuts->SetMaxDCAToVertexZ(3.2);
280  esdcuts->SetDCAToVertex2D(kTRUE);
281  esdcuts->SetMaxChi2TPCConstrainedGlobal(36);
282  esdcuts->SetMaxFractionSharedTPCClusters(0.4);
283  return esdcuts;
284 }
285 
286 double AliEmcalAnalysisFactory::ValueDecoder(const char *cutstring, const char *tag) {
287  TString cuttstring(cutstring);
288  Int_t position(cuttstring.Index(tag) + strlen(tag));
289  TString valuestring = cuttstring(position, 4);
290  Int_t value = valuestring.Atoi();
291  return static_cast<double>(value) / 10.;
292 }
293 
294 } /* namespace EMCalTriggerPtAnalysis */
Interface for virtual track selection.
double Double_t
Definition: External.C:58
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.
int Int_t
Definition: External.C:63
Collection of helper functions used to configure the analysis.
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.
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
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.