AliPhysics  608b256 (608b256)
AliAnalysisTaskGammaConvDtrue.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 <iostream>
28 #include <THistManager.h>
29 #include <TList.h>
30 #include <TMath.h>
31 #include <TParticle.h>
32 #include "AliAnalysisManager.h"
33 #include "AliLog.h"
34 #include "AliMCEvent.h"
36 
38 
41  fHistos(nullptr)
42 {
43 
44 }
45 
47  AliAnalysisTaskEmcal(name, true),
48  fHistos(nullptr)
49 {
50  this->SetMakeGeneralHistograms(true);
51  DefineOutput(1, TList::Class());
52 }
53 
55  if(fHistos) delete fHistos;
56 }
57 
60 
61  fHistos = new THistManager(Form("Histos_%s", GetName()));
62 
63  fHistos->CreateTH1("hTrueD0pt", "True D0 pt spectrum", 200, 0., 200.);
64  fHistos->CreateTH1("hTrueD0pi0piplpimi", "True D0 pt spectrum (3 pion channel)", 200, 0., 200.);
65  fHistos->CreateTH1("hTrueD0pi0piplpimiAcc", "True D0 pt spectrum (3 pion channel, in acceptance)", 200, 0., 200.);
66  fHistos->CreateTH2("hPi0FromD0pt", "pt of the pi0 from D0 decay", 200, 0., 200., 200, 0., 200.);
67  fHistos->CreateTH2("hPiPlFromD0pt", "pt of the pi+ from D0 decay", 200, 0., 200., 200, 0., 200.);
68  fHistos->CreateTH2("hPiMiFromD0pt", "pt of the pi- from D0 decay", 200, 0., 200., 200, 0., 200.);
69 
70  for(auto h : *fHistos->GetListOfHistograms()) fOutput->Add(h);
71  PostData(1, fOutput);
72 }
73 
75  if(!fMCEvent) {
76  AliErrorStream() << "No MC event available" << std::endl;
77  return false;
78  }
79  for(int ipart = 0; ipart < fMCEvent->GetNumberOfTracks(); ipart++){
80  auto part = fMCEvent->GetTrack(ipart);
81  if(TMath::Abs(part->PdgCode()) != 421) continue;
82  if(TMath::Abs(part->Eta()) < 0.5) continue;
83  fHistos->FillTH1("hTrueD0pt", part->Pt());
84  // check for 3 pion decay
85  auto decay = CheckFor3PionDecay(part);
86  if(!(decay.fPi0daughter && decay.fPiMidaughter && decay.fPiPldaughter)) continue;
87  fHistos->FillTH1("hTrueD0pi0piplpimi", part->Pt());
88  // check whether all daughters are in the acceptance;
89  if(TMath::Abs(decay.fPiPldaughter->Eta()) > 0.8) continue;
90  if(TMath::Abs(decay.fPiMidaughter->Eta()) > 0.8) continue;
91  if(TMath::Abs(decay.fPi0daughter->Eta()) > 0.7) continue; // EMCAL
92  fHistos->FillTH1("hTrueD0pi0piplpimiAcc", part->Pt());
93 
94  fHistos->FillTH2("hPi0FromD0pt", part->Pt(), decay.fPi0daughter->Pt());
95  fHistos->FillTH2("hPiPlFromD0pt", part->Pt(), decay.fPiPldaughter->Pt());
96  fHistos->FillTH2("hPiMiFromD0pt", part->Pt(), decay.fPiMidaughter->Pt());
97  }
98  return true;
99 }
100 
103  decay.fPi0daughter = nullptr;
104  decay.fPiPldaughter = nullptr;
105  decay.fPiMidaughter = nullptr;
106  AliDebug(1, "Found D0\n");
107  int did = 0;
108  for(auto idaughter = d0mother->GetDaughterFirst(); idaughter <= d0mother->GetDaughterLast(); idaughter++){
109  auto daughterpart = fMCEvent->GetTrack(idaughter);
110  AliDebug(2, Form("Daughter %d: %d\n", did, daughterpart->PdgCode()));
111  if(TMath::Abs(daughterpart->PdgCode()) == 111) decay.fPi0daughter = daughterpart;
112  if(daughterpart->PdgCode() == 211) decay.fPiPldaughter = daughterpart;
113  if(daughterpart->PdgCode() == -211) decay.fPiMidaughter = daughterpart;
114  }
115 
116  return decay;
117 }
118 
120  auto mgr = AliAnalysisManager::GetAnalysisManager();
121  if(!mgr) {
122  std::cerr << "AliAnalysisTaskGammaConvDtrue: No AnalysisManager defined" << std::endl;
123  return nullptr;
124  }
125 
126  auto d0task = new AliAnalysisTaskGammaConvDtrue("d0task");
127  mgr->AddTask(d0task);
128 
129  TString outputcont = mgr->GetCommonFileName();
130  outputcont += ":D0MCtrue";
131 
132  mgr->ConnectInput(d0task, 0, mgr->GetCommonInputContainer());
133  mgr->ConnectOutput(d0task, 1, mgr->CreateContainer("D0true", TList::Class(), AliAnalysisManager::kOutputContainer, outputcont));
134  return d0task;
135 }
D03PionDecay CheckFor3PionDecay(AliVParticle *d0mother) const
Base task in the EMCAL framework.
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
Fill a 2D histogram within the container.
static AliAnalysisTaskGammaConvDtrue * AddTaskGammaConvDtrue()
TH2 * CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
Create a new TH2 within the container.
THashList * GetListOfHistograms() const
Get the list of histograms.
Definition: THistManager.h:671
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
virtual bool Run()
Run function. This is the core function of the analysis and contains the user code. Therefore users have to implement this function.
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
THistManager * fHistos
! Output histograms
decay
Definition: HFPtSpectrum.C:42
AliEmcalList * fOutput
!output list
void SetMakeGeneralHistograms(Bool_t g)
Enable general histograms.
Container class for histograms.
Definition: THistManager.h:99
void UserCreateOutputObjects()
Main initialization function on the worker.