AliPhysics  05d84ab (05d84ab)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskDmesonJetsDetectorResponse.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 
17 
18 // Definitions of class AliAnalysisTaskDmesonJetsDetectorResponse::AliDmesonMatchInfoSummary
19 
23 
24 // Definitions of class AliAnalysisTaskDmesonJetsDetectorResponse::AliD0MatchInfoSummary
25 
29 
32 {
33  fGenerated.Reset();
35 }
36 
41 {
42  fReconstructed.Set(reco);
43 }
44 
49 {
50  fGenerated.Set(truth);
51 }
52 
53 // Definitions of class AliAnalysisTaskDmesonJetsDetectorResponse::AliDStarMatchInfoSummary
54 
58 
61 {
62  fGenerated.Reset();
63  fReconstructed.Reset();
64 }
65 
70 {
71  fReconstructed.Set(reco);
72 }
73 
78 {
79  fGenerated.Set(truth);
80 }
81 
82 // Definitions of class AliAnalysisTaskDmesonJetsDetectorResponse::ResponseEngine
83 
87 
90  TObject(),
91  fCandidateType(kD0toKpi),
92  fInhibit(kFALSE),
93  fName(),
94  fTree(0),
95  fCurrentDmeson(0),
96  fCurrentJetInfoReco(0),
97  fCurrentJetInfoTruth(0),
98  fDataSlotNumber(-1),
99  fRecontructed(0),
100  fGenerated(0)
101 {
102 
103 }
104 
109  TObject(),
110  fCandidateType(type),
111  fInhibit(kFALSE),
112  fName(),
113  fTree(0),
114  fCurrentDmeson(0),
115  fCurrentJetInfoReco(0),
116  fCurrentJetInfoTruth(0),
117  fDataSlotNumber(-1),
118  fRecontructed(0),
119  fGenerated(0)
120 {
121 
122 }
123 
128  TObject(source),
129  fCandidateType(source.fCandidateType),
130  fInhibit(source.fInhibit),
131  fName(source.fName),
132  fTree(0),
133  fCurrentDmeson(0),
134  fCurrentJetInfoReco(0),
135  fCurrentJetInfoTruth(0),
136  fDataSlotNumber(source.fDataSlotNumber),
137  fRecontructed(source.fRecontructed),
138  fGenerated(source.fGenerated)
139 {
140 }
141 
146 {
147  new (this) ResponseEngine(source);
148  return *this;
149 }
150 
155 {
156  fInhibit = (fRecontructed == 0 || fGenerated == 0);
157  fName = fRecontructed->GetCandidateName();
158  return !fInhibit;
159 }
160 
163 {
164 
165 }
166 
172 {
173  TString classname;
174  switch (fCandidateType) {
175  case kD0toKpi:
176  classname = "AliAnalysisTaskDmesonJetsDetectorResponse::AliD0MatchInfoSummary";
177  fCurrentDmeson = new AliD0MatchInfoSummary();
178  break;
179  case kDstartoKpipi:
180  classname = "AliAnalysisTaskDmesonJetsDetectorResponse::AliDStarMatchInfoSummary";
181  fCurrentDmeson = new AliDStarMatchInfoSummary();
182  break;
183  }
184  TString treeName = TString::Format("%s_%s", taskName, GetName());
185  fTree = new TTree(treeName, treeName);
186  fTree->Branch("DmesonJet", classname, &fCurrentDmeson);
187 
188  fCurrentJetInfoTruth = new AliJetInfoSummary*[fGenerated->GetJetDefinitions().size()];
189  for (Int_t i = 0; i < fGenerated->GetJetDefinitions().size(); i++) {
190  fCurrentJetInfoTruth[i] = new AliJetInfoSummary();
191  TString bname = TString::Format("%s_truth", fGenerated->GetJetDefinitions()[i].GetName());
192  fTree->Branch(bname, "AliAnalysisTaskDmesonJets::AliJetInfoSummary", &fCurrentJetInfoTruth[i]);
193  }
194 
195  fCurrentJetInfoReco = new AliJetInfoSummary*[fRecontructed->GetJetDefinitions().size()];
196  for (Int_t i = 0; i < fRecontructed->GetJetDefinitions().size(); i++) {
197  fCurrentJetInfoReco[i] = new AliJetInfoSummary();
198  TString bname = TString::Format("%s_reco", fRecontructed->GetJetDefinitions()[i].GetName());
199  fTree->Branch(bname, "AliAnalysisTaskDmesonJets::AliJetInfoSummary", &fCurrentJetInfoReco[i]);
200  }
201 
202  return fTree;
203 }
204 
210 {
211  fRecontructed->FillQA(applyKinCuts);
212  fGenerated->FillQA(applyKinCuts);
213 
214  std::map<int, AliDmesonJetInfo>& recoDmesons = fRecontructed->GetDmesons();
215  std::map<int, AliDmesonJetInfo>& truthDmesons = fGenerated->GetDmesons();
216 
217  for (auto& dmeson_reco : recoDmesons) {
218  fCurrentDmeson->Reset();
219  for (UInt_t ij = 0; ij < fRecontructed->GetJetDefinitions().size(); ij++) {
220  fCurrentJetInfoReco[ij]->Reset();
221  }
222  for (UInt_t ij = 0; ij < fGenerated->GetJetDefinitions().size(); ij++) {
223  fCurrentJetInfoTruth[ij]->Reset();
224  }
225 
226  fCurrentDmeson->SetReconstructed(dmeson_reco.second);
227  Int_t accJets = 0;
228  for (UInt_t ij = 0; ij < fRecontructed->GetJetDefinitions().size(); ij++) {
229  AliJetInfo* jet = dmeson_reco.second.GetJet(fRecontructed->GetJetDefinitions()[ij].GetName());
230  if (!jet) continue;
231  if (applyKinCuts && !fRecontructed->GetJetDefinitions()[ij].IsJetInAcceptance(*jet)) continue;
232  fCurrentJetInfoReco[ij]->Set(dmeson_reco.second, fRecontructed->GetJetDefinitions()[ij].GetName());
233  accJets++;
234  }
235  if (accJets == 0) continue;
236 
237  if (dmeson_reco.second.fMCLabel >= 0) {
238  std::map<int, AliDmesonJetInfo>::iterator it = truthDmesons.find(dmeson_reco.second.fMCLabel);
239  if (it != truthDmesons.end()) {
240  std::pair<const int, AliDmesonJetInfo>& dmeson_truth = (*it);
241  dmeson_truth.second.fReconstructed = kTRUE;
242  fCurrentDmeson->SetGenerated((*it).second);
243  for (UInt_t ij = 0; ij < fGenerated->GetJetDefinitions().size(); ij++) {
244  AliJetInfo* jet = dmeson_truth.second.GetJet(fGenerated->GetJetDefinitions()[ij].GetName());
245  if (!jet) continue;
246  fCurrentJetInfoTruth[ij]->Set(dmeson_truth.second, fGenerated->GetJetDefinitions()[ij].GetName());
247  }
248  }
249  }
250 
251  fTree->Fill();
252  }
253 
254  for (UInt_t ij = 0; ij < fRecontructed->GetJetDefinitions().size(); ij++) {
255  fCurrentJetInfoReco[ij]->Reset();
256  }
257 
258  for (auto& dmeson_truth : truthDmesons) {
259  fCurrentDmeson->Reset();
260  if (dmeson_truth.second.fReconstructed) continue;
261  fCurrentDmeson->SetGenerated(dmeson_truth.second);
262  Int_t accJets = 0;
263  for (UInt_t ij = 0; ij < fGenerated->GetJetDefinitions().size(); ij++) {
264  fCurrentJetInfoTruth[ij]->Reset();
265  AliJetInfo* jet = dmeson_truth.second.GetJet(fGenerated->GetJetDefinitions()[ij].GetName());
266  if (!jet) continue;
267  if (applyKinCuts && !fGenerated->GetJetDefinitions()[ij].IsJetInAcceptance(*jet)) continue;
268  fCurrentJetInfoTruth[ij]->Set(dmeson_truth.second, fGenerated->GetJetDefinitions()[ij].GetName());
269  accJets++;
270  }
271  if (accJets == 0) continue;
272 
273  fTree->Fill();
274  }
275 
276  return kTRUE;
277 }
278 
279 // Definitions of class AliAnalysisTaskDmesonJetsDetectorResponse
280 
284 
289 {
291 }
292 
297  AliAnalysisTaskDmesonJets(name, nOutputTrees),
298  fResponseEngines()
299 {
301 }
302 
305 {
306  ::Info("UserCreateOutputObjects", "CreateOutputObjects of task %s", GetName());
307 
309 
310  for (auto &param : fAnalysisEngines) {
311  if (param.IsInhibit()) continue;
312  if (param.GetMCMode() != kSignalOnly && param.GetMCMode() != kMCTruth) continue;
313 
314  std::map<ECandidateType_t, ResponseEngine>::iterator it = fResponseEngines.find(param.GetCandidateType());
315 
316  if (it == fResponseEngines.end()) {
317  it = (fResponseEngines.insert(std::pair<const ECandidateType_t, ResponseEngine>(param.GetCandidateType(), ResponseEngine(param.GetCandidateType())))).first;
318  }
319 
320  if (param.GetMCMode() == kMCTruth) {
321  (*it).second.SetGeneratedAnalysisEngine(&param);
322  }
323  else {
324  (*it).second.SetReconstructedAnalysisEngine(&param);
325  }
326  }
327 
328  Int_t treeSlot = 0;
329 
330  for (auto &resp : fResponseEngines) {
331  if (!resp.second.CheckInit()) continue;
332 
333  resp.second.BuildTree(GetName());
334  if (treeSlot < fNOutputTrees) {
335  resp.second.AssignDataSlot(treeSlot+2);
336  treeSlot++;
337  PostDataFromResponseEngine(resp.second);
338  }
339  else {
340  AliError(Form("Number of data output slots %d not sufficient. Tree of response engine %s will not be posted!", fNOutputTrees, resp.second.GetName()));
341  }
342  }
343 }
344 
348 {
350 }
351 
356 {
358 }
359 
364 {
365  for (auto &resp : fResponseEngines) {
366 
367  if (resp.second.IsInhibit()) continue;
368 
369  resp.second.FillTree(fApplyKinematicCuts);
370 
371  PostDataFromResponseEngine(resp.second);
372  }
373 
374  return kTRUE;
375 
376 }
377 
382 {
384  AliWarning("This class only provides a tree output.");
385  }
386 
387  // Always set it to kNoOutput: base class does not generate any output (other than QA histograms), all the output comes from the derived class
389 }
390 
397 {
398  if (eng.GetDataSlotNumber() >= 0 && eng.GetTree()) {
399  PostData(eng.GetDataSlotNumber(), eng.GetTree());
400  return eng.GetDataSlotNumber();
401  }
402  else {
403  return -1;
404  }
405 }
std::list< AnalysisEngine > fAnalysisEngines
Array of analysis parameters.
Analysis task for D meson jets.
Lightweight class that encapsulates matching between reconstructed and generated D0 mesons...
Analysis task used to build a detector response for D meson jets.
Lightweight class that encapsulates D meson jets.
std::map< ECandidateType_t, ResponseEngine > fResponseEngines
! Response engines
Analysis engine to produce detector response matrix in the D meson jet analysis.
virtual void UserCreateOutputObjects()
Creates the output containers.
virtual void UserCreateOutputObjects()
Creates the output containers.
AliAnalysisTaskDmesonJetsDetectorResponse()
This is the default constructor, used for ROOT I/O purposes.
Lightweight class that encapsulates matching between reconstructed and generated D mesons...
Lightweight class that encapsulates matching between reconstructed and generated D* mesons...
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
Bool_t fApplyKinematicCuts
Apply jet kinematic cuts.
EOutputType_t fOutputType
Output type: none, TTree or THnSparse.
Int_t fNOutputTrees
Maximum number of output trees.
void RunAnalysis()
Run the requested analysis for the current event.