AliPhysics  d497547 (d497547)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AddTaskEMCALAlig.C
Go to the documentation of this file.
1 
11  const char *ntracks = "usedefault",
12  const char *nclusters = "usedefault",
13  const char* ncells = "usedefault",
14  const char *suffix = "",
15  Int_t TriggerMode = 0,
16  const char *sRunPeriod = "lhc16k"
17  )
18 {
19  /* TriggerMode
20  default = INT7
21  1 = GA
22  2 = JE
23  3 = INT7 | GA | JE
24  */
25 
26  UInt_t Selection;
27 
28  switch (TriggerMode) {
29  case 0:
30  Selection = AliVEvent::kINT7;
31  break;
32  case 1:
33  Selection = AliVEvent::kEMCEGA;
34  break;
35  case 2:
36  Selection = AliVEvent::kEMCEJE;
37  break;
38  case 3:
39  Selection = AliVEvent::kINT7 | AliVEvent::kEMCEJE | AliVEvent::kEMCEGA;
40  break;
41 
42  }
43 
44  //AliTrackContainer::SetDefTrackCutsPeriod(sRunPeriod);
45 
46  // Get the pointer to the existing analysis manager via the static access method.
47  //==============================================================================
48  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
49  if (!mgr)
50  {
51  ::Error("AddTaskEmcalAlig", "No analysis manager to connect to.");
52  return 0;
53  }
54 
55  // Check the analysis type using the event handlers connected to the analysis manager.
56  //==============================================================================
57  AliVEventHandler* handler = mgr->GetInputEventHandler();
58  if (!handler)
59  {
60  ::Error("AddTaskEmcalAlig", "This task requires an input event handler");
61  return 0;
62  }
63 
64  enum EDataType_t {
65  kUnknown,
66  kESD,
67  kAOD
68  };
69 
70  EDataType_t dataType = kUnknown;
71 
72 
73  if (handler->InheritsFrom("AliESDInputHandler")) {
74  dataType = kESD;
75  }
76  else if (handler->InheritsFrom("AliAODInputHandler")) {
77  dataType = kAOD;
78  }
79 
80  //-------------------------------------------------------
81  // Init the task and do settings
82  //-------------------------------------------------------
83 
84  TString trackName(ntracks);
85  TString clusName(nclusters);
86  TString cellName(ncells);
87 
88  if (trackName == "usedefault") {
89  if (dataType == kESD) {
90  trackName = "Tracks";
91  }
92  else if (dataType == kAOD) {
93  trackName = "tracks";
94  }
95  else {
96  trackName = "";
97  }
98  }
99 
100  if (clusName == "usedefault") {
101  if (dataType == kESD) {
102  clusName = "CaloClusters";
103  }
104  else if (dataType == kAOD) {
105  clusName = "caloClusters";
106  }
107  else {
108  clusName = "";
109  }
110  }
111 
112  if (cellName == "usedefault") {
113  if (dataType == kESD) {
114  cellName = "EMCALCells";
115  }
116  else if (dataType == kAOD) {
117  cellName = "emcalCells";
118  }
119  else {
120  cellName = "";
121  }
122  }
123 
124  TString name("AliAnalysisTaskEMCALAlig");
125  if (!trackName.IsNull()) {
126  name += "_";
127  name += trackName;
128  }
129  if (!clusName.IsNull()) {
130  name += "_";
131  name += clusName;
132  }
133  if (!cellName.IsNull()) {
134  name += "_";
135  name += cellName;
136  }
137  if (strcmp(suffix,"") != 0) {
138  name += "_";
139  name += suffix;
140  }
141 
142  AliAnalysisTaskEMCALAlig* sampleTask = new AliAnalysisTaskEMCALAlig(name);
143  sampleTask->SetCaloCellsName(cellName);
144  sampleTask->SetVzRange(-10,10);
145 
146  if (trackName == "mcparticles") {
147  AliMCParticleContainer* mcpartCont = sampleTask->AddMCParticleContainer(trackName);
148  }
149  else if (trackName == "tracks" || trackName == "Tracks") {
150  AliTrackContainer* trackCont = sampleTask->AddTrackContainer(trackName);
151  }
152  else if (!trackName.IsNull()) {
153  sampleTask->AddParticleContainer(trackName);
154  }
155  sampleTask->AddClusterContainer(clusName);
156 
157  //Cluster cuts
158  sampleTask->GetClusterContainer(0)->SetClusECut(0.);
159  sampleTask->GetClusterContainer(0)->SetClusPtCut(0.);
161  sampleTask->GetClusterContainer(0)->SetDefaultClusterEnergy(AliVCluster::kNonLinCorr);
162 
163  //Track cuts
164  sampleTask->GetParticleContainer(0)->SetParticlePtCut(1.2);
166  sampleTask->GetTrackContainer(0)->SetAODFilterBits(AliAODTrack::kTrkGlobalNoDCA);
167  sampleTask->GetTrackContainer(0)->SetEtaLimits(-0.7, 0.7);
168 
169  sampleTask->SetHistoBins(600, 0, 300);
170  sampleTask->SelectCollisionCandidates(Selection);
171 
172 
173  //-------------------------------------------------------
174  // Final settings, pass to manager and set the containers
175  //-------------------------------------------------------
176 
177  mgr->AddTask(sampleTask);
178 
179  // Create containers for input/output
180  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer() ;
181  TString contname(name);
182  contname += "_histos";
183  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contname.Data(),
184  TList::Class(),AliAnalysisManager::kOutputContainer,
185  Form("%s", AliAnalysisManager::GetCommonFileName()));
186  mgr->ConnectInput (sampleTask, 0, cinput1 );
187  mgr->ConnectOutput (sampleTask, 1, coutput1 );
188 
189  return sampleTask;
190 }
void SetParticlePtCut(Double_t cut)
Container with name, TClonesArray and cuts for particles.
void SetVzRange(Double_t min, Double_t max)
AliClusterContainer * AddClusterContainer(const char *n)
Create new cluster container and attach it to the task.
AliParticleContainer * GetParticleContainer(Int_t i=0) const
Get particle container attached to this task.
void SetAODFilterBits(UInt_t bits)
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
AliAnalysisTaskEMCALAlig * AddTaskEmcalAlig(const char *ntracks="usedefault", const char *nclusters="usedefault", const char *ncells="usedefault", const char *suffix="", Int_t TriggerMode=0, const char *sRunPeriod="lhc16k")
void SetClusNonLinCorrEnergyCut(Double_t cut)
AliParticleContainer * AddParticleContainer(const char *n)
Create new particle container and attach it to the task.
AliClusterContainer * GetClusterContainer(Int_t i=0) const
Get cluster container attached to this task.
AliMCParticleContainer * AddMCParticleContainer(const char *n)
Create new container for MC particles and attach it to the task.
void SetHistoBins(Int_t nbins, Double_t min, Double_t max)
AliTrackContainer * AddTrackContainer(const char *n)
Create new track container and attach it to the task.
AliTrackContainer * GetTrackContainer(Int_t i=0) const
void SetTrackFilterType(ETrackFilterType_t f)
void SetClusPtCut(Double_t cut)
void SetCaloCellsName(const char *n)
void SetClusECut(Double_t cut)
void SetDefaultClusterEnergy(Int_t d)
Container for MC-true particles within the EMCAL framework.