AliPhysics  e59a9ba (e59a9ba)
 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  // always fill D meson tree, even if no jet was accepted
236  //if (accJets == 0) continue;
237 
238  if (dmeson_reco.second.fMCLabel >= 0) {
239  std::map<int, AliDmesonJetInfo>::iterator it = truthDmesons.find(dmeson_reco.second.fMCLabel);
240  if (it != truthDmesons.end()) {
241  std::pair<const int, AliDmesonJetInfo>& dmeson_truth = (*it);
242  dmeson_truth.second.fReconstructed = kTRUE;
243  fCurrentDmeson->SetGenerated((*it).second);
244  for (UInt_t ij = 0; ij < fGenerated->GetJetDefinitions().size(); ij++) {
245  AliJetInfo* jet = dmeson_truth.second.GetJet(fGenerated->GetJetDefinitions()[ij].GetName());
246  if (!jet) continue;
247  fCurrentJetInfoTruth[ij]->Set(dmeson_truth.second, fGenerated->GetJetDefinitions()[ij].GetName());
248  }
249  }
250  }
251 
252  fTree->Fill();
253  }
254 
255  for (UInt_t ij = 0; ij < fRecontructed->GetJetDefinitions().size(); ij++) {
256  fCurrentJetInfoReco[ij]->Reset();
257  }
258 
259  for (auto& dmeson_truth : truthDmesons) {
260  fCurrentDmeson->Reset();
261  if (dmeson_truth.second.fReconstructed) continue;
262  fCurrentDmeson->SetGenerated(dmeson_truth.second);
263  Int_t accJets = 0;
264  for (UInt_t ij = 0; ij < fGenerated->GetJetDefinitions().size(); ij++) {
265  fCurrentJetInfoTruth[ij]->Reset();
266  AliJetInfo* jet = dmeson_truth.second.GetJet(fGenerated->GetJetDefinitions()[ij].GetName());
267  if (!jet) continue;
268  if (applyKinCuts && !fGenerated->GetJetDefinitions()[ij].IsJetInAcceptance(*jet)) continue;
269  fCurrentJetInfoTruth[ij]->Set(dmeson_truth.second, fGenerated->GetJetDefinitions()[ij].GetName());
270  accJets++;
271  }
272  if (accJets == 0) continue;
273 
274  fTree->Fill();
275  }
276 
277  return kTRUE;
278 }
279 
280 // Definitions of class AliAnalysisTaskDmesonJetsDetectorResponse
281 
285 
290 {
292 }
293 
298  AliAnalysisTaskDmesonJets(name, nOutputTrees),
299  fResponseEngines()
300 {
302 }
303 
306 {
307  ::Info("UserCreateOutputObjects", "CreateOutputObjects of task %s", GetName());
308 
310 
311  for (auto &param : fAnalysisEngines) {
312  if (param.IsInhibit()) continue;
313  if (param.GetMCMode() != kSignalOnly && param.GetMCMode() != kMCTruth) continue;
314 
315  std::map<ECandidateType_t, ResponseEngine>::iterator it = fResponseEngines.find(param.GetCandidateType());
316 
317  if (it == fResponseEngines.end()) {
318  it = (fResponseEngines.insert(std::pair<const ECandidateType_t, ResponseEngine>(param.GetCandidateType(), ResponseEngine(param.GetCandidateType())))).first;
319  }
320 
321  if (param.GetMCMode() == kMCTruth) {
322  (*it).second.SetGeneratedAnalysisEngine(&param);
323  }
324  else {
325  (*it).second.SetReconstructedAnalysisEngine(&param);
326  }
327  }
328 
329  Int_t treeSlot = 0;
330 
331  for (auto &resp : fResponseEngines) {
332  if (!resp.second.CheckInit()) continue;
333 
334  resp.second.BuildTree(GetName());
335  if (treeSlot < fNOutputTrees) {
336  resp.second.AssignDataSlot(treeSlot+2);
337  treeSlot++;
338  PostDataFromResponseEngine(resp.second);
339  }
340  else {
341  AliError(Form("Number of data output slots %d not sufficient. Tree of response engine %s will not be posted!", fNOutputTrees, resp.second.GetName()));
342  }
343  }
344 }
345 
349 {
351 }
352 
357 {
359 }
360 
365 {
366  for (auto &resp : fResponseEngines) {
367 
368  if (resp.second.IsInhibit()) continue;
369 
370  resp.second.FillTree(fApplyKinematicCuts);
371 
372  PostDataFromResponseEngine(resp.second);
373  }
374 
375  return kTRUE;
376 
377 }
378 
383 {
385  AliWarning("This class only provides a tree output.");
386  }
387 
388  // Always set it to kNoOutput: base class does not generate any output (other than QA histograms), all the output comes from the derived class
390 }
391 
398 {
399  if (eng.GetDataSlotNumber() >= 0 && eng.GetTree()) {
400  PostData(eng.GetDataSlotNumber(), eng.GetTree());
401  return eng.GetDataSlotNumber();
402  }
403  else {
404  return -1;
405  }
406 }
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.